|
@@ -3,13 +3,13 @@ package cn.rankin.productservice.controller;
|
|
|
import cn.rankin.common.utils.api.model.BaseCode;
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
|
-import cn.rankin.common.utils.dto.product.GroupDTO;
|
|
|
-import cn.rankin.common.utils.dto.product.TagDTO;
|
|
|
+import cn.rankin.data.api.product.dto.GroupDTO;
|
|
|
+import cn.rankin.data.api.product.dto.TagDTO;
|
|
|
import cn.rankin.common.utils.dto.search.GroupSearchDTO;
|
|
|
import cn.rankin.common.utils.enums.BaseOrderEnum;
|
|
|
-import cn.rankin.productservice.entity.Group;
|
|
|
-import cn.rankin.productservice.entity.Tag;
|
|
|
-import cn.rankin.productservice.service.GroupService;
|
|
|
+import cn.rankin.data.api.product.entity.TagGroup;
|
|
|
+import cn.rankin.data.api.product.entity.Tag;
|
|
|
+import cn.rankin.productservice.service.TagGroupService;
|
|
|
import cn.rankin.productservice.service.TagService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -26,51 +26,51 @@ import java.util.List;
|
|
|
public class GroupController {
|
|
|
|
|
|
@Autowired
|
|
|
- private GroupService groupService;
|
|
|
+ private TagGroupService tagGroupService;
|
|
|
|
|
|
@Autowired
|
|
|
private TagService tagService;
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
- public APIResult<Page<Group>> search(GroupSearchDTO searchDTO) {
|
|
|
- Group group = new Group();
|
|
|
+ public APIResult<Page<TagGroup>> search(GroupSearchDTO searchDTO) {
|
|
|
+ TagGroup tagGroup = new TagGroup();
|
|
|
|
|
|
String code = searchDTO.getCode();
|
|
|
if (!StringUtils.isEmpty(code)) {
|
|
|
- group.setCode("%" + code + "%");
|
|
|
+ tagGroup.setCode("%" + code + "%");
|
|
|
}
|
|
|
|
|
|
String name = searchDTO.getName();
|
|
|
if (!StringUtils.isEmpty(name)) {
|
|
|
- group.setName("%" + name + "%");
|
|
|
+ tagGroup.setName("%" + name + "%");
|
|
|
}
|
|
|
|
|
|
// others
|
|
|
- group.setStatus(searchDTO.getStatus());
|
|
|
- group.setMerchantId(searchDTO.getMerchantId());
|
|
|
+ tagGroup.setStatus(searchDTO.getStatus());
|
|
|
+ tagGroup.setMerchantId(searchDTO.getMerchantId());
|
|
|
|
|
|
// sort
|
|
|
LinkedHashMap<String, BaseOrderEnum> sort = new LinkedHashMap<>();
|
|
|
sort.put("gmtModified", BaseOrderEnum.DESC);
|
|
|
|
|
|
- return groupService.search(group, searchDTO.getPageNo(), searchDTO.getPageSize(), sort);
|
|
|
+ return tagGroupService.search(tagGroup, searchDTO.getPageNo(), searchDTO.getPageSize(), sort);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
- public APIResult<Group> create(@Valid @RequestBody GroupDTO groupDTO) {
|
|
|
+ public APIResult<TagGroup> create(@Valid @RequestBody GroupDTO groupDTO) {
|
|
|
|
|
|
- APIResult<Group> result = groupService.create(groupDTO);
|
|
|
+ APIResult<TagGroup> result = tagGroupService.create(groupDTO);
|
|
|
if (!result.getSuccess()) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- Group group = result.getData();
|
|
|
+ TagGroup tagGroup = result.getData();
|
|
|
|
|
|
List<TagDTO> tagDTOList = groupDTO.getTagList();
|
|
|
if (!CollectionUtils.isEmpty(tagDTOList)) {
|
|
|
- APIResult<List<Tag>> tagResult = tagService.updateGroupRelation(group.getId(), tagDTOList);
|
|
|
- group.setTagList(tagResult.getData());
|
|
|
+ APIResult<List<Tag>> tagResult = tagService.updateGroupRelation(tagGroup.getId(), tagDTOList);
|
|
|
+ tagGroup.setTagList(tagResult.getData());
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -78,21 +78,21 @@ public class GroupController {
|
|
|
|
|
|
@Transactional
|
|
|
@RequestMapping(method = RequestMethod.PUT)
|
|
|
- public APIResult<Group> update(@Valid @RequestBody GroupDTO groupDTO) {
|
|
|
- APIResult<Group> result = groupService.update(groupDTO);
|
|
|
+ public APIResult<TagGroup> update(@Valid @RequestBody GroupDTO groupDTO) {
|
|
|
+ APIResult<TagGroup> result = tagGroupService.update(groupDTO);
|
|
|
if (!result.getSuccess()) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- Group group = result.getData();
|
|
|
+ TagGroup tagGroup = result.getData();
|
|
|
|
|
|
List<TagDTO> tagDTOList = groupDTO.getTagList();
|
|
|
if (tagDTOList != null) {
|
|
|
- APIResult<List<Tag>> tagResult = tagService.updateGroupRelation(group.getId(), tagDTOList);
|
|
|
+ APIResult<List<Tag>> tagResult = tagService.updateGroupRelation(tagGroup.getId(), tagDTOList);
|
|
|
if (!tagResult.getSuccess()) {
|
|
|
return APIResult.error(new BaseCode(tagResult.getCode(), tagResult.getMessage()));
|
|
|
}
|
|
|
- group.setTagList(tagResult.getData());
|
|
|
+ tagGroup.setTagList(tagResult.getData());
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -100,7 +100,7 @@ public class GroupController {
|
|
|
|
|
|
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
|
|
public APIResult<Boolean> delete(@PathVariable("id") String id) {
|
|
|
- APIResult<Boolean> groupResult = groupService.delete(id);
|
|
|
+ APIResult<Boolean> groupResult = tagGroupService.delete(id);
|
|
|
if (!groupResult.getSuccess()) {
|
|
|
return groupResult;
|
|
|
}
|
|
@@ -110,10 +110,10 @@ public class GroupController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
|
|
- public APIResult<Group> getGroup(@PathVariable("id") String id) {
|
|
|
- APIResult<Group> result = groupService.findNormalById(id);
|
|
|
- Group group = result.getData();
|
|
|
- if (!result.getSuccess() || group == null) {
|
|
|
+ public APIResult<TagGroup> getGroup(@PathVariable("id") String id) {
|
|
|
+ APIResult<TagGroup> result = tagGroupService.findNormalById(id);
|
|
|
+ TagGroup tagGroup = result.getData();
|
|
|
+ if (!result.getSuccess() || tagGroup == null) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -122,7 +122,7 @@ public class GroupController {
|
|
|
return APIResult.error(new BaseCode(tagResult.getCode(), tagResult.getMessage()));
|
|
|
}
|
|
|
|
|
|
- group.setTagList(tagResult.getData());
|
|
|
+ tagGroup.setTagList(tagResult.getData());
|
|
|
return result;
|
|
|
|
|
|
}
|