Browse Source

标签添加

dev_shibei_match
zxc 5 years ago
parent
commit
ccd33df10d
  1. 24
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/AddTagFormDTO.java
  2. 23
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/AddTagResultDTO.java
  3. 19
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueTagsController.java
  4. 1
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueCategoryDao.java
  5. 9
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueTagsDao.java
  6. 11
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueTagsService.java
  7. 43
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueTagsServiceImpl.java
  8. 10
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueTagsDao.xml

24
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/AddTagFormDTO.java

@ -0,0 +1,24 @@
package com.epmet.dto.form;
import com.google.gson.internal.$Gson$Types;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/12/9 下午3:25
*/
@Data
public class AddTagFormDTO implements Serializable {
private static final long serialVersionUID = -3245317956853388308L;
public interface AddTag{}
@NotBlank(message = "标签名称不能为空",groups = AddTag.class)
private String tagName;
private String customerId;
}

23
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/AddTagResultDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/12/9 下午5:09
*/
@Data
@AllArgsConstructor
public class AddTagResultDTO implements Serializable {
private static final long serialVersionUID = 4769136806332933579L;
private String tagId;
public AddTagResultDTO() {
this.tagId = "";
}
}

19
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueTagsController.java

@ -17,15 +17,19 @@
package com.epmet.controller; package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IssueTagsDTO; import com.epmet.dto.IssueTagsDTO;
import com.epmet.dto.form.AddTagFormDTO;
import com.epmet.dto.result.AddTagResultDTO;
import com.epmet.excel.IssueTagsExcel; import com.epmet.excel.IssueTagsExcel;
import com.epmet.service.IssueTagsService; import com.epmet.service.IssueTagsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -91,4 +95,17 @@ public class IssueTagsController {
ExcelUtils.exportExcelToTarget(response, null, list, IssueTagsExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, IssueTagsExcel.class);
} }
/**
* @Description 标签添加
* @Param form
* @author zxc
* @date 2020/12/9 下午3:29
*/
@PostMapping("add")
public Result<AddTagResultDTO> addTag(@RequestBody AddTagFormDTO form, @LoginUser TokenDto tokenDto){
ValidatorUtils.validateEntity(form, AddTagFormDTO.AddTag.class);
AddTagResultDTO addTagResultDTO = issueTagsService.addTag(form, tokenDto);
return new Result<AddTagResultDTO>().ok(addTagResultDTO);
}
} }

1
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueCategoryDao.java

@ -49,6 +49,7 @@ public interface IssueCategoryDao extends BaseDao<IssueCategoryEntity> {
* @Author sun * @Author sun
**/ **/
List<ProjectCategoryTagResultDTO> selectProjectCategoryList(@Param("categoryIdList") List<String> categoryIdList); List<ProjectCategoryTagResultDTO> selectProjectCategoryList(@Param("categoryIdList") List<String> categoryIdList);
// List<ProjectCategoryTagResultDTO> selectProjectCategoryList(List<String> categoryIdList);
/** /**
* 获取议题分类 * 获取议题分类

9
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueTagsDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IssueTagsDTO; import com.epmet.dto.IssueTagsDTO;
import com.epmet.dto.form.AddTagFormDTO;
import com.epmet.dto.result.IssueCategoryTagResultDTO; import com.epmet.dto.result.IssueCategoryTagResultDTO;
import com.epmet.entity.IssueTagsEntity; import com.epmet.entity.IssueTagsEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -49,4 +50,12 @@ public interface IssueTagsDao extends BaseDao<IssueTagsEntity> {
* @return java.util.List<com.epmet.dto.IssueTagsDTO> * @return java.util.List<com.epmet.dto.IssueTagsDTO>
*/ */
List<IssueTagsDTO> selectTagsByIssue(@Param("issueId") String issueId); List<IssueTagsDTO> selectTagsByIssue(@Param("issueId") String issueId);
/**
* @Description 查询标签是否重名
* @Param form
* @author zxc
* @date 2020/12/9 下午3:40
*/
String selectTagNameCount(AddTagFormDTO form);
} }

11
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueTagsService.java

@ -19,7 +19,10 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.IssueTagsDTO; import com.epmet.dto.IssueTagsDTO;
import com.epmet.dto.form.AddTagFormDTO;
import com.epmet.dto.result.AddTagResultDTO;
import com.epmet.entity.IssueTagsEntity; import com.epmet.entity.IssueTagsEntity;
import java.util.List; import java.util.List;
@ -101,4 +104,12 @@ public interface IssueTagsService extends BaseService<IssueTagsEntity> {
* @return java.util.List<com.epmet.dto.IssueTagsDTO> * @return java.util.List<com.epmet.dto.IssueTagsDTO>
*/ */
List<IssueTagsDTO> getTagsByIssue(String issueId); List<IssueTagsDTO> getTagsByIssue(String issueId);
/**
* @Description 标签添加
* @Param form
* @author zxc
* @date 2020/12/9 下午3:29
*/
AddTagResultDTO addTag(AddTagFormDTO form, TokenDto tokenDto);
} }

43
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueTagsServiceImpl.java

@ -20,14 +20,23 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.IssueProjectTagDictDao;
import com.epmet.dao.IssueTagsDao; import com.epmet.dao.IssueTagsDao;
import com.epmet.dto.IssueTagsDTO; import com.epmet.dto.IssueTagsDTO;
import com.epmet.dto.form.AddTagFormDTO;
import com.epmet.dto.result.AddTagResultDTO;
import com.epmet.dto.result.IssueCategoryTagResultDTO;
import com.epmet.entity.IssueProjectTagDictEntity;
import com.epmet.entity.IssueTagsEntity; import com.epmet.entity.IssueTagsEntity;
import com.epmet.redis.IssueProjectTagDictRedis;
import com.epmet.redis.IssueTagsRedis; import com.epmet.redis.IssueTagsRedis;
import com.epmet.service.IssueTagsService; import com.epmet.service.IssueTagsService;
import com.epmet.utils.ModuleConstants;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -48,6 +57,10 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
@Autowired @Autowired
private IssueTagsRedis issueTagsRedis; private IssueTagsRedis issueTagsRedis;
@Autowired
private IssueProjectTagDictDao issueProjectTagDictDao;
@Autowired
private IssueProjectTagDictRedis dictRedis;
@Override @Override
public PageData<IssueTagsDTO> page(Map<String, Object> params) { public PageData<IssueTagsDTO> page(Map<String, Object> params) {
@ -114,4 +127,32 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
return baseDao.selectTagsByIssue(issueId); return baseDao.selectTagsByIssue(issueId);
} }
/**
* @Description 标签添加
* @Param form
* @author zxc
* @date 2020/12/9 下午3:29
*/
@Override
public AddTagResultDTO addTag(AddTagFormDTO form, TokenDto tokenDto) {
form.setCustomerId(tokenDto.getCustomerId());
String tagId = baseDao.selectTagNameCount(form);
if (StringUtils.isNotBlank(tagId)){
return new AddTagResultDTO(tagId);
}
IssueProjectTagDictEntity entity = new IssueProjectTagDictEntity();
entity.setCustomerId(form.getCustomerId());
entity.setCategoryId(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_ID);
entity.setTagName(form.getTagName());
entity.setIsDefault(NumConstant.ONE_STR);
entity.setIssueUseCount(NumConstant.ZERO);
entity.setProjectUseCount(NumConstant.ZERO);
issueProjectTagDictDao.insert(entity);
IssueCategoryTagResultDTO issueCategoryTagResultDTO = new IssueCategoryTagResultDTO();
issueCategoryTagResultDTO.setId(entity.getId());
issueCategoryTagResultDTO.setName(entity.getTagName());
dictRedis.addIssueProjectTag(entity.getCustomerId(),entity.getCategoryId(),issueCategoryTagResultDTO);
return new AddTagResultDTO();
}
} }

10
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueTagsDao.xml

@ -28,4 +28,14 @@
AND ISSUE_ID = #{issueId} AND ISSUE_ID = #{issueId}
</select> </select>
<!-- 查询标签是否重名 -->
<select id="selectTagNameCount" resultType="java.lang.String">
SELECT
ID
FROM issue_project_tag_dict
WHERE DEL_FLAG = 0
AND TAG_NAME = #{tagName}
AND (CUSTOMER_ID = 'default' OR CUSTOMER_ID = #{customerId})
</select>
</mapper> </mapper>
Loading…
Cancel
Save