Browse Source

add
/tagType/{code}

guozhaoshun 6 years ago
parent
commit
ebb60529f4

+ 3 - 2
rankin-api-web/src/main/java/cn/rankin/apiweb/controller/TagController.java

@@ -7,6 +7,7 @@ import cn.rankin.common.utils.api.page.Page;
 import cn.rankin.data.api.app.vo.DeviceUserVo;
 import cn.rankin.data.api.app.vo.ItemVo;
 import cn.rankin.data.api.app.vo.TagGroupVo;
+import cn.rankin.data.api.app.vo.TagTypeVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -30,9 +31,9 @@ public class TagController {
     }
 
     @RequestMapping(value = "/tagType/{code}", method = RequestMethod.GET)
-    public APIResult<TagGroupVo> getTagType(@NeedUser DeviceUserVo user, @PathVariable("code") String code) {
+    public APIResult<TagTypeVo> getTagType(@NeedUser DeviceUserVo user,@PathVariable("code") String code) {
         String merchantId = user.getMerchantId();
-        return tagService.findTagGroupByCode(code, merchantId);
+        return tagService.findTagTypeByCode(code, merchantId);
     }
 
 }

+ 4 - 0
rankin-api-web/src/main/java/cn/rankin/apiweb/service/tag/TagClient.java

@@ -4,6 +4,7 @@ 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.TagGroup;
+import cn.rankin.data.api.product.entity.TagType;
 import org.springframework.cloud.netflix.feign.FeignClient;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -16,6 +17,9 @@ public interface TagClient {
     @RequestMapping(value = "/app/tagGroup/code/{code}", method = RequestMethod.GET)
     APIResult<TagGroup> findTagGroupByCode(@PathVariable("code") String code, @RequestParam("merchantId") String merchantId);
 
+    @RequestMapping(value = "/app/tagType/code/{code}", method = RequestMethod.GET)
+    APIResult<TagType> findTagTypeByCode(@PathVariable("code") String code, @RequestParam("merchantId") String merchantId);
+
     @RequestMapping(value = "/app/tag/item/{tagId}", method = RequestMethod.GET)
     APIResult<Page<ItemVo>> findPageByTagId(@PathVariable("tagId") String tagId, @RequestParam("merchantId") String merchantId,
                                             @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize);

+ 15 - 0
rankin-api-web/src/main/java/cn/rankin/apiweb/service/tag/TagService.java

@@ -5,7 +5,9 @@ import cn.rankin.common.utils.api.model.BaseCode;
 import cn.rankin.common.utils.api.page.Page;
 import cn.rankin.data.api.app.vo.ItemVo;
 import cn.rankin.data.api.app.vo.TagGroupVo;
+import cn.rankin.data.api.app.vo.TagTypeVo;
 import cn.rankin.data.api.product.entity.TagGroup;
+import cn.rankin.data.api.product.entity.TagType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -27,7 +29,20 @@ public class TagService {
         return APIResult.ok(tagGroupVo);
     }
 
+    public APIResult<TagTypeVo> findTagTypeByCode(String code, String merchantId) {
+        APIResult<TagType> apiResult = tagClient.findTagTypeByCode(code,merchantId);
+        if (!apiResult.getSuccess()) {
+            return APIResult.error(new BaseCode(apiResult.getCode(), apiResult.getMessage()));
+        }
+        TagType tagType = apiResult.getData();
+        TagTypeVo tagTypeVo = convert(tagType);
+        return APIResult.ok(tagTypeVo);
+    }
+
     public APIResult<Page<ItemVo>> findPageByTagId(String tagId, String merchantId, Integer pageNo, Integer pageSize) {
         return tagClient.findPageByTagId(tagId, merchantId, pageNo, pageSize);
     }
+
+
+
 }

+ 19 - 0
rankin-api-web/src/main/java/cn/rankin/apiweb/utils/DTOConverter.java

@@ -41,6 +41,25 @@ public class DTOConverter {
         return tagGroupVo;
     }
 
+    public static TagTypeVo convert(TagType tagType) {
+        TagTypeVo tagTypeVo = new TagTypeVo();
+        tagTypeVo.setName(tagType.getName());
+        List<TagVo> tagVoList = new ArrayList<>();
+        List<Tag> tagList = tagType.getTagList();
+        if (CollectionUtils.isEmpty(tagList)) {
+            return tagTypeVo;
+        }
+        for (Tag tag : tagList) {
+            TagVo tagVo = new TagVo();
+            tagVo.setId(tag.getId());
+            tagVo.setName(tag.getName());
+            tagVoList.add(tagVo);
+        }
+        tagTypeVo.setList(tagVoList);
+        return tagTypeVo;
+    }
+
+
     public static CourseVo convert(Course course) {
         CourseVo courseVo = new CourseVo();
         courseVo.setBreadCrumb(course.getBreadCrumb());