Browse Source

feat: 待办事项

xdd 2 weeks ago
parent
commit
35c86e56c8

+ 75 - 0
fs-service/src/main/java/com/fs/todo/domain/FsTodoItems.java

@@ -0,0 +1,75 @@
+package com.fs.todo.domain;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import java.time.LocalDateTime;
+
+/**
+ * 待办事项表
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class FsTodoItems {
+
+    /**
+     * 待办事项ID
+     */
+    private Long id;
+
+    /**
+     * 待办事项标题
+     */
+    private String title;
+
+    /**
+     * 待办事项详细描述
+     */
+    private String description;
+
+    /**
+     * 状态:0-未开始,1-进行中,2-已完成
+     */
+    private Integer status;
+
+    /**
+     * 创建者ID(管理员)
+     */
+    private Long creatorId;
+
+    /**
+     * 负责人ID(销售人员)
+     */
+    private Long assigneeId;
+
+    /**
+     * 优先级:0-低,1-中,2-高
+     */
+    private Integer priority;
+
+    /**
+     * 截止日期
+     */
+    private LocalDateTime dueDate;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 完成时间
+     */
+    private LocalDateTime completeTime;
+
+    /**
+     * 任务分类
+     */
+    private Integer cateId;
+}

+ 81 - 0
fs-service/src/main/java/com/fs/todo/mapper/FsTodoItemsMapper.java

@@ -0,0 +1,81 @@
+package com.fs.todo.mapper;
+
+import com.fs.todo.domain.FsTodoItems;
+import com.fs.todo.param.QueryTodoItemsParam;
+import org.apache.ibatis.annotations.*;
+import java.util.List;
+
+/**
+ * 待办事项表 Mapper接口
+ */
+@Mapper
+public interface FsTodoItemsMapper {
+
+    /**
+     * 根据ID查询待办事项
+     */
+    @Select("SELECT * FROM fs_todo_items WHERE id = #{id}")
+    FsTodoItems selectById(@Param("id") Long id);
+
+
+
+    /**
+     * 查询所有待办事项
+     */
+    @Select("SELECT * FROM fs_todo_items ORDER BY create_time DESC")
+    List<FsTodoItems> selectAll();
+
+    /**
+     * 根据状态查询待办事项
+     */
+    @Select("SELECT * FROM fs_todo_items WHERE status = #{status} ORDER BY create_time DESC")
+    List<FsTodoItems> selectByStatus(@Param("status") Integer status);
+
+    /**
+     * 根据创建者ID查询待办事项
+     */
+    @Select("SELECT * FROM fs_todo_items WHERE creator_id = #{creatorId} ORDER BY create_time DESC")
+    List<FsTodoItems> selectByCreatorId(@Param("creatorId") Long creatorId);
+
+    /**
+     * 根据负责人ID查询待办事项
+     */
+    @Select("SELECT * FROM fs_todo_items WHERE assignee_id = #{assigneeId} ORDER BY create_time DESC")
+    List<FsTodoItems> selectByAssigneeId(@Param("assigneeId") Long assigneeId);
+
+    /**
+     * 新增待办事项
+     */
+    @Insert("INSERT INTO fs_todo_items(title, description, status, creator_id, assignee_id, priority, due_date) " +
+            "VALUES(#{title}, #{description}, #{status}, #{creatorId}, #{assigneeId}, #{priority}, #{dueDate})")
+    @Options(useGeneratedKeys = true, keyProperty = "id")
+    int insert(FsTodoItems fsTodoItems);
+
+    /**
+     * 更新待办事项
+     */
+    @Update("UPDATE fs_todo_items SET title = #{title}, description = #{description}, status = #{status}, " +
+            "assignee_id = #{assigneeId}, priority = #{priority}, due_date = #{dueDate}, " +
+            "complete_time = #{completeTime} WHERE id = #{id}")
+    int updateById(FsTodoItems fsTodoItems);
+
+    /**
+     * 更新待办事项状态
+     */
+    @Update("UPDATE fs_todo_items SET status = #{status}, complete_time = #{completeTime} WHERE id = #{id}")
+    int updateStatus(@Param("id") Long id, @Param("status") Integer status, @Param("completeTime") String completeTime);
+
+    /**
+     * 根据ID删除待办事项
+     */
+    @Update("DELETE FROM fs_todo_items WHERE id = #{id}")
+    int deleteById(@Param("id") Long id);
+
+
+    /**
+     * 分页查询
+     * @param param 参数
+     * @return List<FsTodoItems>
+     */
+    List<FsTodoItems> listPage(QueryTodoItemsParam param);
+}

