Browse Source

任务看板回复功能

wangzhuo 2 years ago
parent
commit
04262eb530

+ 34 - 0
blade-service-api/blade-mocha-item-api/src/main/java/org/springblade/mocha/dto/CommentDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.dto;
+
+import org.springblade.mocha.entity.Comment;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 评论数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CommentDTO extends Comment {
+	private static final long serialVersionUID = 1L;
+
+}

+ 99 - 0
blade-service-api/blade-mocha-item-api/src/main/java/org/springblade/mocha/entity/Comment.java

@@ -0,0 +1,99 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.entity;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 评论实体类
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+@Data
+@TableName("basic_comment")
+@ApiModel(value = "Comment对象", description = "评论")
+public class Comment implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * id
+	 */
+	@ApiModelProperty(value = "id")
+	private Long id;
+	/**
+	 * 任务看板id
+	 */
+	@ApiModelProperty(value = "任务看板id")
+	private Long primaryId;
+	/**
+	 * 评论内容
+	 */
+	@ApiModelProperty(value = "评论内容")
+	private String discuss;
+	/**
+	 * 创建人
+	 */
+	@ApiModelProperty(value = "创建人")
+	private Long createUser;
+	/**
+	 * 创建人名
+	 */
+	@ApiModelProperty(value = "创建人名")
+	private String createUserName;
+	/**
+	 * 创建时间
+	 */
+	@ApiModelProperty(value = "创建时间")
+	private LocalDateTime createTime;
+	/**
+	 * 修改人
+	 */
+	@ApiModelProperty(value = "修改人")
+	private Long updateUser;
+	/**
+	 * 修改人名
+	 */
+	@ApiModelProperty(value = "修改人名")
+	private String updateUserName;
+	/**
+	 * 修改时间
+	 */
+	@ApiModelProperty(value = "修改时间")
+	private LocalDateTime updateTime;
+	/**
+	 * 是否已删除(0 否 1是)
+	 */
+	@ApiModelProperty(value = "是否已删除(0 否 1是)")
+	@TableLogic(value = "0", delval = "1")
+	private Integer isDeleted;
+
+	/**
+	 * 租户id
+	 */
+	private String tenantId;
+}

+ 36 - 0
blade-service-api/blade-mocha-item-api/src/main/java/org/springblade/mocha/vo/CommentVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.vo;
+
+import org.springblade.mocha.entity.Comment;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+
+/**
+ * 评论视图实体类
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "CommentVO对象", description = "评论")
+public class CommentVO extends Comment {
+	private static final long serialVersionUID = 1L;
+
+}

+ 151 - 0
blade-service/blade-mocha-item/src/main/java/org/springblade/mocha/controller/CommentController.java

@@ -0,0 +1,151 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.mocha.entity.Comment;
+import org.springblade.mocha.vo.CommentVO;
+import org.springblade.mocha.service.ICommentService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 评论 控制器
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/comment")
+@Api(value = "评论", tags = "评论接口")
+public class CommentController extends BladeController {
+
+	private final ICommentService commentService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入comment")
+	public R<Comment> detail(Comment comment) {
+		Comment detail = commentService.getOne(Condition.getQueryWrapper(comment));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页 评论
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入comment")
+	public R<IPage<Comment>> list(Comment comment, Query query) {
+		IPage<Comment> pages = commentService.page(Condition.getPage(query), Condition.getQueryWrapper(comment));
+		return R.data(pages);
+	}
+
+	/**
+	 * 自定义分页 评论
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入comment")
+	public R<IPage<CommentVO>> page(CommentVO comment, Query query) {
+		IPage<CommentVO> pages = commentService.selectCommentPage(Condition.getPage(query), comment);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 评论
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入comment")
+	public R save(@Valid @RequestBody Comment comment) {
+		comment.setTenantId(AuthUtil.getTenantId());
+		return R.status(commentService.save(comment));
+	}
+
+	/**
+	 * 修改 评论
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入comment")
+	public R update(@Valid @RequestBody Comment comment) {
+		return R.status(commentService.updateById(comment));
+	}
+
+	/**
+	 * 新增或修改 评论
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入comment")
+	public R submit(@Valid @RequestBody Comment comment) {
+		if (comment.getId() != null) {
+			comment.setUpdateUser(AuthUtil.getUserId());
+			comment.setUpdateTime(LocalDateTime.now());
+		} else {
+			comment.setCreateUser(AuthUtil.getUserId());
+			comment.setCreateTime(LocalDateTime.now());
+		}
+		return R.status(commentService.saveOrUpdate(comment));
+	}
+
+
+	/**
+	 * 删除 评论
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(commentService.removeByIds(Func.toLongList(ids)));
+	}
+
+	/**
+	 * 根据主表id查询数据
+	 */
+	@GetMapping("/task/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入comment")
+	public R<List<Comment>> getDetailByTask(Comment comment) {
+		List<Comment> comments = commentService.getDetailByTask(comment.getId());
+		return R.data(comments);
+	}
+
+
+}

