|
|
@@ -0,0 +1,91 @@
|
|
|
+package com.mokamrp.privates.controller;
|
|
|
+
|
|
|
+import com.mokamrp.privates.constant.HttpMsg;
|
|
|
+import com.mokamrp.privates.constant.HttpStatus;
|
|
|
+import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
+import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
+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.pojo.User;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import com.mokamrp.privates.service.OasBoxService;
|
|
|
+import com.mokamrp.privates.mapper.pojo.OasBox;
|
|
|
+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 javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 私域公众号/小程序库 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author leon
|
|
|
+ * @since 2021-09-29
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/oasBox")
|
|
|
+public class OasBoxController extends BaseController<OasBox> {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public OasBoxService oasBoxService;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * @fast
|
|
|
+ * 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
+ * 如果需要定制化,需要将BaseController中对应的方法复制到当前控制器,然后进行修改
|
|
|
+ */
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ ResHandle<List<OasBox>> res = oasBoxService.getList(postBasePageHandle);
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @param authUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/import")
|
|
|
+ public Object uploadFile(@RequestBody MultipartFile file, @AuthUser User authUser) {
|
|
|
+ Map<String, Object> map = new HashMap<>(16);
|
|
|
+ Map<Integer, String> feild = new HashMap<>(5);
|
|
|
+ feild.put(0, "type");
|
|
|
+ feild.put(1, "ghId");
|
|
|
+ feild.put(2, "boxName");
|
|
|
+ feild.put(3, "boxType");
|
|
|
+ feild.put(4, "fansType");
|
|
|
+ feild.put(5, "scope");
|
|
|
+ feild.put(6, "remark");
|
|
|
+ List<Map<String, String>> row;
|
|
|
+ VoltaHandle<ArrayList<Map<String, String>>> voltaRes = Analysis.analysis(file, feild);
|
|
|
+ if (voltaRes.getErr() != null) {
|
|
|
+ return AjaxResult.error(voltaRes.getErr());
|
|
|
+ }
|
|
|
+ row = voltaRes.getData();
|
|
|
+ Boolean res = oasBoxService.importData(row, authUser);
|
|
|
+ return AjaxResult.success(HttpMsg.importSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|