Bläddra i källkod

素材标签逻辑

syh 4 år sedan
förälder
incheckning
ab44b7baa0

+ 19 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TagInfoController.java

@@ -7,8 +7,10 @@ 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 org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -39,13 +41,13 @@ public class TagInfoController {
 	 * @return
 	 */
 	@GetMapping(value = "/list")
-	public Result<IPage<TagInfo>> queryPageList(TagInfo tagInfo,
-												@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-												@RequestParam(name="pageSize", defaultValue="100") Integer pageSize,
+	public Result<IPage<TagInfo>> queryPageList(TagInfo tagInfo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="100") Integer pageSize,
 												HttpServletRequest req) {
 		Result<IPage<TagInfo>> result = new Result<>();
+		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		QueryWrapper<TagInfo> queryWrapper = QueryGenerator.initQueryWrapper(tagInfo, req.getParameterMap());
 		Page<TagInfo> page = new Page<>(pageNo, pageSize);
+		queryWrapper.eq("del_flag",0);
 		IPage<TagInfo> pageList = tagInfoService.page(page, queryWrapper);
 		result.setSuccess(true);
 		result.setResult(pageList);
@@ -61,8 +63,12 @@ public class TagInfoController {
 	public Result<TagInfo> add(@RequestBody TagInfo tagInfo) {
 		Result<TagInfo> result = new Result<>();
 		try {
+			LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 			tagInfo.setDelFlag(0);
-			tagInfo.setStatus(1);
+			if(null == tagInfo.getStatus()){
+				tagInfo.setStatus(1);
+			}
+			tagInfo.setUserId(user.getId());
 			int level = 1;
 			Long parentId = tagInfo.getParentId();
 			if(null!=parentId){
@@ -72,12 +78,20 @@ public class TagInfoController {
 					return result;
 				}
 				String tagCode = parentTag.getTagCode()+tagInfo.getTagCode();
-				level = parentTag.getLevel()+1;
 				TagInfo getTag = tagInfoService.getByTagCode(tagCode);
 				if(null!=getTag){
 					result.error500("标签编码已存在");
 					return result;
 				}
+				tagInfo.setTagCategoryId(parentTag.getTagCategoryId());
+				if(parentTag.getLevel() == 1){
+					tagInfo.setFirstTagId(parentTag.getId());
+				}
+				if(parentTag.getLevel() == 2){
+					tagInfo.setSecendTagId(parentTag.getId());
+					tagInfo.setFirstTagId(parentTag.getParentId());
+				}
+				level = parentTag.getLevel()+1;
 				tagInfo.setTagCode(tagCode);
 			}
 			tagInfo.setLevel(level);

+ 24 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/TagCategoryInfo.java

@@ -0,0 +1,24 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+@Data
+@TableName("ctop_tag_category")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class TagCategoryInfo {
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    private String name;
+    private String code;
+    private Integer status;
+    private Date createTime;
+    private Date updateTime;
+}

+ 11 - 4
module-common/src/main/java/cn/com/ctop/common/module/entity/TagInfo.java

@@ -1,10 +1,10 @@
 package cn.com.ctop.common.module.entity;
 
+import cn.com.ctop.common.module.annotation.Dict;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -23,15 +23,22 @@ import java.util.Date;
 @Accessors(chain = true)
 @ApiModel(value="ctop_tag_info对象", description="标签信息")
 public class TagInfo {
-
-	/**id*/
 	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
 	private Long id;
+	@Dict(dicCode = "id",dictTable="ctop_tag_info",dicText="tag_name")
 	private Long parentId;
+	@Dict(dicCode = "id",dictTable="ctop_tag_category",dicText="name")
+	private Long tagCategoryId;
+	@Dict(dicCode = "id",dictTable="ctop_tag_info",dicText="tag_name")
+	private Long firstTagId;
+	@Dict(dicCode = "id",dictTable="ctop_tag_info",dicText="tag_name")
+	private Long secendTagId;
+	@Dict(dicCode = "id",dictTable="sys_user",dicText="realname")
+	private String userId;
 	private String tagName;
 	private Integer tagOrder;
 	private String description;
+	private String model;
 	private String tagCode;
 	private Integer level;
 	private Integer status;

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/TagCategoryInfoMapper.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.TagCategoryInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface TagCategoryInfoMapper extends BaseMapper<TagCategoryInfo> {
+}

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/TagCategoryInfoMapper.xml

@@ -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="cn.com.ctop.common.module.mapper.TagCategoryInfoMapper">
+
+</mapper>

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ITagCategoryInfoService.java

@@ -0,0 +1,7 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.TagCategoryInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+public interface ITagCategoryInfoService extends IService<TagCategoryInfo> {
+}

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/TagCategoryInfoServiceImpl.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.TagCategoryInfo;
+import cn.com.ctop.common.module.mapper.TagCategoryInfoMapper;
+import cn.com.ctop.common.module.service.ITagCategoryInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TagCategoryInfoServiceImpl extends ServiceImpl<TagCategoryInfoMapper, TagCategoryInfo> implements ITagCategoryInfoService {
+}