Commit bee321e6 by wenyang

标签库集合查询增加条件,并支出查询无效的标签;使用场景新增上传图片功能

parent 6c7a0966
......@@ -34,11 +34,15 @@ import com.yd.api.agms.vo.tag.TagViewUpdateRequestVO;
import com.yd.api.agms.vo.tag.TagViewUpdateResponseVO;
import com.yd.api.result.JsonResult;
import com.yd.util.CommonUtil;
import com.yd.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletResponse;
@Controller
......@@ -382,15 +386,19 @@ public class AgmsController {
return result;
}
/**
* AGMS -- 前端显示标签 保存与修改
* @param requestVO 请求数据
* @return 响应数据
*/
@RequestMapping(value="/tagViewUpdate")
public Object tagViewUpdate(@RequestBody TagViewUpdateRequestVO requestVO) {
JsonResult result = new JsonResult();
TagViewUpdateResponseVO responseVO = agmsTagService.tagViewUpdate(requestVO);
public Object tagViewUpdate(@RequestParam(value = "requestVO",required = true) String requestVO,
@RequestParam(value = "tagViewImage",required = false) MultipartFile tagViewImage) throws Exception{
requestVO = new String(requestVO.getBytes("ISO-8859-1"),"UTF-8");
TagViewUpdateRequestVO request = (TagViewUpdateRequestVO)JsonUtil.jsonToObj(requestVO, TagViewUpdateRequestVO.class);
JsonResult result = new JsonResult();
TagViewUpdateResponseVO responseVO = agmsTagService.tagViewUpdate(request,tagViewImage);
result.setData(responseVO);
result.addResult(responseVO);
return result;
......
package com.yd.api.agms.service;
import org.springframework.web.multipart.MultipartFile;
import com.yd.api.agms.vo.tag.TagUpdateRequestVO;
import com.yd.api.agms.vo.tag.TagUpdateResponseVO;
import com.yd.api.agms.vo.tag.TagViewUpdateRequestVO;
......@@ -19,8 +21,9 @@ public interface AgmsTagService {
/**
* AGMS -- 前端显示标签 保存与修改
* @param requestVO 请求数据
* @param tagViewImage 请求文件图片
* @return 响应数据
*/
TagViewUpdateResponseVO tagViewUpdate(TagViewUpdateRequestVO requestVO);
TagViewUpdateResponseVO tagViewUpdate(TagViewUpdateRequestVO requestVO,MultipartFile tagViewImage);
}
package com.yd.api.agms.service.impl;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.yd.api.agms.service.AgmsTagService;
import com.yd.api.agms.vo.tag.TagUpdateRequestVO;
import com.yd.api.agms.vo.tag.TagUpdateResponseVO;
......@@ -10,13 +19,13 @@ import com.yd.dal.entity.meta.MdTagNew;
import com.yd.dal.entity.meta.MdTagView;
import com.yd.dal.service.meta.MdTagNewDALService;
import com.yd.dal.service.meta.MdTagViewDALService;
import com.yd.rmi.ali.oss.service.OssService;
import com.yd.rmi.ali.oss.vo.OssOperateTypeEnum;
import com.yd.rmi.ali.oss.vo.OssRequestVO;
import com.yd.rmi.ali.oss.vo.OssResponseVO;
import com.yd.rmi.cache.SystemConfigService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author xxy
......@@ -30,6 +39,12 @@ public class AgmsTagServiceImpl implements AgmsTagService {
@Autowired
public MdTagViewDALService mdTagViewDALService;
@Autowired
private SystemConfigService systemConfigService;
@Autowired
private OssService ossService;
@Override
public TagUpdateResponseVO tagUpdate(TagUpdateRequestVO requestVO) {
......@@ -79,11 +94,12 @@ public class AgmsTagServiceImpl implements AgmsTagService {
/**
* AGMS -- 前端显示标签 保存与修改
* @author xxy
* @author ywenyang
* @param tagViewImage 请求文件图片
* @date 2021年06月30日 23:39
*/
@Override
public TagViewUpdateResponseVO tagViewUpdate(TagViewUpdateRequestVO requestVO) {
public TagViewUpdateResponseVO tagViewUpdate(TagViewUpdateRequestVO requestVO,MultipartFile tagViewImage) {
TagViewUpdateResponseVO responseVO = new TagViewUpdateResponseVO();
CommonResult commonResult = new CommonResult();
tagViewUpdateEntryCheck(requestVO,commonResult);
......@@ -91,9 +107,55 @@ public class AgmsTagServiceImpl implements AgmsTagService {
responseVO.setCommonResult(commonResult);
return responseVO;
}
//上传文件
boolean success = false;
String message = "";
String filePathOss = null;
if (tagViewImage != null) {
String originalFilename = null;
String ossKey = null;
originalFilename = tagViewImage.getOriginalFilename();
ossKey = "downloadfile/" + originalFilename.replaceAll(" ", "").replaceAll(" ", "");
File file = null;
try {
file = File.createTempFile("tmp", null);
tagViewImage.transferTo(file);
OssRequestVO ossRequestVO = new OssRequestVO();
ossRequestVO.setOperateType(OssOperateTypeEnum.PUT_OBJECT.getCode());
String bucketName = systemConfigService.getSingleConfigValue("ALI_OSS_IMAGES");
ossRequestVO.setBucketName(bucketName);
ossRequestVO.setKey(ossKey);
ossRequestVO.setFile(file);
OssResponseVO ossresponseVO = ossService.ossOperate(ossRequestVO);
if(ossresponseVO.getCommonResult().isSuccess()){
ossRequestVO.setOperateType(OssOperateTypeEnum.GENERATE_URL.getCode());
ossresponseVO = ossService.ossOperate(ossRequestVO);
filePathOss = ossresponseVO.getUrl();
}else{
success = true;
message = ossresponseVO.getCommonResult().getMessage();
}
} catch (IOException e) {
e.printStackTrace();
success = true;
message = "Update FileImage error:" + e.getMessage();
}finally{
if(file != null){file.delete();}
}
if(success){
commonResult.setSuccess(false);
commonResult.setMessage(message);
responseVO.setCommonResult(commonResult);
return responseVO;
}
}
MdTagView mdTagView = new MdTagView();
BeanUtils.copyProperties(requestVO,mdTagView);
if(filePathOss != null && !"".equals(filePathOss)){
mdTagView.setDisplayImage(filePathOss);
}
if (CommonUtil.isNullOrZero(requestVO.getId())){
mdTagView.setCreatedAt(new Date());
mdTagView.setUpdatedAt(new Date());
......@@ -105,6 +167,7 @@ public class AgmsTagServiceImpl implements AgmsTagService {
mdTagView.setUpdatedBy(requestVO.getLoginId());
mdTagViewDALService.updateByPrimaryKeySelective(mdTagView);
}
responseVO.setFilePathOss(mdTagView.getDisplayImage());
commonResult.setSuccess(true);
commonResult.setMessage(ZHBErrorConfig.getErrorInfo("800000"));
responseVO.setId(mdTagView.getId());
......
......@@ -12,6 +12,9 @@ public class TagViewUpdateResponseVO {
private CommonResult commonResult;
private String filePathOss;
/**
* Gets the value of commonResult. *
*
......@@ -47,12 +50,27 @@ public class TagViewUpdateResponseVO {
public void setId(Long id) {
this.id = id;
}
/**
* @return the filePathOss
*/
public String getFilePathOss() {
return filePathOss;
}
/**
* @param filePathOss the filePathOss to set
*/
public void setFilePathOss(String filePathOss) {
this.filePathOss = filePathOss;
}
@Override
@Override
public String toString() {
return "TagUpdateResponseVO{" +
"id=" + id +
", commonResult=" + commonResult +
"filePathOss=" + filePathOss +
'}';
}
}
package com.yd.api.metadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yd.api.metadata.service.MetadataService;
import com.yd.api.metadata.vo.TagQueryRequestVO;
import com.yd.api.metadata.vo.TagQueryResponseVO;
import com.yd.api.metadata.vo.TagViewQueryRequestVO;
import com.yd.api.metadata.vo.TagViewQueryResponseVO;
......@@ -26,12 +26,13 @@ public class MetadataController {
/**
* 标签合集查询
* @param requestVO
* @return TagQueryResponseVO
*/
@GetMapping("/tagQuery")
public Object tagQuery(@RequestParam(value = "isActive",required = false) Long isActive){
@RequestMapping("/tagQuery")
public Object tagQuery(@RequestBody TagQueryRequestVO requestVO){
JsonResult result = new JsonResult();
TagQueryResponseVO responseVO = metadataService.tagQuery(isActive);
TagQueryResponseVO responseVO = metadataService.tagQuery(requestVO);
result.setData(responseVO);
result.addResult(responseVO);
return result;
......@@ -39,6 +40,7 @@ public class MetadataController {
/**
* 前端显示标签合集查询
* @param requestVO
* @return TagViewQueryResponseVO
* @date 2021年06月21日 17:14
*/
......
package com.yd.api.metadata.service;
import com.yd.api.metadata.vo.TagQueryRequestVO;
import com.yd.api.metadata.vo.TagQueryResponseVO;
import com.yd.api.metadata.vo.TagViewQueryRequestVO;
import com.yd.api.metadata.vo.TagViewQueryResponseVO;
......@@ -7,10 +8,10 @@ import com.yd.api.metadata.vo.TagViewQueryResponseVO;
public interface MetadataService {
/**
* 标签合集查询
* @param isActive 是否启用
* @return
* @param requestVO
* @return TagQueryResponseVO
*/
TagQueryResponseVO tagQuery(Long isActive);
TagQueryResponseVO tagQuery(TagQueryRequestVO requestVO);
/**
* 前端显示标签合集查询
......
package com.yd.api.metadata.service.impl;
import com.yd.api.agms.vo.tag.TagViewUpdateRequestVO;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yd.api.metadata.service.MetadataService;
import com.yd.api.metadata.vo.TagQueryInfo;
import com.yd.api.metadata.vo.TagQueryRequestVO;
import com.yd.api.metadata.vo.TagQueryResponseVO;
import com.yd.api.metadata.vo.TagViewQueryInfo;
import com.yd.api.metadata.vo.TagViewQueryRequestVO;
......@@ -15,15 +25,6 @@ import com.yd.dal.service.meta.MdTagViewDALService;
import com.yd.dal.service.metadata.MetadataDALService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author xxy
......@@ -44,25 +45,79 @@ public class MetadataServiceImpl implements MetadataService {
@Override
@SuppressWarnings("unchecked")
public TagQueryResponseVO tagQuery(Long isActive) {
public TagQueryResponseVO tagQuery(TagQueryRequestVO requestVO) {
TagQueryResponseVO responseVO = new TagQueryResponseVO();
CommonResult commonResult = new CommonResult();
tagQueryCheck(requestVO, commonResult);
if (!commonResult.isSuccess()){
responseVO.setCommonResult(commonResult);
return responseVO;
}
List<MdTagNew> mdTagNewList = mdTagNewDalService.selectByIsActive(isActive);
Long isActive = null, configLevel = null, upperTagId = null;
String tagName = null;
if(requestVO.getIsActive() != null){
isActive = requestVO.getIsActive().longValue();
}
if(requestVO.getConfigLevel() != null){
configLevel = requestVO.getConfigLevel();
}
if(requestVO.getUpperTagId() != null){
upperTagId = requestVO.getUpperTagId();
}
if(!CommonUtil.isNullOrBlank(requestVO.getTagName())){
if(requestVO.getConfigLevel() == null){
commonResult.setSuccess(false);
commonResult.setMessage(ZHBErrorConfig.getErrorInfo("830036"));
responseVO.setCommonResult(commonResult);
return responseVO;
}
tagName = requestVO.getTagName()+"%";
}
List<MdTagNew> mdTagNewList = mdTagNewDalService.selectByIsActive(isActive,configLevel,upperTagId,tagName);
List<TagQueryInfo> tagQueryInfos = new ArrayList<>(16);
List<MdTagNew> mdTagNewAddList = new ArrayList<>(16);
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate( "configLevel", 1L);
List<MdTagNew> objectListSelect= (List<MdTagNew>) CollectionUtils.select(mdTagNewList, predicateClause);
mdTagNewAddList.addAll(objectListSelect);
classificationBuildUpMdTag(mdTagNewList,mdTagNewAddList,objectListSelect,tagQueryInfos);
mdTagNewList.removeAll(mdTagNewAddList);
uncategorizedMdTag(mdTagNewList,tagQueryInfos);
if(configLevel == null){
if((requestVO.getUpperTagId() != null || !CommonUtil.isNullOrBlank(requestVO.getTagName()))){
if(mdTagNewList != null && mdTagNewList.size() >0 && mdTagNewList.get(0) != null)
configLevel = ((MdTagNew)mdTagNewList.get(0)).getConfigLevel();
}else{
configLevel = 1L;
}
}
if(isActive == null || isActive == 1L || (configLevel != null || upperTagId != null || !CommonUtil.isNullOrBlank(requestVO.getTagName()))){
List<MdTagNew> mdTagNewAddList = new ArrayList<>(16);
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate( "configLevel", configLevel);
List<MdTagNew> objectListSelect= (List<MdTagNew>) CollectionUtils.select(mdTagNewList, predicateClause);
mdTagNewAddList.addAll(objectListSelect);
classificationBuildUpMdTag(mdTagNewList,mdTagNewAddList,objectListSelect,tagQueryInfos);
mdTagNewList.removeAll(mdTagNewAddList);
// uncategorizedMdTag(mdTagNewList,tagQueryInfos);
}else{
for (MdTagNew mdTagNew : mdTagNewList) {
TagQueryInfo tagQueryInfo = new TagQueryInfo();
BeanUtils.copyProperties(mdTagNew,tagQueryInfo);
tagQueryInfo.setCreatedAt(CommonUtil.dateParseString(mdTagNew.getCreatedAt(),"yyyy-MM-dd HH:mm:ss"));
tagQueryInfo.setUpdatedAt(CommonUtil.dateParseString(mdTagNew.getUpdatedAt(),"yyyy-MM-dd HH:mm:ss"));
tagQueryInfos.add(tagQueryInfo);
}
}
responseVO.setTagQueryInfos(tagQueryInfos);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO;
}
private void tagQueryCheck(TagQueryRequestVO requestVO, CommonResult commonResult) {
// if (requestVO.getIsActive() == null){
// commonResult.setSuccess(false);
// commonResult.setMessage(ZHBErrorConfig.getErrorInfo("830031"));
// return;
// }
commonResult.setSuccess(true);
commonResult.setMessage(ZHBErrorConfig.getErrorInfo("800000"));
}
@SuppressWarnings("unchecked")
private void classificationBuildUpMdTag(List<MdTagNew> mdTagNewList,
......
package com.yd.api.metadata.vo;
/**
* @author ywenYang
* @date 2021年06月30日 23:41
*/
public class TagQueryRequestVO {
private Long configLevel;//标签级别(1=一级; 2=二级; 3=三级)
private Long upperTagId;//上级标签
private String tagName;//标签名称
private Integer isActive;//
/**
* @return the configLevel
*/
public Long getConfigLevel() {
return configLevel;
}
/**
* @param configLevel the configLevel to set
*/
public void setConfigLevel(Long configLevel) {
this.configLevel = configLevel;
}
/**
* @return the upperTagId
*/
public Long getUpperTagId() {
return upperTagId;
}
/**
* @param upperTagId the upperTagId to set
*/
public void setUpperTagId(Long upperTagId) {
this.upperTagId = upperTagId;
}
/**
* @return the tagName
*/
public String getTagName() {
return tagName;
}
/**
* @param tagName the tagName to set
*/
public void setTagName(String tagName) {
this.tagName = tagName;
}
/**
* @return the isActive
*/
public Integer getIsActive() {
return isActive;
}
/**
* @param isActive the isActive to set
*/
public void setIsActive(Integer isActive) {
this.isActive = isActive;
}
@Override
public String toString() {
return "MdTagNew{" +
", configLevel='" + configLevel + '\'' +
", upperTagId='" + upperTagId + '\'' +
", tagName='" + tagName + '\'' +
", isActive=" + isActive +
'}';
}
}
......@@ -23,5 +23,5 @@ public interface MdTagNewMapper {
int batchInsert(@Param("list") List<MdTagNew> list);
List<MdTagNew> selectByIsActive(@Param("isActive")Long isActive);
List<MdTagNew> selectByIsActive(@Param("isActive")Long isActive,@Param("configLevel")Long configLevel,@Param("upperTagId")Long upperTagId,@Param("tagName")String tagName);
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import java.util.List;
* @author xxy
*/
public interface MdTagNewDALService {
List<MdTagNew> selectByIsActive(Long isActive);
List<MdTagNew> selectByIsActive(Long isActive,Long configLevel,Long upperTagId,String tagName);
void insert(MdTagNew mdTagNew);
......
......@@ -3,6 +3,8 @@ package com.yd.dal.service.meta.impl;
import com.yd.dal.entity.meta.MdTagNew;
import com.yd.dal.mapper.meta.MdTagNewMapper;
import com.yd.dal.service.meta.MdTagNewDALService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -18,8 +20,8 @@ public class MdTagNewDALServiceImpl implements MdTagNewDALService {
public MdTagNewMapper mapper;
@Override
public List<MdTagNew> selectByIsActive(Long isActive) {
return mapper.selectByIsActive(isActive);
public List<MdTagNew> selectByIsActive(Long isActive,Long configLevel,Long upperTagId,String tagName) {
return mapper.selectByIsActive(isActive,configLevel,upperTagId,tagName);
}
@Override
......
......@@ -49,4 +49,5 @@
830032=上级显示标签不存在!
830033=上级显示标签的标签显示类别与保存标签的显示类别不一致!
830034=保存标签的标签级别与上级显示标签的标签级别不能相隔多级!
830035=根据基础标签ID查找不到有效的基础标签!
\ No newline at end of file
830035=根据基础标签ID查找不到有效的基础标签!
830036=标签名称有值时标签级别不能为空!
\ No newline at end of file
......@@ -274,8 +274,18 @@
<include refid="Base_Column_List" />
from ag_md_tag_new
<where>
1 = 1
<if test="isActive != null">
is_active = #{isActive,jdbcType=BIGINT}
and is_active = #{isActive,jdbcType=BIGINT}
</if>
<if test="configLevel != null">
and config_level = #{configLevel,jdbcType=BIGINT}
</if>
<if test="upperTagId != null">
and upper_tag_id = #{upperTagId,jdbcType=BIGINT}
</if>
<if test="tagName != null">
and tag_name like #{tagName,jdbcType=VARCHAR}
</if>
</where>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment