From c6667e0e3ac42f628bc87b0fbfed5f5c1d0a1a6e Mon Sep 17 00:00:00 2001 From: jameszow Date: Mon, 4 Sep 2023 20:20:05 +0800 Subject: [PATCH] Api controller change --- .gitignore | 3 +- .../com/wansensoft/api/LogController.java | 43 +++++++++ .../com/wansensoft/api/MybatisPlusConfig.java | 24 +++++ .../wansensoft/api/ResourceController.java | 90 ++++++++++++------- .../api/account/AccountController.java | 15 ++-- .../api/account/AccountHeadController.java | 10 +-- .../wansensoft/api/depot/DepotController.java | 18 ++-- .../api/depot/DepotHeadController.java | 21 +++-- .../api/depot/DepotItemController.java | 7 +- .../api/function/FunctionController.java | 5 +- .../api/inOutItem/InOutItemController.java | 10 +-- .../api/material/MaterialController.java | 38 ++++---- .../api/person/PersonController.java | 9 +- .../PlatformConfigController.java | 9 +- .../wansensoft/api/role/RoleController.java | 11 +-- .../serialNumber/SerialNumberController.java | 12 ++- .../api/supplier/SupplierController.java | 15 ++-- .../api/tenant/TenantController.java | 8 +- .../wansensoft/api/unit/UnitController.java | 11 +-- .../api/user/UserBusinessController.java | 13 ++- .../wansensoft/api/user/UserController.java | 30 +++---- .../java/com/wansensoft/dto/PageSizeDto.java | 22 +++++ .../dto/depot/RetailOutboundDto.java | 51 +++++++++++ middleware/pom.xml | 6 ++ .../java/com/wansensoft/middleware/Main.java | 7 -- .../middleware/MpCodeQuickGeneration.java | 37 ++++++++ .../service/depotHead/DepotHeadService.java | 6 +- .../depotHead/DepotHeadServiceImpl.java | 67 ++++++++++++++ .../com/wansensoft/utils/AnnotationUtils.java | 2 +- .../java/com/wansensoft/utils/ErpInfo.java | 26 +++--- .../java/com/wansensoft/utils/ParamUtils.java | 2 +- .../java/com/wansensoft/utils/Response.java | 80 +++++++++++++++++ .../com/wansensoft/utils/ResponseCode.java | 14 ++- .../wansensoft/utils/ResponseJsonUtil.java | 25 ++---- .../com/wansensoft/utils/enums/CodeEnum.java | 46 ++++++++++ 35 files changed, 585 insertions(+), 208 deletions(-) create mode 100644 api/src/main/java/com/wansensoft/api/LogController.java create mode 100644 api/src/main/java/com/wansensoft/api/MybatisPlusConfig.java create mode 100644 domain/src/main/java/com/wansensoft/dto/PageSizeDto.java create mode 100644 domain/src/main/java/com/wansensoft/dto/depot/RetailOutboundDto.java delete mode 100644 middleware/src/main/java/com/wansensoft/middleware/Main.java create mode 100644 middleware/src/main/java/com/wansensoft/middleware/MpCodeQuickGeneration.java create mode 100644 utils/src/main/java/com/wansensoft/utils/Response.java create mode 100644 utils/src/main/java/com/wansensoft/utils/enums/CodeEnum.java diff --git a/.gitignore b/.gitignore index 957d4bcd..fd35dd9c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,10 @@ hs_err_pid* .idea -**/target +**/target/ /logs.home_IS_UNDEFINED **/*.iml .gitattributes +/api/src/main/resources/application-prod.yml \ No newline at end of file diff --git a/api/src/main/java/com/wansensoft/api/LogController.java b/api/src/main/java/com/wansensoft/api/LogController.java new file mode 100644 index 00000000..feced9fa --- /dev/null +++ b/api/src/main/java/com/wansensoft/api/LogController.java @@ -0,0 +1,43 @@ +package com.wansensoft.api; + +import com.wansensoft.entities.log.Log; +import com.wansensoft.entities.user.User; +import com.wansensoft.service.log.LogService; +import com.wansensoft.utils.BaseResponseInfo; +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping(value = "/log") +public class LogController { + + private final LogService logService; + + public LogController(LogService logService) { + this.logService = logService; + } + + @GetMapping("/getAllList") + public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception { + BaseResponseInfo res = new BaseResponseInfo(); + try { + Map data = new HashMap<>(); + List dataList = logService.getLog(); + if(dataList!=null) { + data.put("logList", dataList); + } + res.code = 200; + res.data = data; + } catch(Exception e){ + res.code = 500; + res.data = "获取失败"; + } + return res; + } +} diff --git a/api/src/main/java/com/wansensoft/api/MybatisPlusConfig.java b/api/src/main/java/com/wansensoft/api/MybatisPlusConfig.java new file mode 100644 index 00000000..b14ec5e7 --- /dev/null +++ b/api/src/main/java/com/wansensoft/api/MybatisPlusConfig.java @@ -0,0 +1,24 @@ +package com.wansensoft.api; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan("com.wansensoft.mappers") +public class MybatisPlusConfig { + + /** + * 添加分页插件 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } +} diff --git a/api/src/main/java/com/wansensoft/api/ResourceController.java b/api/src/main/java/com/wansensoft/api/ResourceController.java index ef3108d5..03d08fd3 100644 --- a/api/src/main/java/com/wansensoft/api/ResourceController.java +++ b/api/src/main/java/com/wansensoft/api/ResourceController.java @@ -4,11 +4,11 @@ import com.wansensoft.utils.constants.BusinessConstants; import com.wansensoft.service.CommonQueryManager; import com.wansensoft.utils.*; +import com.wansensoft.utils.enums.CodeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.HashMap; @@ -19,34 +19,37 @@ @Api(tags = {"资源接口"}) public class ResourceController { - @Resource - private CommonQueryManager configResourceManager; + private final CommonQueryManager configResourceManager; + + public ResourceController(CommonQueryManager configResourceManager) { + this.configResourceManager = configResourceManager; + } @GetMapping(value = "/{apiName}/info") @ApiOperation(value = "根据id获取信息") - public String getList(@PathVariable("apiName") String apiName, + public Response> getList(@PathVariable("apiName") String apiName, @RequestParam("id") Long id, HttpServletRequest request) throws Exception { Object obj = configResourceManager.selectOne(apiName, id); Map objectMap = new HashMap(); if(obj != null) { objectMap.put("info", obj); - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @GetMapping(value = "/{apiName}/list") @ApiOperation(value = "获取信息列表") - public String getList(@PathVariable("apiName") String apiName, + public Response getList(@PathVariable("apiName") String apiName, @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, @RequestParam(value = Constants.SEARCH, required = false) String search, HttpServletRequest request)throws Exception { Map parameterMap = ParamUtils.requestToMap(request); parameterMap.put(Constants.SEARCH, search); - Map objectMap = new HashMap(); + Map objectMap = new HashMap<>(); if (pageSize != null && pageSize <= 0) { pageSize = 10; } @@ -58,77 +61,104 @@ public String getList(@PathVariable("apiName") String apiName, if (list != null) { objectMap.put("total", configResourceManager.counts(apiName, parameterMap)); objectMap.put("rows", list); - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER); objectMap.put("rows", new ArrayList()); - return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); + return Response.responseMsg(CodeEnum.QUERY_DATA_EMPTY); } } +// @GetMapping(value = "/{apiName}/list") +// @ApiOperation(value = "获取信息列表") +// public String getList(@PathVariable("apiName") String apiName, +// @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, +// @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, +// @RequestParam(value = Constants.SEARCH, required = false) String search, +// HttpServletRequest request)throws Exception { +// Map parameterMap = ParamUtils.requestToMap(request); +// parameterMap.put(Constants.SEARCH, search); +// Map objectMap = new HashMap(); +// if (pageSize != null && pageSize <= 0) { +// pageSize = 10; +// } +// String offset = ParamUtils.getPageOffset(currentPage, pageSize); +// if (StringUtil.isNotEmpty(offset)) { +// parameterMap.put(Constants.OFFSET, offset); +// } +// List list = configResourceManager.select(apiName, parameterMap); +// if (list != null) { +// objectMap.put("total", configResourceManager.counts(apiName, parameterMap)); +// objectMap.put("rows", list); +// System.err.println(ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, Integer.parseInt(ErpInfo.OK.code))); +// return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, Integer.parseInt(ErpInfo.OK.code)); +// } else { +// objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER); +// objectMap.put("rows", new ArrayList()); +// return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", Integer.parseInt(ErpInfo.OK.code)); +// } +// } @PostMapping(value = "/{apiName}/add", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "新增") - public String addResource(@PathVariable("apiName") String apiName, + public Response addResource(@PathVariable("apiName") String apiName, @RequestBody JSONObject obj, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int insert = configResourceManager.insert(apiName, obj, request); if(insert > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else if(insert == -1) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @PutMapping(value = "/{apiName}/update", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "修改") - public String updateResource(@PathVariable("apiName") String apiName, + public Response updateResource(@PathVariable("apiName") String apiName, @RequestBody JSONObject obj, HttpServletRequest request)throws Exception { - Map objectMap = new HashMap(); int update = configResourceManager.update(apiName, obj, request); if(update > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else if(update == -1) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @DeleteMapping(value = "/{apiName}/delete", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "删除") - public String deleteResource(@PathVariable("apiName") String apiName, + public Response deleteResource(@PathVariable("apiName") String apiName, @RequestParam("id") Long id, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int delete = configResourceManager.delete(apiName, id, request); if(delete > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else if(delete == -1) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @DeleteMapping(value = "/{apiName}/deleteBatch", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "批量删除") - public String batchDeleteResource(@PathVariable("apiName") String apiName, + public Response batchDeleteResource(@PathVariable("apiName") String apiName, @RequestParam("ids") String ids, HttpServletRequest request)throws Exception { - Map objectMap = new HashMap(); int delete = configResourceManager.deleteBatch(apiName, ids, request); if(delete > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else if(delete == -1) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @GetMapping(value = "/{apiName}/checkIsNameExist") @ApiOperation(value = "检查名称是否存在") - public String checkIsNameExist(@PathVariable("apiName") String apiName, + public Response> checkIsNameExist(@PathVariable("apiName") String apiName, @RequestParam Long id, @RequestParam(value ="name", required = false) String name, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); @@ -138,7 +168,7 @@ public String checkIsNameExist(@PathVariable("apiName") String apiName, } else { objectMap.put("status", false); } - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } diff --git a/api/src/main/java/com/wansensoft/api/account/AccountController.java b/api/src/main/java/com/wansensoft/api/account/AccountController.java index 35381f7f..157ca5f9 100644 --- a/api/src/main/java/com/wansensoft/api/account/AccountController.java +++ b/api/src/main/java/com/wansensoft/api/account/AccountController.java @@ -7,7 +7,8 @@ import com.wansensoft.service.systemConfig.SystemConfigService; import com.wansensoft.utils.BaseResponseInfo; import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; +import com.wansensoft.utils.enums.CodeEnum; import com.wansensoft.vo.AccountVo4InOutList; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -153,15 +154,15 @@ public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Intege */ @PostMapping(value = "/updateIsDefault") @ApiOperation(value = "更新默认账户") - public String updateIsDefault(@RequestBody JSONObject object, + public Response updateIsDefault(@RequestBody JSONObject object, HttpServletRequest request) throws Exception{ Long accountId = object.getLong("id"); Map objectMap = new HashMap<>(); int res = accountService.updateIsDefault(accountId); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(CodeEnum.ERROR); } } @@ -196,16 +197,16 @@ public BaseResponseInfo getStatistics(@RequestParam("name") String name, */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { Boolean status = jsonObject.getBoolean("status"); String ids = jsonObject.getString("ids"); Map objectMap = new HashMap<>(); int res = accountService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(CodeEnum.ERROR); } } } diff --git a/api/src/main/java/com/wansensoft/api/account/AccountHeadController.java b/api/src/main/java/com/wansensoft/api/account/AccountHeadController.java index ff8727cf..e91afdf5 100644 --- a/api/src/main/java/com/wansensoft/api/account/AccountHeadController.java +++ b/api/src/main/java/com/wansensoft/api/account/AccountHeadController.java @@ -5,10 +5,10 @@ import com.wansensoft.entities.account.AccountHeadVo4Body; import com.wansensoft.entities.account.AccountHeadVo4ListEx; import com.wansensoft.service.accountHead.AccountHeadService; +import com.wansensoft.utils.Response; import com.wansensoft.utils.constants.ExceptionConstants; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.enums.CodeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -37,16 +37,16 @@ public class AccountHeadController { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态-审核或者反审核") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request) throws Exception{ Map objectMap = new HashMap<>(); String status = jsonObject.getString("status"); String ids = jsonObject.getString("ids"); int res = accountHeadService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(CodeEnum.ERROR); } } diff --git a/api/src/main/java/com/wansensoft/api/depot/DepotController.java b/api/src/main/java/com/wansensoft/api/depot/DepotController.java index 444c9c35..c36f7598 100644 --- a/api/src/main/java/com/wansensoft/api/depot/DepotController.java +++ b/api/src/main/java/com/wansensoft/api/depot/DepotController.java @@ -9,8 +9,8 @@ import com.wansensoft.service.material.MaterialService; import com.wansensoft.service.userBusiness.UserBusinessService; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; +import com.wansensoft.utils.enums.CodeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -22,7 +22,7 @@ import java.util.*; /** - * @author ji sheng hua 752*718*920 + * */ @RestController @RequestMapping(value = "/depot") @@ -142,15 +142,15 @@ public BaseResponseInfo findDepotByCurrentUser(HttpServletRequest request) throw */ @PostMapping(value = "/updateIsDefault") @ApiOperation(value = "更新默认仓库") - public String updateIsDefault(@RequestBody JSONObject object, + public Response updateIsDefault(@RequestBody JSONObject object, HttpServletRequest request) throws Exception{ Long depotId = object.getLong("id"); Map objectMap = new HashMap<>(); int res = depotService.updateIsDefault(depotId); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(CodeEnum.ERROR); } } @@ -203,16 +203,16 @@ public BaseResponseInfo getAllList(@RequestParam("mId") Long mId, */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { Boolean status = jsonObject.getBoolean("status"); String ids = jsonObject.getString("ids"); Map objectMap = new HashMap<>(); int res = depotService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(CodeEnum.ERROR); } } } diff --git a/api/src/main/java/com/wansensoft/api/depot/DepotHeadController.java b/api/src/main/java/com/wansensoft/api/depot/DepotHeadController.java index 91bead7c..e9aba4a0 100644 --- a/api/src/main/java/com/wansensoft/api/depot/DepotHeadController.java +++ b/api/src/main/java/com/wansensoft/api/depot/DepotHeadController.java @@ -2,6 +2,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.wansensoft.dto.depot.RetailOutboundDto; import com.wansensoft.entities.depot.DepotHead; import com.wansensoft.entities.depot.DepotHeadVo4Body; import com.wansensoft.service.depot.DepotService; @@ -11,6 +13,7 @@ import com.wansensoft.utils.constants.ExceptionConstants; import com.wansensoft.service.redis.RedisService; import com.wansensoft.utils.*; +import com.wansensoft.utils.enums.CodeEnum; import com.wansensoft.vo.DepotHeadVo4InDetail; import com.wansensoft.vo.DepotHeadVo4InOutMCount; import com.wansensoft.vo.DepotHeadVo4List; @@ -49,6 +52,12 @@ public DepotHeadController(DepotHeadService depotHeadService, DepotService depot this.redisService = redisService; } + @GetMapping("/getAllList") + public Response> getList(@ModelAttribute RetailOutboundDto retailOutboundDto){ + return Response.responseData(depotHeadService.selectByConditionDepotHead(retailOutboundDto)); + } + + /** * 批量设置状态-审核或者反审核 * @param jsonObject @@ -57,16 +66,16 @@ public DepotHeadController(DepotHeadService depotHeadService, DepotService depot */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态-审核或者反审核") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request) throws Exception{ Map objectMap = new HashMap<>(); String status = jsonObject.getString("status"); String ids = jsonObject.getString("ids"); int res = depotHeadService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(CodeEnum.ERROR); } } @@ -501,7 +510,7 @@ public BaseResponseInfo getCreatorByRoleType(HttpServletRequest request) { */ @GetMapping(value = "/debtList") @ApiOperation(value = "查询存在欠款的单据") - public String debtList(@RequestParam(value = Constants.SEARCH, required = false) String search, + public Response debtList(@RequestParam(value = Constants.SEARCH, required = false) String search, @RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize, HttpServletRequest request)throws Exception { @@ -520,11 +529,11 @@ public String debtList(@RequestParam(value = Constants.SEARCH, required = false) if (list != null) { objectMap.put("rows", list); objectMap.put("total", total); - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { objectMap.put("rows", new ArrayList<>()); objectMap.put("total", 0); - return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); + return Response.responseData(objectMap); } } } diff --git a/api/src/main/java/com/wansensoft/api/depot/DepotItemController.java b/api/src/main/java/com/wansensoft/api/depot/DepotItemController.java index 5b02a93b..104ae84e 100644 --- a/api/src/main/java/com/wansensoft/api/depot/DepotItemController.java +++ b/api/src/main/java/com/wansensoft/api/depot/DepotItemController.java @@ -19,6 +19,7 @@ import com.wansensoft.utils.constants.ExceptionConstants; import com.wansensoft.plugins.exception.BusinessRunTimeException; import com.wansensoft.utils.*; +import com.wansensoft.utils.enums.CodeEnum; import com.wansensoft.vo.DepotItemStockWarningCount; import com.wansensoft.vo.DepotItemVoBatchNumberList; import io.swagger.annotations.Api; @@ -86,7 +87,7 @@ public DepotItemController(DepotHeadService depotHeadService, DepotItemService d */ @GetMapping(value = "/findDetailByDepotIdsAndMaterialId") @ApiOperation(value = "根据仓库和商品查询单据列表") - public String findDetailByDepotIdsAndMaterialId( + public Response findDetailByDepotIdsAndMaterialId( @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, @RequestParam(value = "depotIds",required = false) String depotIds, @@ -130,12 +131,12 @@ public String findDetailByDepotIdsAndMaterialId( if (list == null) { objectMap.put("rows", new ArrayList()); objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER); - return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); + return Response.responseMsg(CodeEnum.QUERY_DATA_EMPTY); } objectMap.put("rows", dataArray); objectMap.put("total", depotItemService.findDetailByDepotIdsAndMaterialIdCount(depotIds, forceFlag, sku, batchNumber, StringUtil.toNull(number), beginTime, endTime, mId)); - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } /** diff --git a/api/src/main/java/com/wansensoft/api/function/FunctionController.java b/api/src/main/java/com/wansensoft/api/function/FunctionController.java index f71aff99..66214cb2 100644 --- a/api/src/main/java/com/wansensoft/api/function/FunctionController.java +++ b/api/src/main/java/com/wansensoft/api/function/FunctionController.java @@ -13,6 +13,7 @@ import com.wansensoft.utils.StringUtil; import com.wansensoft.utils.Tools; import com.wansensoft.utils.*; +import com.wansensoft.utils.enums.CodeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -46,7 +47,7 @@ public FunctionController(FunctionService functionService, UserBusinessService u @GetMapping(value = "/checkIsNumberExist") @ApiOperation(value = "检查编号是否存在") - public String checkIsNumberExist(@RequestParam Long id, + public Response> checkIsNumberExist(@RequestParam Long id, @RequestParam(value ="number", required = false) String number, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); @@ -56,7 +57,7 @@ public String checkIsNumberExist(@RequestParam Long id, } else { objectMap.put("status", false); } - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } /** diff --git a/api/src/main/java/com/wansensoft/api/inOutItem/InOutItemController.java b/api/src/main/java/com/wansensoft/api/inOutItem/InOutItemController.java index a2de78c1..f8e6f0fe 100644 --- a/api/src/main/java/com/wansensoft/api/inOutItem/InOutItemController.java +++ b/api/src/main/java/com/wansensoft/api/inOutItem/InOutItemController.java @@ -5,7 +5,7 @@ import com.wansensoft.entities.inOutItem.InOutItem; import com.wansensoft.service.inOutItem.InOutItemService; import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -67,16 +67,16 @@ public String findBySelect(@RequestParam("type") String type, HttpServletRequest */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, - HttpServletRequest request)throws Exception { + public Response batchSetStatus(@RequestBody JSONObject jsonObject, + HttpServletRequest request)throws Exception { Boolean status = jsonObject.getBoolean("status"); String ids = jsonObject.getString("ids"); Map objectMap = new HashMap<>(); int res = inOutItemService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(objectMap); } } } diff --git a/api/src/main/java/com/wansensoft/api/material/MaterialController.java b/api/src/main/java/com/wansensoft/api/material/MaterialController.java index 78f051cc..5a24aae9 100644 --- a/api/src/main/java/com/wansensoft/api/material/MaterialController.java +++ b/api/src/main/java/com/wansensoft/api/material/MaterialController.java @@ -11,8 +11,8 @@ import com.wansensoft.service.unit.UnitService; import com.wansensoft.utils.BaseResponseInfo; import com.wansensoft.utils.ErpInfo; +import com.wansensoft.utils.Response; import com.wansensoft.utils.StringUtil; -import com.wansensoft.utils.ResponseJsonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -72,12 +72,12 @@ public MaterialController(MaterialService materialService, DepotItemService depo */ @GetMapping(value = "/checkIsExist") @ApiOperation(value = "检查商品是否存在") - public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name, - @RequestParam("model") String model, @RequestParam("color") String color, - @RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs, - @RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2, - @RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId, - HttpServletRequest request)throws Exception { + public Response> checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name, + @RequestParam("model") String model, @RequestParam("color") String color, + @RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs, + @RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2, + @RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit, @RequestParam("unitId") Long unitId, + HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); int exist = materialService.checkIsExist(id, name, StringUtil.toNull(model), StringUtil.toNull(color), StringUtil.toNull(standard), StringUtil.toNull(mfrs), StringUtil.toNull(otherField1), @@ -87,7 +87,7 @@ public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") St } else { objectMap.put("status", false); } - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } /** @@ -99,16 +99,16 @@ public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") St */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态-启用或者禁用") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { Boolean status = jsonObject.getBoolean("status"); String ids = jsonObject.getString("ids"); Map objectMap = new HashMap<>(); int res = materialService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(objectMap); } } @@ -623,35 +623,31 @@ public BaseResponseInfo getListWithStock(@RequestParam("currentPage") Integer cu */ @PostMapping(value = "/batchSetMaterialCurrentStock") @ApiOperation(value = "批量设置商品当前的实时库存(按每个仓库)") - public String batchSetMaterialCurrentStock(@RequestBody JSONObject jsonObject, + public Response batchSetMaterialCurrentStock(@RequestBody JSONObject jsonObject, HttpServletRequest request) { String ids = jsonObject.getString("ids"); - Map objectMap = new HashMap<>(); int res = materialService.batchSetMaterialCurrentStock(ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } /** * 批量更新商品信息 * @param jsonObject - * @param request * @return * @throws Exception */ @PostMapping(value = "/batchUpdate") @ApiOperation(value = "批量更新商品信息") - public String batchUpdate(@RequestBody JSONObject jsonObject, - HttpServletRequest request) { - Map objectMap = new HashMap<>(); + public Response batchUpdate(@RequestBody JSONObject jsonObject) { int res = materialService.batchUpdate(jsonObject); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } diff --git a/api/src/main/java/com/wansensoft/api/person/PersonController.java b/api/src/main/java/com/wansensoft/api/person/PersonController.java index 36ea2e27..312fc81e 100644 --- a/api/src/main/java/com/wansensoft/api/person/PersonController.java +++ b/api/src/main/java/com/wansensoft/api/person/PersonController.java @@ -5,8 +5,7 @@ import com.wansensoft.entities.person.Person; import com.wansensoft.service.person.PersonService; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -145,16 +144,16 @@ public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request) { Boolean status = jsonObject.getBoolean("status"); String ids = jsonObject.getString("ids"); Map objectMap = new HashMap<>(); int res = personService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(objectMap); } } } diff --git a/api/src/main/java/com/wansensoft/api/platformConfig/PlatformConfigController.java b/api/src/main/java/com/wansensoft/api/platformConfig/PlatformConfigController.java index 1915916b..8b13b932 100644 --- a/api/src/main/java/com/wansensoft/api/platformConfig/PlatformConfigController.java +++ b/api/src/main/java/com/wansensoft/api/platformConfig/PlatformConfigController.java @@ -4,8 +4,7 @@ import com.wansensoft.entities.platformConfig.PlatformConfig; import com.wansensoft.service.platformConfig.PlatformConfigService; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -96,16 +95,16 @@ public String getPlatformRegisterFlag(HttpServletRequest request) { */ @PostMapping(value = "/updatePlatformConfigByKey") @ApiOperation(value = "根据platformKey更新platformValue") - public String updatePlatformConfigByKey(@RequestBody JSONObject object, + public Response updatePlatformConfigByKey(@RequestBody JSONObject object, HttpServletRequest request) { Map objectMap = new HashMap<>(); String platformKey = object.getString("platformKey"); String platformValue = object.getString("platformValue"); int res = platformConfigService.updatePlatformConfigByKey(platformKey, platformValue); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(objectMap); } } diff --git a/api/src/main/java/com/wansensoft/api/role/RoleController.java b/api/src/main/java/com/wansensoft/api/role/RoleController.java index cd31b22f..45c42bfc 100644 --- a/api/src/main/java/com/wansensoft/api/role/RoleController.java +++ b/api/src/main/java/com/wansensoft/api/role/RoleController.java @@ -5,8 +5,7 @@ import com.wansensoft.entities.role.Role; import com.wansensoft.service.role.RoleService; import com.wansensoft.service.userBusiness.UserBusinessService; -import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -22,8 +21,6 @@ @RequestMapping(value = "/role") @Api(tags = {"角色管理"}) public class RoleController { - private Logger logger = LoggerFactory.getLogger(RoleController.class); - private final RoleService roleService; private final UserBusinessService userBusinessService; @@ -79,16 +76,16 @@ public List allList(HttpServletRequest request)throws Exception { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request) { Boolean status = jsonObject.getBoolean("status"); String ids = jsonObject.getString("ids"); Map objectMap = new HashMap<>(); int res = roleService.batchSetStatus(status, ids); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseData(objectMap); } } } diff --git a/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java b/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java index 08745161..b2267602 100644 --- a/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java +++ b/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java @@ -8,13 +8,11 @@ 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.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; import jakarta.servlet.http.HttpServletRequest; @@ -48,7 +46,7 @@ public SerialNumberController(SerialNumberService serialNumberService, DepotHead */ @PostMapping("/batAddSerialNumber") @ApiOperation(value = "批量添加序列号") - public String batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServletRequest request) { + public Response batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServletRequest request) { Map objectMap = new HashMap<>(); String materialCode = jsonObject.getString("materialCode"); String serialNumberPrefix = jsonObject.getString("serialNumberPrefix"); @@ -56,11 +54,11 @@ public String batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServlet 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); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else if(insert == -1) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } diff --git a/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java b/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java index 017fcffb..ba650422 100644 --- a/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java +++ b/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java @@ -10,11 +10,9 @@ import com.wansensoft.utils.BaseResponseInfo; import com.wansensoft.utils.ErpInfo; import com.wansensoft.utils.ExcelUtils; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -47,7 +45,7 @@ public SupplierController(SupplierService supplierService, UserBusinessService u @GetMapping(value = "/checkIsNameAndTypeExist") @ApiOperation(value = "检查名称和类型是否存在") - public String checkIsNameAndTypeExist(@RequestParam Long id, + public Response > checkIsNameAndTypeExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name, @RequestParam(value ="type") String type, HttpServletRequest request)throws Exception { @@ -58,7 +56,7 @@ public String checkIsNameAndTypeExist(@RequestParam Long id, } else { objectMap.put("status", false); } - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } /** @@ -206,16 +204,15 @@ public JSONArray findBySelectRetail(HttpServletRequest request) { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request) { 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); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } diff --git a/api/src/main/java/com/wansensoft/api/tenant/TenantController.java b/api/src/main/java/com/wansensoft/api/tenant/TenantController.java index 1c7ee3b2..053aa5fe 100644 --- a/api/src/main/java/com/wansensoft/api/tenant/TenantController.java +++ b/api/src/main/java/com/wansensoft/api/tenant/TenantController.java @@ -3,7 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.wansensoft.service.tenant.TenantService; import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -30,16 +30,16 @@ public TenantController(TenantService tenantService) { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response 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); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(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 index 234b00e5..ef06968b 100644 --- a/api/src/main/java/com/wansensoft/api/unit/UnitController.java +++ b/api/src/main/java/com/wansensoft/api/unit/UnitController.java @@ -5,15 +5,13 @@ import com.wansensoft.service.unit.UnitService; import com.wansensoft.utils.BaseResponseInfo; import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.ResponseJsonUtil; +import com.wansensoft.utils.Response; 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") @@ -55,16 +53,15 @@ public BaseResponseInfo getAllList(HttpServletRequest request) { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request) { 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); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } diff --git a/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java b/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java index db70cf88..4c956aa5 100644 --- a/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java +++ b/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java @@ -5,12 +5,9 @@ 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 com.wansensoft.utils.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; import jakarta.servlet.http.HttpServletRequest; @@ -67,9 +64,9 @@ public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId */ @GetMapping(value = "/checkIsValueExist") @ApiOperation(value = "校验存在") - public String checkIsValueExist(@RequestParam(value ="type", required = false) String type, - @RequestParam(value ="keyId", required = false) String keyId, - HttpServletRequest request) { + public Response checkIsValueExist(@RequestParam(value ="type", required = false) String type, + @RequestParam(value ="keyId", required = false) String keyId, + HttpServletRequest request) { Map objectMap = new HashMap(); Long id = userBusinessService.checkIsValueExist(type, keyId); if(id != null) { @@ -77,7 +74,7 @@ public String checkIsValueExist(@RequestParam(value ="type", required = false) S } else { objectMap.put("id", null); } - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseData(objectMap); } /** diff --git a/api/src/main/java/com/wansensoft/api/user/UserController.java b/api/src/main/java/com/wansensoft/api/user/UserController.java index 179d37aa..f34c8d15 100644 --- a/api/src/main/java/com/wansensoft/api/user/UserController.java +++ b/api/src/main/java/com/wansensoft/api/user/UserController.java @@ -6,7 +6,6 @@ import com.wansensoft.entities.tenant.Tenant; import com.wansensoft.entities.user.User; import com.wansensoft.entities.user.UserEx; -import com.wansensoft.service.log.LogService; import com.wansensoft.service.role.RoleService; import com.wansensoft.service.tenant.TenantService; import com.wansensoft.service.user.UserService; @@ -97,17 +96,15 @@ public BaseResponseInfo weixinLogin(@RequestBody JSONObject jsonObject, @PostMapping(value = "/weixinBind") @ApiOperation(value = "绑定微信") - public String weixinBind(@RequestBody JSONObject jsonObject, - HttpServletRequest request)throws Exception { - Map objectMap = new HashMap<>(); + public Response weixinBind(@RequestBody JSONObject jsonObject) { 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); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -147,7 +144,7 @@ public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse r @PostMapping(value = "/resetPwd") @ApiOperation(value = "重置密码") - public String resetPwd(@RequestBody JSONObject jsonObject, + public Response resetPwd(@RequestBody JSONObject jsonObject, HttpServletRequest request) throws Exception { Map objectMap = new HashMap<>(); Long id = jsonObject.getLong("id"); @@ -155,15 +152,15 @@ public String resetPwd(@RequestBody JSONObject jsonObject, String md5Pwd = Tools.md5Encryp(password); int update = userService.resetPwd(md5Pwd, id); if(update > 0) { - return ResponseJsonUtil.returnJson(objectMap, SUCCESS, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @PutMapping(value = "/updatePwd") @ApiOperation(value = "更新密码") - public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { + public Response updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { Integer flag = 0; Map objectMap = new HashMap(); try { @@ -183,15 +180,15 @@ public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest r } objectMap.put("status", flag); if(flag > 0) { - return ResponseJsonUtil.returnJson(objectMap, info, ErpInfo.OK.code); + return Response.responseData(info); } else { - return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, 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); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -399,16 +396,15 @@ public BaseResponseInfo randomImage(HttpServletResponse response,@PathVariable S */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public String batchSetStatus(@RequestBody JSONObject jsonObject, + public Response batchSetStatus(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { Byte status = jsonObject.getByte("status"); String ids = jsonObject.getString("ids"); - Map objectMap = new HashMap<>(); int res = userService.batchSetStatus(status, ids, request); if(res > 0) { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); + return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); } else { - return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } diff --git a/domain/src/main/java/com/wansensoft/dto/PageSizeDto.java b/domain/src/main/java/com/wansensoft/dto/PageSizeDto.java new file mode 100644 index 00000000..3ea69f94 --- /dev/null +++ b/domain/src/main/java/com/wansensoft/dto/PageSizeDto.java @@ -0,0 +1,22 @@ +package com.wansensoft.dto; + +import lombok.Data; + +/** + * 默认分页数据传输对象,针对需要进行分页查询的请求 + * 如果需要就继承该类 + */ +@Data +public class PageSizeDto { + + /** + * 查询列表总记录数 + */ + int pageTotal = 0; + + /** + * 每页显示条数,默认10 + */ + int pageSize = 10; + +} diff --git a/domain/src/main/java/com/wansensoft/dto/depot/RetailOutboundDto.java b/domain/src/main/java/com/wansensoft/dto/depot/RetailOutboundDto.java new file mode 100644 index 00000000..ccc652c1 --- /dev/null +++ b/domain/src/main/java/com/wansensoft/dto/depot/RetailOutboundDto.java @@ -0,0 +1,51 @@ +package com.wansensoft.dto.depot; + +import com.wansensoft.dto.PageSizeDto; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 零售出库查询数据请求Dto + */ +@Data +@Builder +@EqualsAndHashCode(callSuper = true) +public class RetailOutboundDto extends PageSizeDto { + + private String type; + + private String subType; + + private String roleType; + + private String hasDebt; + + private String status; + + private String purchaseStatus; + + private String number; + + private String linkNumber; + + private String beginTime; + + private String endTime; + + private String materialParam; + + private Long organId; + + private Long creator; + + private Long depotId; + + private Long accountId; + + private String remark; + + private int offset; + + private int rows; +} diff --git a/middleware/pom.xml b/middleware/pom.xml index bfae7d5d..8c800cf3 100644 --- a/middleware/pom.xml +++ b/middleware/pom.xml @@ -23,5 +23,11 @@ aliyun-sdk-oss 3.16.3 + + + com.baomidou + mybatis-plus-generator + 3.5.3.1 + \ No newline at end of file diff --git a/middleware/src/main/java/com/wansensoft/middleware/Main.java b/middleware/src/main/java/com/wansensoft/middleware/Main.java deleted file mode 100644 index 3e1de444..00000000 --- a/middleware/src/main/java/com/wansensoft/middleware/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.wansensoft.middleware; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/middleware/src/main/java/com/wansensoft/middleware/MpCodeQuickGeneration.java b/middleware/src/main/java/com/wansensoft/middleware/MpCodeQuickGeneration.java new file mode 100644 index 00000000..ecfd3fe5 --- /dev/null +++ b/middleware/src/main/java/com/wansensoft/middleware/MpCodeQuickGeneration.java @@ -0,0 +1,37 @@ +package com.wansensoft.middleware; + +import com.baomidou.mybatisplus.generator.FastAutoGenerator; +import com.baomidou.mybatisplus.generator.config.OutputFile; +import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; + +import java.sql.Types; +import java.util.Collections; + +public class MpCodeQuickGeneration { + public static void main(String[] args) { + FastAutoGenerator.create("jdbc:mysql://localhost:3306/wansenerp2?useUnicode=true&characterEncoding=utf-8&useSSL=false", "root", "PaSsw0Rd") + .globalConfig(builder -> { + builder.author("James Zow") // 设置作者 + .enableSwagger() // 开启 swagger 模式 + .fileOverride() // 覆盖已生成文件 + .outputDir("E:\\opensource\\WansenERP\\middleware\\src\\main\\resources"); // 指定输出目录 + }) + .dataSourceConfig(builder -> builder.typeConvertHandler((globalConfig, typeRegistry, metaInfo) -> { + + return typeRegistry.getColumnType(metaInfo); + + })) + .packageConfig(builder -> { + builder.parent("com.wansensoft.mappers") // 设置父包名 + .moduleName("dao") // 设置父包模块名 + .pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\opensource\\WansenERP\\middleware\\src\\main\\resources")); // 设置mapperXml生成路径 + }) + .strategyConfig(builder -> { + builder.addInclude("product_attribute") // 设置需要生成的表名 + .addTablePrefix("t_", "c_"); // 设置过滤表前缀 + }) + .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板 + .execute(); + } +} \ No newline at end of file diff --git a/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadService.java b/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadService.java index 33f1e410..b93c6438 100644 --- a/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadService.java +++ b/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadService.java @@ -1,7 +1,9 @@ package com.wansensoft.service.depotHead; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.wansensoft.dto.depot.RetailOutboundDto; import com.wansensoft.entities.depot.DepotHead; import com.wansensoft.vo.DepotHeadVo4InDetail; import com.wansensoft.vo.DepotHeadVo4InOutMCount; @@ -125,4 +127,6 @@ int debtListCount(Long organId, String materialParam, String number, String begi String roleType, String status); String getBillCategory(String subType); -} + + List selectByConditionDepotHead(RetailOutboundDto retailOutboundDto); +} \ No newline at end of file diff --git a/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadServiceImpl.java b/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadServiceImpl.java index 7bbfdcc8..047895ae 100644 --- a/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadServiceImpl.java +++ b/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadServiceImpl.java @@ -1,7 +1,9 @@ package com.wansensoft.service.depotHead; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.wansensoft.dto.depot.RetailOutboundDto; import com.wansensoft.entities.account.AccountItem; import com.wansensoft.entities.depot.DepotHead; import com.wansensoft.entities.depot.DepotHeadExample; @@ -1303,4 +1305,69 @@ public String getBillCategory(String subType) { return "buy"; } } + + @Override + public List selectByConditionDepotHead(RetailOutboundDto retailOutboundDto) { + if (retailOutboundDto == null) { + return null; + } + + List resList = new ArrayList<>(); + try{ + String depotIds = depotService.findDepotStrByCurrentUser(); + String [] depotArray=depotIds.split(","); + String [] creatorArray = getCreatorArray(retailOutboundDto.getRoleType()); + String beginTime = Tools.parseDayToTime(retailOutboundDto.getBeginTime(), BusinessConstants.DAY_FIRST_TIME); + String endTime = Tools.parseDayToTime(retailOutboundDto.getEndTime(), BusinessConstants.DAY_LAST_TIME); + List list = depotHeadMapperEx + .debtList(retailOutboundDto.getOrganId(), creatorArray, retailOutboundDto.getStatus(), retailOutboundDto.getNumber(), + beginTime, endTime, retailOutboundDto.getMaterialParam(), depotArray, retailOutboundDto.getOffset(), retailOutboundDto.getRows()); + if (null != list) { + List idList = new ArrayList<>(); + for (DepotHeadVo4List dh : list) { + idList.add(dh.getId()); + } + //通过批量查询去构造map + Map materialsListMap = findMaterialsListMapByHeaderIdList(idList); + for (DepotHeadVo4List dh : list) { + if(dh.getChangeAmount() != null) { + dh.setChangeAmount(dh.getChangeAmount().abs()); + } + if(dh.getTotalPrice() != null) { + dh.setTotalPrice(dh.getTotalPrice().abs()); + } + if(dh.getDeposit() == null) { + dh.setDeposit(BigDecimal.ZERO); + } + if(dh.getOperTime() != null) { + dh.setOperTimeStr(Tools.getCenternTime(dh.getOperTime())); + } + BigDecimal discountLastMoney = dh.getDiscountLastMoney()!=null?dh.getDiscountLastMoney():BigDecimal.ZERO; + BigDecimal otherMoney = dh.getOtherMoney()!=null?dh.getOtherMoney():BigDecimal.ZERO; + BigDecimal deposit = dh.getDeposit()!=null?dh.getDeposit():BigDecimal.ZERO; + BigDecimal changeAmount = dh.getChangeAmount()!=null?dh.getChangeAmount().abs():BigDecimal.ZERO; + //本单欠款(如果退货则为负数) + dh.setNeedDebt(discountLastMoney.add(otherMoney).subtract(deposit.add(changeAmount))); + if(BusinessConstants.SUB_TYPE_PURCHASE_RETURN.equals(dh.getSubType()) || BusinessConstants.SUB_TYPE_SALES_RETURN.equals(dh.getSubType())) { + dh.setNeedDebt(BigDecimal.ZERO.subtract(dh.getNeedDebt())); + } + BigDecimal needDebt = dh.getNeedDebt()!=null?dh.getNeedDebt():BigDecimal.ZERO; + BigDecimal finishDebt = commonService.getEachAmountByBillId(dh.getId()); + finishDebt = finishDebt!=null?finishDebt:BigDecimal.ZERO; + //已收欠款 + dh.setFinishDebt(finishDebt); + //待收欠款 + dh.setDebt(needDebt.subtract(finishDebt)); + //商品信息简述 + if(materialsListMap!=null) { + dh.setMaterialsList(materialsListMap.get(dh.getId())); + } + resList.add(dh); + } + } + }catch(Exception e){ + JshException.readFail(logger, e); + } + return resList; + } } diff --git a/utils/src/main/java/com/wansensoft/utils/AnnotationUtils.java b/utils/src/main/java/com/wansensoft/utils/AnnotationUtils.java index 4640d4d3..5be90600 100644 --- a/utils/src/main/java/com/wansensoft/utils/AnnotationUtils.java +++ b/utils/src/main/java/com/wansensoft/utils/AnnotationUtils.java @@ -4,7 +4,7 @@ import java.lang.annotation.Documented; /** - * @author jishenghua qq752718920 2018-10-7 15:26:27 + * */ public class AnnotationUtils { public static A getAnnotation(Class cls, Class annotationClass) { diff --git a/utils/src/main/java/com/wansensoft/utils/ErpInfo.java b/utils/src/main/java/com/wansensoft/utils/ErpInfo.java index 0785c539..cb255485 100644 --- a/utils/src/main/java/com/wansensoft/utils/ErpInfo.java +++ b/utils/src/main/java/com/wansensoft/utils/ErpInfo.java @@ -5,21 +5,21 @@ */ public enum ErpInfo { //通过构造传递参数 - OK(200, "成功"), - BAD_REQUEST(400, "请求错误或参数错误"), - UNAUTHORIZED(401, "未认证用户"), - INVALID_VERIFY_CODE(461, "错误的验证码"), - ERROR(500, "服务内部错误"), - WARING_MSG(201, "提醒信息"), - REDIRECT(301, "session失效,重定向"), - FORWARD_REDIRECT(302, "转发请求session失效"), - FORWARD_FAILED(303, "转发请求失败!"), - TEST_USER(-1, "演示用户禁止操作"); + OK("200", "成功"), + BAD_REQUEST("400", "请求错误或参数错误"), + UNAUTHORIZED("401", "未认证用户"), + INVALID_VERIFY_CODE("461", "错误的验证码"), + ERROR("500", "服务内部错误"), + WARING_MSG("201", "提醒信息"), + REDIRECT("301", "session失效,重定向"), + FORWARD_REDIRECT("302", "转发请求session失效"), + FORWARD_FAILED("303", "转发请求失败!"), + TEST_USER("-1", "演示用户禁止操作"); - public final int code; + public final String code; public final String name; - public int getCode() { + public String getCode() { return code; } @@ -30,7 +30,7 @@ public String getName() { /** * 定义枚举构造函数 */ - ErpInfo(int code, String name) { + ErpInfo(String code, String name) { this.code = code; this.name = name; } diff --git a/utils/src/main/java/com/wansensoft/utils/ParamUtils.java b/utils/src/main/java/com/wansensoft/utils/ParamUtils.java index a8ff3832..a3855b3f 100644 --- a/utils/src/main/java/com/wansensoft/utils/ParamUtils.java +++ b/utils/src/main/java/com/wansensoft/utils/ParamUtils.java @@ -15,7 +15,7 @@ public static String getPageOffset(Integer currentPage, Integer pageSize) { if (offset <= 0) { return "0"; } else { - return new StringBuffer().append(offset).toString(); + return String.valueOf(offset); } } return null; diff --git a/utils/src/main/java/com/wansensoft/utils/Response.java b/utils/src/main/java/com/wansensoft/utils/Response.java new file mode 100644 index 00000000..9d968b88 --- /dev/null +++ b/utils/src/main/java/com/wansensoft/utils/Response.java @@ -0,0 +1,80 @@ +package com.wansensoft.utils; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.wansensoft.utils.enums.CodeEnum; + +import java.io.Serial; +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Response implements Serializable { + + @Serial + private static final long serialVersionUID = 793034041048451317L; + + private String msg; + + private String code; + + private T data; + + public static Response success() { + return responseMsg(CodeEnum.SUCCESS); + } + + public static Response fail() { + return responseMsg(CodeEnum.ERROR); + } + + public static Response responseMsg(CodeEnum codeEnum) { + Response baseResponse = new Response(); + baseResponse.setCode(codeEnum.getCode()); + baseResponse.setMsg(codeEnum.getMsg()); + return baseResponse; + } + + public static Response responseMsg(String code, String msg) { + Response baseResponse = new Response(); + baseResponse.setCode(code); + baseResponse.setMsg(msg); + return baseResponse; + } + + public static Response responseData(T data) { + Response baseResponse = new Response(); + baseResponse.setCode(CodeEnum.SUCCESS.getCode()); + baseResponse.setData(data); + return baseResponse; + } + + public static Response responseData(String code, T data) { + Response baseResponse = new Response(); + baseResponse.setCode(code); + baseResponse.setData(data); + return baseResponse; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } +} diff --git a/utils/src/main/java/com/wansensoft/utils/ResponseCode.java b/utils/src/main/java/com/wansensoft/utils/ResponseCode.java index 5fc3e4a9..fe75d4e7 100644 --- a/utils/src/main/java/com/wansensoft/utils/ResponseCode.java +++ b/utils/src/main/java/com/wansensoft/utils/ResponseCode.java @@ -3,22 +3,18 @@ import com.alibaba.fastjson.annotation.JSONCreator; import com.alibaba.fastjson.annotation.JSONField; -/** - * @author jishenghua qq752718920 2018-10-7 15:26:27 - */ + public class ResponseCode { public final int code; public final Object data; - /** - * - * @param code - * @param data - */ + + + @JSONCreator public ResponseCode(@JSONField(name = "code") int code, @JSONField(name = "data")Object data) { this.code = code; this.data = data; } -} \ No newline at end of file +} diff --git a/utils/src/main/java/com/wansensoft/utils/ResponseJsonUtil.java b/utils/src/main/java/com/wansensoft/utils/ResponseJsonUtil.java index f9fa8748..d6de6ce8 100644 --- a/utils/src/main/java/com/wansensoft/utils/ResponseJsonUtil.java +++ b/utils/src/main/java/com/wansensoft/utils/ResponseJsonUtil.java @@ -17,9 +17,8 @@ public class ResponseJsonUtil { FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+8")); } - /** - * 响应过滤器 - */ + + public static final class ResponseFilter extends ExtJsonUtils.ExtFilter implements ValueFilter { @Override public Object process(Object object, String name, Object value) { @@ -33,11 +32,7 @@ public Object process(Object object, String name, Object value) { } } - /** - * - * @param responseCode - * @return - */ + public static String backJson4HttpApi(ResponseCode responseCode) { if (responseCode != null) { String result = JSON.toJSONString(responseCode, new ResponseFilter(), @@ -49,11 +44,8 @@ public static String backJson4HttpApi(ResponseCode responseCode) { return null; } - /** - * 验证失败的json串 - * @param code - * @return - */ + + public static String backJson4VerifyFailure(int code) { Map map = new HashMap(); map.put("message", "未通过验证"); @@ -62,11 +54,8 @@ public static String backJson4VerifyFailure(int code) { SerializerFeature.WriteNonStringKeyAsString); } - /** - * 成功的json串 - * @param responseCode - * @return - */ + + public static String backJson(ResponseCode responseCode) { if (responseCode != null) { return JSON.toJSONString(responseCode, new ResponseFilter(), diff --git a/utils/src/main/java/com/wansensoft/utils/enums/CodeEnum.java b/utils/src/main/java/com/wansensoft/utils/enums/CodeEnum.java new file mode 100644 index 00000000..c15e62c9 --- /dev/null +++ b/utils/src/main/java/com/wansensoft/utils/enums/CodeEnum.java @@ -0,0 +1,46 @@ +package com.wansensoft.utils.enums; + +public enum CodeEnum { + + // 一级基本宏观状态码 + SUCCESS("A0000", "系统执行成功"), + ERROR("B0001", "系统执行出错"), + // 用户类代码 + REGISTER_SUCCESS("A0001", "用户注册成功"), + USER_EXISTS("A0011", "用户名已存在"), + USER_LOGOUT("A0012", "账户注销成功"), + QUERY_DATA_EMPTY("A0404", "查询数据不存在"), + PARAMETER_NULL("C0001","请求必填参数为空"), + NOT_PERMISSION("D0000", "没有权限"); + + /** + * 响应状态码 + */ + private String code; + + /** + * 响应提示 + */ + private String msg; + + CodeEnum(String code, String msg) { + this.code = code; + this.msg = msg; + } + + public void setCode(String code) { + this.code = code; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public String getCode() { + return code; + } + + public String getMsg() { + return msg; + } +}