|
|
@@ -6,13 +6,14 @@ import com.mokamrp.privates.constant.Constants;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.constant.RedisKey;
|
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
|
-import com.mokamrp.privates.entity.AddHandle;
|
|
|
-import com.mokamrp.privates.entity.DelHandle;
|
|
|
-import com.mokamrp.privates.entity.EditHandle;
|
|
|
-import com.mokamrp.privates.entity.SetGroupHandle;
|
|
|
+import com.mokamrp.privates.entity.*;
|
|
|
import com.mokamrp.privates.entity.pangu.CustserviceListHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.CustserviceVo;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.PromoteCode;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.PromoteQrcodePool;
|
|
|
+import com.mokamrp.privates.service.pangu.PromoteCodeService;
|
|
|
+import com.mokamrp.privates.service.pangu.PromoteQrcodePoolService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
@@ -23,9 +24,8 @@ import com.mokamrp.privates.mapper.pangu.pojo.Custservice;
|
|
|
import javax.validation.Valid;
|
|
|
import java.awt.*;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -45,6 +45,12 @@ public class CustserviceController extends BaseController<Custservice> {
|
|
|
@Autowired
|
|
|
public StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public PromoteCodeService promoteCodeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public PromoteQrcodePoolService promoteQrcodePoolService;
|
|
|
+
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -102,6 +108,31 @@ public class CustserviceController extends BaseController<Custservice> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/adds")
|
|
|
+ public Object adds(@Valid @RequestBody AddsHandle<Custservice> addsHandle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ Map<String, List<Integer>> result = new HashMap<>();
|
|
|
+ List<Integer> successList = new ArrayList<>();
|
|
|
+ List<Integer> errorList = new ArrayList<>();
|
|
|
+ for (Custservice raw : addsHandle.getRaws()) {
|
|
|
+ this.onInsert(raw);
|
|
|
+ Boolean res = service.save(raw);
|
|
|
+ if (res) {
|
|
|
+ successList.add(1);
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ errorList.add(1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.sync();
|
|
|
+ result.put("successList", successList);
|
|
|
+ result.put("errorList", errorList);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/edit")
|
|
|
public Object edit(@Valid @RequestBody EditHandle<Custservice> editHandle, BindingResult bindingResult) {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
@@ -126,6 +157,17 @@ public class CustserviceController extends BaseController<Custservice> {
|
|
|
return AjaxResult.success(Constants.SUCCESS,true);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //.批量上下架
|
|
|
+ @PostMapping("/setGrounding")
|
|
|
+ public Object setGrounding(@Valid @RequestBody SetGroundingHandle setGroundingHandle, BindingResult bindingResult){
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ Boolean res = custserviceService.setGrounding(setGroundingHandle);
|
|
|
+ return AjaxResult.success(Constants.SUCCESS,true);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 同步到redis
|
|
|
* @return
|