objectMap = new HashMap<>();
+ int res = roleService.batchSetStatus(status, ids);
+ if(res > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+}
diff --git a/api/src/main/java/com/wansensoft/api/role/SysRoleController.java b/api/src/main/java/com/wansensoft/api/role/SysRoleController.java
index c6aa4129..8a1f02d1 100644
--- a/api/src/main/java/com/wansensoft/api/role/SysRoleController.java
+++ b/api/src/main/java/com/wansensoft/api/role/SysRoleController.java
@@ -1,29 +1,9 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.role;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.wansensoft.dto.role.AddOrUpdateRoleDTO;
-import com.wansensoft.dto.role.RoleListDTO;
-import com.wansensoft.service.role.ISysRoleService;
-import com.wansensoft.service.role.KtSysRoleService;
-import com.wansensoft.service.system.ISysMenuService;
-import com.wansensoft.utils.response.Response;
-import com.wansensoft.vo.RoleVO;
-import org.springframework.web.bind.annotation.*;
-import java.util.List;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
/**
*
@@ -34,45 +14,7 @@
* @since 2023-09-05
*/
@RestController
-@RequestMapping("sysRole")
+@RequestMapping("/sysRole")
public class SysRoleController {
- private final ISysMenuService menuService;
-
- private final KtSysRoleService ktSysRoleService;
-
- public SysRoleController(ISysMenuService menuService, KtSysRoleService ktSysRoleService) {
- this.menuService = menuService;
- this.ktSysRoleService = ktSysRoleService;
- }
-
- @GetMapping("menu")
- public Response queryMenu() {
- return menuService.menuList();
- }
-
- @GetMapping("list")
- public Response> getRoleList() {
- return ktSysRoleService.roleList();
- }
-
- @PostMapping("PageList")
- public Response> getRolePageList(@RequestBody RoleListDTO roleListDTO) {
- return ktSysRoleService.rolePageList(roleListDTO);
- }
-
- @PostMapping("updateStatus")
- public Response updateStatus(@RequestParam(value = "id") String id, @RequestParam(value = "status") Integer status) {
- return ktSysRoleService.updateStatus(id, status);
- }
-
- @PostMapping("addOrUpdateRole")
- public Response addOrUpdateRole(@RequestBody AddOrUpdateRoleDTO addOrUpdateRoleDTO) {
- return ktSysRoleService.addOrUpdateRole(addOrUpdateRoleDTO);
- }
-
- @PostMapping("deleteRole")
- public Response deleteRole(@RequestParam(value = "id") String id) {
- return ktSysRoleService.deleteRole(id);
- }
}
diff --git a/api/src/main/java/com/wansensoft/api/role/SysRoleMenuRelController.java b/api/src/main/java/com/wansensoft/api/role/SysRoleMenuRelController.java
index 61926fe3..8d72c1ed 100644
--- a/api/src/main/java/com/wansensoft/api/role/SysRoleMenuRelController.java
+++ b/api/src/main/java/com/wansensoft/api/role/SysRoleMenuRelController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.role;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/sequence/SequenceController.java b/api/src/main/java/com/wansensoft/api/sequence/SequenceController.java
new file mode 100644
index 00000000..c4f828c1
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/sequence/SequenceController.java
@@ -0,0 +1,51 @@
+package com.wansensoft.api.sequence;
+
+import com.wansensoft.service.sequence.SequenceService;
+import com.wansensoft.utils.BaseResponseInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/sequence")
+@Api(tags = {"单据编号"})
+public class SequenceController {
+ private Logger logger = LoggerFactory.getLogger(SequenceController.class);
+
+ private final SequenceService sequenceService;
+
+ public SequenceController(SequenceService sequenceService) {
+ this.sequenceService = sequenceService;
+ }
+
+ /**
+ * 单据编号生成接口
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/buildNumber")
+ @ApiOperation(value = "单据编号生成接口")
+ public BaseResponseInfo buildNumber(HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ Map map = new HashMap();
+ try {
+ String number = sequenceService.buildOnlyNumber();
+ map.put("defaultNumber", number);
+ res.code = 200;
+ res.data = map;
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+}
diff --git a/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java b/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java
new file mode 100644
index 00000000..cc975cdc
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java
@@ -0,0 +1,110 @@
+package com.wansensoft.api.serialNumber;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wansensoft.entities.depot.DepotItem;
+import com.wansensoft.entities.serialNumber.SerialNumberEx;
+import com.wansensoft.service.depotHead.DepotHeadService;
+import com.wansensoft.service.depotItem.DepotItemService;
+import com.wansensoft.service.serialNumber.SerialNumberService;
+import com.wansensoft.utils.BaseResponseInfo;
+import com.wansensoft.utils.ErpInfo;
+import com.wansensoft.utils.Response;
+import com.wansensoft.utils.Tools;
+import com.wansensoft.utils.ResponseJsonUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/serialNumber")
+@Api(tags = {"序列号管理"})
+@Slf4j
+public class SerialNumberController {
+ private final SerialNumberService serialNumberService;
+ private final DepotHeadService depotHeadService;
+ private final DepotItemService depotItemService;
+
+ public SerialNumberController(SerialNumberService serialNumberService, DepotHeadService depotHeadService, DepotItemService depotItemService) {
+ this.serialNumberService = serialNumberService;
+ this.depotHeadService = depotHeadService;
+ this.depotItemService = depotItemService;
+ }
+
+ /**
+ * description:
+ *批量添加序列号
+ * @Param: materialName
+ * @Param: serialNumberPrefix
+ * @Param: batAddTotal
+ * @Param: remark
+ * @return java.lang.Object
+ */
+ @PostMapping("/batAddSerialNumber")
+ @ApiOperation(value = "批量添加序列号")
+ public String batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception{
+ Map objectMap = new HashMap<>();
+ String materialCode = jsonObject.getString("materialCode");
+ String serialNumberPrefix = jsonObject.getString("serialNumberPrefix");
+ Integer batAddTotal = jsonObject.getInteger("batAddTotal");
+ String remark = jsonObject.getString("remark");
+ int insert = serialNumberService.batAddSerialNumber(materialCode,serialNumberPrefix,batAddTotal,remark);
+ if(insert > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else if(insert == -1) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+
+ /**
+ * 获取序列号商品
+ * @param name
+ * @param depotId
+ * @param barCode
+ * @param currentPage
+ * @param pageSize
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/getEnableSerialNumberList")
+ @ApiOperation(value = "获取序列号商品")
+ public BaseResponseInfo getEnableSerialNumberList(@RequestParam("name") String name,
+ @RequestParam("depotItemId") Long depotItemId,
+ @RequestParam("depotId") Long depotId,
+ @RequestParam("barCode") String barCode,
+ @RequestParam("page") Integer currentPage,
+ @RequestParam("rows") Integer pageSize,
+ HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ Map map = new HashMap<>();
+ try {
+ String number = "";
+ if(depotItemId != null) {
+ DepotItem depotItem = depotItemService.getDepotItem(depotItemId);
+ number = depotHeadService.getDepotHead(depotItem.getHeaderId()).getNumber();
+ }
+ List list = serialNumberService.getEnableSerialNumberList(number, name, depotId, barCode, (currentPage-1)*pageSize, pageSize);
+ for(SerialNumberEx serialNumberEx: list) {
+ serialNumberEx.setCreateTimeStr(Tools.getCenternTime(serialNumberEx.getCreateTime()));
+ }
+ Long total = serialNumberService.getEnableSerialNumberCount(number, name, depotId, barCode);
+ map.put("rows", list);
+ map.put("total", total);
+ res.code = 200;
+ res.data = map;
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "获取数据失败";
+ log.error(e.getMessage());
+ }
+ return res;
+ }
+}
diff --git a/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java b/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java
new file mode 100644
index 00000000..340dc6c8
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java
@@ -0,0 +1,385 @@
+package com.wansensoft.api.supplier;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.wansensoft.entities.supplier.Supplier;
+import com.wansensoft.service.supplier.SupplierService;
+import com.wansensoft.service.systemConfig.SystemConfigService;
+import com.wansensoft.service.user.UserService;
+import com.wansensoft.service.userBusiness.UserBusinessService;
+import com.wansensoft.utils.BaseResponseInfo;
+import com.wansensoft.utils.ErpInfo;
+import com.wansensoft.utils.ExcelUtils;
+import com.wansensoft.utils.ResponseJsonUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/supplier")
+@Api(tags = {"商家管理"})
+public class SupplierController {
+
+ private final SupplierService supplierService;
+
+ private final UserBusinessService userBusinessService;
+
+ private final SystemConfigService systemConfigService;
+
+ private final UserService userService;
+
+ public SupplierController(SupplierService supplierService, UserBusinessService userBusinessService, SystemConfigService systemConfigService, UserService userService) {
+ this.supplierService = supplierService;
+ this.userBusinessService = userBusinessService;
+ this.systemConfigService = systemConfigService;
+ this.userService = userService;
+ }
+
+ @GetMapping(value = "/checkIsNameAndTypeExist")
+ @ApiOperation(value = "检查名称和类型是否存在")
+ public String checkIsNameAndTypeExist(@RequestParam Long id,
+ @RequestParam(value ="name", required = false) String name,
+ @RequestParam(value ="type") String type,
+ HttpServletRequest request)throws Exception {
+ Map objectMap = new HashMap<>();
+ int exist = supplierService.checkIsNameAndTypeExist(id, name, type);
+ if(exist > 0) {
+ objectMap.put("status", true);
+ } else {
+ objectMap.put("status", false);
+ }
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ }
+
+ /**
+ * 查找客户信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_cus")
+ @ApiOperation(value = "查找客户信息")
+ public JSONArray findBySelectCus(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ String type = "UserCustomer";
+ Long userId = userService.getUserId(request);
+ //获取权限信息
+ String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString());
+ List supplierList = supplierService.findBySelectCus();
+ JSONArray dataArray = new JSONArray();
+ if (null != supplierList) {
+ boolean customerFlag = systemConfigService.getCustomerFlag();
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ Boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
+ if (!customerFlag || flag) {
+ item.put("id", supplier.getId());
+ item.put("supplier", supplier.getSupplier()); //客户名称
+ dataArray.add(item);
+ }
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 查找供应商信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_sup")
+ @ApiOperation(value = "查找供应商信息")
+ public JSONArray findBySelectSup(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ List supplierList = supplierService.findBySelectSup();
+ JSONArray dataArray = new JSONArray();
+ if (null != supplierList) {
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ //供应商名称
+ item.put("supplier", supplier.getSupplier());
+ dataArray.add(item);
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 查找往来单位,含供应商和客户信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_organ")
+ @ApiOperation(value = "查找往来单位,含供应商和客户信息")
+ public JSONArray findBySelectOrgan(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ JSONArray dataArray = new JSONArray();
+ //1、获取供应商信息
+ List supplierList = supplierService.findBySelectSup();
+ if (null != supplierList) {
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ item.put("supplier", supplier.getSupplier() + "[供应商]"); //供应商名称
+ dataArray.add(item);
+ }
+ }
+ //2、获取客户信息
+ String type = "UserCustomer";
+ Long userId = userService.getUserId(request);
+ String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString());
+ List customerList = supplierService.findBySelectCus();
+ if (null != customerList) {
+ boolean customerFlag = systemConfigService.getCustomerFlag();
+ for (Supplier supplier : customerList) {
+ JSONObject item = new JSONObject();
+ Boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
+ if (!customerFlag || flag) {
+ item.put("id", supplier.getId());
+ item.put("supplier", supplier.getSupplier() + "[客户]"); //客户名称
+ dataArray.add(item);
+ }
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 查找会员信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_retail")
+ @ApiOperation(value = "查找会员信息")
+ public JSONArray findBySelectRetail(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ List supplierList = supplierService.findBySelectRetail();
+ JSONArray dataArray = new JSONArray();
+ if (null != supplierList) {
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ //客户名称
+ item.put("supplier", supplier.getSupplier());
+ item.put("advanceIn", supplier.getAdvanceIn()); //预付款金额
+ dataArray.add(item);
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 批量设置状态-启用或者禁用
+ * @param jsonObject
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/batchSetStatus")
+ @ApiOperation(value = "批量设置状态")
+ public String batchSetStatus(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request)throws Exception {
+ Boolean status = jsonObject.getBoolean("status");
+ String ids = jsonObject.getString("ids");
+ Map objectMap = new HashMap<>();
+ int res = supplierService.batchSetStatus(status, ids);
+ if(res > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+
+ /**
+ * 用户对应客户显示
+ * @param type
+ * @param keyId
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/findUserCustomer")
+ @ApiOperation(value = "用户对应客户显示")
+ public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
+ HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ //获取权限信息
+ String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
+ List dataList = supplierService.findUserCustomer();
+ //开始拼接json数据
+ JSONObject outer = new JSONObject();
+ outer.put("id", 0);
+ outer.put("key", 0);
+ outer.put("value", 0);
+ outer.put("title", "客户列表");
+ outer.put("attributes", "客户列表");
+ //存放数据json数组
+ JSONArray dataArray = new JSONArray();
+ if (null != dataList) {
+ for (Supplier supplier : dataList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ item.put("key", supplier.getId());
+ item.put("value", supplier.getId());
+ item.put("title", supplier.getSupplier());
+ item.put("attributes", supplier.getSupplier());
+ boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
+ if (flag) {
+ item.put("checked", true);
+ }
+ dataArray.add(item);
+ }
+ }
+ outer.put("children", dataArray);
+ arr.add(outer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 根据客户或供应商查询期初、期初已收等信息
+ * @param organId
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/getBeginNeedByOrganId")
+ @ApiOperation(value = "根据客户或供应商查询期初、期初已收等信息")
+ public BaseResponseInfo getBeginNeedByOrganId(@RequestParam("organId") Long organId,
+ HttpServletRequest request)throws Exception {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ Map map = supplierService.getBeginNeedByOrganId(organId);
+ res.code = 200;
+ res.data = map;
+ } catch (Exception e) {
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+ /**
+ * 导入供应商
+ * @param file
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importVendor")
+ @ApiOperation(value = "导入供应商")
+ public BaseResponseInfo importVendor(MultipartFile file,
+ HttpServletRequest request, HttpServletResponse response) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ supplierService.importVendor(file, request);
+ res.code = 200;
+ res.data = "导入成功";
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "导入失败";
+ }
+ return res;
+ }
+
+ /**
+ * 导入客户
+ * @param file
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importCustomer")
+ @ApiOperation(value = "导入客户")
+ public BaseResponseInfo importCustomer(MultipartFile file,
+ HttpServletRequest request, HttpServletResponse response) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ supplierService.importCustomer(file, request);
+ res.code = 200;
+ res.data = "导入成功";
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "导入失败";
+ }
+ return res;
+ }
+
+ /**
+ * 导入会员
+ * @param file
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importMember")
+ @ApiOperation(value = "导入会员")
+ public BaseResponseInfo importMember(MultipartFile file,
+ HttpServletRequest request, HttpServletResponse response) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ supplierService.importMember(file, request);
+ res.code = 200;
+ res.data = "导入成功";
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "导入失败";
+ }
+ return res;
+ }
+
+ /**
+ * 生成excel表格
+ * @param supplier
+ * @param type
+ * @param phonenum
+ * @param telephone
+ * @param request
+ * @param response
+ * @return
+ */
+ @GetMapping(value = "/exportExcel")
+ public void exportExcel(@RequestParam(value = "supplier", required = false) String supplier,
+ @RequestParam("type") String type,
+ @RequestParam(value = "phonenum", required = false) String phonenum,
+ @RequestParam(value = "telephone", required = false) String telephone,
+ HttpServletRequest request, HttpServletResponse response) {
+ try {
+ List dataList = supplierService.findByAll(supplier, type, phonenum, telephone);
+ File file = supplierService.exportExcel(dataList, type);
+ ExcelUtils.downloadExcel(file, file.getName(), response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/api/src/main/java/com/wansensoft/api/system/SysConfigController.java b/api/src/main/java/com/wansensoft/api/system/SysConfigController.java
index e27e99e3..b2bde5e1 100644
--- a/api/src/main/java/com/wansensoft/api/system/SysConfigController.java
+++ b/api/src/main/java/com/wansensoft/api/system/SysConfigController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.system;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/system/SysDepartmentController.java b/api/src/main/java/com/wansensoft/api/system/SysDepartmentController.java
deleted file mode 100644
index 148b3eb0..00000000
--- a/api/src/main/java/com/wansensoft/api/system/SysDepartmentController.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
-package com.wansensoft.api.system;
-
-import com.wansensoft.dto.organization.DeptListDTO;
-import com.wansensoft.service.system.ISysDepartmentService;
-import com.wansensoft.utils.response.Response;
-import com.wansensoft.vo.DeptListVO;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-/**
- *
- * 机构表 前端控制器
- *
- */
-@RestController
-@RequestMapping("/dept")
-public class SysDepartmentController {
-
- private final ISysDepartmentService departmentService;
-
- public SysDepartmentController(ISysDepartmentService departmentService) {
- this.departmentService = departmentService;
- }
-
- @GetMapping("list")
- public Response list(@RequestBody DeptListDTO deptListDto) {
- return departmentService.deptList(deptListDto);
- }
-
- @GetMapping("userDeptRel")
- public Response> getUserDeptRel() {
- return departmentService.getUserDeptRel();
- }
-}
diff --git a/api/src/main/java/com/wansensoft/api/system/SysLogController.java b/api/src/main/java/com/wansensoft/api/system/SysLogController.java
index 45a78403..410facea 100644
--- a/api/src/main/java/com/wansensoft/api/system/SysLogController.java
+++ b/api/src/main/java/com/wansensoft/api/system/SysLogController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.system;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/system/SysMenuController.java b/api/src/main/java/com/wansensoft/api/system/SysMenuController.java
index a2240748..c6112779 100644
--- a/api/src/main/java/com/wansensoft/api/system/SysMenuController.java
+++ b/api/src/main/java/com/wansensoft/api/system/SysMenuController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.system;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/system/SysMsgController.java b/api/src/main/java/com/wansensoft/api/system/SysMsgController.java
index cfb1367e..88d055c7 100644
--- a/api/src/main/java/com/wansensoft/api/system/SysMsgController.java
+++ b/api/src/main/java/com/wansensoft/api/system/SysMsgController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.system;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/system/SysOrganizationController.java b/api/src/main/java/com/wansensoft/api/system/SysOrganizationController.java
new file mode 100644
index 00000000..c4b7c9b8
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/system/SysOrganizationController.java
@@ -0,0 +1,20 @@
+package com.wansensoft.api.system;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ *
+ * 机构表 前端控制器
+ *
+ *
+ * @author James Zow
+ * @since 2023-09-05
+ */
+@RestController
+@RequestMapping("/sys-organization")
+public class SysOrganizationController {
+
+}
diff --git a/api/src/main/java/com/wansensoft/api/system/SysPlatformConfigController.java b/api/src/main/java/com/wansensoft/api/system/SysPlatformConfigController.java
index 7648fbf4..681508ce 100644
--- a/api/src/main/java/com/wansensoft/api/system/SysPlatformConfigController.java
+++ b/api/src/main/java/com/wansensoft/api/system/SysPlatformConfigController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.system;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/system/SysSerialNumberController.java b/api/src/main/java/com/wansensoft/api/system/SysSerialNumberController.java
index 1a30dcd7..ee2ea359 100644
--- a/api/src/main/java/com/wansensoft/api/system/SysSerialNumberController.java
+++ b/api/src/main/java/com/wansensoft/api/system/SysSerialNumberController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.system;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/system/SystemConfigController.java b/api/src/main/java/com/wansensoft/api/system/SystemConfigController.java
new file mode 100644
index 00000000..29001b79
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/system/SystemConfigController.java
@@ -0,0 +1,267 @@
+package com.wansensoft.api.system;
+
+import com.wansensoft.entities.system.SystemConfig;
+import com.wansensoft.service.depot.DepotService;
+import com.wansensoft.service.systemConfig.SystemConfigService;
+import com.wansensoft.service.user.UserService;
+import com.wansensoft.service.userBusiness.UserBusinessService;
+import com.wansensoft.utils.BaseResponseInfo;
+import com.wansensoft.utils.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.HandlerMapping;
+
+import javax.imageio.ImageIO;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+
+@RestController
+@RequestMapping(value = "/systemConfig")
+@Api(tags = {"系统参数"})
+public class SystemConfigController {
+ private Logger logger = LoggerFactory.getLogger(SystemConfigController.class);
+
+ private final SystemConfigService systemConfigService;
+
+ @Value(value="${file.uploadType}")
+ private Long fileUploadType;
+
+ @Value(value="${file.path}")
+ private String filePath;
+
+ @Value(value="10485760")
+ private Long maxFileSize;
+
+ @Value(value="10485760")
+ private Long maxRequestSize;
+
+ public SystemConfigController(SystemConfigService systemConfigService) {
+ this.systemConfigService = systemConfigService;
+ }
+
+ /**
+ * 获取当前租户的配置信息
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/getCurrentInfo")
+ @ApiOperation(value = "获取当前租户的配置信息")
+ public BaseResponseInfo getCurrentInfo(HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try{
+ List list = systemConfigService.getSystemConfig();
+ res.code = 200;
+ if(!list.isEmpty()) {
+ res.data = list.get(0);
+ }
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+ /**
+ * 获取文件大小限制
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/fileSizeLimit")
+ @ApiOperation(value = "获取文件大小限制")
+ public BaseResponseInfo fileSizeLimit(HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try{
+ long limit = 0L;
+ if(maxFileSize UTF-8 进行编码转换
+ String imgPath = extractPathFromPattern(request);
+ if(StringUtil.isEmpty(imgPath) || imgPath=="null"){
+ return;
+ }
+ // 其余处理略
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ imgPath = imgPath.replace("..", "");
+ if (imgPath.endsWith(",")) {
+ imgPath = imgPath.substring(0, imgPath.length() - 1);
+ }
+ String fileUrl = "";
+ if(fileUploadType == 1) {
+ fileUrl = systemConfigService.getFileUrlLocal(imgPath);
+ inputStream = new BufferedInputStream(new FileInputStream(fileUrl));
+ } else if(fileUploadType == 2) {
+ fileUrl = systemConfigService.getFileUrlAliOss(imgPath);
+ URL url = new URL(fileUrl);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("GET");
+ conn.setConnectTimeout(5 * 1000);
+ inputStream = conn.getInputStream();// 通过输入流获取图片数据
+ }
+ outputStream = response.getOutputStream();
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = inputStream.read(buf)) > 0) {
+ outputStream.write(buf, 0, len);
+ }
+ response.flushBuffer();
+ } catch (IOException e) {
+ logger.error("预览文件失败" + e.getMessage());
+ response.setStatus(404);
+ } catch (Exception e) {
+ response.setStatus(404);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ /**
+ * 预览缩略图&下载文件
+ * @param request
+ * @param response
+ */
+ @GetMapping(value = "/static/mini/**")
+ @ApiOperation(value = "预览缩略图&下载文件")
+ public void viewMini(HttpServletRequest request, HttpServletResponse response) {
+ // ISO-8859-1 ==> UTF-8 进行编码转换
+ String imgPath = extractPathFromPattern(request);
+ if(StringUtil.isEmpty(imgPath) || imgPath=="null"){
+ return;
+ }
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ imgPath = imgPath.replace("..", "");
+ if (imgPath.endsWith(",")) {
+ imgPath = imgPath.substring(0, imgPath.length() - 1);
+ }
+ String fileUrl = "";
+ if(fileUploadType == 1) {
+ fileUrl = systemConfigService.getFileUrlLocal(imgPath);
+ inputStream = new BufferedInputStream(new FileInputStream(fileUrl));
+ } else if(fileUploadType == 2) {
+ fileUrl = systemConfigService.getFileUrlAliOss(imgPath);
+ URL url = new URL(fileUrl);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("GET");
+ conn.setConnectTimeout(5 * 1000);
+ inputStream = conn.getInputStream();// 通过输入流获取图片数据
+ }
+ int index = fileUrl.lastIndexOf(".");
+ String ext = fileUrl.substring(index + 1);
+ BufferedImage image = systemConfigService.getImageMini(inputStream, 80);
+ outputStream = response.getOutputStream();
+ ImageIO.write(image, ext, outputStream);
+ response.flushBuffer();
+ } catch (Exception e) {
+ response.setStatus(404);
+ } finally {
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ /**
+ * 把指定URL后的字符串全部截断当成参数
+ * 这么做是为了防止URL中包含中文或者特殊字符(/等)时,匹配不了的问题
+ * @param request
+ * @return
+ */
+ private static String extractPathFromPattern(final HttpServletRequest request) {
+ String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
+ String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
+ return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
+ }
+}
diff --git a/api/src/main/java/com/wansensoft/api/tenant/SysTenantController.java b/api/src/main/java/com/wansensoft/api/tenant/SysTenantController.java
index da9a86ef..7ebafe9b 100644
--- a/api/src/main/java/com/wansensoft/api/tenant/SysTenantController.java
+++ b/api/src/main/java/com/wansensoft/api/tenant/SysTenantController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.tenant;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/tenant/TenantController.java b/api/src/main/java/com/wansensoft/api/tenant/TenantController.java
new file mode 100644
index 00000000..1c7ee3b2
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/tenant/TenantController.java
@@ -0,0 +1,45 @@
+package com.wansensoft.api.tenant;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wansensoft.service.tenant.TenantService;
+import com.wansensoft.utils.ErpInfo;
+import com.wansensoft.utils.ResponseJsonUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/tenant")
+@Api(tags = {"租户管理"})
+public class TenantController {
+ private final TenantService tenantService;
+
+ public TenantController(TenantService tenantService) {
+ this.tenantService = tenantService;
+ }
+
+ /**
+ * 批量设置状态-启用或者禁用
+ * @param jsonObject
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/batchSetStatus")
+ @ApiOperation(value = "批量设置状态")
+ public String batchSetStatus(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request)throws Exception {
+ Boolean status = jsonObject.getBoolean("status");
+ String ids = jsonObject.getString("ids");
+ Map objectMap = new HashMap<>();
+ int res = tenantService.batchSetStatus(status, ids);
+ if(res > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+}
diff --git a/api/src/main/java/com/wansensoft/api/unit/UnitController.java b/api/src/main/java/com/wansensoft/api/unit/UnitController.java
new file mode 100644
index 00000000..af0a04a0
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/unit/UnitController.java
@@ -0,0 +1,71 @@
+package com.wansensoft.api.unit;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wansensoft.entities.unit.Unit;
+import com.wansensoft.service.unit.UnitService;
+import com.wansensoft.utils.BaseResponseInfo;
+import com.wansensoft.utils.ErpInfo;
+import com.wansensoft.utils.ResponseJsonUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.servlet.http.HttpServletRequest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/unit")
+@Api(tags = {"单位管理"})
+public class UnitController {
+
+ private final UnitService unitService;
+
+ public UnitController(UnitService unitService) {
+ this.unitService = unitService;
+ }
+
+ /**
+ * 单位列表
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/getAllList")
+ @ApiOperation(value = "单位列表")
+ public BaseResponseInfo getAllList(HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ List unitList = unitService.getUnit();
+ res.code = 200;
+ res.data = unitList;
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+ /**
+ * 批量设置状态-启用或者禁用
+ * @param jsonObject
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/batchSetStatus")
+ @ApiOperation(value = "批量设置状态")
+ public String batchSetStatus(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request)throws Exception {
+ Boolean status = jsonObject.getBoolean("status");
+ String ids = jsonObject.getString("ids");
+ Map objectMap = new HashMap<>();
+ int res = unitService.batchSetStatus(status, ids);
+ if(res > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+}
diff --git a/api/src/main/java/com/wansensoft/api/user/SysUserBusinessController.java b/api/src/main/java/com/wansensoft/api/user/SysUserBusinessController.java
index e3d25d6d..bfd60bd6 100644
--- a/api/src/main/java/com/wansensoft/api/user/SysUserBusinessController.java
+++ b/api/src/main/java/com/wansensoft/api/user/SysUserBusinessController.java
@@ -1,17 +1,6 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.user;
+
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/api/src/main/java/com/wansensoft/api/user/SysUserController.java b/api/src/main/java/com/wansensoft/api/user/SysUserController.java
index 8c4fb41f..ea0be66d 100644
--- a/api/src/main/java/com/wansensoft/api/user/SysUserController.java
+++ b/api/src/main/java/com/wansensoft/api/user/SysUserController.java
@@ -1,28 +1,9 @@
-/*
- * Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
- * with the License. A copy of the License is located at
- *
- * http://opensource.wansenai.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- * and limitations under the License.
- */
package com.wansensoft.api.user;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.wansensoft.dto.user.*;
-import com.wansensoft.service.user.ISysUserService;
-import com.wansensoft.utils.response.Response;
-import com.wansensoft.vo.UserInfoVO;
-import com.wansensoft.vo.UserListVO;
-import com.wansensoft.vo.UserRoleVO;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
-import java.util.List;
+import org.springframework.web.bind.annotation.RestController;
/**
*
@@ -33,72 +14,7 @@
* @since 2023-09-05
*/
@RestController
-@RequestMapping("/user")
+@RequestMapping("/sysUser")
public class SysUserController {
- private final ISysUserService userService;
-
- public SysUserController(ISysUserService userService) {
- this.userService = userService;
- }
-
- @PostMapping("register")
- public Response accountRegister(@RequestBody AccountRegisterDTO accountRegisterDto) {
- return userService.accountRegister(accountRegisterDto);
- }
-
- @PostMapping(value = "login")
- public Response accountLogin(@RequestBody AccountLoginDTO accountLoginDto) {
- return userService.accountLogin(accountLoginDto);
- }
-
- @PostMapping(value = "mobileLogin")
- public Response accountLogin(@RequestBody MobileLoginDTO mobileLoginDto) {
- return userService.mobileLogin(mobileLoginDto);
- }
-
- @PostMapping(value = "updatePassword")
- public Response updatePassword(@RequestBody UpdatePasswordDto updatePasswordDto) {
- return userService.updatePassword(updatePasswordDto);
- }
-
- @GetMapping(value = "info")
- public Response info() {
- return userService.userInfo();
- }
-
- @GetMapping(value = "perm")
- public Response> permission() {
- return userService.userRole();
- }
-
- @GetMapping(value = "logout")
- public Response logout() {
- return userService.userLogout();
- }
-
- @PostMapping(value = "list")
- public Response> list(@RequestBody UserListDTO userListDto) {
- return userService.userList(userListDto);
- }
-
- @PostMapping(value = "update")
- public Response update(@RequestBody UpdateUserDTO updateUserDTO) {
- return userService.updateUser(updateUserDTO);
- }
-
- @PostMapping(value = "addOrUpdate")
- public Response addOrUpdate(@RequestBody AddOrUpdateUserDTO addOrUpdateUserDTO) {
- return userService.addOrUpdate(addOrUpdateUserDTO);
- }
-
- @PostMapping(value = "delete")
- public Response deleteUser(@RequestParam(value = "ids") List ids) {
- return userService.deleteUser(ids);
- }
-
- @PostMapping(value = "resetPassword")
- public Response resetPassword(@RequestParam(value = "id") Long id) {
- return userService.resetPassword(id);
- }
}
diff --git a/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java b/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java
new file mode 100644
index 00000000..49505521
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java
@@ -0,0 +1,109 @@
+package com.wansensoft.api.user;
+
+import com.alibaba.fastjson.JSONObject;
+import com.wansensoft.entities.user.UserBusiness;
+import com.wansensoft.service.user.UserService;
+import com.wansensoft.service.userBusiness.UserBusinessService;
+import com.wansensoft.utils.BaseResponseInfo;
+import com.wansensoft.utils.ErpInfo;
+import com.wansensoft.utils.ResponseJsonUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/userBusiness")
+@Api(tags = {"用户角色模块的关系"})
+public class UserBusinessController {
+
+ private final UserBusinessService userBusinessService;
+
+ public UserBusinessController(UserBusinessService userBusinessService, UserService userService) {
+ this.userBusinessService = userBusinessService;
+ }
+
+ /**
+ * 获取信息
+ * @param keyId
+ * @param type
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/getBasicData")
+ @ApiOperation(value = "获取信息")
+ public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId,
+ @RequestParam(value = "Type") String type,
+ HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ List list = userBusinessService.getBasicData(keyId, type);
+ Map mapData = new HashMap();
+ mapData.put("userBusinessList", list);
+ res.code = 200;
+ res.data = mapData;
+ } catch (Exception e) {
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "查询权限失败";
+ }
+ return res;
+ }
+
+ /**
+ * 校验存在
+ * @param type
+ * @param keyId
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/checkIsValueExist")
+ @ApiOperation(value = "校验存在")
+ public String checkIsValueExist(@RequestParam(value ="type", required = false) String type,
+ @RequestParam(value ="keyId", required = false) String keyId,
+ HttpServletRequest request)throws Exception {
+ Map objectMap = new HashMap();
+ Long id = userBusinessService.checkIsValueExist(type, keyId);
+ if(id != null) {
+ objectMap.put("id", id);
+ } else {
+ objectMap.put("id", null);
+ }
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ }
+
+ /**
+ * 更新角色的按钮权限
+ * @param jsonObject
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/updateBtnStr")
+ @ApiOperation(value = "更新角色的按钮权限")
+ public BaseResponseInfo updateBtnStr(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ String roleId = jsonObject.getString("roleId");
+ String btnStr = jsonObject.getString("btnStr");
+ String keyId = roleId;
+ String type = "RoleFunctions";
+ int back = userBusinessService.updateBtnStr(keyId, type, btnStr);
+ if(back > 0) {
+ res.code = 200;
+ res.data = "成功";
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "更新权限失败";
+ }
+ return res;
+ }
+}
diff --git a/api/src/main/java/com/wansensoft/api/user/UserController.java b/api/src/main/java/com/wansensoft/api/user/UserController.java
new file mode 100644
index 00000000..fa96b706
--- /dev/null
+++ b/api/src/main/java/com/wansensoft/api/user/UserController.java
@@ -0,0 +1,444 @@
+package com.wansensoft.api.user;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.wansensoft.entities.tenant.Tenant;
+import com.wansensoft.entities.user.User;
+import com.wansensoft.entities.user.UserEx;
+import com.wansensoft.service.role.RoleService;
+import com.wansensoft.service.tenant.TenantService;
+import com.wansensoft.service.user.UserService;
+import com.wansensoft.utils.constants.ExceptionConstants;
+import com.wansensoft.plugins.exception.BusinessParamCheckingException;
+import com.wansensoft.service.redis.RedisService;
+import com.wansensoft.utils.*;
+import com.wansensoft.vo.TreeNodeEx;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.util.*;
+
+@RestController
+@RequestMapping(value = "/user")
+@Api(tags = {"用户管理"})
+public class UserController {
+ private Logger logger = LoggerFactory.getLogger(UserController.class);
+
+ @Value("${manage.roleId}")
+ private Integer manageRoleId;
+
+ private final UserService userService;
+
+ private final RoleService roleService;
+
+ private final TenantService tenantService;
+
+ private final RedisService redisService;
+
+ private static String SUCCESS = "操作成功";
+ private static String ERROR = "操作失败";
+
+ public UserController(UserService userService, RoleService roleService, TenantService tenantService, RedisService redisService) {
+ this.userService = userService;
+ this.roleService = roleService;
+ this.tenantService = tenantService;
+ this.redisService = redisService;
+ }
+
+
+ @PostMapping(value = "/login")
+ @ApiOperation(value = "登录")
+ public BaseResponseInfo login(@RequestBody User userParam,
+ HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ Map data = userService.login(userParam, request);
+ res.code = 200;
+ res.data = data;
+ } catch(Exception e){
+ logger.error(e.getMessage());
+ res.code = 500;
+ res.data = "用户登录失败";
+ }
+ return res;
+ }
+
+ @PostMapping(value = "/weixinLogin")
+ @ApiOperation(value = "微信登录")
+ public BaseResponseInfo weixinLogin(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request)throws Exception {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ String weixinCode = jsonObject.getString("weixinCode");
+ User user = userService.getUserByWeixinCode(weixinCode);
+ if(user == null) {
+ res.code = 501;
+ res.data = "微信未绑定";
+ } else {
+ Map data = userService.login(user, request);
+ res.code = 200;
+ res.data = data;
+ }
+ } catch(Exception e){
+ logger.error(e.getMessage());
+ res.code = 500;
+ res.data = "用户登录失败";
+ }
+ return res;
+ }
+
+ @PostMapping(value = "/weixinBind")
+ @ApiOperation(value = "绑定微信")
+ public String weixinBind(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request)throws Exception {
+ Map objectMap = new HashMap<>();
+ String loginName = jsonObject.getString("loginName");
+ String password = jsonObject.getString("password");
+ String weixinCode = jsonObject.getString("weixinCode");
+ int res = userService.weixinBind(loginName, password, weixinCode);
+ if(res > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+
+ @GetMapping(value = "/getUserSession")
+ @ApiOperation(value = "获取用户信息")
+ public BaseResponseInfo getSessionUser(HttpServletRequest request)throws Exception {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ Map data = new HashMap<>();
+ Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
+ User user = userService.getUser(userId);
+ user.setPassword(null);
+ data.put("user", user);
+ res.code = 200;
+ res.data = data;
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "获取session失败";
+ }
+ return res;
+ }
+
+ @GetMapping(value = "/logout")
+ @ApiOperation(value = "退出")
+ public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse response)throws Exception {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ redisService.deleteObjectBySession(request,"userId");
+ redisService.deleteObjectBySession(request,"roleType");
+ redisService.deleteObjectBySession(request,"clientIp");
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "退出失败";
+ }
+ return res;
+ }
+
+ @PostMapping(value = "/resetPwd")
+ @ApiOperation(value = "重置密码")
+ public String resetPwd(@RequestBody JSONObject jsonObject,
+ HttpServletRequest request) throws Exception {
+ Map objectMap = new HashMap<>();
+ Long id = jsonObject.getLong("id");
+ String password = "123456";
+ String md5Pwd = Tools.md5Encryp(password);
+ int update = userService.resetPwd(md5Pwd, id);
+ if(update > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, SUCCESS, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
+ }
+ }
+
+ @PutMapping(value = "/updatePwd")
+ @ApiOperation(value = "更新密码")
+ public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception {
+ Integer flag = 0;
+ Map objectMap = new HashMap();
+ try {
+ String info = "";
+ Long userId = jsonObject.getLong("userId");
+ String oldpwd = jsonObject.getString("oldpassword");
+ String password = jsonObject.getString("password");
+ User user = userService.getUser(userId);
+ //必须和原始密码一致才可以更新密码
+ if (oldpwd.equalsIgnoreCase(user.getPassword())) {
+ user.setPassword(password);
+ flag = userService.updateUserByObj(user); //1-成功
+ info = "修改成功";
+ } else {
+ flag = 2; //原始密码输入错误
+ info = "原始密码输入错误";
+ }
+ objectMap.put("status", flag);
+ if(flag > 0) {
+ return ResponseJsonUtil.returnJson(objectMap, info, ErpInfo.OK.code);
+ } else {
+ return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
+ }
+ } catch (Exception e) {
+ logger.error(">>>>>>>>>>>>>修改用户ID为 : " + jsonObject.getLong("userId") + "密码信息失败", e);
+ flag = 3;
+ objectMap.put("status", flag);
+ return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
+ }
+ }
+
+ /**
+ * 获取全部用户数据列表
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/getAllList")
+ @ApiOperation(value = "获取全部用户数据列表")
+ public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ Map data = new HashMap();
+ List dataList = userService.getUser();
+ if(dataList!=null) {
+ data.put("userList", dataList);
+ }
+ res.code = 200;
+ res.data = data;
+ } catch(Exception e){
+ res.code = 500;
+ res.data = "获取失败";
+ }
+ return res;
+ }
+
+ /**
+ * 用户列表,用于用户下拉框
+ * @param request
+ * @return
+ * @throws Exception
+ */
+ @GetMapping(value = "/getUserList")
+ @ApiOperation(value = "用户列表")
+ public JSONArray getUserList(HttpServletRequest request)throws Exception {
+ JSONArray dataArray = new JSONArray();
+ try {
+ List dataList = userService.getUser();
+ if (null != dataList) {
+ for (User user : dataList) {
+ JSONObject item = new JSONObject();
+ item.put("id", user.getId());
+ item.put("userName", user.getUsername());
+ dataArray.add(item);
+ }
+ }
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return dataArray;
+ }
+
+ /**
+ * description:
+ * 新增用户及机构和用户关系
+ * @Param: beanJson
+ * @return java.lang.Object
+ */
+ @PostMapping("/addUser")
+ @ApiOperation(value = "新增用户")
+ @ResponseBody
+ public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
+ JSONObject result = ExceptionConstants.standardSuccess();
+ User userInfo = userService.getCurrentUser();
+ Tenant tenant = tenantService.getTenantByTenantId(userInfo.getTenantId());
+ Long count = userService.countUser(null,null);
+ if(tenant!=null) {
+ if(count>= tenant.getUserNumLimit()) {
+ throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
+ ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
+ } else {
+ UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
+ userService.addUserAndOrgUserRel(ue, request);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * description:
+ * 修改用户及机构和用户关系
+ * @Param: beanJson
+ * @return java.lang.Object
+ */
+ @PutMapping("/updateUser")
+ @ApiOperation(value = "修改用户")
+ @ResponseBody
+ public Object updateUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
+ JSONObject result = ExceptionConstants.standardSuccess();
+ UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
+ userService.updateUserAndOrgUserRel(ue, request);
+ return result;
+ }
+
+ /**
+ * 注册用户
+ * @param ue
+ * @return
+ * @throws Exception
+ */
+ @PostMapping(value = "/registerUser")
+ @ApiOperation(value = "注册用户")
+ public Object registerUser(@RequestBody UserEx ue,
+ HttpServletRequest request)throws Exception{
+ JSONObject result = ExceptionConstants.standardSuccess();
+ ue.setUsername(ue.getLoginName());
+ userService.checkLoginName(ue); //检查登录名
+ ue = userService.registerUser(ue,manageRoleId,request);
+ return result;
+ }
+
+ /**
+ * 获取机构用户树
+ * @return
+ * @throws Exception
+ */
+ @RequestMapping("/getOrganizationUserTree")
+ @ApiOperation(value = "获取机构用户树")
+ public JSONArray getOrganizationUserTree()throws Exception{
+ JSONArray arr=new JSONArray();
+ List organizationUserTree= userService.getOrganizationUserTree();
+ if(organizationUserTree!=null&&organizationUserTree.size()>0){
+ for(TreeNodeEx node:organizationUserTree){
+ String str=JSON.toJSONString(node);
+ JSONObject obj=JSON.parseObject(str);
+ arr.add(obj) ;
+ }
+ }
+ return arr;
+ }
+
+ @GetMapping(value = "/getCurrentPriceLimit")
+ @ApiOperation(value = "查询当前用户的价格屏蔽")
+ public BaseResponseInfo getCurrentPriceLimit(HttpServletRequest request)throws Exception {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ Map data = new HashMap<>();
+ String priceLimit = roleService.getCurrentPriceLimit(request);
+ data.put("priceLimit", priceLimit);
+ res.code = 200;
+ res.data = data;
+ } catch(Exception e){
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "获取session失败";
+ }
+ return res;
+ }
+
+ /**
+ * 获取当前用户的角色类型
+ * @param request
+ * @return
+ */
+ @GetMapping("/getRoleTypeByCurrentUser")
+ @ApiOperation(value = "获取当前用户的角色类型")
+ public BaseResponseInfo getRoleTypeByCurrentUser(HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ Map data = new HashMap