From 03941ed4fa0fcf582e4aa8d118366231bee1870a Mon Sep 17 00:00:00 2001
From: futian.liu <liufutianyoo@163.com>
Date: 星期二, 12 十二月 2023 11:13:33 +0800
Subject: [PATCH] api文档

---
 consum-base/src/main/java/com/consum/base/controller/FinSysTenantController.java |  195 +++++++++++++++++++++++++-----------------------
 1 files changed, 103 insertions(+), 92 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/controller/FinSysTenantController.java b/consum-base/src/main/java/com/consum/base/controller/FinSysTenantController.java
index 398a0b7..ea9e566 100644
--- a/consum-base/src/main/java/com/consum/base/controller/FinSysTenantController.java
+++ b/consum-base/src/main/java/com/consum/base/controller/FinSysTenantController.java
@@ -1,25 +1,5 @@
 package com.consum.base.controller;
 
-import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.context.AnalysisContext;
-import com.alibaba.excel.event.AnalysisEventListener;
-import com.alibaba.excel.exception.ExcelDataConvertException;
-import com.consum.base.BaseController;
-import com.consum.base.core.utils.FinSysTenantUtils;
-import com.consum.base.pojo.FinSysTenantParam;
-import com.consum.base.pojo.FinSysTenantSearchParam;
-import com.consum.base.service.FinSysTenantServiceImpl;
-import com.consum.base.service.FinSysTenantUserServiceImpl;
-import com.consum.model.po.FinSysTenant;
-import com.consum.model.po.FinSysTenantUser;
-import com.consum.model.vo.FinSysTenantUserResult;
-import com.walker.db.page.GenericPager;
-import com.walker.infrastructure.tree.TreeNode;
-import com.walker.infrastructure.utils.StringUtils;
-import com.walker.web.ResponseValue;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URLEncoder;
@@ -30,6 +10,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
@@ -41,28 +22,52 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.alibaba.excel.exception.ExcelDataConvertException;
+import com.consum.base.BaseController;
+import com.consum.base.core.utils.CommonUtil;
+import com.consum.base.core.utils.FinSysTenantUtils;
+import com.consum.base.pojo.FinSysTenantParam;
+import com.consum.base.pojo.FinSysTenantSearchParam;
+import com.consum.base.service.FinSysTenantService;
+import com.consum.base.service.FinSysTenantUserServiceImpl;
+import com.consum.model.po.FinSysTenant;
+import com.consum.model.po.FinSysTenantUser;
+import com.consum.model.vo.FinSysTenantUserResult;
+import com.walker.db.page.GenericPager;
+import com.walker.infrastructure.tree.TreeNode;
+import com.walker.infrastructure.utils.StringUtils;
+import com.walker.web.ResponseValue;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
 /**
- * @Description 鍖哄垝
+ * @Description 鏈烘瀯
  * @Author wh
  * @Date 2023/7/13 19:51
  */
