czh-20260430-实现任务管理后端功能
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-module-bpm-flowable</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-system-local-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
|
||||
+534
@@ -0,0 +1,534 @@
|
||||
package org.jeecg.modules.demo.tasklist.controller;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskList;
|
||||
import org.jeecg.modules.demo.tasklist.vo.TaskListPage;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskListReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskListGroupReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.MoveTaskListReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.AddCollaboratorReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CollaboratorVO;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListService;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListDetialService;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListPermissionService;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListFavoriteService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 任务清单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Tag(name="任务清单表")
|
||||
@RestController
|
||||
@RequestMapping("/tasklist/taskList")
|
||||
@Slf4j
|
||||
public class TaskListController {
|
||||
@Autowired
|
||||
private ITaskListService taskListService;
|
||||
@Autowired
|
||||
private ITaskListDetialService taskListDetialService;
|
||||
@Autowired
|
||||
private ITaskListPermissionService taskListPermissionService;
|
||||
@Autowired
|
||||
private ITaskListFavoriteService taskListFavoriteService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param taskList
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "任务清单表-分页列表查询")
|
||||
@Operation(summary="任务清单表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<TaskList>> queryPageList(TaskList taskList,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<TaskList> queryWrapper = QueryGenerator.initQueryWrapper(taskList, req.getParameterMap());
|
||||
Page<TaskList> page = new Page<TaskList>(pageNo, pageSize);
|
||||
IPage<TaskList> pageList = taskListService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param taskListPage
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "任务清单表-添加")
|
||||
@Operation(summary="任务清单表-添加")
|
||||
@RequiresPermissions("tasklist:task_list:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody TaskListPage taskListPage) {
|
||||
TaskList taskList = new TaskList();
|
||||
BeanUtils.copyProperties(taskListPage, taskList);
|
||||
taskListService.saveMain(taskList, taskListPage.getTaskListDetialList(),taskListPage.getTaskListPermissionList(),taskListPage.getTaskListFavoriteList());
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param taskListPage
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "任务清单表-编辑")
|
||||
@Operation(summary="任务清单表-编辑")
|
||||
@RequiresPermissions("tasklist:task_list:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody TaskListPage taskListPage) {
|
||||
TaskList taskList = new TaskList();
|
||||
BeanUtils.copyProperties(taskListPage, taskList);
|
||||
TaskList taskListEntity = taskListService.getById(taskList.getId());
|
||||
if(taskListEntity==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
taskListService.updateMain(taskList, taskListPage.getTaskListDetialList(),taskListPage.getTaskListPermissionList(),taskListPage.getTaskListFavoriteList());
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "任务清单表-通过id删除")
|
||||
@Operation(summary="任务清单表-通过id删除")
|
||||
@RequiresPermissions("tasklist:task_list:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
taskListService.delMain(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "任务清单表-批量删除")
|
||||
@Operation(summary="任务清单表-批量删除")
|
||||
@RequiresPermissions("tasklist:task_list:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.taskListService.delBatchMain(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "任务清单表-通过id查询")
|
||||
@Operation(summary="任务清单表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<TaskList> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
TaskList taskList = taskListService.getById(id);
|
||||
if(taskList==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(taskList);
|
||||
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-新建任务清单")
|
||||
@Operation(summary = "新建任务清单")
|
||||
@PostMapping(value = "/addTaskList")
|
||||
public Result<String> addTaskList(@RequestBody CreateTaskListReq req) {
|
||||
try {
|
||||
String id = taskListService.createTaskList(req);
|
||||
return Result.OK("创建成功!", id);
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-新建任务清单分组")
|
||||
@Operation(summary = "新建任务清单分组")
|
||||
@PostMapping(value = "/addTaskListGroup")
|
||||
public Result<String> addTaskListGroup(@RequestBody CreateTaskListGroupReq req) {
|
||||
try {
|
||||
String id = taskListService.createTaskListGroup(req);
|
||||
return Result.OK("创建成功!", id);
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-拖拽移动任务清单")
|
||||
@Operation(summary = "拖拽移动任务清单")
|
||||
@PostMapping(value = "/moveTaskList")
|
||||
public Result<String> moveTaskList(@RequestBody MoveTaskListReq req) {
|
||||
try {
|
||||
taskListService.moveTaskList(req);
|
||||
return Result.OK("移动成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-拖拽移动分组")
|
||||
@Operation(summary = "拖拽移动分组")
|
||||
@PostMapping(value = "/moveGroup")
|
||||
public Result<String> moveGroup(@RequestBody Map<String, Object> params) {
|
||||
try {
|
||||
String groupId = (String) params.get("groupId");
|
||||
Integer sortOrder = params.get("sortOrder") != null ? ((Number) params.get("sortOrder")).intValue() : null;
|
||||
taskListService.moveGroup(groupId, sortOrder);
|
||||
return Result.OK("移动成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-获取当前用户收藏列表")
|
||||
@Operation(summary = "获取当前用户收藏列表")
|
||||
@GetMapping(value = "/myFavorites")
|
||||
public Result<List<TaskListFavorite>> myFavorites() {
|
||||
List<TaskListFavorite> list = taskListService.getMyFavorites();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-删除任务清单")
|
||||
@Operation(summary = "删除任务清单(所有者操作)")
|
||||
@PostMapping(value = "/deleteTaskList")
|
||||
public Result<String> deleteTaskList(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.deleteTaskList(params.get("id"));
|
||||
return Result.OK("删除成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-移除收藏")
|
||||
@Operation(summary = "从收藏栏移除")
|
||||
@PostMapping(value = "/removeFavorite")
|
||||
public Result<String> removeFavorite(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.removeFavorite(params.get("favoriteId"));
|
||||
return Result.OK("移除成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-添加到收藏")
|
||||
@Operation(summary = "添加清单到收藏栏")
|
||||
@PostMapping(value = "/addToFavorites")
|
||||
public Result<String> addToFavorites(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.addToFavorites(params.get("taskListId"));
|
||||
return Result.OK("添加成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-移除分组")
|
||||
@Operation(summary = "从收藏栏移除分组及子项")
|
||||
@PostMapping(value = "/removeFavoriteGroup")
|
||||
public Result<String> removeFavoriteGroup(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.removeFavoriteGroup(params.get("groupId"));
|
||||
return Result.OK("移除成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-重命名分组")
|
||||
@Operation(summary = "重命名任务清单分组")
|
||||
@PostMapping(value = "/renameGroup")
|
||||
public Result<String> renameGroup(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.renameGroup(params.get("groupId"), params.get("newName"));
|
||||
return Result.OK("重命名成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-重命名清单")
|
||||
@Operation(summary = "重命名任务清单")
|
||||
@PostMapping(value = "/renameTaskList")
|
||||
public Result<String> renameTaskList(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.renameTaskList(params.get("taskListId"), params.get("newName"));
|
||||
return Result.OK("重命名成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-获取我所有的清单")
|
||||
@Operation(summary = "获取我所有的清单")
|
||||
@GetMapping(value = "/myOwnLists")
|
||||
public Result<List<TaskList>> myOwnLists() {
|
||||
List<TaskList> list = taskListService.getMyOwnLists();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-获取所有清单")
|
||||
@Operation(summary = "获取所有清单")
|
||||
@GetMapping(value = "/allLists")
|
||||
public Result<List<TaskList>> getAllLists() {
|
||||
return Result.OK(taskListService.getAllLists());
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-获取我协作的清单")
|
||||
@Operation(summary = "获取我协作的清单")
|
||||
@GetMapping(value = "/myCollabLists")
|
||||
public Result<List<TaskList>> myCollabLists() {
|
||||
List<TaskList> list = taskListService.getMyCollabLists();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-获取协作人列表")
|
||||
@Operation(summary = "获取清单协作人列表")
|
||||
@GetMapping(value = "/getCollaborators")
|
||||
public Result<List<CollaboratorVO>> getCollaborators(@RequestParam(name="taskListId", required=true) String taskListId) {
|
||||
List<CollaboratorVO> list = taskListService.getCollaborators(taskListId);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-添加协作人")
|
||||
@Operation(summary = "添加协作人")
|
||||
@PostMapping(value = "/addCollaborator")
|
||||
public Result<String> addCollaborator(@RequestBody AddCollaboratorReq req) {
|
||||
try {
|
||||
taskListService.addCollaborator(req);
|
||||
return Result.OK("添加成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-移除协作人")
|
||||
@Operation(summary = "移除协作人")
|
||||
@PostMapping(value = "/removeCollaborator")
|
||||
public Result<String> removeCollaborator(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.removeCollaborator(params.get("permissionId"));
|
||||
return Result.OK("移除成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-修改协作人权限")
|
||||
@Operation(summary = "修改协作人权限")
|
||||
@PostMapping(value = "/updateCollaboratorPermission")
|
||||
public Result<String> updateCollaboratorPermission(@RequestBody Map<String, String> params) {
|
||||
try {
|
||||
taskListService.updateCollaboratorPermission(params.get("permissionId"), params.get("permission"));
|
||||
return Result.OK("修改成功!");
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-获取当前用户对清单的权限")
|
||||
@Operation(summary = "获取当前用户对清单的权限")
|
||||
@GetMapping(value = "/getMyPermission")
|
||||
public Result<String> getMyPermission(@RequestParam(name="taskListId", required=true) String taskListId) {
|
||||
String permission = taskListService.getMyPermission(taskListId);
|
||||
return Result.OK("查询成功", permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "任务清单详情表通过主表ID查询")
|
||||
@Operation(summary="任务清单详情表主表ID查询")
|
||||
@GetMapping(value = "/queryTaskListDetialByMainId")
|
||||
public Result<List<TaskListDetial>> queryTaskListDetialListByMainId(@RequestParam(name="id",required=true) String id) {
|
||||
List<TaskListDetial> taskListDetialList = taskListDetialService.selectByMainId(id);
|
||||
return Result.OK(taskListDetialList);
|
||||
}
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "任务清单权限表通过主表ID查询")
|
||||
@Operation(summary="任务清单权限表主表ID查询")
|
||||
@GetMapping(value = "/queryTaskListPermissionByMainId")
|
||||
public Result<List<TaskListPermission>> queryTaskListPermissionListByMainId(@RequestParam(name="id",required=true) String id) {
|
||||
List<TaskListPermission> taskListPermissionList = taskListPermissionService.selectByMainId(id);
|
||||
return Result.OK(taskListPermissionList);
|
||||
}
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "任务清单收藏表通过主表ID查询")
|
||||
@Operation(summary="任务清单收藏表主表ID查询")
|
||||
@GetMapping(value = "/queryTaskListFavoriteByMainId")
|
||||
public Result<List<TaskListFavorite>> queryTaskListFavoriteListByMainId(@RequestParam(name="id",required=true) String id) {
|
||||
List<TaskListFavorite> taskListFavoriteList = taskListFavoriteService.selectByMainId(id);
|
||||
return Result.OK(taskListFavoriteList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param taskList
|
||||
*/
|
||||
@RequiresPermissions("tasklist:task_list:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, TaskList taskList) {
|
||||
|
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<TaskList> queryWrapper = QueryGenerator.initQueryWrapper(taskList, request.getParameterMap());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
//配置选中数据查询条件
|
||||
String selections = request.getParameter("selections");
|
||||
if(oConvertUtils.isNotEmpty(selections)) {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
queryWrapper.in("id",selectionList);
|
||||
}
|
||||
//Step.2 获取导出数据
|
||||
List<TaskList> taskListList = taskListService.list(queryWrapper);
|
||||
|
||||
// Step.3 组装pageList
|
||||
List<TaskListPage> pageList = new ArrayList<TaskListPage>();
|
||||
for (TaskList main : taskListList) {
|
||||
TaskListPage vo = new TaskListPage();
|
||||
BeanUtils.copyProperties(main, vo);
|
||||
List<TaskListDetial> taskListDetialList = taskListDetialService.selectByMainId(main.getId());
|
||||
vo.setTaskListDetialList(taskListDetialList);
|
||||
List<TaskListPermission> taskListPermissionList = taskListPermissionService.selectByMainId(main.getId());
|
||||
vo.setTaskListPermissionList(taskListPermissionList);
|
||||
List<TaskListFavorite> taskListFavoriteList = taskListFavoriteService.selectByMainId(main.getId());
|
||||
vo.setTaskListFavoriteList(taskListFavoriteList);
|
||||
pageList.add(vo);
|
||||
}
|
||||
|
||||
// Step.4 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "任务清单表列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, TaskListPage.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("任务清单表数据", "导出人:"+sysUser.getRealname(), "任务清单表"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("tasklist:task_list:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<TaskListPage> list = ExcelImportUtil.importExcel(file.getInputStream(), TaskListPage.class, params);
|
||||
for (TaskListPage page : list) {
|
||||
TaskList po = new TaskList();
|
||||
BeanUtils.copyProperties(page, po);
|
||||
taskListService.saveMain(po, page.getTaskListDetialList(),page.getTaskListPermissionList(),page.getTaskListFavoriteList());
|
||||
}
|
||||
return Result.OK("文件导入成功!数据行数:" + list.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return Result.error("文件导入失败:"+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.OK("文件导入失败!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-我负责的任务")
|
||||
@Operation(summary = "获取当前用户负责的任务")
|
||||
@GetMapping(value = "/myResponsibleTasks")
|
||||
public Result<List<TaskListDetial>> myResponsibleTasks() {
|
||||
List<TaskListDetial> list = taskListService.myResponsibleTasks();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@AutoLog(value = "任务清单表-我关注的任务")
|
||||
@Operation(summary = "获取当前用户关注的任务")
|
||||
@GetMapping(value = "/myFollowedTasks")
|
||||
public Result<List<TaskListDetial>> myFollowedTasks() {
|
||||
List<TaskListDetial> list = taskListService.myFollowedTasks();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package org.jeecg.modules.demo.tasklist.controller;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListDetialService;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.MoveTaskReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/tasklist/taskListDetial")
|
||||
public class TaskListDetialController {
|
||||
|
||||
@Autowired
|
||||
private ITaskListDetialService taskListDetialService;
|
||||
|
||||
@PostMapping(value = "/add")
|
||||
public Result<TaskListDetial> add(@RequestBody CreateTaskReq req) {
|
||||
try {
|
||||
TaskListDetial result = taskListDetialService.createTask(req);
|
||||
return Result.OK(result);
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody TaskListDetial task) {
|
||||
try {
|
||||
taskListDetialService.editTask(task);
|
||||
return Result.OK("编辑成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id") String id) {
|
||||
try {
|
||||
taskListDetialService.deleteTask(id);
|
||||
return Result.OK("删除成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/listByMainId")
|
||||
public Result<List<TaskListDetial>> listByMainId(@RequestParam(name = "mainId") String mainId) {
|
||||
List<TaskListDetial> list = taskListDetialService.queryTopLevelByMainId(mainId);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/listAllByMainId")
|
||||
public Result<List<TaskListDetial>> listAllByMainId(@RequestParam(name = "mainId") String mainId) {
|
||||
List<TaskListDetial> list = taskListDetialService.queryAllByMainId(mainId);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/toggleStatus")
|
||||
public Result<?> toggleStatus(@RequestBody Map<String, String> body) {
|
||||
try {
|
||||
String id = body.get("id");
|
||||
taskListDetialService.toggleStatus(id);
|
||||
return Result.OK("操作成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/moveTask")
|
||||
public Result<?> moveTask(@RequestBody MoveTaskReq req) {
|
||||
try {
|
||||
taskListDetialService.moveTask(req);
|
||||
return Result.OK("移动成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/moveTaskGroup")
|
||||
public Result<?> moveTaskGroup(@RequestBody Map<String, Object> params) {
|
||||
try {
|
||||
String taskGroupId = (String) params.get("taskGroupId");
|
||||
Integer targetSortOrder = params.get("targetSortOrder") != null ? ((Number) params.get("targetSortOrder")).intValue() : null;
|
||||
taskListDetialService.moveTaskGroup(taskGroupId, targetSortOrder);
|
||||
return Result.OK("移动成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/follow")
|
||||
public Result<?> follow(@RequestBody Map<String, String> body) {
|
||||
try {
|
||||
String id = body.get("id");
|
||||
taskListDetialService.followTask(id);
|
||||
return Result.OK("关注成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/unfollow")
|
||||
public Result<?> unfollow(@RequestBody Map<String, String> body) {
|
||||
try {
|
||||
String id = body.get("id");
|
||||
taskListDetialService.unfollowTask(id);
|
||||
return Result.OK("取消关注成功");
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/loadSubTasks")
|
||||
public Result<List<TaskListDetial>> loadSubTasks(
|
||||
@RequestParam(name = "parentTaskId") String parentTaskId,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize) {
|
||||
List<TaskListDetial> list = taskListDetialService.loadSubTasks(parentTaskId, pageNo, pageSize);
|
||||
return Result.OK(list);
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package org.jeecg.modules.demo.tasklist.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Schema(description="任务清单表")
|
||||
@Data
|
||||
@TableName("task_list")
|
||||
public class TaskList implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@Schema(description = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Schema(description = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Schema(description = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**清单名称*/
|
||||
@Excel(name = "清单名称", width = 15)
|
||||
@Schema(description = "清单名称")
|
||||
private java.lang.String tasklistName;
|
||||
/**删除标识*/
|
||||
@Excel(name = "删除标识", width = 15)
|
||||
@Schema(description = "删除标识")
|
||||
@TableLogic
|
||||
private java.lang.String delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "所有者名称")
|
||||
private java.lang.String ownerName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "协作者名称")
|
||||
private java.lang.String collaboratorNames;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "创建时间字符串")
|
||||
private java.lang.String createTimeStr;
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
package org.jeecg.modules.demo.tasklist.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import java.util.Date;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单详情表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Schema(description="任务清单详情表")
|
||||
@Data
|
||||
@TableName("task_list_detial")
|
||||
public class TaskListDetial implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@Schema(description = "创建人")
|
||||
private java.lang.String createBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "创建人名称")
|
||||
private java.lang.String createByName;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Schema(description = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Schema(description = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**主表ID*/
|
||||
@Schema(description = "主表ID")
|
||||
private java.lang.String mainId;
|
||||
/**父节点ID*/
|
||||
@Excel(name = "父节点ID", width = 15)
|
||||
@Schema(description = "父节点ID")
|
||||
private java.lang.String pid;
|
||||
/**是否有子节点*/
|
||||
@Excel(name = "是否有子节点", width = 15)
|
||||
@Schema(description = "是否有子节点")
|
||||
private java.lang.String hasChild;
|
||||
/**排序号*/
|
||||
@Excel(name = "排序号", width = 15)
|
||||
@Schema(description = "排序号")
|
||||
private java.lang.Integer sortOrder;
|
||||
/**任务名称*/
|
||||
@Excel(name = "任务名称", width = 15)
|
||||
@Schema(description = "任务名称")
|
||||
private java.lang.String taskName;
|
||||
/**任务描述*/
|
||||
@Excel(name = "任务描述", width = 15)
|
||||
@Schema(description = "任务描述")
|
||||
private java.lang.String taskDesc;
|
||||
/**优先级*/
|
||||
@Excel(name = "优先级", width = 15, dicCode = "task_priority")
|
||||
@Schema(description = "优先级")
|
||||
private java.lang.String priority;
|
||||
/**完成状态*/
|
||||
@Excel(name = "完成状态", width = 15)
|
||||
@Schema(description = "完成状态")
|
||||
private java.lang.Integer taskStatus;
|
||||
/**负责人ID*/
|
||||
@Excel(name = "负责人ID", width = 15)
|
||||
@Schema(description = "负责人ID")
|
||||
private java.lang.String assigneeId;
|
||||
/**负责人*/
|
||||
@Excel(name = "负责人", width = 15)
|
||||
@Schema(description = "负责人")
|
||||
private java.lang.String assigneeName;
|
||||
/**关注人ID*/
|
||||
@Excel(name = "关注人ID", width = 15)
|
||||
@Schema(description = "关注人ID")
|
||||
private java.lang.String followersId;
|
||||
/**关注人*/
|
||||
@Excel(name = "关注人", width = 15)
|
||||
@Schema(description = "关注人")
|
||||
private java.lang.String followersName;
|
||||
/**分配人ID*/
|
||||
@Excel(name = "分配人ID", width = 15)
|
||||
@Schema(description = "分配人ID")
|
||||
private java.lang.String assignId;
|
||||
/**分配人*/
|
||||
@Excel(name = "分配人", width = 15)
|
||||
@Schema(description = "分配人")
|
||||
private java.lang.String assignName;
|
||||
/**开始时间*/
|
||||
@Excel(name = "开始时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "开始时间")
|
||||
private java.util.Date startTime;
|
||||
/**结束时间*/
|
||||
@Excel(name = "结束时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "结束时间")
|
||||
private java.util.Date endTime;
|
||||
/**完成时间*/
|
||||
@Excel(name = "完成时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "完成时间")
|
||||
private java.util.Date completeTime;
|
||||
/**类型*/
|
||||
@Excel(name = "类型", width = 15)
|
||||
@Schema(description = "类型")
|
||||
private java.lang.String type;
|
||||
/**子任务数*/
|
||||
@Excel(name = "子任务数", width = 15)
|
||||
@Schema(description = "子任务数")
|
||||
private java.lang.Integer subTaskCount;
|
||||
/**子任务完成数*/
|
||||
@Excel(name = "子任务完成数", width = 15)
|
||||
@Schema(description = "子任务完成数")
|
||||
private java.lang.Integer completedSubTaskCount;
|
||||
/**参与人ID*/
|
||||
@Excel(name = "参与人ID", width = 15)
|
||||
@Schema(description = "参与人ID")
|
||||
private java.lang.String participantId;
|
||||
/**参与人*/
|
||||
@Excel(name = "参与人", width = 15)
|
||||
@Schema(description = "参与人")
|
||||
private java.lang.String participantName;
|
||||
/**其他事项说明*/
|
||||
@Excel(name = "其他事项说明", width = 15)
|
||||
@Schema(description = "其他事项说明")
|
||||
private java.lang.String remark;
|
||||
/**删除标识*/
|
||||
@Excel(name = "删除标识", width = 15)
|
||||
@Schema(description = "删除标识")
|
||||
@TableLogic
|
||||
private java.lang.String delFlag;
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package org.jeecg.modules.demo.tasklist.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import java.util.Date;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单收藏表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Schema(description="任务清单收藏表")
|
||||
@Data
|
||||
@TableName("task_list_favorite")
|
||||
public class TaskListFavorite implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@Schema(description = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Schema(description = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Schema(description = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**主表ID*/
|
||||
@Schema(description = "主表ID")
|
||||
private java.lang.String mainId;
|
||||
/**任务清单(分组)名称*/
|
||||
@Excel(name = "任务清单(分组)名称", width = 15)
|
||||
@Schema(description = "任务清单(分组)名称")
|
||||
private java.lang.String tasklistName;
|
||||
/**用户ID*/
|
||||
@Excel(name = "用户ID", width = 15)
|
||||
@Schema(description = "用户ID")
|
||||
private java.lang.String userId;
|
||||
/**类型(0是分组,1是清单)*/
|
||||
@Excel(name = "类型(0是分组,1是清单)", width = 15)
|
||||
@Schema(description = "类型(0是分组,1是清单)")
|
||||
private java.lang.String type;
|
||||
/**父节点ID*/
|
||||
@Excel(name = "父节点ID", width = 15)
|
||||
@Schema(description = "父节点ID")
|
||||
private java.lang.String pid;
|
||||
/**是否有子节点*/
|
||||
@Excel(name = "是否有子节点", width = 15)
|
||||
@Schema(description = "是否有子节点")
|
||||
private java.lang.String hasChild;
|
||||
/**排序*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
@Schema(description = "排序")
|
||||
private java.lang.Integer sortOrder;
|
||||
/**删除标识*/
|
||||
@Excel(name = "删除标识", width = 15)
|
||||
@Schema(description = "删除标识")
|
||||
@TableLogic
|
||||
private java.lang.String delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "当前用户对该清单的权限")
|
||||
private java.lang.String permission;
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package org.jeecg.modules.demo.tasklist.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import java.util.Date;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Schema(description="任务清单权限表")
|
||||
@Data
|
||||
@TableName("task_list_permission")
|
||||
public class TaskListPermission implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@Schema(description = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Schema(description = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Schema(description = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**主表ID*/
|
||||
@Schema(description = "主表ID")
|
||||
private java.lang.String mainId;
|
||||
/**用户ID*/
|
||||
@Excel(name = "用户ID", width = 15)
|
||||
@Schema(description = "用户ID")
|
||||
private java.lang.String userId;
|
||||
/**权限类型*/
|
||||
@Excel(name = "权限类型", width = 15, dicCode = "collaboration_permission")
|
||||
@Dict(dicCode = "collaboration_permission")
|
||||
@Schema(description = "权限类型")
|
||||
private java.lang.String permission;
|
||||
/**删除标识*/
|
||||
@Excel(name = "删除标识", width = 15)
|
||||
@Schema(description = "删除标识")
|
||||
@TableLogic
|
||||
private java.lang.String delFlag;
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package org.jeecg.modules.demo.tasklist.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface TaskListDetialMapper extends BaseMapper<TaskListDetial> {
|
||||
|
||||
boolean deleteByMainId(@Param("mainId") String mainId);
|
||||
|
||||
List<TaskListDetial> selectByMainId(@Param("mainId") String mainId);
|
||||
|
||||
void shiftSortOrderUp(@Param("mainId") String mainId, @Param("pid") String pid, @Param("fromSort") Integer fromSort);
|
||||
|
||||
void shiftSortOrderDown(@Param("mainId") String mainId, @Param("pid") String pid, @Param("fromSort") Integer fromSort);
|
||||
|
||||
Integer getMaxSortOrder(@Param("mainId") String mainId, @Param("pid") String pid);
|
||||
|
||||
int appendFollower(@Param("taskId") String taskId, @Param("userId") String userId, @Param("userName") String userName);
|
||||
|
||||
int removeFollower(@Param("taskId") String taskId, @Param("userId") String userId, @Param("userName") String userName);
|
||||
|
||||
int toggleTaskStatus(@Param("taskId") String taskId, @Param("updateBy") String updateBy, @Param("newStatus") Integer newStatus, @Param("completeTime") java.util.Date completeTime);
|
||||
|
||||
List<TaskListDetial> selectAllByMainId(@Param("mainId") String mainId);
|
||||
|
||||
List<TaskListDetial> selectTopLevelByMainId(@Param("mainId") String mainId);
|
||||
|
||||
List<TaskListDetial> selectSubTasksByPage(@Param("parentId") String parentId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
|
||||
|
||||
void updatePidAndSort(@Param("id") String id, @Param("pid") String pid, @Param("sortOrder") Integer sortOrder);
|
||||
|
||||
List<TaskListDetial> selectChildrenByPid(@Param("pid") String pid);
|
||||
|
||||
void resetPidToNull(@Param("pid") String pid, @Param("mainId") String mainId);
|
||||
|
||||
void incrementSubTaskCount(@Param("parentId") String parentId);
|
||||
|
||||
void decrementSubTaskCount(@Param("parentId") String parentId);
|
||||
|
||||
void incrementCompletedSubTaskCount(@Param("parentId") String parentId);
|
||||
|
||||
void decrementCompletedSubTaskCount(@Param("parentId") String parentId);
|
||||
|
||||
void updateHasChild(@Param("parentId") String parentId, @Param("hasChild") String hasChild);
|
||||
|
||||
void shiftSortOrderUpForGroup(@Param("mainId") String mainId, @Param("fromSort") Integer fromSort);
|
||||
|
||||
void shiftSortOrderDownForGroup(@Param("mainId") String mainId, @Param("fromSort") Integer fromSort);
|
||||
|
||||
Integer getMaxSortOrderForGroup(@Param("mainId") String mainId);
|
||||
|
||||
void updateSortOrder(@Param("id") String id, @Param("sortOrder") Integer sortOrder);
|
||||
|
||||
Integer countChildrenByPid(@Param("pid") String pid);
|
||||
|
||||
List<TaskListDetial> selectByAssigneeId(@Param("assigneeId") String assigneeId);
|
||||
|
||||
List<TaskListDetial> selectByFollowersId(@Param("followersId") String followersId);
|
||||
|
||||
void appendAssigner(@Param("taskId") String taskId, @Param("userId") String userId, @Param("userName") String userName);
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package org.jeecg.modules.demo.tasklist.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单收藏表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface TaskListFavoriteMapper extends BaseMapper<TaskListFavorite> {
|
||||
|
||||
/**
|
||||
* 通过主表id删除子表数据
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean deleteByMainId(@Param("mainId") String mainId);
|
||||
|
||||
/**
|
||||
* 通过主表id查询子表数据
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return List<TaskListFavorite>
|
||||
*/
|
||||
public List<TaskListFavorite> selectByMainId(@Param("mainId") String mainId);
|
||||
|
||||
Integer selectMaxSortOrder(@Param("userId") String userId, @Param("pid") String pid);
|
||||
|
||||
Integer selectMaxSortOrderByType(@Param("userId") String userId, @Param("pid") String pid, @Param("type") String type);
|
||||
|
||||
void shiftSortOrderUp(@Param("userId") String userId, @Param("pid") String pid, @Param("fromSort") Integer fromSort);
|
||||
|
||||
void shiftSortOrderDown(@Param("userId") String userId, @Param("pid") String pid, @Param("fromSort") Integer fromSort);
|
||||
|
||||
void shiftSortOrderUpByType(@Param("userId") String userId, @Param("type") String type, @Param("fromSort") Integer fromSort);
|
||||
|
||||
void shiftSortOrderDownByType(@Param("userId") String userId, @Param("type") String type, @Param("fromSort") Integer fromSort);
|
||||
|
||||
Integer countChildrenByPid(@Param("userId") String userId, @Param("pid") String pid);
|
||||
|
||||
void updatePidAndSort(@Param("id") String id, @Param("pid") String pid, @Param("sortOrder") Integer sortOrder);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.demo.tasklist.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskList;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface TaskListMapper extends BaseMapper<TaskList> {
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package org.jeecg.modules.demo.tasklist.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface TaskListPermissionMapper extends BaseMapper<TaskListPermission> {
|
||||
|
||||
/**
|
||||
* 通过主表id删除子表数据
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean deleteByMainId(@Param("mainId") String mainId);
|
||||
|
||||
/**
|
||||
* 通过主表id查询子表数据
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return List<TaskListPermission>
|
||||
*/
|
||||
public List<TaskListPermission> selectByMainId(@Param("mainId") String mainId);
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
<?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="org.jeecg.modules.demo.tasklist.mapper.TaskListDetialMapper">
|
||||
|
||||
<delete id="deleteByMainId" parameterType="java.lang.String">
|
||||
DELETE FROM task_list_detial WHERE main_id = #{mainId}
|
||||
</delete>
|
||||
|
||||
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial WHERE main_id = #{mainId}
|
||||
</select>
|
||||
|
||||
<update id="shiftSortOrderUp">
|
||||
UPDATE task_list_detial
|
||||
SET sort_order = sort_order + 1
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
AND sort_order >= #{fromSort}
|
||||
</update>
|
||||
|
||||
<update id="shiftSortOrderDown">
|
||||
UPDATE task_list_detial
|
||||
SET sort_order = sort_order - 1
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
AND sort_order > #{fromSort}
|
||||
</update>
|
||||
|
||||
<select id="getMaxSortOrder" resultType="java.lang.Integer">
|
||||
SELECT IFNULL(MAX(sort_order), 0)
|
||||
FROM task_list_detial
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
</select>
|
||||
|
||||
<update id="appendFollower">
|
||||
UPDATE task_list_detial
|
||||
SET followers_id = CONCAT(IFNULL(followers_id, ''), ',', #{userId}),
|
||||
followers_name = CONCAT(IFNULL(followers_name, ''), ',', #{userName})
|
||||
WHERE id = #{taskId} AND del_flag = '0'
|
||||
AND (followers_id IS NULL OR followers_id NOT LIKE CONCAT('%', #{userId}, '%'))
|
||||
</update>
|
||||
|
||||
<update id="removeFollower">
|
||||
UPDATE task_list_detial
|
||||
SET followers_id = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', followers_id, ','), CONCAT(',', #{userId}, ','), ',')),
|
||||
followers_name = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', followers_name, ','), CONCAT(',', #{userName}, ','), ','))
|
||||
WHERE id = #{taskId} AND del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="toggleTaskStatus">
|
||||
UPDATE task_list_detial
|
||||
SET task_status = #{newStatus},
|
||||
complete_time = #{completeTime},
|
||||
update_by = #{updateBy}, update_time = NOW()
|
||||
WHERE id = #{taskId} AND del_flag = '0'
|
||||
</update>
|
||||
|
||||
<select id="selectAllByMainId" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
ORDER BY sort_order ASC
|
||||
</select>
|
||||
|
||||
<select id="selectTopLevelByMainId" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND (
|
||||
type = '0'
|
||||
OR (type = '1' AND (pid IS NULL OR EXISTS (
|
||||
SELECT 1 FROM task_list_detial g WHERE g.id = task_list_detial.pid AND g.type = '0' AND g.del_flag = '0'
|
||||
)))
|
||||
)
|
||||
ORDER BY sort_order ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSubTasksByPage" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial
|
||||
WHERE pid = #{parentId} AND type = '1' AND del_flag = '0'
|
||||
ORDER BY sort_order ASC
|
||||
LIMIT #{offset}, #{pageSize}
|
||||
</select>
|
||||
|
||||
<update id="updatePidAndSort">
|
||||
UPDATE task_list_detial
|
||||
SET pid = #{pid}, sort_order = #{sortOrder}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectChildrenByPid" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial
|
||||
WHERE pid = #{pid} AND del_flag = '0'
|
||||
</select>
|
||||
|
||||
<update id="resetPidToNull">
|
||||
UPDATE task_list_detial
|
||||
SET pid = NULL
|
||||
WHERE pid = #{pid} AND main_id = #{mainId} AND del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="incrementSubTaskCount">
|
||||
UPDATE task_list_detial SET sub_task_count = IFNULL(sub_task_count, 0) + 1, has_child = '1'
|
||||
WHERE id = #{parentId}
|
||||
</update>
|
||||
|
||||
<update id="decrementSubTaskCount">
|
||||
UPDATE task_list_detial SET sub_task_count = GREATEST(IFNULL(sub_task_count, 1) - 1, 0)
|
||||
WHERE id = #{parentId}
|
||||
</update>
|
||||
|
||||
<update id="incrementCompletedSubTaskCount">
|
||||
UPDATE task_list_detial SET completed_sub_task_count = IFNULL(completed_sub_task_count, 0) + 1
|
||||
WHERE id = #{parentId}
|
||||
</update>
|
||||
|
||||
<update id="decrementCompletedSubTaskCount">
|
||||
UPDATE task_list_detial SET completed_sub_task_count = GREATEST(IFNULL(completed_sub_task_count, 1) - 1, 0)
|
||||
WHERE id = #{parentId}
|
||||
</update>
|
||||
|
||||
<update id="updateHasChild">
|
||||
UPDATE task_list_detial SET has_child = #{hasChild} WHERE id = #{parentId}
|
||||
</update>
|
||||
|
||||
<update id="shiftSortOrderUpForGroup">
|
||||
UPDATE task_list_detial
|
||||
SET sort_order = sort_order + 1
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND type = '0'
|
||||
AND (pid IS NULL OR pid = '')
|
||||
AND sort_order >= #{fromSort}
|
||||
</update>
|
||||
|
||||
<update id="shiftSortOrderDownForGroup">
|
||||
UPDATE task_list_detial
|
||||
SET sort_order = sort_order - 1
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND type = '0'
|
||||
AND (pid IS NULL OR pid = '')
|
||||
AND sort_order > #{fromSort}
|
||||
</update>
|
||||
|
||||
<select id="getMaxSortOrderForGroup" resultType="java.lang.Integer">
|
||||
SELECT IFNULL(MAX(sort_order), 0)
|
||||
FROM task_list_detial
|
||||
WHERE main_id = #{mainId} AND del_flag = '0'
|
||||
AND type = '0'
|
||||
AND (pid IS NULL OR pid = '')
|
||||
</select>
|
||||
|
||||
<update id="updateSortOrder">
|
||||
UPDATE task_list_detial SET sort_order = #{sortOrder} WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="countChildrenByPid" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM task_list_detial
|
||||
WHERE pid = #{pid} AND del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectByAssigneeId" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial
|
||||
WHERE type = '1' AND del_flag = '0'
|
||||
AND assignee_id LIKE CONCAT('%', #{assigneeId}, '%')
|
||||
</select>
|
||||
|
||||
<select id="selectByFollowersId" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListDetial">
|
||||
SELECT * FROM task_list_detial
|
||||
WHERE type = '1' AND del_flag = '0'
|
||||
AND followers_id LIKE CONCAT('%', #{followersId}, '%')
|
||||
</select>
|
||||
|
||||
<update id="appendAssigner">
|
||||
UPDATE task_list_detial
|
||||
SET assign_id = TRIM(BOTH ',' FROM CONCAT(IFNULL(assign_id, ''), ',', #{userId})),
|
||||
assign_name = TRIM(BOTH ',' FROM CONCAT(IFNULL(assign_name, ''), ',', #{userName}))
|
||||
WHERE id = #{taskId} AND del_flag = '0'
|
||||
AND (assign_id IS NULL OR assign_id NOT LIKE CONCAT('%', #{userId}, '%'))
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?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="org.jeecg.modules.demo.tasklist.mapper.TaskListFavoriteMapper">
|
||||
|
||||
<delete id="deleteByMainId" parameterType="java.lang.String">
|
||||
DELETE
|
||||
FROM task_list_favorite
|
||||
WHERE
|
||||
main_id = #{mainId} </delete>
|
||||
|
||||
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListFavorite">
|
||||
SELECT *
|
||||
FROM task_list_favorite
|
||||
WHERE
|
||||
main_id = #{mainId} </select>
|
||||
|
||||
<select id="selectMaxSortOrder" resultType="java.lang.Integer">
|
||||
SELECT IFNULL(MAX(sort_order), 0)
|
||||
FROM task_list_favorite
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
</select>
|
||||
|
||||
<select id="selectMaxSortOrderByType" resultType="java.lang.Integer">
|
||||
SELECT IFNULL(MAX(sort_order), 0)
|
||||
FROM task_list_favorite
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND type = #{type}
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
</select>
|
||||
|
||||
<update id="shiftSortOrderUp">
|
||||
UPDATE task_list_favorite
|
||||
SET sort_order = sort_order + 1
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
AND sort_order >= #{fromSort}
|
||||
</update>
|
||||
|
||||
<update id="shiftSortOrderDown">
|
||||
UPDATE task_list_favorite
|
||||
SET sort_order = sort_order - 1
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
AND sort_order > #{fromSort}
|
||||
</update>
|
||||
|
||||
<update id="shiftSortOrderUpByType">
|
||||
UPDATE task_list_favorite
|
||||
SET sort_order = sort_order + 1
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND type = #{type}
|
||||
AND pid IS NULL
|
||||
AND sort_order >= #{fromSort}
|
||||
</update>
|
||||
|
||||
<update id="shiftSortOrderDownByType">
|
||||
UPDATE task_list_favorite
|
||||
SET sort_order = sort_order - 1
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND type = #{type}
|
||||
AND pid IS NULL
|
||||
AND sort_order > #{fromSort}
|
||||
</update>
|
||||
|
||||
<select id="countChildrenByPid" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM task_list_favorite
|
||||
WHERE user_id = #{userId} AND del_flag = '0'
|
||||
AND (pid = #{pid} OR (#{pid} IS NULL AND pid IS NULL))
|
||||
</select>
|
||||
|
||||
<update id="updatePidAndSort">
|
||||
UPDATE task_list_favorite
|
||||
SET pid = #{pid}, sort_order = #{sortOrder}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?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="org.jeecg.modules.demo.tasklist.mapper.TaskListMapper">
|
||||
|
||||
</mapper>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?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="org.jeecg.modules.demo.tasklist.mapper.TaskListPermissionMapper">
|
||||
|
||||
<delete id="deleteByMainId" parameterType="java.lang.String">
|
||||
DELETE
|
||||
FROM task_list_permission
|
||||
WHERE
|
||||
main_id = #{mainId} </delete>
|
||||
|
||||
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.tasklist.entity.TaskListPermission">
|
||||
SELECT *
|
||||
FROM task_list_permission
|
||||
WHERE
|
||||
main_id = #{mainId} </select>
|
||||
</mapper>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package org.jeecg.modules.demo.tasklist.service;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.MoveTaskReq;
|
||||
|
||||
public interface ITaskListDetialService extends IService<TaskListDetial> {
|
||||
|
||||
List<TaskListDetial> selectByMainId(String mainId);
|
||||
|
||||
TaskListDetial createTask(CreateTaskReq req);
|
||||
|
||||
void editTask(TaskListDetial task);
|
||||
|
||||
void deleteTask(String taskId);
|
||||
|
||||
List<TaskListDetial> queryAllByMainId(String mainId);
|
||||
|
||||
List<TaskListDetial> queryTopLevelByMainId(String mainId);
|
||||
|
||||
void toggleStatus(String taskId);
|
||||
|
||||
void moveTask(MoveTaskReq req);
|
||||
|
||||
void moveTaskGroup(String taskGroupId, Integer targetSortOrder);
|
||||
|
||||
void followTask(String taskId);
|
||||
|
||||
void unfollowTask(String taskId);
|
||||
|
||||
List<TaskListDetial> loadSubTasks(String parentTaskId, Integer pageNo, Integer pageSize);
|
||||
|
||||
void ensureDefaultGroup(String mainId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package org.jeecg.modules.demo.tasklist.service;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单收藏表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITaskListFavoriteService extends IService<TaskListFavorite> {
|
||||
|
||||
/**
|
||||
* 通过主表id查询子表数据
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return List<TaskListFavorite>
|
||||
*/
|
||||
public List<TaskListFavorite> selectByMainId(String mainId);
|
||||
|
||||
Integer getMaxSortOrder(String userId, String pid);
|
||||
|
||||
Integer getMaxSortOrderByType(String userId, String pid, String type);
|
||||
|
||||
void shiftSortOrderUp(String userId, String pid, Integer fromSort);
|
||||
|
||||
void shiftSortOrderDown(String userId, String pid, Integer fromSort);
|
||||
|
||||
void shiftSortOrderUpByType(String userId, String type, Integer fromSort);
|
||||
|
||||
void shiftSortOrderDownByType(String userId, String type, Integer fromSort);
|
||||
|
||||
Integer countChildren(String userId, String pid);
|
||||
|
||||
void updatePidAndSort(String favoriteId, String pid, Integer sortOrder);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package org.jeecg.modules.demo.tasklist.service;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITaskListPermissionService extends IService<TaskListPermission> {
|
||||
|
||||
/**
|
||||
* 通过主表id查询子表数据
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return List<TaskListPermission>
|
||||
*/
|
||||
public List<TaskListPermission> selectByMainId(String mainId);
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package org.jeecg.modules.demo.tasklist.service;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskList;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskListReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskListGroupReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.MoveTaskListReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.AddCollaboratorReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CollaboratorVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITaskListService extends IService<TaskList> {
|
||||
|
||||
/**
|
||||
* 添加一对多
|
||||
*
|
||||
* @param taskList
|
||||
* @param taskListDetialList
|
||||
* @param taskListPermissionList
|
||||
* @param taskListFavoriteList
|
||||
*/
|
||||
public void saveMain(TaskList taskList,List<TaskListDetial> taskListDetialList,List<TaskListPermission> taskListPermissionList,List<TaskListFavorite> taskListFavoriteList) ;
|
||||
|
||||
/**
|
||||
* 修改一对多
|
||||
*
|
||||
* @param taskList
|
||||
* @param taskListDetialList
|
||||
* @param taskListPermissionList
|
||||
* @param taskListFavoriteList
|
||||
*/
|
||||
public void updateMain(TaskList taskList,List<TaskListDetial> taskListDetialList,List<TaskListPermission> taskListPermissionList,List<TaskListFavorite> taskListFavoriteList);
|
||||
|
||||
/**
|
||||
* 删除一对多
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void delMain (String id);
|
||||
|
||||
/**
|
||||
* 批量删除一对多
|
||||
*
|
||||
* @param idList
|
||||
*/
|
||||
public void delBatchMain (Collection<? extends Serializable> idList);
|
||||
|
||||
String createTaskList(CreateTaskListReq req);
|
||||
|
||||
String createTaskListGroup(CreateTaskListGroupReq req);
|
||||
|
||||
void moveTaskList(MoveTaskListReq req);
|
||||
|
||||
void moveGroup(String groupId, Integer sortOrder);
|
||||
|
||||
List<TaskListFavorite> getMyFavorites();
|
||||
|
||||
void deleteTaskList(String taskListId);
|
||||
|
||||
void removeFavorite(String favoriteId);
|
||||
|
||||
void removeFavoriteGroup(String groupId);
|
||||
|
||||
void renameGroup(String groupId, String newName);
|
||||
|
||||
void renameTaskList(String taskListId, String newName);
|
||||
|
||||
List<TaskList> getMyOwnLists();
|
||||
|
||||
List<TaskList> getAllLists();
|
||||
|
||||
List<TaskList> getMyCollabLists();
|
||||
|
||||
List<CollaboratorVO> getCollaborators(String taskListId);
|
||||
|
||||
void addCollaborator(AddCollaboratorReq req);
|
||||
|
||||
void removeCollaborator(String permissionId);
|
||||
|
||||
void updateCollaboratorPermission(String permissionId, String newPermission);
|
||||
|
||||
String getMyPermission(String taskListId);
|
||||
|
||||
void addToFavorites(String taskListId);
|
||||
|
||||
List<TaskListDetial> myResponsibleTasks();
|
||||
|
||||
List<TaskListDetial> myFollowedTasks();
|
||||
|
||||
}
|
||||
+512
@@ -0,0 +1,512 @@
|
||||
package org.jeecg.modules.demo.tasklist.service.impl;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListDetialMapper;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListPermissionMapper;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListDetialService;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.MoveTaskReq;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class TaskListDetialServiceImpl extends ServiceImpl<TaskListDetialMapper, TaskListDetial> implements ITaskListDetialService {
|
||||
|
||||
@Autowired
|
||||
private TaskListDetialMapper taskListDetialMapper;
|
||||
@Autowired
|
||||
private TaskListPermissionMapper taskListPermissionMapper;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
@Override
|
||||
public List<TaskListDetial> selectByMainId(String mainId) {
|
||||
return taskListDetialMapper.selectByMainId(mainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TaskListDetial createTask(CreateTaskReq req) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
String permission = getPermission(req.getMainId(), userId);
|
||||
if (permission == null) {
|
||||
throw new RuntimeException("无权限在此清单中创建任务");
|
||||
}
|
||||
if ("3".equals(permission)) {
|
||||
throw new RuntimeException("可阅读者无法创建任务");
|
||||
}
|
||||
|
||||
if ("1".equals(req.getType()) && oConvertUtils.isEmpty(req.getPid())) {
|
||||
ensureDefaultGroup(req.getMainId());
|
||||
TaskListDetial defaultGroup = findDefaultGroup(req.getMainId());
|
||||
if (defaultGroup != null) {
|
||||
req.setPid(defaultGroup.getId());
|
||||
}
|
||||
}
|
||||
|
||||
TaskListDetial entity = new TaskListDetial();
|
||||
entity.setMainId(req.getMainId());
|
||||
entity.setTaskName(req.getTaskName());
|
||||
entity.setTaskDesc(req.getTaskDesc());
|
||||
entity.setPriority(req.getPriority());
|
||||
entity.setType(req.getType() != null ? req.getType() : "1");
|
||||
entity.setPid(normalizePid(req.getPid()));
|
||||
entity.setTaskStatus(0);
|
||||
entity.setSubTaskCount(0);
|
||||
entity.setCompletedSubTaskCount(0);
|
||||
entity.setHasChild("0");
|
||||
entity.setCreateBy(userId);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setDelFlag("0");
|
||||
entity.setSysOrgCode(loginUser.getOrgCode());
|
||||
|
||||
if ("1".equals(req.getType()) && oConvertUtils.isNotEmpty(req.getAssigneeId())) {
|
||||
entity.setAssigneeId(req.getAssigneeId());
|
||||
entity.setAssigneeName(translateUserIdsToNames(req.getAssigneeId()));
|
||||
entity.setAssignId(userId);
|
||||
entity.setAssignName(loginUser.getRealname());
|
||||
}
|
||||
|
||||
if (req.getStartTime() != null) {
|
||||
entity.setStartTime(req.getStartTime());
|
||||
}
|
||||
if (req.getEndTime() != null) {
|
||||
entity.setEndTime(req.getEndTime());
|
||||
}
|
||||
|
||||
if (req.getSortOrder() != null) {
|
||||
taskListDetialMapper.shiftSortOrderUp(req.getMainId(), normalizePid(req.getPid()), req.getSortOrder());
|
||||
entity.setSortOrder(req.getSortOrder());
|
||||
} else {
|
||||
Integer maxSort = taskListDetialMapper.getMaxSortOrder(req.getMainId(), normalizePid(req.getPid()));
|
||||
entity.setSortOrder(maxSort + 1);
|
||||
}
|
||||
|
||||
taskListDetialMapper.insert(entity);
|
||||
|
||||
if ("1".equals(entity.getType()) && oConvertUtils.isNotEmpty(entity.getPid())) {
|
||||
TaskListDetial parent = taskListDetialMapper.selectById(entity.getPid());
|
||||
if (parent != null && "1".equals(parent.getType())) {
|
||||
taskListDetialMapper.incrementSubTaskCount(parent.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void editTask(TaskListDetial task) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListDetial existing = taskListDetialMapper.selectById(task.getId());
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
|
||||
String permission = getPermission(existing.getMainId(), userId);
|
||||
if (permission == null) {
|
||||
throw new RuntimeException("无权限编辑此任务");
|
||||
}
|
||||
if ("3".equals(permission)) {
|
||||
String assigneeId = existing.getAssigneeId();
|
||||
if (oConvertUtils.isEmpty(assigneeId) || !assigneeId.contains(userId)) {
|
||||
throw new RuntimeException("可阅读者只能编辑自己负责的任务");
|
||||
}
|
||||
}
|
||||
|
||||
if (task.getAssigneeId() != null) {
|
||||
if (oConvertUtils.isNotEmpty(task.getAssigneeId()) && oConvertUtils.isEmpty(task.getAssigneeName())) {
|
||||
task.setAssigneeName(translateUserIdsToNames(task.getAssigneeId()));
|
||||
}
|
||||
if (oConvertUtils.isEmpty(task.getAssigneeId())) {
|
||||
task.setAssigneeName("");
|
||||
}
|
||||
}
|
||||
|
||||
if (task.getParticipantId() != null) {
|
||||
if (oConvertUtils.isNotEmpty(task.getParticipantId()) && oConvertUtils.isEmpty(task.getParticipantName())) {
|
||||
task.setParticipantName(translateUserIdsToNames(task.getParticipantId()));
|
||||
}
|
||||
if (oConvertUtils.isEmpty(task.getParticipantId())) {
|
||||
task.setParticipantName("");
|
||||
}
|
||||
}
|
||||
|
||||
if (task.getFollowersId() != null) {
|
||||
if (oConvertUtils.isNotEmpty(task.getFollowersId()) && oConvertUtils.isEmpty(task.getFollowersName())) {
|
||||
task.setFollowersName(translateUserIdsToNames(task.getFollowersId()));
|
||||
}
|
||||
if (oConvertUtils.isEmpty(task.getFollowersId())) {
|
||||
task.setFollowersName("");
|
||||
}
|
||||
}
|
||||
|
||||
task.setUpdateBy(userId);
|
||||
task.setUpdateTime(new Date());
|
||||
|
||||
boolean clearStartTime = task.getStartTime() == null && existing.getStartTime() != null;
|
||||
boolean clearEndTime = task.getEndTime() == null && existing.getEndTime() != null;
|
||||
|
||||
taskListDetialMapper.updateById(task);
|
||||
|
||||
if (clearStartTime || clearEndTime) {
|
||||
UpdateWrapper<TaskListDetial> uw = new UpdateWrapper<>();
|
||||
uw.eq("id", task.getId());
|
||||
if (clearStartTime) uw.set("start_time", null);
|
||||
if (clearEndTime) uw.set("end_time", null);
|
||||
taskListDetialMapper.update(null, uw);
|
||||
}
|
||||
|
||||
taskListDetialMapper.appendAssigner(task.getId(), userId, loginUser.getRealname());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteTask(String taskId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListDetial existing = taskListDetialMapper.selectById(taskId);
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
|
||||
String permission = getPermission(existing.getMainId(), userId);
|
||||
if (permission == null) {
|
||||
throw new RuntimeException("无权限删除此任务");
|
||||
}
|
||||
if ("3".equals(permission)) {
|
||||
throw new RuntimeException("可阅读者无法删除任务");
|
||||
}
|
||||
|
||||
if ("0".equals(existing.getType()) && "默认分组".equals(existing.getTaskName())) {
|
||||
throw new RuntimeException("默认分组不能删除");
|
||||
}
|
||||
|
||||
if ("0".equals(existing.getType())) {
|
||||
taskListDetialMapper.resetPidToNull(taskId, existing.getMainId());
|
||||
}
|
||||
|
||||
List<TaskListDetial> children = taskListDetialMapper.selectChildrenByPid(taskId);
|
||||
for (TaskListDetial child : children) {
|
||||
deleteTaskRecursive(child);
|
||||
}
|
||||
|
||||
taskListDetialMapper.deleteById(taskId);
|
||||
|
||||
if (oConvertUtils.isNotEmpty(existing.getPid())) {
|
||||
TaskListDetial parent = taskListDetialMapper.selectById(existing.getPid());
|
||||
if (parent != null && "1".equals(parent.getType())) {
|
||||
taskListDetialMapper.decrementSubTaskCount(parent.getId());
|
||||
if (existing.getTaskStatus() != null && existing.getTaskStatus() == 1) {
|
||||
taskListDetialMapper.decrementCompletedSubTaskCount(parent.getId());
|
||||
}
|
||||
Integer childCount = taskListDetialMapper.countChildrenByPid(parent.getId());
|
||||
if (childCount == null || childCount == 0) {
|
||||
taskListDetialMapper.updateHasChild(parent.getId(), "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteTaskRecursive(TaskListDetial task) {
|
||||
List<TaskListDetial> children = taskListDetialMapper.selectChildrenByPid(task.getId());
|
||||
for (TaskListDetial child : children) {
|
||||
deleteTaskRecursive(child);
|
||||
}
|
||||
taskListDetialMapper.deleteById(task.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskListDetial> queryAllByMainId(String mainId) {
|
||||
List<TaskListDetial> list = taskListDetialMapper.selectAllByMainId(mainId);
|
||||
fillCreateByName(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskListDetial> queryTopLevelByMainId(String mainId) {
|
||||
List<TaskListDetial> list = taskListDetialMapper.selectTopLevelByMainId(mainId);
|
||||
fillCreateByName(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void toggleStatus(String taskId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListDetial existing = taskListDetialMapper.selectById(taskId);
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
|
||||
String permission = getPermission(existing.getMainId(), userId);
|
||||
if (permission == null) {
|
||||
throw new RuntimeException("无权限操作此任务");
|
||||
}
|
||||
if ("3".equals(permission)) {
|
||||
String assigneeId = existing.getAssigneeId();
|
||||
if (oConvertUtils.isEmpty(assigneeId) || !assigneeId.contains(userId)) {
|
||||
throw new RuntimeException("可阅读者只能操作自己负责的任务");
|
||||
}
|
||||
}
|
||||
|
||||
int oldStatus = existing.getTaskStatus() != null ? existing.getTaskStatus() : 0;
|
||||
int newStatus = oldStatus == 0 ? 1 : 0;
|
||||
java.util.Date completeTime = oldStatus == 0 ? new java.util.Date() : null;
|
||||
|
||||
taskListDetialMapper.toggleTaskStatus(taskId, userId, newStatus, completeTime);
|
||||
|
||||
if (oConvertUtils.isNotEmpty(existing.getPid())) {
|
||||
TaskListDetial parent = taskListDetialMapper.selectById(existing.getPid());
|
||||
if (parent != null && "1".equals(parent.getType())) {
|
||||
if (oldStatus == 0) {
|
||||
taskListDetialMapper.incrementCompletedSubTaskCount(parent.getId());
|
||||
} else {
|
||||
taskListDetialMapper.decrementCompletedSubTaskCount(parent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void moveTask(MoveTaskReq req) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListDetial task = taskListDetialMapper.selectById(req.getTaskId());
|
||||
if (task == null) {
|
||||
throw new RuntimeException("任务不存在");
|
||||
}
|
||||
|
||||
String permission = getPermission(task.getMainId(), userId);
|
||||
if (permission == null) {
|
||||
throw new RuntimeException("无权限移动此任务");
|
||||
}
|
||||
if ("3".equals(permission)) {
|
||||
throw new RuntimeException("可阅读者无法移动任务");
|
||||
}
|
||||
|
||||
String oldPid = normalizePid(task.getPid());
|
||||
Integer oldSort = task.getSortOrder();
|
||||
String newPid = normalizePid(req.getTargetPid());
|
||||
|
||||
Integer maxSort = taskListDetialMapper.getMaxSortOrder(task.getMainId(), newPid);
|
||||
Integer targetSort;
|
||||
if (req.getTargetSortOrder() != null) {
|
||||
targetSort = req.getTargetSortOrder();
|
||||
} else {
|
||||
targetSort = maxSort + 1;
|
||||
}
|
||||
if (targetSort < 1) targetSort = 1;
|
||||
if (targetSort > maxSort + 1) targetSort = maxSort + 1;
|
||||
|
||||
taskListDetialMapper.shiftSortOrderDown(task.getMainId(), oldPid, oldSort);
|
||||
|
||||
taskListDetialMapper.shiftSortOrderUp(task.getMainId(), newPid, targetSort);
|
||||
|
||||
taskListDetialMapper.updatePidAndSort(req.getTaskId(), newPid, targetSort);
|
||||
|
||||
if (oConvertUtils.isNotEmpty(oldPid)) {
|
||||
TaskListDetial oldParent = taskListDetialMapper.selectById(oldPid);
|
||||
if (oldParent != null && "1".equals(oldParent.getType())) {
|
||||
Integer childCount = taskListDetialMapper.countChildrenByPid(oldPid);
|
||||
if (childCount == null || childCount == 0) {
|
||||
taskListDetialMapper.updateHasChild(oldPid, "0");
|
||||
}
|
||||
taskListDetialMapper.decrementSubTaskCount(oldPid);
|
||||
}
|
||||
}
|
||||
|
||||
if (oConvertUtils.isNotEmpty(newPid)) {
|
||||
TaskListDetial newParent = taskListDetialMapper.selectById(newPid);
|
||||
if (newParent != null && "1".equals(newParent.getType())) {
|
||||
taskListDetialMapper.incrementSubTaskCount(newPid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void moveTaskGroup(String taskGroupId, Integer targetSortOrder) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListDetial group = taskListDetialMapper.selectById(taskGroupId);
|
||||
if (group == null || !"0".equals(group.getType())) {
|
||||
throw new RuntimeException("分组不存在");
|
||||
}
|
||||
String mainId = group.getMainId();
|
||||
|
||||
String permission = getPermission(mainId, userId);
|
||||
if (permission == null || "3".equals(permission)) {
|
||||
throw new RuntimeException("无权限移动此分组");
|
||||
}
|
||||
|
||||
Integer oldSort = group.getSortOrder();
|
||||
Integer maxSort = taskListDetialMapper.getMaxSortOrderForGroup(mainId);
|
||||
Integer targetSort = targetSortOrder != null ? targetSortOrder : 1;
|
||||
if (targetSort < 1) targetSort = 1;
|
||||
if (targetSort > maxSort) targetSort = maxSort;
|
||||
|
||||
taskListDetialMapper.shiftSortOrderDownForGroup(mainId, oldSort);
|
||||
|
||||
taskListDetialMapper.shiftSortOrderUpForGroup(mainId, targetSort);
|
||||
|
||||
taskListDetialMapper.updateSortOrder(taskGroupId, targetSort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void followTask(String taskId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
String userName = loginUser.getRealname();
|
||||
taskListDetialMapper.appendFollower(taskId, userId, userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unfollowTask(String taskId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
String userName = loginUser.getRealname();
|
||||
taskListDetialMapper.removeFollower(taskId, userId, userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskListDetial> loadSubTasks(String parentTaskId, Integer pageNo, Integer pageSize) {
|
||||
if (pageNo == null || pageNo < 1) pageNo = 1;
|
||||
if (pageSize == null || pageSize < 1) pageSize = 20;
|
||||
int offset = (pageNo - 1) * pageSize;
|
||||
List<TaskListDetial> list = taskListDetialMapper.selectSubTasksByPage(parentTaskId, offset, pageSize);
|
||||
fillCreateByName(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void ensureDefaultGroup(String mainId) {
|
||||
TaskListDetial defaultGroup = findDefaultGroup(mainId);
|
||||
if (defaultGroup == null) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TaskListDetial group = new TaskListDetial();
|
||||
group.setMainId(mainId);
|
||||
group.setTaskName("默认分组");
|
||||
group.setType("0");
|
||||
group.setPid(null);
|
||||
group.setSortOrder(0);
|
||||
group.setHasChild("0");
|
||||
group.setSubTaskCount(0);
|
||||
group.setCompletedSubTaskCount(0);
|
||||
group.setCreateBy(loginUser.getId());
|
||||
group.setCreateTime(new Date());
|
||||
group.setDelFlag("0");
|
||||
taskListDetialMapper.insert(group);
|
||||
}
|
||||
}
|
||||
|
||||
private TaskListDetial findDefaultGroup(String mainId) {
|
||||
LambdaQueryWrapper<TaskListDetial> query = new LambdaQueryWrapper<>();
|
||||
query.eq(TaskListDetial::getMainId, mainId);
|
||||
query.eq(TaskListDetial::getType, "0");
|
||||
query.eq(TaskListDetial::getTaskName, "默认分组");
|
||||
query.last("LIMIT 1");
|
||||
return taskListDetialMapper.selectOne(query);
|
||||
}
|
||||
|
||||
private String getPermission(String mainId, String userId) {
|
||||
LambdaQueryWrapper<TaskListPermission> query = new LambdaQueryWrapper<>();
|
||||
query.eq(TaskListPermission::getMainId, mainId);
|
||||
query.eq(TaskListPermission::getUserId, userId);
|
||||
TaskListPermission perm = taskListPermissionMapper.selectOne(query);
|
||||
return perm != null ? perm.getPermission() : null;
|
||||
}
|
||||
|
||||
private String normalizePid(String pid) {
|
||||
return oConvertUtils.isNotEmpty(pid) ? pid : null;
|
||||
}
|
||||
|
||||
private void fillCreateByName(List<TaskListDetial> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (TaskListDetial task : list) {
|
||||
if (oConvertUtils.isNotEmpty(task.getCreateBy())) {
|
||||
LoginUser createUser = sysBaseAPI.getUserById(task.getCreateBy());
|
||||
if (createUser != null) {
|
||||
task.setCreateByName(createUser.getRealname());
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(task.getAssigneeId()) && oConvertUtils.isEmpty(task.getAssigneeName())) {
|
||||
task.setAssigneeName(translateUserIdsToNames(task.getAssigneeId()));
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(task.getParticipantId()) && oConvertUtils.isEmpty(task.getParticipantName())) {
|
||||
task.setParticipantName(translateUserIdsToNames(task.getParticipantId()));
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(task.getFollowersId()) && oConvertUtils.isEmpty(task.getFollowersName())) {
|
||||
task.setFollowersName(translateUserIdsToNames(task.getFollowersId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String translateUserIdsToNames(String ids) {
|
||||
if (oConvertUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
String[] idArr = ids.split(",");
|
||||
StringBuilder names = new StringBuilder();
|
||||
for (String id : idArr) {
|
||||
if (oConvertUtils.isNotEmpty(id)) {
|
||||
LoginUser user = sysBaseAPI.getUserById(id.trim());
|
||||
if (user != null) {
|
||||
if (names.length() > 0) {
|
||||
names.append(",");
|
||||
}
|
||||
names.append(user.getRealname());
|
||||
}
|
||||
}
|
||||
}
|
||||
return names.length() > 0 ? names.toString() : null;
|
||||
}
|
||||
|
||||
private String mergeIds(String existingIds, String newIds) {
|
||||
Set<String> idSet = new LinkedHashSet<>();
|
||||
if (oConvertUtils.isNotEmpty(existingIds)) {
|
||||
for (String id : existingIds.split(",")) {
|
||||
String trimmed = id.trim();
|
||||
if (oConvertUtils.isNotEmpty(trimmed)) {
|
||||
idSet.add(trimmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(newIds)) {
|
||||
for (String id : newIds.split(",")) {
|
||||
String trimmed = id.trim();
|
||||
if (oConvertUtils.isNotEmpty(trimmed)) {
|
||||
idSet.add(trimmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
return idSet.isEmpty() ? null : String.join(",", idSet);
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package org.jeecg.modules.demo.tasklist.service.impl;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListFavoriteMapper;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListFavoriteService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单收藏表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TaskListFavoriteServiceImpl extends ServiceImpl<TaskListFavoriteMapper, TaskListFavorite> implements ITaskListFavoriteService {
|
||||
|
||||
@Autowired
|
||||
private TaskListFavoriteMapper taskListFavoriteMapper;
|
||||
|
||||
@Override
|
||||
public List<TaskListFavorite> selectByMainId(String mainId) {
|
||||
return taskListFavoriteMapper.selectByMainId(mainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMaxSortOrder(String userId, String pid) {
|
||||
Integer max = taskListFavoriteMapper.selectMaxSortOrder(userId, pid);
|
||||
return max != null ? max : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMaxSortOrderByType(String userId, String pid, String type) {
|
||||
Integer max = taskListFavoriteMapper.selectMaxSortOrderByType(userId, pid, type);
|
||||
return max != null ? max : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shiftSortOrderUp(String userId, String pid, Integer fromSort) {
|
||||
taskListFavoriteMapper.shiftSortOrderUp(userId, pid, fromSort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shiftSortOrderDown(String userId, String pid, Integer fromSort) {
|
||||
taskListFavoriteMapper.shiftSortOrderDown(userId, pid, fromSort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shiftSortOrderUpByType(String userId, String type, Integer fromSort) {
|
||||
taskListFavoriteMapper.shiftSortOrderUpByType(userId, type, fromSort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shiftSortOrderDownByType(String userId, String type, Integer fromSort) {
|
||||
taskListFavoriteMapper.shiftSortOrderDownByType(userId, type, fromSort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countChildren(String userId, String pid) {
|
||||
return taskListFavoriteMapper.countChildrenByPid(userId, pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePidAndSort(String favoriteId, String pid, Integer sortOrder) {
|
||||
taskListFavoriteMapper.updatePidAndSort(favoriteId, pid, sortOrder);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.jeecg.modules.demo.tasklist.service.impl;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListPermissionMapper;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListPermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TaskListPermissionServiceImpl extends ServiceImpl<TaskListPermissionMapper, TaskListPermission> implements ITaskListPermissionService {
|
||||
|
||||
@Autowired
|
||||
private TaskListPermissionMapper taskListPermissionMapper;
|
||||
|
||||
@Override
|
||||
public List<TaskListPermission> selectByMainId(String mainId) {
|
||||
return taskListPermissionMapper.selectByMainId(mainId);
|
||||
}
|
||||
}
|
||||
+758
@@ -0,0 +1,758 @@
|
||||
package org.jeecg.modules.demo.tasklist.service.impl;
|
||||
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskList;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListDetialMapper;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListPermissionMapper;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListFavoriteMapper;
|
||||
import org.jeecg.modules.demo.tasklist.mapper.TaskListMapper;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListService;
|
||||
import org.jeecg.modules.demo.tasklist.service.ITaskListFavoriteService;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskListReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CreateTaskListGroupReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.MoveTaskListReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.AddCollaboratorReq;
|
||||
import org.jeecg.modules.demo.tasklist.vo.CollaboratorVO;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TaskListServiceImpl extends ServiceImpl<TaskListMapper, TaskList> implements ITaskListService {
|
||||
|
||||
@Autowired
|
||||
private TaskListMapper taskListMapper;
|
||||
@Autowired
|
||||
private TaskListDetialMapper taskListDetialMapper;
|
||||
@Autowired
|
||||
private TaskListPermissionMapper taskListPermissionMapper;
|
||||
@Autowired
|
||||
private TaskListFavoriteMapper taskListFavoriteMapper;
|
||||
@Autowired
|
||||
private ITaskListFavoriteService taskListFavoriteService;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveMain(TaskList taskList, List<TaskListDetial> taskListDetialList,List<TaskListPermission> taskListPermissionList,List<TaskListFavorite> taskListFavoriteList) {
|
||||
taskListMapper.insert(taskList);
|
||||
if(taskListDetialList!=null && taskListDetialList.size()>0) {
|
||||
for(TaskListDetial entity:taskListDetialList) {
|
||||
//外键设置
|
||||
entity.setMainId(taskList.getId());
|
||||
taskListDetialMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
if(taskListPermissionList!=null && taskListPermissionList.size()>0) {
|
||||
for(TaskListPermission entity:taskListPermissionList) {
|
||||
//外键设置
|
||||
entity.setMainId(taskList.getId());
|
||||
taskListPermissionMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
if(taskListFavoriteList!=null && taskListFavoriteList.size()>0) {
|
||||
for(TaskListFavorite entity:taskListFavoriteList) {
|
||||
//外键设置
|
||||
entity.setMainId(taskList.getId());
|
||||
taskListFavoriteMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateMain(TaskList taskList,List<TaskListDetial> taskListDetialList,List<TaskListPermission> taskListPermissionList,List<TaskListFavorite> taskListFavoriteList) {
|
||||
taskListMapper.updateById(taskList);
|
||||
|
||||
//1.先删除子表数据
|
||||
taskListDetialMapper.deleteByMainId(taskList.getId());
|
||||
taskListPermissionMapper.deleteByMainId(taskList.getId());
|
||||
taskListFavoriteMapper.deleteByMainId(taskList.getId());
|
||||
|
||||
//2.子表数据重新插入
|
||||
if(taskListDetialList!=null && taskListDetialList.size()>0) {
|
||||
for(TaskListDetial entity:taskListDetialList) {
|
||||
//外键设置
|
||||
entity.setMainId(taskList.getId());
|
||||
taskListDetialMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
if(taskListPermissionList!=null && taskListPermissionList.size()>0) {
|
||||
for(TaskListPermission entity:taskListPermissionList) {
|
||||
//外键设置
|
||||
entity.setMainId(taskList.getId());
|
||||
taskListPermissionMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
if(taskListFavoriteList!=null && taskListFavoriteList.size()>0) {
|
||||
for(TaskListFavorite entity:taskListFavoriteList) {
|
||||
//外键设置
|
||||
entity.setMainId(taskList.getId());
|
||||
taskListFavoriteMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delMain(String id) {
|
||||
taskListDetialMapper.deleteByMainId(id);
|
||||
taskListPermissionMapper.deleteByMainId(id);
|
||||
taskListFavoriteMapper.deleteByMainId(id);
|
||||
taskListMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delBatchMain(Collection<? extends Serializable> idList) {
|
||||
for(Serializable id:idList) {
|
||||
taskListDetialMapper.deleteByMainId(id.toString());
|
||||
taskListPermissionMapper.deleteByMainId(id.toString());
|
||||
taskListFavoriteMapper.deleteByMainId(id.toString());
|
||||
taskListMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTaskList(CreateTaskListReq req) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
if (oConvertUtils.isNotEmpty(req.getPid())) {
|
||||
TaskListFavorite groupFav = taskListFavoriteMapper.selectById(req.getPid());
|
||||
if (groupFav == null || !"0".equals(groupFav.getType()) || !userId.equals(groupFav.getUserId())) {
|
||||
throw new RuntimeException("目标分组不存在或无权限");
|
||||
}
|
||||
}
|
||||
|
||||
Integer targetSort;
|
||||
if (req.getSortOrder() != null) {
|
||||
taskListFavoriteService.shiftSortOrderUp(userId, req.getPid(), req.getSortOrder());
|
||||
targetSort = req.getSortOrder();
|
||||
} else {
|
||||
String pidForSort = oConvertUtils.isNotEmpty(req.getPid()) ? req.getPid() : null;
|
||||
targetSort = taskListFavoriteService.getMaxSortOrderByType(userId, pidForSort, "1") + 1;
|
||||
}
|
||||
|
||||
TaskList taskList = new TaskList();
|
||||
taskList.setTasklistName(req.getTasklistName());
|
||||
taskListMapper.insert(taskList);
|
||||
|
||||
TaskListDetial defaultGroup = new TaskListDetial();
|
||||
defaultGroup.setMainId(taskList.getId());
|
||||
defaultGroup.setTaskName("默认分组");
|
||||
defaultGroup.setType("0");
|
||||
defaultGroup.setPid(null);
|
||||
defaultGroup.setSortOrder(0);
|
||||
defaultGroup.setHasChild("0");
|
||||
defaultGroup.setSubTaskCount(0);
|
||||
defaultGroup.setCompletedSubTaskCount(0);
|
||||
defaultGroup.setCreateBy(userId);
|
||||
defaultGroup.setCreateTime(new java.util.Date());
|
||||
defaultGroup.setDelFlag("0");
|
||||
taskListDetialMapper.insert(defaultGroup);
|
||||
|
||||
TaskListFavorite favorite = new TaskListFavorite();
|
||||
favorite.setMainId(taskList.getId());
|
||||
favorite.setUserId(userId);
|
||||
favorite.setType("1");
|
||||
favorite.setPid(req.getPid());
|
||||
favorite.setHasChild("0");
|
||||
favorite.setSortOrder(targetSort);
|
||||
favorite.setTasklistName(req.getTasklistName());
|
||||
taskListFavoriteMapper.insert(favorite);
|
||||
|
||||
TaskListPermission permission = new TaskListPermission();
|
||||
permission.setMainId(taskList.getId());
|
||||
permission.setUserId(userId);
|
||||
permission.setPermission("1");
|
||||
taskListPermissionMapper.insert(permission);
|
||||
|
||||
if (oConvertUtils.isNotEmpty(req.getPid())) {
|
||||
TaskListFavorite parentFav = new TaskListFavorite();
|
||||
parentFav.setId(req.getPid());
|
||||
parentFav.setHasChild("1");
|
||||
taskListFavoriteMapper.updateById(parentFav);
|
||||
}
|
||||
|
||||
return taskList.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTaskListGroup(CreateTaskListGroupReq req) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
Integer sortOrder = 1;
|
||||
taskListFavoriteMapper.shiftSortOrderUpByType(userId, "0", sortOrder);
|
||||
|
||||
TaskListFavorite favorite = new TaskListFavorite();
|
||||
favorite.setMainId(null);
|
||||
favorite.setUserId(userId);
|
||||
favorite.setType("0");
|
||||
favorite.setPid(null);
|
||||
favorite.setHasChild("0");
|
||||
favorite.setSortOrder(sortOrder);
|
||||
favorite.setTasklistName(req.getTasklistName());
|
||||
taskListFavoriteMapper.insert(favorite);
|
||||
|
||||
return favorite.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void moveTaskList(MoveTaskListReq req) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListFavorite favorite = taskListFavoriteMapper.selectById(req.getFavoriteId());
|
||||
if (favorite == null || !userId.equals(favorite.getUserId())) {
|
||||
throw new RuntimeException("无权限操作此记录");
|
||||
}
|
||||
if ("0".equals(favorite.getType())) {
|
||||
throw new RuntimeException("分组不支持移动操作");
|
||||
}
|
||||
|
||||
String oldPid = normalizePid(favorite.getPid());
|
||||
Integer oldSort = favorite.getSortOrder();
|
||||
|
||||
String newPid = null;
|
||||
if (oConvertUtils.isNotEmpty(req.getTargetGroupId())) {
|
||||
TaskListFavorite targetGroup = taskListFavoriteMapper.selectById(req.getTargetGroupId());
|
||||
if (targetGroup == null || !"0".equals(targetGroup.getType()) || !userId.equals(targetGroup.getUserId())) {
|
||||
throw new RuntimeException("目标分组不存在或无权限");
|
||||
}
|
||||
newPid = normalizePid(req.getTargetGroupId());
|
||||
}
|
||||
|
||||
Integer maxSort = taskListFavoriteService.getMaxSortOrder(userId, newPid);
|
||||
Integer targetSort;
|
||||
if (req.getSortOrder() != null) {
|
||||
targetSort = req.getSortOrder();
|
||||
} else {
|
||||
targetSort = maxSort + 1;
|
||||
}
|
||||
if (targetSort < 1) {
|
||||
targetSort = 1;
|
||||
}
|
||||
if (targetSort > maxSort + 1) {
|
||||
targetSort = maxSort + 1;
|
||||
}
|
||||
|
||||
taskListFavoriteService.shiftSortOrderDown(userId, oldPid, oldSort);
|
||||
|
||||
taskListFavoriteService.shiftSortOrderUp(userId, newPid, targetSort);
|
||||
|
||||
taskListFavoriteService.updatePidAndSort(req.getFavoriteId(), newPid, targetSort);
|
||||
|
||||
if (oConvertUtils.isNotEmpty(oldPid)) {
|
||||
Integer remainCount = taskListFavoriteService.countChildren(userId, oldPid);
|
||||
if (remainCount == 0) {
|
||||
TaskListFavorite oldParent = new TaskListFavorite();
|
||||
oldParent.setId(oldPid);
|
||||
oldParent.setHasChild("0");
|
||||
taskListFavoriteMapper.updateById(oldParent);
|
||||
}
|
||||
}
|
||||
|
||||
if (oConvertUtils.isNotEmpty(newPid)) {
|
||||
TaskListFavorite newParent = new TaskListFavorite();
|
||||
newParent.setId(newPid);
|
||||
newParent.setHasChild("1");
|
||||
taskListFavoriteMapper.updateById(newParent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskListFavorite> getMyFavorites() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
LambdaQueryWrapper<TaskListFavorite> query = new LambdaQueryWrapper<>();
|
||||
query.eq(TaskListFavorite::getUserId, userId);
|
||||
query.orderByAsc(TaskListFavorite::getType);
|
||||
query.orderByAsc(TaskListFavorite::getSortOrder);
|
||||
List<TaskListFavorite> list = taskListFavoriteMapper.selectList(query);
|
||||
for (TaskListFavorite fav : list) {
|
||||
if ("1".equals(fav.getType()) && fav.getMainId() != null && fav.getTasklistName() == null) {
|
||||
TaskList tl = taskListMapper.selectById(fav.getMainId());
|
||||
if (tl != null) {
|
||||
fav.setTasklistName(tl.getTasklistName());
|
||||
}
|
||||
}
|
||||
if ("1".equals(fav.getType()) && fav.getMainId() != null) {
|
||||
LambdaQueryWrapper<TaskListPermission> permQuery = new LambdaQueryWrapper<>();
|
||||
permQuery.eq(TaskListPermission::getMainId, fav.getMainId());
|
||||
permQuery.eq(TaskListPermission::getUserId, userId);
|
||||
TaskListPermission perm = taskListPermissionMapper.selectOne(permQuery);
|
||||
if (perm != null) {
|
||||
fav.setPermission(perm.getPermission());
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteTaskList(String taskListId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> permCheck = new LambdaQueryWrapper<>();
|
||||
permCheck.eq(TaskListPermission::getMainId, taskListId);
|
||||
permCheck.eq(TaskListPermission::getUserId, userId);
|
||||
permCheck.eq(TaskListPermission::getPermission, "1");
|
||||
Long count = taskListPermissionMapper.selectCount(permCheck);
|
||||
if (count == 0) {
|
||||
throw new RuntimeException("仅所有者可删除任务清单");
|
||||
}
|
||||
|
||||
taskListMapper.deleteById(taskListId);
|
||||
|
||||
LambdaQueryWrapper<TaskListDetial> detailQuery = new LambdaQueryWrapper<>();
|
||||
detailQuery.eq(TaskListDetial::getMainId, taskListId);
|
||||
taskListDetialMapper.delete(detailQuery);
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> permQuery = new LambdaQueryWrapper<>();
|
||||
permQuery.eq(TaskListPermission::getMainId, taskListId);
|
||||
taskListPermissionMapper.delete(permQuery);
|
||||
|
||||
LambdaQueryWrapper<TaskListFavorite> favQuery = new LambdaQueryWrapper<>();
|
||||
favQuery.eq(TaskListFavorite::getMainId, taskListId);
|
||||
List<TaskListFavorite> favs = taskListFavoriteMapper.selectList(favQuery);
|
||||
for (TaskListFavorite fav : favs) {
|
||||
String favUserId = fav.getUserId();
|
||||
taskListFavoriteMapper.deleteById(fav.getId());
|
||||
if (fav.getPid() != null) {
|
||||
Integer remainCount = taskListFavoriteService.countChildren(favUserId, fav.getPid());
|
||||
if (remainCount == 0) {
|
||||
TaskListFavorite parentUpdate = new TaskListFavorite();
|
||||
parentUpdate.setId(fav.getPid());
|
||||
parentUpdate.setHasChild("0");
|
||||
taskListFavoriteMapper.updateById(parentUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeFavorite(String favoriteId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListFavorite fav = taskListFavoriteMapper.selectById(favoriteId);
|
||||
if (fav == null || !userId.equals(fav.getUserId())) {
|
||||
throw new RuntimeException("无权限操作此记录");
|
||||
}
|
||||
|
||||
fav.setDelFlag("1");
|
||||
taskListFavoriteMapper.updateById(fav);
|
||||
|
||||
if (fav.getPid() != null) {
|
||||
Integer remainCount = taskListFavoriteService.countChildren(userId, fav.getPid());
|
||||
if (remainCount == 0) {
|
||||
TaskListFavorite parentUpdate = new TaskListFavorite();
|
||||
parentUpdate.setId(fav.getPid());
|
||||
parentUpdate.setHasChild("0");
|
||||
taskListFavoriteMapper.updateById(parentUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeFavoriteGroup(String groupId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListFavorite groupFav = taskListFavoriteMapper.selectById(groupId);
|
||||
if (groupFav == null || !userId.equals(groupFav.getUserId()) || !"0".equals(groupFav.getType())) {
|
||||
throw new RuntimeException("分组不存在或无权限");
|
||||
}
|
||||
|
||||
groupFav.setDelFlag("1");
|
||||
taskListFavoriteMapper.updateById(groupFav);
|
||||
|
||||
LambdaQueryWrapper<TaskListFavorite> childQuery = new LambdaQueryWrapper<>();
|
||||
childQuery.eq(TaskListFavorite::getPid, groupId);
|
||||
childQuery.eq(TaskListFavorite::getUserId, userId);
|
||||
List<TaskListFavorite> children = taskListFavoriteMapper.selectList(childQuery);
|
||||
for (TaskListFavorite child : children) {
|
||||
child.setDelFlag("1");
|
||||
taskListFavoriteMapper.updateById(child);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void renameGroup(String groupId, String newName) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListFavorite groupFav = taskListFavoriteMapper.selectById(groupId);
|
||||
if (groupFav == null || !userId.equals(groupFav.getUserId()) || !"0".equals(groupFav.getType())) {
|
||||
throw new RuntimeException("分组不存在或无权限");
|
||||
}
|
||||
|
||||
groupFav.setTasklistName(newName);
|
||||
taskListFavoriteMapper.updateById(groupFav);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void moveGroup(String groupId, Integer sortOrder) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskListFavorite group = taskListFavoriteMapper.selectById(groupId);
|
||||
if (group == null || !userId.equals(group.getUserId()) || !"0".equals(group.getType())) {
|
||||
throw new RuntimeException("分组不存在或无权限");
|
||||
}
|
||||
|
||||
Integer oldSort = group.getSortOrder();
|
||||
Integer targetSort = (sortOrder != null) ? sortOrder : 0;
|
||||
if (targetSort < 1) {
|
||||
targetSort = 1;
|
||||
}
|
||||
|
||||
Integer maxSort = taskListFavoriteService.getMaxSortOrderByType(userId, null, "0");
|
||||
if (targetSort > maxSort) {
|
||||
targetSort = maxSort;
|
||||
}
|
||||
|
||||
taskListFavoriteService.shiftSortOrderDownByType(userId, "0", oldSort);
|
||||
|
||||
taskListFavoriteService.shiftSortOrderUpByType(userId, "0", targetSort);
|
||||
|
||||
taskListFavoriteService.updatePidAndSort(groupId, null, targetSort);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void renameTaskList(String taskListId, String newName) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
TaskList taskList = taskListMapper.selectById(taskListId);
|
||||
if (taskList == null) {
|
||||
throw new RuntimeException("清单不存在");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> permQuery = new LambdaQueryWrapper<>();
|
||||
permQuery.eq(TaskListPermission::getMainId, taskListId);
|
||||
permQuery.eq(TaskListPermission::getUserId, userId);
|
||||
permQuery.in(TaskListPermission::getPermission, "1", "2");
|
||||
boolean hasPermission = taskListPermissionMapper.exists(permQuery);
|
||||
|
||||
if (!hasPermission) {
|
||||
throw new RuntimeException("清单不存在或无权限");
|
||||
}
|
||||
|
||||
taskList.setTasklistName(newName);
|
||||
taskListMapper.updateById(taskList);
|
||||
|
||||
LambdaQueryWrapper<TaskListFavorite> favQuery = new LambdaQueryWrapper<>();
|
||||
favQuery.eq(TaskListFavorite::getMainId, taskListId);
|
||||
List<TaskListFavorite> favs = taskListFavoriteMapper.selectList(favQuery);
|
||||
for (TaskListFavorite fav : favs) {
|
||||
fav.setTasklistName(newName);
|
||||
taskListFavoriteMapper.updateById(fav);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskList> getMyOwnLists() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> permQuery = new LambdaQueryWrapper<>();
|
||||
permQuery.eq(TaskListPermission::getUserId, userId);
|
||||
permQuery.eq(TaskListPermission::getPermission, "1");
|
||||
List<TaskListPermission> perms = taskListPermissionMapper.selectList(permQuery);
|
||||
|
||||
List<String> mainIds = perms.stream().map(TaskListPermission::getMainId).collect(java.util.stream.Collectors.toList());
|
||||
if (mainIds.isEmpty()) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskList> query = new LambdaQueryWrapper<>();
|
||||
query.in(TaskList::getId, mainIds);
|
||||
query.orderByAsc(TaskList::getCreateTime);
|
||||
return enrichListSummaries(taskListMapper.selectList(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskList> getAllLists() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> permQuery = new LambdaQueryWrapper<>();
|
||||
permQuery.eq(TaskListPermission::getUserId, userId);
|
||||
List<TaskListPermission> perms = taskListPermissionMapper.selectList(permQuery);
|
||||
|
||||
List<String> mainIds = perms.stream().map(TaskListPermission::getMainId).distinct().collect(java.util.stream.Collectors.toList());
|
||||
if (mainIds.isEmpty()) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskList> query = new LambdaQueryWrapper<>();
|
||||
query.in(TaskList::getId, mainIds);
|
||||
query.orderByAsc(TaskList::getCreateTime);
|
||||
return enrichListSummaries(taskListMapper.selectList(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskList> getMyCollabLists() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> permQuery = new LambdaQueryWrapper<>();
|
||||
permQuery.eq(TaskListPermission::getUserId, userId);
|
||||
permQuery.ne(TaskListPermission::getPermission, "1");
|
||||
List<TaskListPermission> perms = taskListPermissionMapper.selectList(permQuery);
|
||||
|
||||
List<String> mainIds = perms.stream().map(TaskListPermission::getMainId).collect(java.util.stream.Collectors.toList());
|
||||
if (mainIds.isEmpty()) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskList> query = new LambdaQueryWrapper<>();
|
||||
query.in(TaskList::getId, mainIds);
|
||||
query.orderByAsc(TaskList::getCreateTime);
|
||||
return enrichListSummaries(taskListMapper.selectList(query));
|
||||
}
|
||||
|
||||
private String normalizePid(String pid) {
|
||||
return oConvertUtils.isNotEmpty(pid) ? pid : null;
|
||||
}
|
||||
|
||||
private List<TaskList> enrichListSummaries(List<TaskList> lists) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
for (TaskList list : lists) {
|
||||
if (list.getCreateTime() != null) {
|
||||
list.setCreateTimeStr(sdf.format(list.getCreateTime()));
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> ownerQuery = new LambdaQueryWrapper<>();
|
||||
ownerQuery.eq(TaskListPermission::getMainId, list.getId());
|
||||
ownerQuery.eq(TaskListPermission::getPermission, "1");
|
||||
TaskListPermission owner = taskListPermissionMapper.selectOne(ownerQuery);
|
||||
if (owner != null) {
|
||||
LoginUser ownerUser = sysBaseAPI.getUserById(owner.getUserId());
|
||||
if (ownerUser != null) {
|
||||
list.setOwnerName(ownerUser.getRealname());
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> collabQuery = new LambdaQueryWrapper<>();
|
||||
collabQuery.eq(TaskListPermission::getMainId, list.getId());
|
||||
collabQuery.ne(TaskListPermission::getPermission, "1");
|
||||
List<TaskListPermission> collabs = taskListPermissionMapper.selectList(collabQuery);
|
||||
if (!collabs.isEmpty()) {
|
||||
List<String> collabUserIds = collabs.stream().map(TaskListPermission::getUserId).collect(java.util.stream.Collectors.toList());
|
||||
List<String> collabNames = new java.util.ArrayList<>();
|
||||
for (String collabUserId : collabUserIds) {
|
||||
LoginUser collabUser = sysBaseAPI.getUserById(collabUserId);
|
||||
if (collabUser != null && collabUser.getRealname() != null) {
|
||||
collabNames.add(collabUser.getRealname());
|
||||
}
|
||||
}
|
||||
list.setCollaboratorNames(String.join(", ", collabNames));
|
||||
}
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CollaboratorVO> getCollaborators(String taskListId) {
|
||||
LambdaQueryWrapper<TaskListPermission> query = new LambdaQueryWrapper<>();
|
||||
query.eq(TaskListPermission::getMainId, taskListId);
|
||||
query.orderByAsc(TaskListPermission::getCreateTime);
|
||||
List<TaskListPermission> perms = taskListPermissionMapper.selectList(query);
|
||||
|
||||
List<CollaboratorVO> result = new java.util.ArrayList<>();
|
||||
for (TaskListPermission perm : perms) {
|
||||
CollaboratorVO vo = new CollaboratorVO();
|
||||
vo.setPermissionId(perm.getId());
|
||||
vo.setUserId(perm.getUserId());
|
||||
vo.setPermission(perm.getPermission());
|
||||
LoginUser user = sysBaseAPI.getUserById(perm.getUserId());
|
||||
if (user != null) {
|
||||
vo.setUsername(user.getRealname());
|
||||
}
|
||||
result.add(vo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addCollaborator(AddCollaboratorReq req) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String currentUserId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> ownerCheck = new LambdaQueryWrapper<>();
|
||||
ownerCheck.eq(TaskListPermission::getMainId, req.getTaskListId());
|
||||
ownerCheck.eq(TaskListPermission::getUserId, currentUserId);
|
||||
ownerCheck.eq(TaskListPermission::getPermission, "1");
|
||||
Long ownerCount = taskListPermissionMapper.selectCount(ownerCheck);
|
||||
if (ownerCount == 0) {
|
||||
throw new RuntimeException("仅所有者可添加协作人");
|
||||
}
|
||||
|
||||
if (!"2".equals(req.getPermission()) && !"3".equals(req.getPermission())) {
|
||||
throw new RuntimeException("权限类型无效,仅支持可阅读(2)或可编辑(3)");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> existCheck = new LambdaQueryWrapper<>();
|
||||
existCheck.eq(TaskListPermission::getMainId, req.getTaskListId());
|
||||
existCheck.eq(TaskListPermission::getUserId, req.getUserId());
|
||||
Long existCount = taskListPermissionMapper.selectCount(existCheck);
|
||||
if (existCount > 0) {
|
||||
throw new RuntimeException("该用户已是协作人");
|
||||
}
|
||||
|
||||
TaskListPermission permission = new TaskListPermission();
|
||||
permission.setMainId(req.getTaskListId());
|
||||
permission.setUserId(req.getUserId());
|
||||
permission.setPermission(req.getPermission());
|
||||
taskListPermissionMapper.insert(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeCollaborator(String permissionId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String currentUserId = loginUser.getId();
|
||||
|
||||
TaskListPermission perm = taskListPermissionMapper.selectById(permissionId);
|
||||
if (perm == null) {
|
||||
throw new RuntimeException("权限记录不存在");
|
||||
}
|
||||
if ("1".equals(perm.getPermission())) {
|
||||
throw new RuntimeException("不能移除所有者");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> ownerCheck = new LambdaQueryWrapper<>();
|
||||
ownerCheck.eq(TaskListPermission::getMainId, perm.getMainId());
|
||||
ownerCheck.eq(TaskListPermission::getUserId, currentUserId);
|
||||
ownerCheck.eq(TaskListPermission::getPermission, "1");
|
||||
Long ownerCount = taskListPermissionMapper.selectCount(ownerCheck);
|
||||
if (ownerCount == 0) {
|
||||
throw new RuntimeException("仅所有者可移除协作人");
|
||||
}
|
||||
|
||||
taskListPermissionMapper.deleteById(permissionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCollaboratorPermission(String permissionId, String newPermission) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String currentUserId = loginUser.getId();
|
||||
|
||||
TaskListPermission perm = taskListPermissionMapper.selectById(permissionId);
|
||||
if (perm == null) {
|
||||
throw new RuntimeException("权限记录不存在");
|
||||
}
|
||||
if ("1".equals(perm.getPermission())) {
|
||||
throw new RuntimeException("不能修改所有者权限");
|
||||
}
|
||||
if (!"2".equals(newPermission) && !"3".equals(newPermission)) {
|
||||
throw new RuntimeException("权限类型无效");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> ownerCheck = new LambdaQueryWrapper<>();
|
||||
ownerCheck.eq(TaskListPermission::getMainId, perm.getMainId());
|
||||
ownerCheck.eq(TaskListPermission::getUserId, currentUserId);
|
||||
ownerCheck.eq(TaskListPermission::getPermission, "1");
|
||||
Long ownerCount = taskListPermissionMapper.selectCount(ownerCheck);
|
||||
if (ownerCount == 0) {
|
||||
throw new RuntimeException("仅所有者可修改协作人权限");
|
||||
}
|
||||
|
||||
TaskListPermission update = new TaskListPermission();
|
||||
update.setId(permissionId);
|
||||
update.setPermission(newPermission);
|
||||
taskListPermissionMapper.updateById(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMyPermission(String taskListId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListPermission> query = new LambdaQueryWrapper<>();
|
||||
query.eq(TaskListPermission::getMainId, taskListId);
|
||||
query.eq(TaskListPermission::getUserId, userId);
|
||||
TaskListPermission perm = taskListPermissionMapper.selectOne(query);
|
||||
return perm != null ? perm.getPermission() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToFavorites(String taskListId) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = loginUser.getId();
|
||||
|
||||
LambdaQueryWrapper<TaskListFavorite> existCheck = new LambdaQueryWrapper<>();
|
||||
existCheck.eq(TaskListFavorite::getMainId, taskListId);
|
||||
existCheck.eq(TaskListFavorite::getUserId, userId);
|
||||
existCheck.eq(TaskListFavorite::getType, "1");
|
||||
Long existCount = taskListFavoriteMapper.selectCount(existCheck);
|
||||
if (existCount > 0) {
|
||||
throw new RuntimeException("该清单已在收藏中");
|
||||
}
|
||||
|
||||
TaskList taskList = taskListMapper.selectById(taskListId);
|
||||
if (taskList == null) {
|
||||
throw new RuntimeException("清单不存在");
|
||||
}
|
||||
|
||||
Integer maxSort = taskListFavoriteService.getMaxSortOrderByType(userId, null, "1");
|
||||
TaskListFavorite favorite = new TaskListFavorite();
|
||||
favorite.setMainId(taskListId);
|
||||
favorite.setUserId(userId);
|
||||
favorite.setType("1");
|
||||
favorite.setPid(null);
|
||||
favorite.setHasChild("0");
|
||||
favorite.setSortOrder(maxSort + 1);
|
||||
favorite.setTasklistName(taskList.getTasklistName());
|
||||
taskListFavoriteMapper.insert(favorite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskListDetial> myResponsibleTasks() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
return taskListDetialMapper.selectByAssigneeId(loginUser.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskListDetial> myFollowedTasks() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
return taskListDetialMapper.selectByFollowersId(loginUser.getId());
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "添加协作人请求")
|
||||
public class AddCollaboratorReq {
|
||||
|
||||
@Schema(description = "清单ID")
|
||||
private String taskListId;
|
||||
|
||||
@Schema(description = "被添加的用户ID")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "权限类型: 2=可编辑 3=可阅读")
|
||||
private String permission;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "协作人信息")
|
||||
public class CollaboratorVO {
|
||||
|
||||
@Schema(description = "权限记录ID")
|
||||
private String permissionId;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "用户姓名")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "权限类型: 1=所有者 2=可编辑 3=可阅读")
|
||||
private String permission;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "创建任务清单分组请求")
|
||||
public class CreateTaskListGroupReq {
|
||||
|
||||
@Schema(description = "分组名称")
|
||||
private String tasklistName;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "创建任务清单请求")
|
||||
public class CreateTaskListReq {
|
||||
|
||||
@Schema(description = "清单名称")
|
||||
private String tasklistName;
|
||||
|
||||
@Schema(description = "父分组ID(可选,不传则放在根级别)")
|
||||
private String pid;
|
||||
|
||||
@Schema(description = "目标排序位置(可选,不传则追加到末尾)")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@Data
|
||||
@Schema(description = "创建任务请求")
|
||||
public class CreateTaskReq {
|
||||
|
||||
@Schema(description = "所属清单ID")
|
||||
private String mainId;
|
||||
|
||||
@Schema(description = "任务名称")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "任务描述")
|
||||
private String taskDesc;
|
||||
|
||||
@Schema(description = "优先级")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "类型:0=任务分组,1=普通任务")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "父节点ID(分组ID或父任务ID,为空则归入默认分组)")
|
||||
private String pid;
|
||||
|
||||
@Schema(description = "负责人ID")
|
||||
private String assigneeId;
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date startTime;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date endTime;
|
||||
|
||||
@Schema(description = "排序号(指定则在指定位置插入)")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "拖拽移动任务清单请求")
|
||||
public class MoveTaskListReq {
|
||||
|
||||
@Schema(description = "被移动的清单对应的 favorite 记录ID")
|
||||
private String favoriteId;
|
||||
|
||||
@Schema(description = "目标分组ID(null 或空字符串表示移动到根级别)")
|
||||
private String targetGroupId;
|
||||
|
||||
@Schema(description = "目标位置排序号(可选,不传则追加到末尾)")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "拖拽移动任务请求")
|
||||
public class MoveTaskReq {
|
||||
|
||||
@Schema(description = "任务ID")
|
||||
private String taskId;
|
||||
|
||||
@Schema(description = "目标父节点ID(分组ID或父任务ID,为空表示移入默认分组)")
|
||||
private String targetPid;
|
||||
|
||||
@Schema(description = "目标位置排序号(可选,不传则追加到末尾)")
|
||||
private Integer targetSortOrder;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Data
|
||||
@Schema(description = "子任务分页请求")
|
||||
public class SubTaskPageReq {
|
||||
|
||||
@Schema(description = "父任务ID")
|
||||
private String parentTaskId;
|
||||
|
||||
@Schema(description = "页码,默认1")
|
||||
private Integer pageNo = 1;
|
||||
|
||||
@Schema(description = "每页条数,默认20")
|
||||
private Integer pageSize = 20;
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package org.jeecg.modules.demo.tasklist.vo;
|
||||
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskList;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListDetial;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListPermission;
|
||||
import org.jeecg.modules.demo.tasklist.entity.TaskListFavorite;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecgframework.poi.excel.annotation.ExcelEntity;
|
||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* @Description: 任务清单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-04-24
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(description="任务清单表")
|
||||
public class TaskListPage {
|
||||
|
||||
/**主键*/
|
||||
@Schema(description = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@Schema(description = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Schema(description = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Schema(description = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
/**清单名称*/
|
||||
@Excel(name = "清单名称", width = 15)
|
||||
@Schema(description = "清单名称")
|
||||
private java.lang.String tasklistName;
|
||||
/**删除标识*/
|
||||
@Excel(name = "删除标识", width = 15)
|
||||
@Schema(description = "删除标识")
|
||||
private java.lang.String delFlag;
|
||||
|
||||
@ExcelCollection(name="任务清单详情表")
|
||||
@Schema(description = "任务清单详情表")
|
||||
private List<TaskListDetial> taskListDetialList;
|
||||
@ExcelCollection(name="任务清单权限表")
|
||||
@Schema(description = "任务清单权限表")
|
||||
private List<TaskListPermission> taskListPermissionList;
|
||||
@ExcelCollection(name="任务清单收藏表")
|
||||
@Schema(description = "任务清单收藏表")
|
||||
private List<TaskListFavorite> taskListFavoriteList;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user