Browse Source

Tag create/update support typeCode

guozhaoshun 6 years ago
parent
commit
3d0665565c

+ 3 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/app/vo/TagVo.java

@@ -4,6 +4,7 @@ import lombok.Data;
 import lombok.ToString;
 
 import java.io.Serializable;
+import java.util.List;
 
 @Data
 @ToString
@@ -12,4 +13,6 @@ public class TagVo implements Serializable {
     private String id;
 
     private String name;
+
+    private List<ItemVo> recs;
 }

+ 2 - 0
rankin-data-api/src/main/java/cn/rankin/data/api/product/dto/TagDTO.java

@@ -13,6 +13,8 @@ public class TagDTO implements Serializable {
 
     private String groupId;
 
+    private String typeCode;
+
     private String name;
 
     private String merchantId;

+ 0 - 38
rankin-product-service/src/main/java/cn/rankin/productservice/controller/app/AppTagController.java

@@ -3,19 +3,12 @@ package cn.rankin.productservice.controller.app;
 import cn.rankin.common.utils.api.model.APIResult;
 import cn.rankin.common.utils.api.page.Page;
 import cn.rankin.data.api.app.vo.ItemVo;
-import cn.rankin.data.api.product.entity.Tag;
 import cn.rankin.data.api.product.entity.TagGroup;
-import cn.rankin.data.api.product.entity.TagType;
-import cn.rankin.productservice.code.ProductServiceAPICode;
-import cn.rankin.productservice.service.TagService;
-import cn.rankin.productservice.service.TagTypeService;
 import cn.rankin.productservice.service.app.ItemService;
 import cn.rankin.productservice.service.TagGroupService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-
 @RestController
 @RequestMapping(value = "/app")
 public class AppTagController {
@@ -24,12 +17,6 @@ public class AppTagController {
     private TagGroupService tagGroupService;
 
     @Autowired
-    private TagTypeService tagTypeService;
-
-    @Autowired
-    private TagService tagService;
-
-    @Autowired
     private ItemService itemService;
 
     @RequestMapping(value = "/tagGroup/code/{code}", method = RequestMethod.GET)
@@ -43,29 +30,4 @@ public class AppTagController {
         return itemService.findPageByTagId(tagId, merchantId, pageNo, pageSize);
     }
 
-
-    @RequestMapping(value = "/tagType/code/{typeCode}", method = RequestMethod.GET)
-    public APIResult<List<Tag>> getTagTypeByCode(@PathVariable("typeCode") String typeCode, @RequestParam("merchantId") String merchantId) {
-        TagType tagType = tagTypeService.getTagTypeByCode(typeCode);
-
-        if (tagType == null) {
-            return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
-        }else{
-            //开始组装数据
-
-            //标签列表数据
-            List<Tag> tagList = tagService.findByTypeCode(typeCode,merchantId);
-
-            //标签下   课程数据
-            tagList.forEach(tag -> {
-                String tagId = tag.getId();
-                List<ItemVo> itemVoList = itemService.findPageByTagId(tagId, merchantId);
-                tag.setRecs(itemVoList);
-
-            });
-
-            return APIResult.ok(tagList);
-        }
-
-    }
 }

+ 0 - 134
rankin-product-service/src/main/java/cn/rankin/productservice/controller/cms/TagTypeController.java

@@ -1,134 +0,0 @@
-package cn.rankin.productservice.controller.cms;
-
-import cn.rankin.common.utils.api.model.APICode;
-import cn.rankin.common.utils.api.model.APIResult;
-import cn.rankin.common.utils.api.page.Page;
-import cn.rankin.common.utils.dto.search.TagTypeSearchDTO;
-import cn.rankin.common.utils.enums.BaseOrderEnum;
-import cn.rankin.data.api.product.dto.TagTypeDTO;
-import cn.rankin.data.api.product.entity.Tag;
-import cn.rankin.data.api.product.entity.TagType;
-import cn.rankin.productservice.code.ProductServiceAPICode;
-import cn.rankin.productservice.service.TagService;
-import cn.rankin.productservice.service.TagTypeService;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-@RestController
-@RequestMapping(value = "tagType")
-public class TagTypeController {
-
-    @Autowired
-    private TagTypeService tagTypeService;
-
-    @Autowired
-    private TagService tagService;
-
-    @RequestMapping(value = "/list", method = RequestMethod.GET)
-    public APIResult<Page<TagType>> search(TagTypeSearchDTO searchDTO) {
-        TagType tagType = new TagType();
-
-        String code = searchDTO.getCode();
-        if (!StringUtils.isEmpty(code)) {
-            tagType.setCode("%" + code + "%");
-        }
-
-        String name = searchDTO.getName();
-        if (!StringUtils.isEmpty(name)) {
-            tagType.setName("%" + name + "%");
-        }
-
-//        // others
-//        tagType.setMerchantId(searchDTO.getMerchantId());
-
-        // sort
-        LinkedHashMap<String, BaseOrderEnum> sort = new LinkedHashMap<>();
-        sort.put("gmtModified", BaseOrderEnum.DESC);
-
-        Page<TagType> pageResult = tagTypeService.search(tagType, searchDTO.getPageNo(), searchDTO.getPageSize(), sort);
-
-
-        return APIResult.ok(pageResult);
-    }
-
-    @Transactional
-    @RequestMapping(method = RequestMethod.POST)
-    public APIResult<TagType> create(@Valid @RequestBody TagTypeDTO tagTypeDTO) {
-        TagType tagType = tagTypeService.create(tagTypeDTO);
-        if(tagType == null){
-            return APIResult.error(APICode.ALREADY_EXISTS);
-        }else{
-            return APIResult.ok(tagType);
-        }
-
-    }
-
-    @RequestMapping(method = RequestMethod.PUT)
-    public APIResult<TagType> update(@RequestBody TagTypeDTO tagTypeDTO) {
-
-        TagType tagType = tagTypeService.update(tagTypeDTO);
-        return APIResult.ok(tagType);
-
-    }
-
-    @RequestMapping(value = "/{tagTypeId}", method = RequestMethod.DELETE)
-    public APIResult<Boolean> delete(@PathVariable("tagTypeId") String tagTypeId) {
-
-        Boolean flag = tagTypeService.delete(tagTypeId);
-        if(flag){
-            return APIResult.ok();
-        }else{
-            return APIResult.error(ProductServiceAPICode.error("删除失败"));
-        }
-
-    }
-
-    @RequestMapping(value = "/{tagTypeId}", method = RequestMethod.GET)
-    public APIResult<TagType> getTagType(@PathVariable("tagTypeId") String tagTypeId, @RequestParam("merchantId") String merchantId) {
-        TagType tagType = tagTypeService.getTagType(tagTypeId);
-
-        if (tagType == null) {
-            return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
-        }else{
-
-            //开始组装数据
-            List<Tag> tagList = tagService.findByTypeCode(tagType.getCode(),merchantId);
-            tagType.setTagList(tagList);
-
-
-            return APIResult.ok(tagType);
-        }
-
-    }
-
-/*    @RequestMapping(value = "/code/{typeCode}", method = RequestMethod.GET)
-    public APIResult<List<Tag>> getTagTypeByCode(@PathVariable("typeCode") String typeCode, @RequestParam("merchantId") String merchantId) {
-        TagType tagType = tagTypeService.getTagTypeByCode(typeCode);
-        if (tagType == null) {
-            return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
-        }else{
-
-            //开始组装数据
-
-            //标签列表数据
-            List<Tag> tagList = tagService.findByTypeCode(typeCode,merchantId);
-
-            //标签下   课程数据
-            tagList.forEach(tag -> {
-                String tagId = tag.getId();
-                List<ItemVo> itemVoList = itemService.findPageByTagId(tagId, merchantId);
-                tag.setRecs(itemVoList);
-
-            });
-
-            return APIResult.ok(tagList);
-        }
-
-    }*/
-}