+@Api(value = "鏈烘瀯绠$悊", tags = "鏈烘瀯绠$悊")
 @RestController
 @RequestMapping("/pc/fin/sys/tenant")
 public class FinSysTenantController extends BaseController {
 
-    private FinSysTenantServiceImpl finSysTenantService;
+    private FinSysTenantService finSysTenantService;
 
     @Autowired
     private FinSysTenantUserServiceImpl finSysTenantUserService;
 
     @Autowired
-    public FinSysTenantController(FinSysTenantServiceImpl finSysTenantService) {
+    public FinSysTenantController(FinSysTenantService finSysTenantService) {
         this.finSysTenantService = finSysTenantService;
     }
 
@@ -133,7 +138,12 @@
      * @Date 2023/7/14 13:59
      */
     @RequestMapping("/select/list")
-    public ResponseValue allocatedList(FinSysTenantSearchParam param) {
+    public ResponseValue allocatedList() {
+        FinSysTenantSearchParam param = CommonUtil.getObjFromReq(FinSysTenantSearchParam.class);
+        FinSysTenantSearchParam param2 = new FinSysTenantSearchParam();
+        CommonUtil.copyProperties(param, param2);
+        param = param2;
+
         FinSysTenantUser sysInfo = getSysInfo();
         if (sysInfo == null) {
             return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
@@ -226,7 +236,7 @@
 
             while (var3.hasNext()) {
                 Object obj = var3.next();
-                node = this.toTreeNode((FinSysTenant) obj);
+                node = this.toTreeNode((FinSysTenant)obj);
 
                 if (node.getId() == this.defaultParentId) {
                     this.rootMap.put(node.getId(), node);
@@ -246,7 +256,7 @@
                     var3 = this.rootMap.values().iterator();
 
                     while (var3.hasNext()) {
-                        TreeNode n = (TreeNode) var3.next();
+                        TreeNode n = (TreeNode)var3.next();
                         n.setParentId(this.defaultParentId);
                         this.dummyRoot.addChild(n);
                     }
@@ -261,16 +271,16 @@
         Iterator i = childMap.values().iterator();
 
         while (i.hasNext()) {
-            _node = (TreeNode) i.next();
+            _node = (TreeNode)i.next();
             this.mountMiddleNode(_node, childMap);
         }
 
     }
 
     private void mountMiddleNode(TreeNode currentNode, Map<Long, TreeNode> childMap) {
-        TreeNode _parentNode = (TreeNode) this.rootMap.get(currentNode.getParentId());
+        TreeNode _parentNode = (TreeNode)this.rootMap.get(currentNode.getParentId());
         if (_parentNode == null) {
-            _parentNode = (TreeNode) childMap.get(currentNode.getId());
+            _parentNode = (TreeNode)childMap.get(currentNode.getId());
             if (_parentNode == null) {
                 throw new NullPointerException("parent node not found, current: " + currentNode);
             }
@@ -285,7 +295,7 @@
 
     protected TreeNode toTreeNode(FinSysTenant entity) {
         TreeNode treeNode =
-            new TreeNode(entity.getId(), entity.getName(), (List) null, entity.getParentId(), entity.getCode());
+            new TreeNode(entity.getId(), entity.getName(), (List)null, entity.getParentId(), entity.getCode());
         return treeNode;
     }
 
@@ -297,7 +307,7 @@
             Iterator var2 = this.rootMap.values().iterator();
 
             while (var2.hasNext()) {
-                TreeNode node = (TreeNode) var2.next();
+                TreeNode node = (TreeNode)var2.next();
                 list.add(node);
             }
             return list;
@@ -308,13 +318,19 @@
      * @Description 涓嶅垎椤垫煡璇�
      */
     @RequestMapping("/select/allList")
-    public ResponseValue allList(FinSysTenantSearchParam param) {
+    public ResponseValue allList() {
+        FinSysTenantSearchParam param = CommonUtil.getObjFromReq(FinSysTenantSearchParam.class);
+        FinSysTenantSearchParam param2 = new FinSysTenantSearchParam();
+        CommonUtil.copyProperties(param, param2);
+        param = param2;
+
         StringBuilder whStr = new StringBuilder("where 1=1 and status = 1 and is_delete = 0 ");
         HashMap parameter = new HashMap<>();
         if (param.getFirstZmS() != null && !param.getFirstZmS().equals("")) {
             whStr.append(" and name is not null and(");
             String upperCase = param.getFirstZmS().toUpperCase();
-            whStr.append("instr(:upperFirstZmS,F_PINYIN( SUBSTR(name, 1, 1)))>0 or instr(:upperFirstZmS2,SUBSTR(name, 1, 1))>0");
+            whStr.append(
+                "instr(:upperFirstZmS,F_PINYIN( SUBSTR(name, 1, 1)))>0 or instr(:upperFirstZmS2,SUBSTR(name, 1, 1))>0");
             parameter.put("upperFirstZmS", upperCase);
             parameter.put("upperFirstZmS2", upperCase);
             whStr.append(")");
@@ -324,7 +340,6 @@
         return ResponseValue.success(select);
     }
 
-
     /**
      * 鍒犻櫎
      *
@@ -332,7 +347,12 @@
      * @date 2023/10/4
      */
     @PostMapping("/del")
-    public ResponseValue del(@RequestBody FinSysTenantParam param) {
+    public ResponseValue del() {
+        FinSysTenantParam param = CommonUtil.getObjFromReqBody(FinSysTenantParam.class);
+        FinSysTenantParam finSysTenantParam = new FinSysTenantParam();
+        CommonUtil.copyProperties(param, finSysTenantParam);
+        param = finSysTenantParam;
+
         if (param.getId() == null) {
             return ResponseValue.error("鏈烘瀯id涓虹┖");
         }
@@ -347,7 +367,12 @@
      * @date 2023/10/4
      */
     @PostMapping("/add")
-    public ResponseValue add(@RequestBody FinSysTenantParam param) {
+    public ResponseValue add() {
+        FinSysTenantParam param = CommonUtil.getObjFromReqBody(FinSysTenantParam.class);
+        FinSysTenantParam finSysTenantParam = new FinSysTenantParam();
+        CommonUtil.copyProperties(param, finSysTenantParam);
+        param = finSysTenantParam;
+
         if (param == null) {
             return ResponseValue.error("鍙傛暟涓虹┖");
         }
@@ -357,7 +382,7 @@
         if (StringUtils.isEmpty(param.getName())) {
             return ResponseValue.error("鏈烘瀯鍚嶇О涓虹┖");
         }
-        FinSysTenant finSysTenant = this.finSysTenantService.selectByTenantId(param.getCode());
+        FinSysTenant finSysTenant = this.finSysTenantService.queryOneByCode(param.getCode());
         if (finSysTenant != null) {
             return ResponseValue.error("鏈烘瀯缂栧彿宸插瓨鍦�");
         }
@@ -374,50 +399,27 @@
     }
 
     @GetMapping("getImportTemplate")
-    public ResponseEntity<InputStreamResource> getImportTemplate() throws IOException {
+    public ResponseEntity<InputStreamResource> getImportTemplate(String type) throws IOException {
         // 浠庡綋鍓嶉」鐩祫婧愮洰褰曡幏鍙栨枃浠�
-        Resource resource = new ClassPathResource("import/鏈烘瀯瀵煎叆妯℃澘.xls");
+        String fileName = null;
+        if ("tenant".equals(type)) {
+            fileName = "鏈烘瀯瀵煎叆妯℃澘.xls";
+        } else if ("goods".equals(type)) {
+            fileName = "鐗╁搧淇℃伅.xls";
+        }
+        Resource resource = new ClassPathResource("import/" + fileName);
         // 鑾峰彇鏂囦欢杈撳叆娴�
         InputStream inputStream = resource.getInputStream();
         // 璁剧疆HTTP鍝嶅簲澶�
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
-        String encodedFilename = URLEncoder.encode("鏈烘瀯瀵煎叆妯℃澘.xls", "UTF-8");
+        String encodedFilename = URLEncoder.encode(fileName, "UTF-8");
         headers.setContentDispositionFormData("attachment", encodedFilename);
         // 鍒涘缓InputStreamResource瀵硅薄锛屽皢鏂囦欢杈撳叆娴佸寘瑁呰捣鏉�
         InputStreamResource resourceToDownload = new InputStreamResource(inputStream);
         // 杩斿洖甯︽湁鏂囦欢杈撳叆娴佺殑ResponseEntity瀵硅薄
-        return ResponseEntity
-            .status(HttpStatus.OK)
-            .headers(headers)
-            .body(resourceToDownload);
+        return ResponseEntity.status(HttpStatus.OK).headers(headers).body(resourceToDownload);
     }
-
-
-    /**
-     * @return 鑾峰彇椤圭洰瀵煎叆鐨勬ā鏉�
-     * @throws IOException
-     */
-    @GetMapping("getProjectImportTemplate")
-    public ResponseEntity<InputStreamResource> getProjectImportTemplate() throws IOException {
-        // 浠庡綋鍓嶉」鐩祫婧愮洰褰曡幏鍙栨枃浠�
-        Resource resource = new ClassPathResource("import/椤圭洰瀵煎叆妯℃澘.xls");
-        // 鑾峰彇鏂囦欢杈撳叆娴�
-        InputStream inputStream = resource.getInputStream();
-        // 璁剧疆HTTP鍝嶅簲澶�
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
-        String encodedFilename = URLEncoder.encode("椤圭洰瀵煎叆妯℃澘.xls", "UTF-8");
-        headers.setContentDispositionFormData("attachment", encodedFilename);
-        // 鍒涘缓InputStreamResource瀵硅薄锛屽皢鏂囦欢杈撳叆娴佸寘瑁呰捣鏉�
-        InputStreamResource resourceToDownload = new InputStreamResource(inputStream);
-        // 杩斿洖甯︽湁鏂囦欢杈撳叆娴佺殑ResponseEntity瀵硅薄
-        return ResponseEntity
-            .status(HttpStatus.OK)
-            .headers(headers)
-            .body(resourceToDownload);
-    }
-
 
     @PostMapping("import")
     public ResponseValue upload(@RequestParam Long pid, MultipartFile file) throws IOException {
@@ -445,8 +447,9 @@
                         "绗�" + analysisContext.readSheetHolder().getRowIndex() + "琛�,鏈烘瀯缂栧彿涓嶈兘涓虹┖鎴栭暱搴﹀ぇ浜�20");
                     throw exception;
                 }
-                if (null != finSysTenantService.selectByTenantId(finSysTenantParam.getCode())) {
-                    throw new IllegalStateException("绗�" + analysisContext.readSheetHolder().getRowIndex() + "琛�,鏈烘瀯缂栧彿宸插瓨鍦�");
+                if (null != finSysTenantService.queryOneByCode(finSysTenantParam.getCode())) {
+                    throw new IllegalStateException(
+                        "绗�" + analysisContext.readSheetHolder().getRowIndex() + "琛�,鏈烘瀯缂栧彿宸插瓨鍦�");
                 }
                 if (StringUtils.isEmpty(finSysTenantParam.getName()) || finSysTenantParam.getName().length() > 100) {
                     IllegalStateException exception = new IllegalStateException(
@@ -468,15 +471,16 @@
             public void onException(Exception exception, AnalysisContext context) {
                 // 濡傛灉鏄煇涓�涓崟鍏冩牸鐨勮浆鎹㈠紓甯� 鑳借幏鍙栧埌鍏蜂綋琛屽彿
                 if (exception instanceof ExcelDataConvertException) {
-                    ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
+                    ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception;
                     logger.error("绗瑊}琛岋紝绗瑊}鍒楄В鏋愬紓甯革紝鏁版嵁涓�:{}", excelDataConvertException.getRowIndex(),
-                        excelDataConvertException.getColumnIndex() + 1, excelDataConvertException.getCellData().getStringValue());
-                    throw new IllegalStateException(
-                        "绗�" + (excelDataConvertException.getRowIndex() + 1) + "琛岋紝绗�" + (excelDataConvertException.getColumnIndex() + 1) + "鍒楄В鏋愬紓甯�,寮傚父鏁版嵁涓�:[ "
-                            + excelDataConvertException.getCellData().getStringValue() + " ]");
+                        excelDataConvertException.getColumnIndex() + 1,
+                        excelDataConvertException.getCellData().getStringValue());
+                    throw new IllegalStateException("绗�" + (excelDataConvertException.getRowIndex() + 1) + "琛岋紝绗�"
+                        + (excelDataConvertException.getColumnIndex() + 1) + "鍒楄В鏋愬紓甯�,寮傚父鏁版嵁涓�:[ "
+                        + excelDataConvertException.getCellData().getStringValue() + " ]");
                 }
                 if (exception instanceof IllegalStateException) {
-                    throw (IllegalStateException) exception;
+                    throw (IllegalStateException)exception;
                 }
 
             }
@@ -493,8 +497,13 @@
      * @date 2023/10/6
      */
     @PostMapping("/edit")
-    public ResponseValue edit(@RequestBody FinSysTenant finSysTenant) {
-        Long id = finSysTenant.getId();
+    public ResponseValue edit() {
+        FinSysTenant param = CommonUtil.getObjFromReqBody(FinSysTenant.class);
+        FinSysTenant finSysTenant = new FinSysTenant();
+        CommonUtil.copyProperties(param, finSysTenant);
+        param = finSysTenant;
+
+        Long id = param.getId();
         if (id == null || id.longValue() <= 0) {
             return ResponseValue.error("缂栬緫鐨勬満鏋勪笉瀛樺湪");
         }
@@ -502,11 +511,11 @@
         if (sysInfo == null) {
             return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
         }
-        //        FinSysTenant finSysTenant1 = this.finSysTenantService.selectByTenantId(sysInfo.getTenantCode());
-//        if (finSysTenant1.getLv() != 1) {
-//            return ResponseValue.error("鏆傛棤淇敼鏉冮檺");
-//        }
-        int num = this.finSysTenantService.updateFinSysTenant(finSysTenant, this.getSysInfo());
+        // FinSysTenant finSysTenant1 = this.finSysTenantService.selectByTenantId(sysInfo.getTenantCode());
+        // if (finSysTenant1.getLv() != 1) {
+        // return ResponseValue.error("鏆傛棤淇敼鏉冮檺");
+        // }
+        int num = this.finSysTenantService.updateFinSysTenant(param, this.getSysInfo());
         return num > 0 ? ResponseValue.success(1) : ResponseValue.error("缂栬緫澶辫触锛�");
     }
 
@@ -546,7 +555,8 @@
             }
             // 鐪�
             FinSysTenant finSysTenant1 = this.finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId()));
-            List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(finSysTenant1.getId());
+            List<FinSysTenantUser> finSysTenantUserList =
+                this.finSysTenantUserService.getByOrgId(finSysTenant1.getId());
             if (!StringUtils.isEmptyList(finSysTenantUserList)) {
                 FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
                 finSysTenantUserResult.setOrgId(finSysTenant1.getId());
@@ -567,7 +577,8 @@
             }
             // 甯�
             FinSysTenant finSysTenant2 = this.finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId()));
-            List<FinSysTenantUser> finSysTenantUserList2 = this.finSysTenantUserService.getByOrgId(finSysTenant2.getId());
+            List<FinSysTenantUser> finSysTenantUserList2 =
+                this.finSysTenantUserService.getByOrgId(finSysTenant2.getId());
             if (!StringUtils.isEmptyList(finSysTenantUserList2)) {
                 FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
                 finSysTenantUserResult.setOrgId(finSysTenant2.getId());
@@ -577,7 +588,8 @@
             }
             // 鐪�
             FinSysTenant finSysTenant1 = this.finSysTenantService.get(new FinSysTenant(finSysTenant2.getParentId()));
-            List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(finSysTenant1.getId());
+            List<FinSysTenantUser> finSysTenantUserList =
+                this.finSysTenantUserService.getByOrgId(finSysTenant1.getId());
             if (!StringUtils.isEmptyList(finSysTenantUserList)) {
                 FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
                 finSysTenantUserResult.setOrgId(finSysTenant1.getId());
@@ -591,8 +603,7 @@
 
     @ApiOperation(value = "鑾峰彇鐖剁骇鏈烘瀯", notes = "鑾峰彇鐖剁骇鏈烘瀯")
     @ApiImplicitParams({
-        @ApiImplicitParam(name = "Authorization", value = "token", dataType = "String", paramType = "header"),
-    })
+        @ApiImplicitParam(name = "Authorization", value = "token", dataType = "String", paramType = "header"),})
     @GetMapping("/get/parent/tenant")
     public ResponseValue getParentTenant() {
         FinSysTenantUser sysInfo = getSysInfo();
@@ -604,7 +615,7 @@
         finSysTenant.setTempId(Long.valueOf(tenantId));
         FinSysTenant userTenant = this.finSysTenantService.get(finSysTenant);
         Long parentId = userTenant.getParentId();
-        //绗竴绾�
+        // 绗竴绾�
         if (parentId == 0) {
             return ResponseValue.success(userTenant);
         } else {

--
Gitblit v1.9.1