|
@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
|
23
|
23
|
|
24
|
24
|
import javax.servlet.http.HttpSession;
|
25
|
25
|
import java.time.LocalDateTime;
|
|
26
|
+import java.util.List;
|
26
|
27
|
|
27
|
28
|
/**
|
28
|
29
|
* <p>
|
|
@@ -69,6 +70,15 @@ public class TpShopTypeController extends BaseController {
|
69
|
70
|
shopType.setSource("self");
|
70
|
71
|
shopType.setCreateUser(userElement.getId());
|
71
|
72
|
shopType.setCreateDate(LocalDateTime.now());
|
|
73
|
+ //查看索引是否存在
|
|
74
|
+ QueryWrapper<TpShopType> shopTypeQueryWrapper = new QueryWrapper<>();
|
|
75
|
+ shopTypeQueryWrapper.eq("community_id",shopType.getCommunityId());
|
|
76
|
+ shopTypeQueryWrapper.eq("sort",shopType.getSort());
|
|
77
|
+ List<TpShopType> list = shopTypeService.list(shopTypeQueryWrapper);
|
|
78
|
+ if (list.size() > 0){
|
|
79
|
+ responseBean.addError("此索引已存在");
|
|
80
|
+ return responseBean;
|
|
81
|
+ }
|
72
|
82
|
boolean state = shopTypeService.save(shopType);
|
73
|
83
|
if (state){
|
74
|
84
|
responseBean.addSuccess("添加成功");
|
|
@@ -101,6 +111,17 @@ public class TpShopTypeController extends BaseController {
|
101
|
111
|
public ResponseBean updateShopType(@RequestBody TpShopType shopType, HttpSession session){
|
102
|
112
|
ResponseBean responseBean = new ResponseBean();
|
103
|
113
|
UserElement userElement = getUserElement(session);
|
|
114
|
+ //查看索引是否存在
|
|
115
|
+ QueryWrapper<TpShopType> shopTypeQueryWrapper = new QueryWrapper<>();
|
|
116
|
+ shopTypeQueryWrapper.eq("community_id",userElement.getCommunityId());
|
|
117
|
+ shopTypeQueryWrapper.eq("sort",shopType.getSort());
|
|
118
|
+ shopTypeQueryWrapper.ne("id",shopType.getId());
|
|
119
|
+ List<TpShopType> list = shopTypeService.list(shopTypeQueryWrapper);
|
|
120
|
+ if (list.size() > 0){
|
|
121
|
+ responseBean.addError("此索引已存在");
|
|
122
|
+ return responseBean;
|
|
123
|
+ }
|
|
124
|
+
|
104
|
125
|
boolean state = shopTypeService.updateById(shopType);
|
105
|
126
|
if (state){
|
106
|
127
|
responseBean.addSuccess("更新成功");
|