Browse Source

素材标签逻辑修改

syh 4 years ago
parent
commit
4ca4b2a547

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

@@ -57,6 +57,11 @@ public class MaterialTagInfoController {
 		return result;
 	}
 
+	@GetMapping(value = "/detail")
+	public Map<String,Object> detailList(MaterialTagInfo materialTagInfo) {
+		return materialTagInfoService.getTagDetail(materialTagInfo);
+	}
+
 	/**
 	  *   添加
 	 * @param materialTagInfo

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

@@ -11,7 +11,6 @@ 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.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -166,15 +165,13 @@ public class TagInfoController {
 		}
 		return result;
 	}
-	@Autowired
-	private ISysRoleService roleService;
 
 	@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
-    public Result<List<TagInfoTreeModel>> queryTreeList() {
+    public Result<List<TagInfoTreeModel>> queryTreeList(@RequestParam(name = "categoryId",defaultValue = "0")Long categoryId) {
 	    Result<List<TagInfoTreeModel>> result = new Result<>();
 	    try {
 			LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-            List<TagInfoTreeModel> list = tagInfoService.queryTreeList(user.getId());
+            List<TagInfoTreeModel> list = tagInfoService.queryTreeList(user.getId(),categoryId);
 	        result.setResult(list);
 	        result.setSuccess(true);
 	    } catch (Exception e) {

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialTagInfo.java

@@ -30,6 +30,7 @@ public class MaterialTagInfo {
 	private Integer status;
 	private String tagName;
 	private String tagCode;
+	private Long categoryId;
 	private Long tagId;
 	private String userId;
 	private Date createTime;

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialTagInfoService.java

@@ -15,4 +15,6 @@ import java.util.Map;
  */
 public interface IMaterialTagInfoService extends IService<MaterialTagInfo> {
     Map<String, Object> mark(JSONObject data, LoginUser loginUser);
+
+    Map<String, Object> getTagDetail(MaterialTagInfo materialTagInfo);
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/ITagInfoService.java

@@ -14,7 +14,7 @@ import java.util.List;
  */
 public interface ITagInfoService extends IService<TagInfo> {
 
-    List<TagInfoTreeModel> queryTreeList(String userId);
+    List<TagInfoTreeModel> queryTreeList(String userId,Long CategoryId);
 
     TagInfo getByTagCode(String tagCode);
 }

+ 21 - 22
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -589,28 +589,15 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                     log.info("素材归属信息入库完成,MaterialId:{}", info.getId());
                 }
             }
-            JSONArray tag = json.getJSONArray("tag");
-            if (!Check.isNull(tag)) {
-                materialTagMapper.deleteByMap(deleteMap);
-                for (int j = 0; j < tag.size(); j++) {
-                    String tagStr = tag.getString(j);
-                    if (!Check.isNull(tagStr)) {
-                        MaterialTag materialTag = new MaterialTag();
-                        materialTag.setMaterialId(info.getCode());
-                        materialTag.setTag(tagStr);
-                        materialTagMapper.insert(materialTag);
-                    }
-                }
-            }
-            JSONArray tagList = json.getJSONArray("tagList");
-            if(null!=tagList&&!tagList.isEmpty()){
-                for(int m=0;m<tagList.size();m++){
-                    Long tagId = tagList.getLong(m);
-                    TagInfo tagInfo = tagInfoService.getById(tagId);
-                    MaterialTagInfo setTag= new MaterialTagInfo(code,tagInfo,userId);
-                    materialTagInfoService.save(setTag);
-                }
-            }
+
+            JSONArray modalityTagList = json.getJSONArray("modalityTagList");
+            insertTagList(code,userId,modalityTagList);
+            JSONArray contentTagList = json.getJSONArray("contentTagList");
+            insertTagList(code,userId,contentTagList);
+            JSONArray senceTagList = json.getJSONArray("senceTagList");
+            insertTagList(code,userId,senceTagList);
+            JSONArray modTagList = json.getJSONArray("modTagList");
+            insertTagList(code,userId,modTagList);
             getFile(info, project.getMediaId());
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
         } catch (Exception e) {
@@ -619,6 +606,18 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         }
         return resultMap;
     }
+
+    private void insertTagList(String code,String userId,JSONArray tagList){
+        if(null!=tagList&&!tagList.isEmpty()){
+            for(int m=0;m<tagList.size();m++){
+                Long tagId = tagList.getLong(m);
+                TagInfo tagInfo = tagInfoService.getById(tagId);
+                MaterialTagInfo setTag= new MaterialTagInfo(code,tagInfo,userId);
+                setTag.setCategoryId(tagInfo.getTagCategoryId());
+                materialTagInfoService.save(setTag);
+            }
+        }
+    }
     @Autowired
     private ITagInfoService tagInfoService;
     @Autowired

+ 33 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialTagInfoServiceImpl.java

@@ -11,6 +11,7 @@ import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.common.system.vo.LoginUser;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -63,6 +65,37 @@ public class MaterialTagInfoServiceImpl extends ServiceImpl<MaterialTagInfoMappe
         return result;
     }
 
+    @Override
+    public Map<String, Object> getTagDetail(MaterialTagInfo materialTagInfo) {
+        Map<String,Object>result = new HashMap<>();
+        String code = materialTagInfo.getCode();
+        if(null == code||"".equals(code.trim())){
+            ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        List<MaterialTagInfo> modalityList = this.getByParams(code,1L);
+        result.put("modalityTagList",modalityList);
+        List<MaterialTagInfo> modList = this.getByParams(code,2L);
+        result.put("modTagList",modList);
+        List<MaterialTagInfo> contentList = this.getByParams(code,3L);
+        result.put("contentTagList",contentList);
+        List<MaterialTagInfo> senceList = this.getByParams(code,4L);
+        result.put("senceTagList",senceList);
+        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    public List<MaterialTagInfo> getByParams(String code,Long categotyId){
+        QueryWrapper<MaterialTagInfo>queryWrapper = new QueryWrapper<>();
+        if(null!=code&&"".equals(code.trim())){
+            queryWrapper.eq("code",code);
+        }
+        if(null!=categotyId&&categotyId!=0){
+            queryWrapper.eq("category_id",categotyId);
+        }
+        return this.list(queryWrapper);
+    }
+
     private void deleteByCode(String code) {
         UpdateWrapper<MaterialTagInfo>updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("code",code).set("status",0).set("update_time",new Date());

+ 4 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/TagInfoServiceImpl.java

@@ -24,8 +24,11 @@ public class TagInfoServiceImpl extends ServiceImpl<TagInfoMapper, TagInfo> impl
      * queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
      */
     @Override
-    public List<TagInfoTreeModel> queryTreeList(String userId) {
+    public List<TagInfoTreeModel> queryTreeList(String userId,Long categoryId) {
         QueryWrapper<TagInfo> query = new QueryWrapper<>();
+        if(null!=categoryId&&categoryId!=0){
+            query.eq("tag_category_id",categoryId);
+        }
         query.eq("del_flag", "0").or(wrapper->wrapper.eq("status",0).eq("user_id",userId));
         query.orderByAsc("tag_order");
         List<TagInfo> list = this.list(query);