+ 71 - 0
fs-service/src/main/java/com/fs/todo/param/QueryTodoItemsParam.java

@@ -0,0 +1,71 @@
+package com.fs.todo.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+public class QueryTodoItemsParam implements Serializable {
+    private Integer pageSize;
+    private Integer pageNum;
+    /**
+     * 待办事项ID
+     */
+    private Long id;
+
+    /**
+     * 待办事项标题
+     */
+    private String title;
+
+    /**
+     * 待办事项详细描述
+     */
+    private String description;
+
+    /**
+     * 状态:0-未开始,1-进行中,2-已完成
+     */
+    private Integer status;
+
+    /**
+     * 创建者ID(管理员)
+     */
+    private Long creatorId;
+
+    /**
+     * 负责人ID(销售人员)
+     */
+    private Long assigneeId;
+
+    /**
+     * 优先级:0-低,1-中,2-高
+     */
+    private Integer priority;
+
+    /**
+     * 截止日期
+     */
+    private LocalDateTime dueDate;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 完成时间
+     */
+    private LocalDateTime completeTime;
+
+    /**
+     * 任务分类
+     */
+    private Integer cateId;
+}

+ 58 - 0
fs-service/src/main/java/com/fs/todo/service/FsTodoItemsService.java

@@ -0,0 +1,58 @@
+package com.fs.todo.service;
+
+import com.fs.todo.domain.FsTodoItems;
+import com.fs.todo.param.QueryTodoItemsParam;
+
+import java.util.List;
+
+/**
+ * 待办事项表 服务类
+ */
+public interface FsTodoItemsService {
+
+    /**
+     * 根据ID查询待办事项
+     */
+    FsTodoItems getById(Long id);
+
+    /**
+     * 查询所有待办事项
+     */
+    List<FsTodoItems> list();
+
+    List<FsTodoItems> listPage(QueryTodoItemsParam param);
+    /**
+     * 根据状态查询待办事项
+     */
+    List<FsTodoItems> listByStatus(Integer status);
+
+    /**
+     * 根据创建者ID查询待办事项
+     */
+    List<FsTodoItems> listByCreatorId(Long creatorId);
+
+    /**
+     * 根据负责人ID查询待办事项
+     */
+    List<FsTodoItems> listByAssigneeId(Long assigneeId);
+
+    /**
+     * 新增待办事项
+     */
+    boolean save(FsTodoItems fsTodoItems);
+
+    /**
+     * 更新待办事项
+     */
+    boolean updateById(FsTodoItems fsTodoItems);
+
+    /**
+     * 更新待办事项状态
+     */
+    boolean updateStatus(Long id, Integer status);
+
+    /**
+     * 根据ID删除待办事项
+     */
+    boolean removeById(Long id);
+}

+ 103 - 0
fs-service/src/main/java/com/fs/todo/service/impl/FsTodoItemsServiceImpl.java

