forked from luyan/epmet-cloud-lingshan
				
			
				 11 changed files with 417 additions and 5 deletions
			
			
		@ -0,0 +1,100 @@ | 
				
			|||
package com.epmet.dto; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; | 
				
			|||
import com.fasterxml.jackson.annotation.JsonFormat; | 
				
			|||
import lombok.Data; | 
				
			|||
import org.hibernate.validator.constraints.Length; | 
				
			|||
 | 
				
			|||
import javax.validation.constraints.NotBlank; | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 议题评论表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2023-02-02 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class IssueCommentDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = 1L; | 
				
			|||
    public interface AddUserInternalGroup { | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public interface AddUserShowGroup extends CustomerClientShowGroup { | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 议题ID | 
				
			|||
     */ | 
				
			|||
    @NotBlank(message = "issueId不能为空",groups = AddUserInternalGroup.class) | 
				
			|||
	private String issueId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 主键ID | 
				
			|||
     */ | 
				
			|||
	private String id; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 客户ID | 
				
			|||
     */ | 
				
			|||
	private String customerId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 评论内容至多200字 | 
				
			|||
     */ | 
				
			|||
    @Length(max = 200,message = "评论内容最多输入200字",groups = AddUserShowGroup.class) | 
				
			|||
    @NotBlank(message = "content不能为空",groups = AddUserInternalGroup.class) | 
				
			|||
	private String content; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 评论用户id | 
				
			|||
     */ | 
				
			|||
	private String userId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 姓名 | 
				
			|||
     */ | 
				
			|||
	private String userName; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 头像 | 
				
			|||
     */ | 
				
			|||
	private String headPhoto; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 删除标识 0.未删除 1.已删除 | 
				
			|||
     */ | 
				
			|||
	private String delFlag; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 乐观锁 | 
				
			|||
     */ | 
				
			|||
	private Integer revision; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 创建人 | 
				
			|||
     */ | 
				
			|||
	private String createdBy; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 创建时间 | 
				
			|||
     */ | 
				
			|||
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") | 
				
			|||
	private Date createdTime; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 更新人 | 
				
			|||
     */ | 
				
			|||
	private String updatedBy; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 更新时间 | 
				
			|||
     */ | 
				
			|||
	private Date updatedTime; | 
				
			|||
 | 
				
			|||
    private String commentId; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,18 @@ | 
				
			|||
package com.epmet.dto.form; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.dto.form.PageFormDTO; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import javax.validation.constraints.NotBlank; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @Description | 
				
			|||
 * @Author yzm | 
				
			|||
 * @Date 2023/2/2 13:45 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class IssueCommentPageFormDTO extends PageFormDTO { | 
				
			|||
    @NotBlank(message = "issueId不能为空",groups = AddUserInternalGroup.class) | 
				
			|||
    private String issueId; | 
				
			|||
} | 
				
			|||
 | 
				
			|||
@ -0,0 +1,61 @@ | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.annotation.LoginUser; | 
				
			|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; | 
				
			|||
import com.epmet.commons.tools.page.PageData; | 
				
			|||
import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			|||
import com.epmet.dto.IssueCommentDTO; | 
				
			|||
import com.epmet.dto.form.IssueCommentPageFormDTO; | 
				
			|||
import com.epmet.service.IssueCommentService; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.PostMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RequestBody; | 
				
			|||
import org.springframework.web.bind.annotation.RequestMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RestController; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 议题评论表 | 
				
			|||
 * 目前只有烟台客户,钉钉居民端,议事厅,可以发表评论 | 
				
			|||
 * 产品没有此功能 | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2023-02-02 | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("issuecomment") | 
				
			|||
public class IssueCommentController { | 
				
			|||
 | 
				
			|||
    @Autowired | 
				
			|||
    private IssueCommentService issueCommentService; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 议题评论列表 | 
				
			|||
     * @param formDTO | 
				
			|||
     * @return | 
				
			|||
     */ | 
				
			|||
    @RequestMapping("page") | 
				
			|||
    public Result<PageData<IssueCommentDTO>> page(@RequestBody IssueCommentPageFormDTO formDTO){ | 
				
			|||
        PageData<IssueCommentDTO> page = issueCommentService.page(formDTO); | 
				
			|||
        return new Result<PageData<IssueCommentDTO>>().ok(page); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 议题评论 | 
				
			|||
     * @param tokenDto | 
				
			|||
     * @param dto | 
				
			|||
     * @return | 
				
			|||
     */ | 
				
			|||
    @NoRepeatSubmit | 
				
			|||
    @PostMapping("save") | 
				
			|||
    public Result save(@LoginUser TokenDto tokenDto, @RequestBody IssueCommentDTO dto){ | 
				
			|||
        dto.setCustomerId(tokenDto.getCustomerId()); | 
				
			|||
        dto.setUserId(tokenDto.getUserId()); | 
				
			|||
        ValidatorUtils.validateEntity(dto,IssueCommentDTO.AddUserShowGroup.class,IssueCommentDTO.AddUserInternalGroup.class); | 
				
			|||
        issueCommentService.save(dto); | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,20 @@ | 
				
			|||
package com.epmet.dao; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.dao.BaseDao; | 
				
			|||
import com.epmet.dto.IssueCommentDTO; | 
				
			|||
import com.epmet.entity.IssueCommentEntity; | 
				
			|||
import org.apache.ibatis.annotations.Mapper; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 议题评论表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2023-02-02 | 
				
			|||
 */ | 
				
			|||
@Mapper | 
				
			|||
public interface IssueCommentDao extends BaseDao<IssueCommentEntity> { | 
				
			|||
 | 
				
			|||
    List<IssueCommentDTO> selectCommentList(String issueId); | 
				
			|||
} | 
				
			|||
@ -0,0 +1,54 @@ | 
				
			|||
package com.epmet.entity; | 
				
			|||
 | 
				
			|||
import com.baomidou.mybatisplus.annotation.TableName; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; | 
				
			|||
import lombok.Data; | 
				
			|||
import lombok.EqualsAndHashCode; | 
				
			|||
 | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 议题评论表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2023-02-02 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
@EqualsAndHashCode(callSuper=false) | 
				
			|||
@TableName("issue_comment") | 
				
			|||
public class IssueCommentEntity extends BaseEpmetEntity { | 
				
			|||
 | 
				
			|||
	private static final long serialVersionUID = 1L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 议题ID | 
				
			|||
     */ | 
				
			|||
	private String issueId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 客户ID | 
				
			|||
     */ | 
				
			|||
	private String customerId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 评论内容至多200字 | 
				
			|||
     */ | 
				
			|||
	private String content; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 评论用户id | 
				
			|||
     */ | 
				
			|||
	private String userId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 姓名 | 
				
			|||
     */ | 
				
			|||
	private String userName; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 头像 | 
				
			|||
     */ | 
				
			|||
	private String headPhoto; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,37 @@ | 
				
			|||
package com.epmet.service; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.BaseService; | 
				
			|||
import com.epmet.commons.tools.page.PageData; | 
				
			|||
import com.epmet.dto.IssueCommentDTO; | 
				
			|||
import com.epmet.dto.form.IssueCommentPageFormDTO; | 
				
			|||
import com.epmet.entity.IssueCommentEntity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 议题评论表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2023-02-02 | 
				
			|||
 */ | 
				
			|||
public interface IssueCommentService extends BaseService<IssueCommentEntity> { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认分页 | 
				
			|||
     * | 
				
			|||
     * @param formDTO | 
				
			|||
     * @return PageData<IssueCommentDTO> | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2023-02-02 | 
				
			|||
     */ | 
				
			|||
    PageData<IssueCommentDTO> page(IssueCommentPageFormDTO formDTO); | 
				
			|||
 | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认保存 | 
				
			|||
     * | 
				
			|||
     * @param dto | 
				
			|||
     * @return void | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2023-02-02 | 
				
			|||
     */ | 
				
			|||
    void save(IssueCommentDTO dto); | 
				
			|||
} | 
				
			|||
@ -0,0 +1,72 @@ | 
				
			|||
package com.epmet.service.impl; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			|||
import com.epmet.commons.tools.constant.NumConstant; | 
				
			|||
import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			|||
import com.epmet.commons.tools.exception.EpmetException; | 
				
			|||
import com.epmet.commons.tools.page.PageData; | 
				
			|||
import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.dao.IssueCommentDao; | 
				
			|||
import com.epmet.dto.IssueCommentDTO; | 
				
			|||
import com.epmet.dto.form.IssueCommentPageFormDTO; | 
				
			|||
import com.epmet.dto.result.UserBaseInfoResultDTO; | 
				
			|||
import com.epmet.entity.IssueCommentEntity; | 
				
			|||
import com.epmet.feign.EpmetUserOpenFeignClient; | 
				
			|||
import com.epmet.service.IssueCommentService; | 
				
			|||
import com.github.pagehelper.PageHelper; | 
				
			|||
import com.github.pagehelper.PageInfo; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
import org.springframework.transaction.annotation.Transactional; | 
				
			|||
import org.springframework.util.CollectionUtils; | 
				
			|||
 | 
				
			|||
import java.util.ArrayList; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 议题评论表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2023-02-02 | 
				
			|||
 */ | 
				
			|||
@Service | 
				
			|||
public class IssueCommentServiceImpl extends BaseServiceImpl<IssueCommentDao, IssueCommentEntity> implements IssueCommentService { | 
				
			|||
    @Autowired | 
				
			|||
    private EpmetUserOpenFeignClient userOpenFeignClient; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 议题评论列表 | 
				
			|||
     * @param formDTO | 
				
			|||
     * @return | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    public PageData<IssueCommentDTO> page(IssueCommentPageFormDTO formDTO) { | 
				
			|||
        PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); | 
				
			|||
        List<IssueCommentDTO> list = baseDao.selectCommentList(formDTO.getIssueId()); | 
				
			|||
        PageInfo<IssueCommentDTO> pageInfo = new PageInfo<>(list); | 
				
			|||
        return new PageData<>(list, pageInfo.getTotal()); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 议题评论 | 
				
			|||
     * 需求来源于烟台:https://modao.cc/app/Uz9nPVerhvcupzLnhoiY#screen=sl8mfpxd863xmb5
 | 
				
			|||
     * @param dto | 
				
			|||
     */ | 
				
			|||
    @Override | 
				
			|||
    @Transactional(rollbackFor = Exception.class) | 
				
			|||
    public void save(IssueCommentDTO dto) { | 
				
			|||
        //查询用户信息
 | 
				
			|||
        List<String> userIdList=new ArrayList<>(); | 
				
			|||
        userIdList.add(dto.getUserId()); | 
				
			|||
        Result<List<UserBaseInfoResultDTO>> userInfoRes= userOpenFeignClient.queryUserBaseInfo(userIdList); | 
				
			|||
        if(!userInfoRes.success()|| CollectionUtils.isEmpty(userInfoRes.getData())){ | 
				
			|||
          throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"查询用户信息异常userId:"+dto.getUserId(),"查询用户信息异常"); | 
				
			|||
        } | 
				
			|||
        IssueCommentEntity entity = ConvertUtils.sourceToTarget(dto, IssueCommentEntity.class); | 
				
			|||
        entity.setHeadPhoto(userInfoRes.getData().get(NumConstant.ZERO).getHeadImgUrl()); | 
				
			|||
        entity.setUserName(userInfoRes.getData().get(NumConstant.ZERO).getRealName()); | 
				
			|||
        insert(entity); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,16 @@ | 
				
			|||
CREATE TABLE `issue_comment` ( | 
				
			|||
                                 `ID` varchar(32) NOT NULL COMMENT '主键ID', | 
				
			|||
                                 `ISSUE_ID` varchar(32) NOT NULL COMMENT '议题ID', | 
				
			|||
                                 `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', | 
				
			|||
                                 `CONTENT` varchar(255) NOT NULL COMMENT '评论内容至多200字', | 
				
			|||
                                 `USER_ID` varchar(64) NOT NULL COMMENT '评论用户id', | 
				
			|||
                                 `USER_NAME` varchar(64) DEFAULT NULL COMMENT '姓名', | 
				
			|||
                                 `HEAD_PHOTO` varchar(255) DEFAULT NULL COMMENT '头像', | 
				
			|||
                                 `DEL_FLAG` varchar(2) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', | 
				
			|||
                                 `REVISION` int(11) NOT NULL COMMENT '乐观锁', | 
				
			|||
                                 `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', | 
				
			|||
                                 `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', | 
				
			|||
                                 `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', | 
				
			|||
                                 `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', | 
				
			|||
                                 PRIMARY KEY (`ID`) | 
				
			|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='议题评论表'; | 
				
			|||
@ -0,0 +1,36 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			|||
 | 
				
			|||
<mapper namespace="com.epmet.dao.IssueCommentDao"> | 
				
			|||
 | 
				
			|||
    <resultMap type="com.epmet.entity.IssueCommentEntity" id="issueCommentMap"> | 
				
			|||
        <result property="id" column="ID"/> | 
				
			|||
        <result property="issueId" column="ISSUE_ID"/> | 
				
			|||
        <result property="customerId" column="CUSTOMER_ID"/> | 
				
			|||
        <result property="content" column="CONTENT"/> | 
				
			|||
        <result property="userId" column="USER_ID"/> | 
				
			|||
        <result property="userName" column="USER_NAME"/> | 
				
			|||
        <result property="headPhoto" column="HEAD_PHOTO"/> | 
				
			|||
        <result property="delFlag" column="DEL_FLAG"/> | 
				
			|||
        <result property="revision" column="REVISION"/> | 
				
			|||
        <result property="createdBy" column="CREATED_BY"/> | 
				
			|||
        <result property="createdTime" column="CREATED_TIME"/> | 
				
			|||
        <result property="updatedBy" column="UPDATED_BY"/> | 
				
			|||
        <result property="updatedTime" column="UPDATED_TIME"/> | 
				
			|||
    </resultMap> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
    <select id="selectCommentList" parameterType="java.lang.String" resultType="com.epmet.dto.IssueCommentDTO"> | 
				
			|||
        SELECT | 
				
			|||
            ic.id as commentId, | 
				
			|||
            ic.* | 
				
			|||
        FROM | 
				
			|||
            issue_comment ic | 
				
			|||
        WHERE | 
				
			|||
            ic.DEL_FLAG = '0' | 
				
			|||
          AND ic.ISSUE_ID = #{issueId} | 
				
			|||
        ORDER BY | 
				
			|||
            ic.CREATED_TIME DESC | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
</mapper> | 
				
			|||
					Loading…
					
					
				
		Reference in new issue