|
@@ -0,0 +1,95 @@
|
|
|
+package cn.rankin.cmsweb.controller.user;
|
|
|
+
|
|
|
+import cn.rankin.cmsweb.assist.resolver.NeedUser;
|
|
|
+import cn.rankin.cmsweb.entity.UserDetails;
|
|
|
+import cn.rankin.cmsweb.service.user.MerchantInfoSetService;
|
|
|
+import cn.rankin.cmsweb.service.user.UserTagServiceInterface;
|
|
|
+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.util.BeanUtil;
|
|
|
+import cn.rankin.data.api.product.vo.TagVo;
|
|
|
+import cn.rankin.data.api.user.dto.UserTagDTO;
|
|
|
+import cn.rankin.data.api.user.dto.UserTagSearchDTO;
|
|
|
+import cn.rankin.data.api.user.entity.UserTag;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/userTag")
|
|
|
+public class UserTagController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserTagServiceInterface userTagService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MerchantInfoSetService<TagVo> merchantInfoSetService;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
+ public APIResult<Page<UserTag>> search(@NeedUser UserDetails user, UserTagSearchDTO searchDTO) {
|
|
|
+ if (!user.isPlatForm()) {
|
|
|
+ searchDTO.setUid(user.getId());
|
|
|
+ }
|
|
|
+ Page<UserTag> userTagPage = userTagService.search(BeanUtil.convertToMap(searchDTO));
|
|
|
+ if (userTagPage != null) {
|
|
|
+ //merchantInfoSetService.setMerchantInfo(apiResult.getData().getList());
|
|
|
+ return APIResult.ok(userTagPage);
|
|
|
+ }else{
|
|
|
+ return APIResult.error(APICode.NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
|
|
+ public APIResult<UserTag> getUserTag(@PathVariable("id") String id) {
|
|
|
+ UserTag userTag = userTagService.getUserTag(id);
|
|
|
+ if (userTag != null) {
|
|
|
+// merchantInfoSetService.setMerchantInfo(apiResult.getData());
|
|
|
+ return APIResult.ok(userTag);
|
|
|
+ }else{
|
|
|
+ return APIResult.error(APICode.NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(method = RequestMethod.POST)
|
|
|
+ public APIResult<UserTag> create(@RequestBody UserTagDTO dto) {
|
|
|
+ UserTag userTag = userTagService.create(dto);
|
|
|
+ if (userTag != null) {
|
|
|
+// merchantInfoSetService.setMerchantInfo(apiResult.getData());
|
|
|
+ return APIResult.ok(userTag);
|
|
|
+ }else{
|
|
|
+ return APIResult.error(APICode.NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(method = RequestMethod.PUT)
|
|
|
+ public APIResult<UserTag> update(@RequestBody UserTagDTO dto) {
|
|
|
+ if(StringUtils.isBlank(dto.getId())){
|
|
|
+ return APIResult.error(APICode.PARAMETER_ERROR);
|
|
|
+ }
|
|
|
+ UserTag userTag = userTagService.update(dto);
|
|
|
+ if (userTag != null) {
|
|
|
+ log.error("update UserTag is error, pid={}", dto.getId());
|
|
|
+// merchantInfoSetService.setMerchantInfo(apiResult.getData());
|
|
|
+ return APIResult.ok(userTag);
|
|
|
+ }else{
|
|
|
+ return APIResult.error(APICode.NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
|
|
+ public APIResult delete(@PathVariable("id") String id) {
|
|
|
+ if(StringUtils.isBlank(id)){
|
|
|
+ return APIResult.error(APICode.PARAMETER_ERROR);
|
|
|
+ }
|
|
|
+ boolean flag = userTagService.delete(id);
|
|
|
+ if(flag){
|
|
|
+ return APIResult.ok();
|
|
|
+ }else{
|
|
|
+ log.error("delete UserTag is error, pid={}", id);
|
|
|
+ return APIResult.error(APICode.OPERATE_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|