@@ -0,0 +1,103 @@
+package com.fs.todo.service.impl;
+
+import com.fs.todo.domain.FsTodoItems;
+import com.fs.todo.mapper.FsTodoItemsMapper;
+import com.fs.todo.param.QueryTodoItemsParam;
+import com.fs.todo.service.FsTodoItemsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.time.LocalDateTime;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 待办事项表 服务实现类
+ */
+@Service
+public class FsTodoItemsServiceImpl implements FsTodoItemsService {
+
+    @Autowired
+    private FsTodoItemsMapper fsTodoItemsMapper;
+
+    /**
+     * 根据ID查询待办事项
+     */
+    @Override
+    public FsTodoItems getById(Long id) {
+        return fsTodoItemsMapper.selectById(id);
+    }
+
+    /**
+     * 查询所有待办事项
+     */
+    @Override
+    public List<FsTodoItems> list() {
+        return fsTodoItemsMapper.selectAll();
+    }
+
+    @Override
+    public List<FsTodoItems> listPage(QueryTodoItemsParam param) {
+        return fsTodoItemsMapper.listPage(param);
+    }
+
+    /**
+     * 根据状态查询待办事项
+     */
+    @Override
+    public List<FsTodoItems> listByStatus(Integer status) {
+        return fsTodoItemsMapper.selectByStatus(status);
+    }
+
+    /**
+     * 根据创建者ID查询待办事项
+     */
+    @Override
+    public List<FsTodoItems> listByCreatorId(Long creatorId) {
+        return fsTodoItemsMapper.selectByCreatorId(creatorId);
+    }
+
+    /**
+     * 根据负责人ID查询待办事项
+     */
+    @Override
+    public List<FsTodoItems> listByAssigneeId(Long assigneeId) {
+        return fsTodoItemsMapper.selectByAssigneeId(assigneeId);
+    }
+
+    /**
+     * 新增待办事项
+     */
+    @Override
+    public boolean save(FsTodoItems fsTodoItems) {
+        return fsTodoItemsMapper.insert(fsTodoItems) > 0;
+    }
+
+    /**
+     * 更新待办事项
+     */
+    @Override
+    public boolean updateById(FsTodoItems fsTodoItems) {
+        return fsTodoItemsMapper.updateById(fsTodoItems) > 0;
+    }
+
+    /**
+     * 更新待办事项状态
+     */
+    @Override
+    public boolean updateStatus(Long id, Integer status) {
+        String completeTime = null;
+        // 如果状态为已完成(2),设置完成时间
+        if (status == 2) {
+            completeTime = LocalDateTime.now().toString();
+        }
+        return fsTodoItemsMapper.updateStatus(id, status, completeTime) > 0;
+    }
+
+    /**
+     * 根据ID删除待办事项
+     */
+    @Override
+    public boolean removeById(Long id) {
+        return fsTodoItemsMapper.deleteById(id) > 0;
+    }
+}