+ 42 - 0
blade-service/blade-mocha-item/src/main/java/org/springblade/mocha/mapper/CommentMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.mapper;
+
+import org.springblade.mocha.entity.Comment;
+import org.springblade.mocha.vo.CommentVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 评论 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+public interface CommentMapper extends BaseMapper<Comment> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param comment
+	 * @return
+	 */
+	List<CommentVO> selectCommentPage(IPage page, CommentVO comment);
+
+}

+ 24 - 0
blade-service/blade-mocha-item/src/main/java/org/springblade/mocha/mapper/CommentMapper.xml

@@ -0,0 +1,24 @@
+<?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.springblade.mocha.mapper.CommentMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="commentResultMap" type="org.springblade.mocha.entity.Comment">
+        <id column="id" property="id"/>
+        <result column="p_id" property="pId"/>
+        <result column="discuss" property="discuss"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_user_name" property="createUserName"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_user_name" property="updateUserName"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="is_deleted" property="isDeleted"/>
+    </resultMap>
+
+
+    <select id="selectCommentPage" resultMap="commentResultMap">
+        select * from basic_comment where is_deleted = 0
+    </select>
+
+</mapper>

+ 49 - 0
blade-service/blade-mocha-item/src/main/java/org/springblade/mocha/service/ICommentService.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.service;
+
+import org.springblade.mocha.entity.Comment;
+import org.springblade.mocha.vo.CommentVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.List;
+
+/**
+ * 评论 服务类
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+public interface ICommentService extends IService<Comment> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param comment
+	 * @return
+	 */
+	IPage<CommentVO> selectCommentPage(IPage<CommentVO> page, CommentVO comment);
+
+	/**
+	 * 根据主表id查询数据
+	 * @param id
+	 * @return
+	 */
+	List<Comment> getDetailByTask(Long id);
+}

+ 51 - 0
blade-service/blade-mocha-item/src/main/java/org/springblade/mocha/service/impl/CommentServiceImpl.java

@@ -0,0 +1,51 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.mocha.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.springblade.mocha.entity.Comment;
+import org.springblade.mocha.vo.CommentVO;
+import org.springblade.mocha.mapper.CommentMapper;
+import org.springblade.mocha.service.ICommentService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.List;
+
+/**
+ * 评论 服务实现类
+ *
+ * @author BladeX
+ * @since 2023-10-27
+ */
+@Service
+public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentService {
+
+	@Override
+	public IPage<CommentVO> selectCommentPage(IPage<CommentVO> page, CommentVO comment) {
+		return page.setRecords(baseMapper.selectCommentPage(page, comment));
+	}
+
+	@Override
+	public List<Comment> getDetailByTask(Long id) {
+		LambdaQueryWrapper<Comment> lqw = new LambdaQueryWrapper<>();
+		lqw.eq(Comment::getPrimaryId, id).orderByAsc(Comment::getCreateTime);
+		return baseMapper.selectList(lqw);
+	}
+
+}