|
|
@@ -1,24 +1,40 @@
|
|
|
package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.mokamrp.privates.constant.Constants;
|
|
|
+import com.mokamrp.privates.constant.HttpMsg;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
-import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
+import com.mokamrp.privates.entity.*;
|
|
|
+import com.mokamrp.privates.entity.pangu.GetFosterwxCashOasBoxMobileGroupHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
-import com.mokamrp.privates.entity.ResHandle;
|
|
|
+import com.mokamrp.privates.help.Analysis;
|
|
|
+import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.Custservice;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashMobileGroup;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBoxMobileGroup;
|
|
|
+import com.mokamrp.privates.mapper.pojo.User;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxCashMobileGroupService;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxMobileGroupService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.SwaggerDefinition;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxService;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBox;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
import javax.validation.Valid;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -29,12 +45,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
* @since 2021-10-09
|
|
|
*/
|
|
|
@RestController
|
|
|
+@Api(tags = "公众号/小程序模块")
|
|
|
@RequestMapping("/pangu/fosterwxCashOasBox")
|
|
|
public class FosterwxCashOasBoxController extends BaseController<FosterwxCashOasBox> {
|
|
|
|
|
|
@Autowired
|
|
|
public FosterwxCashOasBoxService fosterwxCashOasBoxService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public FosterwxCashOasBoxMobileGroupService fosterwxCashOasBoxMobileGroupService;
|
|
|
+
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -42,7 +62,7 @@ public class FosterwxCashOasBoxController extends BaseController<FosterwxCashOas
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
- public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
|
|
|
+ public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult) {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
}
|
|
|
@@ -50,6 +70,125 @@ public class FosterwxCashOasBoxController extends BaseController<FosterwxCashOas
|
|
|
return AjaxResult.success(res);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public Object edit(@Valid @RequestBody EditHandle<FosterwxCashOasBox> editHandle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ this.onUpdate(editHandle);
|
|
|
+ if (editHandle.getRaw().getMobileGroupIds() != null || editHandle.getRaw().getMobileGroupIds().size() > 0) {
|
|
|
+ fosterwxCashOasBoxMobileGroupService.remove(new QueryWrapper<FosterwxCashOasBoxMobileGroup>().eq("oas_box_id", editHandle.getIds()));
|
|
|
+ for (Integer groupId : editHandle.getRaw().getMobileGroupIds()) {
|
|
|
+ FosterwxCashOasBoxMobileGroup add = new FosterwxCashOasBoxMobileGroup();
|
|
|
+ add.setOasBoxId(Integer.parseInt(editHandle.getIds()));
|
|
|
+ add.setCashMobileGroupId(groupId);
|
|
|
+ add.setUpdateAt(LocalDateTime.now());
|
|
|
+ add.setCreateAt(LocalDateTime.now());
|
|
|
+ fosterwxCashOasBoxMobileGroupService.save(add);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ service.update(editHandle.getRaw(), new QueryWrapper<FosterwxCashOasBox>().in("id", editHandle.getIds()));
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "批量设置分组")
|
|
|
+ @PostMapping("/setGroup")
|
|
|
+ public Object setGroup(@Valid @RequestBody SetGroupHandle setGroupHandle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ FosterwxCashOasBox save = new FosterwxCashOasBox();
|
|
|
+ save.setGroupId(setGroupHandle.getGroupId());
|
|
|
+ save.setUpdateAt(LocalDateTime.now());
|
|
|
+ service.update(save, new QueryWrapper<FosterwxCashOasBox>().in("id", setGroupHandle.getIds()));
|
|
|
+// this.sync();
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "批量设置账号分组")
|
|
|
+ @PostMapping("/setMobileGroup")
|
|
|
+ public Object setMobileGroup(@Valid @RequestBody SetIdssHandle handle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ //.遍历公众号小程序ID
|
|
|
+ for (Integer localId : handle.getLocalIds()) {
|
|
|
+ //.遍历账号分组ID
|
|
|
+ for (Integer id : handle.getIds()) {
|
|
|
+ Integer has = fosterwxCashOasBoxMobileGroupService.count(new QueryWrapper<FosterwxCashOasBoxMobileGroup>()
|
|
|
+ .eq("oas_box_id", localId)
|
|
|
+ .eq("cash_mobile_group_id", id));
|
|
|
+ if (has > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ FosterwxCashOasBoxMobileGroup add = new FosterwxCashOasBoxMobileGroup();
|
|
|
+ add.setCashMobileGroupId(id);
|
|
|
+ add.setOasBoxId(localId);
|
|
|
+ add.setCreateAt(LocalDateTime.now());
|
|
|
+ add.setUpdateAt(LocalDateTime.now());
|
|
|
+ fosterwxCashOasBoxMobileGroupService.save(add);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/info")
|
|
|
+ public Object info(@RequestParam(name = "ids") String ids) {
|
|
|
+ if (ids == null || ids.isEmpty()) {
|
|
|
+ return AjaxResult.error("ids null");
|
|
|
+ }
|
|
|
+ FosterwxCashOasBox res = service.getOne(new QueryWrapper<FosterwxCashOasBox>().eq("id", ids));
|
|
|
+ GetFosterwxCashOasBoxMobileGroupHandle handle = new GetFosterwxCashOasBoxMobileGroupHandle();
|
|
|
+ handle.setOasBoxId(res.getId());
|
|
|
+ handle.setPage(1);
|
|
|
+ handle.setPagesize(999999);
|
|
|
+ ResHandle<List<FosterwxCashOasBoxMobileGroup>> list = fosterwxCashOasBoxMobileGroupService.getList(handle);
|
|
|
+ res.setMobileGroups(list.getList());
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "批量设置小程序类型")
|
|
|
+ @PostMapping("/setBoxLocation")
|
|
|
+ public Object setBoxLocation(@Valid @RequestBody SetIdsHandle handle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ FosterwxCashOasBox save = new FosterwxCashOasBox();
|
|
|
+ save.setBoxLocation(handle.getId());
|
|
|
+ save.setUpdateAt(LocalDateTime.now());
|
|
|
+ service.update(save, new QueryWrapper<FosterwxCashOasBox>().in("id", handle.getIds()));
|
|
|
+// this.sync();
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/import")
|
|
|
+ public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
|
|
|
+ Map<String, Object> map = new HashMap<>(16);
|
|
|
+ Map<Integer, String> feild = new HashMap<>();
|
|
|
+ feild.put(0, "stationName");
|
|
|
+ feild.put(1, "groupId");
|
|
|
+ feild.put(2, "mobileGroupId");
|
|
|
+ feild.put(3, "type");
|
|
|
+ feild.put(4, "boxType|default");
|
|
|
+ feild.put(5, "boxLocation|default");
|
|
|
+ feild.put(6, "ghId");
|
|
|
+ feild.put(7, "name");
|
|
|
+ feild.put(8, "scope");
|
|
|
+ feild.put(9, "remark|default");
|
|
|
+ List<Map<String, String>> row = new ArrayList<>();
|
|
|
+ VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
|
|
|
+ if (voltaRes.getErr() != null) {
|
|
|
+ return AjaxResult.error(voltaRes.getErr());
|
|
|
+ }
|
|
|
+ row = voltaRes.getData();
|
|
|
+ try {
|
|
|
+ VoltaHandle<Boolean> res = fosterwxCashOasBoxService.importData(row, authUser);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+ return AjaxResult.success(HttpMsg.importSuccess);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|