+ 108 - 0
fs-service/src/main/resources/mapper/todo/FsTodoItemsMapper.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.todo.mapper.FsTodoItemsMapper">
+
+    <!-- 结果映射 -->
+    <resultMap id="BaseResultMap" type="com.fs.todo.domain.FsTodoItems">
+        <id column="id" property="id" jdbcType="BIGINT"/>
+        <result column="title" property="title" jdbcType="VARCHAR"/>
+        <result column="description" property="description" jdbcType="LONGVARCHAR"/>
+        <result column="status" property="status" jdbcType="TINYINT"/>
+        <result column="creator_id" property="creatorId" jdbcType="BIGINT"/>
+        <result column="assignee_id" property="assigneeId" jdbcType="BIGINT"/>
+        <result column="priority" property="priority" jdbcType="TINYINT"/>
+        <result column="due_date" property="dueDate" jdbcType="TIMESTAMP"/>
+        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
+        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
+        <result column="complete_time" property="completeTime" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <!-- 基础字段 -->
+    <sql id="Base_Column_List">
+        id, title, description, status, creator_id, assignee_id, priority,
+        due_date, create_time, update_time, complete_time
+    </sql>
+
+    <!-- 根据ID查询 -->
+    <select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List"/>
+        FROM fs_todo_items
+        WHERE id = #{id}
+    </select>
+
+    <!-- 查询所有 -->
+    <select id="selectAll" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List"/>
+        FROM fs_todo_items
+        ORDER BY create_time DESC
+    </select>
+
+    <!-- 根据创建者ID查询 -->
+    <select id="selectByCreatorId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List"/>
+        FROM fs_todo_items
+        WHERE creator_id = #{creatorId}
+        ORDER BY create_time DESC
+    </select>
+
+    <!-- 根据负责人ID查询 -->
+    <select id="selectByAssigneeId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List"/>
+        FROM fs_todo_items
+        WHERE assignee_id = #{assigneeId}
+        ORDER BY create_time DESC
+    </select>
+
+    <!-- 根据状态查询 -->
+    <select id="selectByStatus" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+        SELECT <include refid="Base_Column_List"/>
+        FROM fs_todo_items
+        WHERE status = #{status}
+        ORDER BY create_time DESC
+    </select>
+    <select id="listPage" resultType="com.fs.todo.domain.FsTodoItems">
+        SELECT <include refid="Base_Column_List"/>
+        FROM fs_todo_items
+        <where>
+            <if test="id != null">
+                AND id = #{id}
+            </if>
+            <if test="title != null and title != ''">
+                AND title LIKE CONCAT('%', #{title}, '%')
+            </if>
+            <if test="description != null and description != ''">
+                AND description LIKE CONCAT('%', #{description}, '%')
+            </if>
+            <if test="status != null">
+                AND status = #{status}
+            </if>
+            <if test="creatorId != null">
+                AND creator_id = #{creatorId}
+            </if>
+            <if test="assigneeId != null">
+                AND assignee_id = #{assigneeId}
+            </if>
+            <if test="priority != null">
+                AND priority = #{priority}
+            </if>
+            <if test="dueDate != null">
+                AND DATE(due_date) = DATE(#{dueDate})
+            </if>
+            <if test="createTime != null">
+                AND DATE(create_time) = DATE(#{createTime})
+            </if>
+            <if test="updateTime != null">
+                AND DATE(update_time) = DATE(#{updateTime})
+            </if>
+            <if test="completeTime != null">
+                AND DATE(complete_time) = DATE(#{completeTime})
+            </if>
+            <if test="cateId != null">
+                AND cate_id = #{cateId}
+            </if>
+        </where>
+        ORDER BY create_time DESC
+    </select>
+
+
+</mapper>

+ 55 - 0
fs-user-app/src/main/java/com/fs/app/controller/FsTodoItemsController.java

@@ -0,0 +1,55 @@
+package com.fs.app.controller;
+
+import com.fs.app.annotation.Login;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.R;
+import com.fs.his.param.FsFollowListUParam;
+import com.fs.his.vo.FsFollowListUVO;
+import com.fs.todo.domain.FsTodoItems;
+import com.fs.todo.param.QueryTodoItemsParam;
+import com.fs.todo.service.FsTodoItemsService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Api("待办")
+@RestController
+@RequestMapping(value="/app/todoItems")
+public class FsTodoItemsController extends BaseController {
+
+    @Autowired
+    private FsTodoItemsService fsTodoItemsService;
+
+
+    @ApiOperation("查看待办列表")
+    @PostMapping("/listPage")
+    public R listPage(@RequestBody QueryTodoItemsParam param)
+    {
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        List<FsTodoItems> fsTodoItems = fsTodoItemsService.listPage(param);
+        PageInfo<FsTodoItems> listPageInfo=new PageInfo<>(fsTodoItems);
+        return R.ok().put("data",listPageInfo);
+    }
+
+    @ApiOperation("查看详情")
+    @PostMapping("/findById")
+    public R findById(@RequestBody QueryTodoItemsParam param)
+    {
+        FsTodoItems byId = fsTodoItemsService.getById(param.getId());
+        return R.ok().put("data",byId);
+    }
+
+    @ApiOperation("更新详情")
+    @PostMapping("/updateById")
+    public R updateById(@RequestBody QueryTodoItemsParam param)
+    {
+        fsTodoItemsService.updateStatus(param.getId(),param.getStatus());
+        return R.ok();
+    }
+
+}