mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Add fuzzy query function in work items
This commit is contained in:
@@ -35,8 +35,13 @@ public class WorkController {
|
||||
@Autowired
|
||||
private IWorkService workService;
|
||||
@GetMapping
|
||||
public ResponseResult getAll() {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getAll());
|
||||
public ResponseResult getAll(String content) {
|
||||
if (content != null) {
|
||||
List<Work> workList = workService.getWorkByContent(content);
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success",workList);
|
||||
} else {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getAll());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/todo")
|
||||
|
||||
@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.annotation.Version;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -54,6 +56,10 @@ public class UserWork implements Serializable {
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
@TableField("complete_time")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
|
||||
private LocalDateTime completeTime;
|
||||
|
||||
@TableField("deleted")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface WorkMapper extends BaseMapper<Work> {
|
||||
|
||||
Work getWork(Long workId);
|
||||
|
||||
List<Work> getWorkByContent(String content);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public interface IWorkService extends IService<Work> {
|
||||
List<Work> getTodo(Long userId);
|
||||
List<Work> getComplete(Long userId);
|
||||
Work getOne(Long workId);
|
||||
|
||||
List<Work> getWorkByContent(String content);
|
||||
double getProgress(Long workId);
|
||||
|
||||
String getUserName(Long userId);
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,17 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
|
||||
return work;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Work> getWorkByContent(String content) {
|
||||
List<Work> workList = workMapper.getWorkByContent(content);
|
||||
for (Work work:
|
||||
workList) {
|
||||
work.setProgress(getProgress(work.getId()));
|
||||
work.setPublisherName(getUserName(work.getPublisherId()));
|
||||
}
|
||||
return workList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProgress(Long workId) {
|
||||
double workNum = userWorkMapper.selectCount(new QueryWrapper<UserWork>().eq("work_id",workId));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<result property="deadline" column="deadline"/>
|
||||
<collection property="userWorkList" ofType="userWork">
|
||||
<result property="status" column="status"/>
|
||||
<result property="completeTime" column="complete_time"/>
|
||||
</collection>
|
||||
<collection property="worker" ofType="user">
|
||||
<id property="id" column="worker_id"/>
|
||||
@@ -23,7 +24,8 @@
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status
|
||||
tuw.status status,
|
||||
tuw.complete_time complete_time
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
@@ -41,7 +43,8 @@
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status
|
||||
tuw.status status,
|
||||
tuw.complete_time completeTime
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
@@ -51,6 +54,25 @@
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0;
|
||||
</select>
|
||||
<select id="getWorkByContent" parameterType="String" resultMap="workMap">
|
||||
select w.id,
|
||||
content,
|
||||
publisher_id,
|
||||
create_time,
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status,
|
||||
tuw.complete_time completeTime
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
where w.content like '%${content}%'
|
||||
and w.id = tuw.work_id
|
||||
and tuw.user_id = u.id
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0;
|
||||
</select>
|
||||
<select id="getTodo" parameterType="long" resultMap="workMap">
|
||||
select w.id,
|
||||
content,
|
||||
@@ -69,7 +91,7 @@
|
||||
and status = false
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0
|
||||
order by w.id desc;
|
||||
order by w.deadline asc, w.id desc;
|
||||
</select>
|
||||
<select id="getComplete" parameterType="long" resultMap="workMap">
|
||||
select w.id,
|
||||
@@ -79,50 +101,18 @@
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status
|
||||
tuw.status status,
|
||||
tuw.complete_time complete_time
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
where w.id = tuw.work_id
|
||||
where tuw.user_id = #{userId}
|
||||
and tuw.user_id = u.id
|
||||
and tuw.user_id = #{userId}
|
||||
and status = true
|
||||
and w.id = tuw.work_id
|
||||
and tuw.status = true
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0
|
||||
order by w.id desc;
|
||||
</select>
|
||||
<delete id="deleteWorkById" parameterType="int">
|
||||
delete
|
||||
from t_task
|
||||
where id = #{id};
|
||||
</delete>
|
||||
<delete id="deleteWork" parameterType="list">
|
||||
delete
|
||||
from t_task
|
||||
<where>
|
||||
<foreach collection="list" item="id" open="id in(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</delete>
|
||||
<update id="updateWork" parameterType="Work">
|
||||
update t_task
|
||||
<set>
|
||||
<if test="publisher_id!=null and publisher_id!=0">
|
||||
publisher_id = #{publisher_id}
|
||||
</if>
|
||||
<if test="taskStatus!=null">
|
||||
task_status=#{taskStatus}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id};
|
||||
</update>
|
||||
<select id="getOneById" resultMap="workMap">
|
||||
select id, user_id, userName, task_content, create_time, deadline, task_status
|
||||
from t_task,
|
||||
t_user
|
||||
where user_id = userID
|
||||
and id = #{id};
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user