From 027b04e16781b2a2c691495ab44185da0bad360d Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:29:09 +0800 Subject: [PATCH 1/7] ingore Swagger and config --- .../com/wansensoft/api/PluginController.java | 295 +++++++++--------- .../plugins/config/MybatisPlusConfig.java | 24 -- .../plugins/config/Swagger2Config.java | 44 --- .../plugins/config/TenantConfig.java | 100 ------ .../java/com/wansensoft/utils/JsonUtils.java | 22 -- 5 files changed, 148 insertions(+), 337 deletions(-) delete mode 100644 plugins/src/main/java/com/wansensoft/plugins/config/MybatisPlusConfig.java delete mode 100644 plugins/src/main/java/com/wansensoft/plugins/config/Swagger2Config.java delete mode 100644 plugins/src/main/java/com/wansensoft/plugins/config/TenantConfig.java delete mode 100644 utils/src/main/java/com/wansensoft/utils/JsonUtils.java diff --git a/api/src/main/java/com/wansensoft/api/PluginController.java b/api/src/main/java/com/wansensoft/api/PluginController.java index 58d9cbf4..2cb62487 100644 --- a/api/src/main/java/com/wansensoft/api/PluginController.java +++ b/api/src/main/java/com/wansensoft/api/PluginController.java @@ -1,11 +1,14 @@ -package com.wansensoft.api;//package com.wansensoft.erp.controller; +//package com.wansensoft.api; // -//import constants.com.wansensoft.BusinessConstants; -//import entities.datasource.com.wansensoft.User; -//import user.service.com.wansensoft.UserService; -//import utils.com.wansensoft.utils.BaseResponseInfo; -//import utils.com.wansensoft.utils.ComputerInfo; -//import utils.com.wansensoft.utils.StringUtil; +//import com.gitee.starblues.core.PluginInfo; +//import com.gitee.starblues.integration.application.PluginApplication; +//import com.gitee.starblues.integration.operator.PluginOperator; +//import com.wansensoft.entities.user.User; +//import com.wansensoft.service.user.UserService; +//import com.wansensoft.utils.BaseResponseInfo; +//import com.wansensoft.utils.ComputerInfo; +//import com.wansensoft.utils.StringUtil; +//import com.wansensoft.utils.constants.BusinessConstants; //import io.swagger.annotations.Api; //import io.swagger.annotations.ApiOperation; //import org.springframework.beans.factory.annotation.Autowired; @@ -13,29 +16,27 @@ //import org.springframework.web.bind.annotation.*; //import org.springframework.web.multipart.MultipartFile; // -//import jakarta.annotation.Resource; //import jakarta.servlet.http.HttpServletRequest; //import jakarta.servlet.http.HttpServletResponse; //import java.nio.file.Paths; //import java.util.*; // ///** -// * 插件jar 包测试功能 -// * @author jishenghua -// * @version 1.0 +// * 插件包 +// * // */ //@RestController //@RequestMapping("/plugin") //@Api(tags = {"插件管理"}) //public class PluginController { // -// @Resource -// private UserService userService; +// private final UserService userService; // // private final PluginOperator pluginOperator; // // @Autowired -// public PluginController(PluginApplication pluginApplication) { +// public PluginController(UserService userService, PluginApplication pluginApplication) { +// this.userService = userService; // this.pluginOperator = pluginApplication.getPluginOperator(); // } // /** @@ -59,7 +60,7 @@ // resList = list; // } else { // for (PluginInfo pi : list) { -// String desc = pi.getPluginDescriptor().getPluginDescription(); +// String desc = pi.getPluginDescriptor().getDescription(); // if (desc.contains(name)) { // resList.add(pi); // } @@ -82,21 +83,21 @@ // * 获取插件jar文件名 // * @return 获取插件文件名。只在生产环境显示 // */ -// @GetMapping("/files") -// @ApiOperation(value = "获取插件jar文件名") -// public Set getPluginFilePaths(){ -// try { -// User userInfo = userService.getCurrentUser(); -// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { -// return pluginOperator.getPluginFilePaths(); -// } else { -// return null; -// } -// } catch (Exception e) { -// e.printStackTrace(); -// return null; -// } -// } +//// @GetMapping("/files") +//// @ApiOperation(value = "获取插件jar文件名") +//// public Set getPluginFilePaths(){ +//// try { +//// User userInfo = userService.getCurrentUser(); +//// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { +//// return pluginOperator.getPluginFilePaths(); +//// } else { +//// return null; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// return null; +//// } +//// } // // // /** @@ -173,34 +174,34 @@ // * @param id 插件id // * @return 返回操作结果 // */ -// @PostMapping("/uninstall/{id}") -// @ApiOperation(value = "根据插件id卸载插件") -// public BaseResponseInfo uninstall(@PathVariable("id") String id){ -// BaseResponseInfo res = new BaseResponseInfo(); -// Map map = new HashMap(); -// String message = ""; -// try { -// User userInfo = userService.getCurrentUser(); -// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { -// if (pluginOperator.uninstall(id, true)) { -// message = "plugin '" + id + "' uninstall success"; -// } else { -// message = "plugin '" + id + "' uninstall failure"; -// } -// } else { -// message = "power is limit"; -// } -// map.put("message", message); -// res.code = 200; -// res.data = map; -// } catch (Exception e) { -// e.printStackTrace(); -// map.put("message", "plugin '" + id +"' uninstall failure. " + e.getMessage()); -// res.code = 500; -// res.data = map; -// } -// return res; -// } +//// @PostMapping("/uninstall/{id}") +//// @ApiOperation(value = "根据插件id卸载插件") +//// public BaseResponseInfo uninstall(@PathVariable("id") String id){ +//// BaseResponseInfo res = new BaseResponseInfo(); +//// Map map = new HashMap(); +//// String message = ""; +//// try { +//// User userInfo = userService.getCurrentUser(); +//// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { +//// if (pluginOperator.uninstall(id, true)) { +//// message = "plugin '" + id + "' uninstall success"; +//// } else { +//// message = "plugin '" + id + "' uninstall failure"; +//// } +//// } else { +//// message = "power is limit"; +//// } +//// map.put("message", message); +//// res.code = 200; +//// res.data = map; +//// } catch (Exception e) { +//// e.printStackTrace(); +//// map.put("message", "plugin '" + id +"' uninstall failure. " + e.getMessage()); +//// res.code = 500; +//// res.data = map; +//// } +//// return res; +//// } // // // /** @@ -208,25 +209,25 @@ // * @param path 插件路径名称 // * @return 操作结果 // */ -// @PostMapping("/installByPath") -// @ApiOperation(value = "根据插件路径安装插件") -// public String install(@RequestParam("path") String path){ -// try { -// User userInfo = userService.getCurrentUser(); -// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { -// if (pluginOperator.install(Paths.get(path))) { -// return "installByPath success"; -// } else { -// return "installByPath failure"; -// } -// } else { -// return "installByPath failure"; -// } -// } catch (Exception e) { -// e.printStackTrace(); -// return "installByPath failure : " + e.getMessage(); -// } -// } +//// @PostMapping("/installByPath") +//// @ApiOperation(value = "根据插件路径安装插件") +//// public String install(@RequestParam("path") String path){ +//// try { +//// User userInfo = userService.getCurrentUser(); +//// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { +//// if (pluginOperator.install(Paths.get(path))) { +//// return "installByPath success"; +//// } else { +//// return "installByPath failure"; +//// } +//// } else { +//// return "installByPath failure"; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// return "installByPath failure : " + e.getMessage(); +//// } +//// } // // // /** @@ -234,78 +235,78 @@ // * @param file 上传文件 multipartFile // * @return 操作结果 // */ -// @PostMapping("/uploadInstallPluginJar") -// @ApiOperation(value = "上传并安装插件") -// public BaseResponseInfo install(MultipartFile file, HttpServletRequest request, HttpServletResponse response){ -// BaseResponseInfo res = new BaseResponseInfo(); -// try { -// User userInfo = userService.getCurrentUser(); -// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { -// pluginOperator.uploadPluginAndStart(file); -// res.code = 200; -// res.data = "导入成功"; -// } else { -// res.code = 500; -// res.data = "抱歉,无操作权限!"; -// } -// } catch(Exception e){ -// e.printStackTrace(); -// res.code = 500; -// res.data = "导入失败"; -// } -// return res; -// } +//// @PostMapping("/uploadInstallPluginJar") +//// @ApiOperation(value = "上传并安装插件") +//// public BaseResponseInfo install(MultipartFile file, HttpServletRequest request, HttpServletResponse response){ +//// BaseResponseInfo res = new BaseResponseInfo(); +//// try { +//// User userInfo = userService.getCurrentUser(); +//// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { +//// pluginOperator.uploadPluginAndStart(file); +//// res.code = 200; +//// res.data = "导入成功"; +//// } else { +//// res.code = 500; +//// res.data = "抱歉,无操作权限!"; +//// } +//// } catch(Exception e){ +//// e.printStackTrace(); +//// res.code = 500; +//// res.data = "导入失败"; +//// } +//// return res; +//// } +//// +//// /** +//// * 上传插件的配置文件。注意: 该操作只适用于生产环境 +//// * @param multipartFile 上传文件 multipartFile +//// * @return 操作结果 +//// */ +//// @PostMapping("/uploadPluginConfigFile") +//// @ApiOperation(value = "上传插件的配置文件") +//// public String uploadConfig(@RequestParam("configFile") MultipartFile multipartFile){ +//// try { +//// User userInfo = userService.getCurrentUser(); +//// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { +//// if (pluginOperator.uploadConfigFile(multipartFile)) { +//// return "uploadConfig success"; +//// } else { +//// return "uploadConfig failure"; +//// } +//// } else { +//// return "installByPath failure"; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// return "uploadConfig failure : " + e.getMessage(); +//// } +//// } // -// /** -// * 上传插件的配置文件。注意: 该操作只适用于生产环境 -// * @param multipartFile 上传文件 multipartFile -// * @return 操作结果 -// */ -// @PostMapping("/uploadPluginConfigFile") -// @ApiOperation(value = "上传插件的配置文件") -// public String uploadConfig(@RequestParam("configFile") MultipartFile multipartFile){ -// try { -// User userInfo = userService.getCurrentUser(); -// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { -// if (pluginOperator.uploadConfigFile(multipartFile)) { -// return "uploadConfig success"; -// } else { -// return "uploadConfig failure"; -// } -// } else { -// return "installByPath failure"; -// } -// } catch (Exception e) { -// e.printStackTrace(); -// return "uploadConfig failure : " + e.getMessage(); -// } -// } // -// -// /** -// * 备份插件。注意: 该操作只适用于生产环境 -// * @param pluginId 插件id -// * @return 操作结果 -// */ -// @PostMapping("/back/{pluginId}") -// @ApiOperation(value = "备份插件") -// public String backupPlugin(@PathVariable("pluginId") String pluginId){ -// try { -// User userInfo = userService.getCurrentUser(); -// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { -// if (pluginOperator.backupPlugin(pluginId, "testBack")) { -// return "backupPlugin success"; -// } else { -// return "backupPlugin failure"; -// } -// } else { -// return "backupPlugin failure"; -// } -// } catch (Exception e) { -// e.printStackTrace(); -// return "backupPlugin failure : " + e.getMessage(); -// } -// } +//// /** +//// * 备份插件。注意: 该操作只适用于生产环境 +//// * @param pluginId 插件id +//// * @return 操作结果 +//// */ +//// @PostMapping("/back/{pluginId}") +//// @ApiOperation(value = "备份插件") +//// public String backupPlugin(@PathVariable("pluginId") String pluginId){ +//// try { +//// User userInfo = userService.getCurrentUser(); +//// if(BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) { +//// if (pluginOperator.backupPlugin(pluginId, "testBack")) { +//// return "backupPlugin success"; +//// } else { +//// return "backupPlugin failure"; +//// } +//// } else { +//// return "backupPlugin failure"; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// return "backupPlugin failure : " + e.getMessage(); +//// } +//// } // // /** // * 获取加密后的mac diff --git a/plugins/src/main/java/com/wansensoft/plugins/config/MybatisPlusConfig.java b/plugins/src/main/java/com/wansensoft/plugins/config/MybatisPlusConfig.java deleted file mode 100644 index c569e127..00000000 --- a/plugins/src/main/java/com/wansensoft/plugins/config/MybatisPlusConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.wansensoft.plugins.config; - -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/plugins/src/main/java/com/wansensoft/plugins/config/Swagger2Config.java b/plugins/src/main/java/com/wansensoft/plugins/config/Swagger2Config.java deleted file mode 100644 index 40a98dbd..00000000 --- a/plugins/src/main/java/com/wansensoft/plugins/config/Swagger2Config.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.wansensoft.plugins.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * 插件集成配置 - * - * @author jishenghua - * @version 1.0 - */ -@Configuration -@EnableSwagger2 -public class Swagger2Config { - - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(this.apiInfo()) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("华夏ERP Restful Api") - .description("华夏ERP接口描述") - .termsOfServiceUrl("http://127.0.0.1") - .contact(new Contact("jishenghua", "", "")) - .version("3.0") - .build(); - } - -} diff --git a/plugins/src/main/java/com/wansensoft/plugins/config/TenantConfig.java b/plugins/src/main/java/com/wansensoft/plugins/config/TenantConfig.java deleted file mode 100644 index 4ba22f89..00000000 --- a/plugins/src/main/java/com/wansensoft/plugins/config/TenantConfig.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.wansensoft.plugins.config; - -import org.mybatis.spring.mapper.MapperScannerConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Service; - -@Service -public class TenantConfig { - -// @Bean -// public PaginationInnerInterceptor paginationInterceptor(HttpServletRequest request) { -// PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); -// List sqlParserList = new ArrayList<>(); -// TenantSqlParser tenantSqlParser = new TenantSqlParser(); -// tenantSqlParser.setTenantHandler(new TenantHandler() { -// @Override -// public Expression getTenantId() { -// String token = request.getHeader("X-Access-Token"); -// Long tenantId = Tools.getTenantIdByToken(token); -// if (tenantId!=0L) { -// return new LongValue(tenantId); -// } else { -// //超管 -// return null; -// } -// } -// -// @Override -// public String getTenantIdColumn() { -// return "tenant_id"; -// } -// -// @Override -// public boolean doTableFilter(String tableName) { -// //获取开启状态 -// Boolean res = true; -// String token = request.getHeader("X-Access-Token"); -// Long tenantId = Tools.getTenantIdByToken(token); -// if (tenantId!=0L) { -// // 这里可以判断是否过滤表 -// if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName) -// || "jsh_user_business".equals(tableName) || "jsh_function".equals(tableName) -// || "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) { -// res = true; -// } else { -// res = false; -// } -// } -// return res; -// } -// }); -// -// sqlParserList.add(tenantSqlParser); -// paginationInterceptor.setSqlParserList(sqlParserList); -// paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() { -// @Override -// public boolean doFilter(MetaObject metaObject) { -// MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject); -// // 过滤自定义查询此时无租户信息约束出现 -// if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserByWeixinOpenId".equals(ms.getId())) { -// return true; -// } else if ("com.jsh.erp.datasource.mappers.UserMapperEx.updateUserWithWeixinOpenId".equals(ms.getId())) { -// return true; -// } else if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())) { -// return true; -// } else if ("com.jsh.erp.datasource.mappers.UserMapperEx.disableUserByLimit".equals(ms.getId())) { -// return true; -// } else if ("com.jsh.erp.datasource.mappers.RoleMapperEx.getRoleWithoutTenant".equals(ms.getId())) { -// return true; -// } else if ("com.jsh.erp.datasource.mappers.LogMapperEx.insertLogWithUserId".equals(ms.getId())) { -// return true; -// } -// return false; -// } -// }); -// return paginationInterceptor; -// } - - /** - * 相当于顶部的: - * {@code @MapperScan("com.wansensoft.erp.datasource.mappers*")} - * 这里可以扩展,比如使用配置文件来配置扫描Mapper的路径 - */ - @Bean - public MapperScannerConfigurer mapperScannerConfigurer() { - MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer(); - scannerConfigurer.setBasePackage("com.wansensoft.erp.datasource.mappers*"); - return scannerConfigurer; - } - - /** - * 性能分析拦截器,不建议生产使用 - */ -// @Bean -// public PerformanceInterceptor performanceInterceptor(){ -// return new PerformanceInterceptor(); -// } - - -} diff --git a/utils/src/main/java/com/wansensoft/utils/JsonUtils.java b/utils/src/main/java/com/wansensoft/utils/JsonUtils.java deleted file mode 100644 index 84943da6..00000000 --- a/utils/src/main/java/com/wansensoft/utils/JsonUtils.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.wansensoft.utils; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * Created by jishenghua 2018-5-11 09:48:08 - * - * @author jishenghua - */ -public class JsonUtils { - - public static JSONObject ok(){ - JSONObject obj = new JSONObject(); - JSONObject tmp = new JSONObject(); - tmp.put("message", "成功"); - obj.put("code", 200); - obj.put("data", tmp); - return obj; - } - -} From 989a0fad361b51b0fb3a1058790f912db46657aa Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:29:53 +0800 Subject: [PATCH 2/7] add @InterceptorIgnore(tenantLine = "true") fix #30 --- .../main/java/com/wansensoft/mappers/log/LogMapperEx.java | 2 ++ .../main/java/com/wansensoft/mappers/role/RoleMapperEx.java | 3 +++ .../main/java/com/wansensoft/mappers/user/UserMapperEx.java | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/dao/src/main/java/com/wansensoft/mappers/log/LogMapperEx.java b/dao/src/main/java/com/wansensoft/mappers/log/LogMapperEx.java index 3bcb2691..38e01313 100644 --- a/dao/src/main/java/com/wansensoft/mappers/log/LogMapperEx.java +++ b/dao/src/main/java/com/wansensoft/mappers/log/LogMapperEx.java @@ -1,5 +1,6 @@ package com.wansensoft.mappers.log; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.wansensoft.entities.log.Log; import com.wansensoft.vo.LogVo4List; @@ -37,5 +38,6 @@ Long getCountByIpAndDate( @Param("clientIp") String clientIp, @Param("createTime") String createTime); + @InterceptorIgnore(tenantLine = "true") int insertLogWithUserId(Log log); } \ No newline at end of file diff --git a/dao/src/main/java/com/wansensoft/mappers/role/RoleMapperEx.java b/dao/src/main/java/com/wansensoft/mappers/role/RoleMapperEx.java index 6a84e41a..ffb938c7 100644 --- a/dao/src/main/java/com/wansensoft/mappers/role/RoleMapperEx.java +++ b/dao/src/main/java/com/wansensoft/mappers/role/RoleMapperEx.java @@ -1,5 +1,6 @@ package com.wansensoft.mappers.role; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.wansensoft.entities.role.Role; import com.wansensoft.entities.role.RoleEx; @@ -24,6 +25,8 @@ Long countsByRole( int batchDeleteRoleByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]); + + @InterceptorIgnore(tenantLine = "true") Role getRoleWithoutTenant( @Param("roleId") Long roleId); } \ No newline at end of file diff --git a/dao/src/main/java/com/wansensoft/mappers/user/UserMapperEx.java b/dao/src/main/java/com/wansensoft/mappers/user/UserMapperEx.java index 407f7caa..fb324807 100644 --- a/dao/src/main/java/com/wansensoft/mappers/user/UserMapperEx.java +++ b/dao/src/main/java/com/wansensoft/mappers/user/UserMapperEx.java @@ -1,5 +1,6 @@ package com.wansensoft.mappers.user; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.wansensoft.entities.user.User; import com.wansensoft.entities.user.UserEx; @@ -23,6 +24,7 @@ Long countsByUser( @Param("userName") String userName, @Param("loginName") String loginName); + @InterceptorIgnore(tenantLine = "true") List getUserListByUserNameOrLoginName(@Param("userName") String userName, @Param("loginName") String loginName); @@ -31,15 +33,18 @@ List getUserListByUserNameOrLoginName(@Param("userName") String userName, List getNodeTree(); List getNextNodeTree(Map parameterMap); + @InterceptorIgnore(tenantLine = "true") void disableUserByLimit(@Param("tenantId") Long tenantId); List getListByOrgaId( @Param("id") Long id, @Param("orgaId") Long orgaId); + @InterceptorIgnore(tenantLine = "true") User getUserByWeixinOpenId( @Param("weixinOpenId") String weixinOpenId); + @InterceptorIgnore(tenantLine = "true") int updateUserWithWeixinOpenId( @Param("loginName") String loginName, @Param("password") String password, From b00489205d60643a9a9015520ecd482e26a93e4e Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:30:11 +0800 Subject: [PATCH 3/7] cancel spring-brick jar --- plugins/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/pom.xml b/plugins/pom.xml index b432fe83..f77a113c 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -23,6 +23,12 @@ utils 1.0-SNAPSHOT + + + + + + From ec201d6c98416228a30ce66b1cfa1977c4ac02eb Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:30:23 +0800 Subject: [PATCH 4/7] cancel plugin config --- api/src/main/resources/application-dev.yml | 7 ++++--- api/src/main/resources/application.yml | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/src/main/resources/application-dev.yml b/api/src/main/resources/application-dev.yml index d955dc4f..428471f7 100644 --- a/api/src/main/resources/application-dev.yml +++ b/api/src/main/resources/application-dev.yml @@ -35,6 +35,7 @@ file: path: /opt/wansenerp/upload plugin: - runMode: prod - pluginPath: plugins - pluginConfigFilePath: pluginConfig \ No newline at end of file + runMode: dev + mainPackage: + - plugins + pluginPath: plugins \ No newline at end of file diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index 6729fce4..51ad3aad 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -34,4 +34,5 @@ mybatis-plus: #刷新mapper 调试神器 refresh-mapper: true configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file + log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file From 819a4ef49485bb3f0614f5e7ef06fdad9765144b Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:30:41 +0800 Subject: [PATCH 5/7] Fixed response data --- .../wansensoft/api/ResourceController.java | 50 ++++++++++--------- .../api/account/AccountController.java | 16 +++--- .../api/account/AccountHeadController.java | 9 ++-- .../wansensoft/api/depot/DepotController.java | 14 +++--- .../api/depot/DepotHeadController.java | 13 +++-- .../api/depot/DepotItemController.java | 7 ++- .../api/function/FunctionController.java | 5 +- .../api/inOutItem/InOutItemController.java | 10 ++-- .../api/material/MaterialController.java | 37 +++++++------- .../api/person/PersonController.java | 11 ++-- .../PlatformConfigController.java | 11 ++-- .../wansensoft/api/role/RoleController.java | 12 +++-- .../serialNumber/SerialNumberController.java | 9 ++-- .../api/supplier/SupplierController.java | 15 +++--- .../api/tenant/TenantController.java | 8 +-- .../wansensoft/api/unit/UnitController.java | 14 ++++-- .../api/user/UserBusinessController.java | 11 ++-- .../wansensoft/api/user/UserController.java | 29 ++++++----- .../com/wansensoft/service/CommonService.java | 4 -- .../service/depotHead/DepotHeadService.java | 2 - .../depotHead/DepotHeadServiceImpl.java | 44 ++-------------- .../service/user/UserServiceImpl.java | 16 +++--- .../java/com/wansensoft/utils/ErpInfo.java | 26 +++++----- 23 files changed, 173 insertions(+), 200 deletions(-) diff --git a/api/src/main/java/com/wansensoft/api/ResourceController.java b/api/src/main/java/com/wansensoft/api/ResourceController.java index 03d08fd3..abdbd188 100644 --- a/api/src/main/java/com/wansensoft/api/ResourceController.java +++ b/api/src/main/java/com/wansensoft/api/ResourceController.java @@ -27,22 +27,22 @@ public ResourceController(CommonQueryManager configResourceManager) { @GetMapping(value = "/{apiName}/info") @ApiOperation(value = "根据id获取信息") - public Response> getList(@PathVariable("apiName") String apiName, + public String 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 Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @GetMapping(value = "/{apiName}/list") @ApiOperation(value = "获取信息列表") - public Response getList(@PathVariable("apiName") String apiName, + 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, @@ -61,11 +61,11 @@ public Response getList(@PathVariable("apiName") String apiName, if (list != null) { objectMap.put("total", configResourceManager.counts(apiName, parameterMap)); objectMap.put("rows", list); - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER); objectMap.put("rows", new ArrayList()); - return Response.responseMsg(CodeEnum.QUERY_DATA_EMPTY); + return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); } } // @GetMapping(value = "/{apiName}/list") @@ -100,65 +100,67 @@ public Response getList(@PathVariable("apiName") String apiName, @PostMapping(value = "/{apiName}/add", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "新增") - public Response addResource(@PathVariable("apiName") String apiName, + public String 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else if(insert == -1) { - return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @PutMapping(value = "/{apiName}/update", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "修改") - public Response updateResource(@PathVariable("apiName") String apiName, + public String 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else if(update == -1) { - return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @DeleteMapping(value = "/{apiName}/delete", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "删除") - public Response deleteResource(@PathVariable("apiName") String apiName, + public String 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else if(delete == -1) { - return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @DeleteMapping(value = "/{apiName}/deleteBatch", produces = {"application/javascript", "application/json"}) @ApiOperation(value = "批量删除") - public Response batchDeleteResource(@PathVariable("apiName") String apiName, + public String 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else if(delete == -1) { - return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @GetMapping(value = "/{apiName}/checkIsNameExist") @ApiOperation(value = "检查名称是否存在") - public Response> checkIsNameExist(@PathVariable("apiName") String apiName, + public String checkIsNameExist(@PathVariable("apiName") String apiName, @RequestParam Long id, @RequestParam(value ="name", required = false) String name, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); @@ -168,7 +170,7 @@ public Response> checkIsNameExist(@PathVariable("apiName") S } else { objectMap.put("status", false); } - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } 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 157ca5f9..1ea6faeb 100644 --- a/api/src/main/java/com/wansensoft/api/account/AccountController.java +++ b/api/src/main/java/com/wansensoft/api/account/AccountController.java @@ -7,8 +7,7 @@ import com.wansensoft.service.systemConfig.SystemConfigService; import com.wansensoft.utils.BaseResponseInfo; import com.wansensoft.utils.ErpInfo; -import com.wansensoft.utils.Response; -import com.wansensoft.utils.enums.CodeEnum; +import com.wansensoft.utils.ResponseJsonUtil; import com.wansensoft.vo.AccountVo4InOutList; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -16,7 +15,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.util.HashMap; @@ -154,15 +152,15 @@ public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Intege */ @PostMapping(value = "/updateIsDefault") @ApiOperation(value = "更新默认账户") - public Response updateIsDefault(@RequestBody JSONObject object, + public String 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 Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(CodeEnum.ERROR); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -197,16 +195,16 @@ public BaseResponseInfo getStatistics(@RequestParam("name") String name, */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, + 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 = accountService.batchSetStatus(status, ids); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(CodeEnum.ERROR); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } 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 e91afdf5..a4e74fad 100644 --- a/api/src/main/java/com/wansensoft/api/account/AccountHeadController.java +++ b/api/src/main/java/com/wansensoft/api/account/AccountHeadController.java @@ -8,7 +8,8 @@ import com.wansensoft.utils.Response; import com.wansensoft.utils.constants.ExceptionConstants; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.enums.CodeEnum; +import com.wansensoft.utils.ErpInfo; +import com.wansensoft.utils.ResponseJsonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -37,16 +38,16 @@ public class AccountHeadController { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态-审核或者反审核") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, + public String 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 Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(CodeEnum.ERROR); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } 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 c36f7598..c2b857f1 100644 --- a/api/src/main/java/com/wansensoft/api/depot/DepotController.java +++ b/api/src/main/java/com/wansensoft/api/depot/DepotController.java @@ -9,7 +9,9 @@ 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.Response; +import com.wansensoft.utils.ResponseJsonUtil; import com.wansensoft.utils.enums.CodeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -142,15 +144,15 @@ public BaseResponseInfo findDepotByCurrentUser(HttpServletRequest request) throw */ @PostMapping(value = "/updateIsDefault") @ApiOperation(value = "更新默认仓库") - public Response updateIsDefault(@RequestBody JSONObject object, + public String 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 Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(CodeEnum.ERROR); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -203,16 +205,16 @@ public BaseResponseInfo getAllList(@RequestParam("mId") Long mId, */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, + 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 = depotService.batchSetStatus(status, ids); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(CodeEnum.ERROR); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } 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 96d6ea82..109c8275 100644 --- a/api/src/main/java/com/wansensoft/api/depot/DepotHeadController.java +++ b/api/src/main/java/com/wansensoft/api/depot/DepotHeadController.java @@ -13,7 +13,6 @@ 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; @@ -66,16 +65,16 @@ public Response> getList(@RequestBody RetailOutboundDto r */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态-审核或者反审核") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, + public String 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 Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(CodeEnum.ERROR); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -510,7 +509,7 @@ public BaseResponseInfo getCreatorByRoleType(HttpServletRequest request) { */ @GetMapping(value = "/debtList") @ApiOperation(value = "查询存在欠款的单据") - public Response debtList(@RequestParam(value = Constants.SEARCH, required = false) String search, + public String debtList(@RequestParam(value = Constants.SEARCH, required = false) String search, @RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize, HttpServletRequest request)throws Exception { @@ -529,11 +528,11 @@ public Response debtList(@RequestParam(value = Constants.SEARCH, required = fals if (list != null) { objectMap.put("rows", list); objectMap.put("total", total); - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { objectMap.put("rows", new ArrayList<>()); objectMap.put("total", 0); - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); } } } 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 104ae84e..5b02a93b 100644 --- a/api/src/main/java/com/wansensoft/api/depot/DepotItemController.java +++ b/api/src/main/java/com/wansensoft/api/depot/DepotItemController.java @@ -19,7 +19,6 @@ 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; @@ -87,7 +86,7 @@ public DepotItemController(DepotHeadService depotHeadService, DepotItemService d */ @GetMapping(value = "/findDetailByDepotIdsAndMaterialId") @ApiOperation(value = "根据仓库和商品查询单据列表") - public Response findDetailByDepotIdsAndMaterialId( + public String 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, @@ -131,12 +130,12 @@ public Response findDetailByDepotIdsAndMaterialId( if (list == null) { objectMap.put("rows", new ArrayList()); objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER); - return Response.responseMsg(CodeEnum.QUERY_DATA_EMPTY); + return ResponseJsonUtil.returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); } objectMap.put("rows", dataArray); objectMap.put("total", depotItemService.findDetailByDepotIdsAndMaterialIdCount(depotIds, forceFlag, sku, batchNumber, StringUtil.toNull(number), beginTime, endTime, mId)); - return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, 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 66214cb2..f71aff99 100644 --- a/api/src/main/java/com/wansensoft/api/function/FunctionController.java +++ b/api/src/main/java/com/wansensoft/api/function/FunctionController.java @@ -13,7 +13,6 @@ 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; @@ -47,7 +46,7 @@ public FunctionController(FunctionService functionService, UserBusinessService u @GetMapping(value = "/checkIsNumberExist") @ApiOperation(value = "检查编号是否存在") - public Response> checkIsNumberExist(@RequestParam Long id, + public String checkIsNumberExist(@RequestParam Long id, @RequestParam(value ="number", required = false) String number, HttpServletRequest request)throws Exception { Map objectMap = new HashMap(); @@ -57,7 +56,7 @@ public Response> checkIsNumberExist(@RequestParam Long id, } else { objectMap.put("status", false); } - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } /** 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 f8e6f0fe..a2de78c1 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.Response; +import com.wansensoft.utils.ResponseJsonUtil; 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 Response batchSetStatus(@RequestBody JSONObject jsonObject, - HttpServletRequest request)throws Exception { + 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 = inOutItemService.batchSetStatus(status, ids); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } 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 5a24aae9..8352995c 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 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 { + 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 { 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 Response> checkIsExist(@RequestParam("id") Long id, @ } else { objectMap.put("status", false); } - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } /** @@ -99,16 +99,16 @@ public Response> checkIsExist(@RequestParam("id") Long id, @ */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态-启用或者禁用") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, + 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 = materialService.batchSetStatus(status, ids); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -623,14 +623,15 @@ public BaseResponseInfo getListWithStock(@RequestParam("currentPage") Integer cu */ @PostMapping(value = "/batchSetMaterialCurrentStock") @ApiOperation(value = "批量设置商品当前的实时库存(按每个仓库)") - public Response batchSetMaterialCurrentStock(@RequestBody JSONObject jsonObject, + public String batchSetMaterialCurrentStock(@RequestBody JSONObject jsonObject, HttpServletRequest request) { String ids = jsonObject.getString("ids"); + Map objectMap = new HashMap<>(); int res = materialService.batchSetMaterialCurrentStock(ids); if(res > 0) { - return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -642,12 +643,14 @@ public Response batchSetMaterialCurrentStock(@RequestBody JSONObject jsonObject, */ @PostMapping(value = "/batchUpdate") @ApiOperation(value = "批量更新商品信息") - public Response batchUpdate(@RequestBody JSONObject jsonObject) { + public String batchUpdate(@RequestBody JSONObject jsonObject, + HttpServletRequest request) { + Map objectMap = new HashMap<>(); int res = materialService.batchUpdate(jsonObject); if(res > 0) { - return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, 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 312fc81e..fd822efc 100644 --- a/api/src/main/java/com/wansensoft/api/person/PersonController.java +++ b/api/src/main/java/com/wansensoft/api/person/PersonController.java @@ -5,7 +5,8 @@ import com.wansensoft.entities.person.Person; import com.wansensoft.service.person.PersonService; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.Response; +import com.wansensoft.utils.ErpInfo; +import com.wansensoft.utils.ResponseJsonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -144,16 +145,16 @@ public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, - HttpServletRequest request) { + 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 = personService.batchSetStatus(status, ids); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } 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 8b13b932..9ee75785 100644 --- a/api/src/main/java/com/wansensoft/api/platformConfig/PlatformConfigController.java +++ b/api/src/main/java/com/wansensoft/api/platformConfig/PlatformConfigController.java @@ -4,7 +4,8 @@ import com.wansensoft.entities.platformConfig.PlatformConfig; import com.wansensoft.service.platformConfig.PlatformConfigService; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.Response; +import com.wansensoft.utils.ErpInfo; +import com.wansensoft.utils.ResponseJsonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -95,16 +96,16 @@ public String getPlatformRegisterFlag(HttpServletRequest request) { */ @PostMapping(value = "/updatePlatformConfigByKey") @ApiOperation(value = "根据platformKey更新platformValue") - public Response updatePlatformConfigByKey(@RequestBody JSONObject object, - HttpServletRequest request) { + public String updatePlatformConfigByKey(@RequestBody JSONObject object, + HttpServletRequest request)throws Exception { Map objectMap = new HashMap<>(); String platformKey = object.getString("platformKey"); String platformValue = object.getString("platformValue"); int res = platformConfigService.updatePlatformConfigByKey(platformKey, platformValue); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } 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 45c42bfc..97eb4620 100644 --- a/api/src/main/java/com/wansensoft/api/role/RoleController.java +++ b/api/src/main/java/com/wansensoft/api/role/RoleController.java @@ -5,7 +5,9 @@ import com.wansensoft.entities.role.Role; import com.wansensoft.service.role.RoleService; import com.wansensoft.service.userBusiness.UserBusinessService; -import com.wansensoft.utils.Response; +import com.wansensoft.service.userBusiness.UserBusinessServiceImpl; +import com.wansensoft.utils.ErpInfo; +import com.wansensoft.utils.ResponseJsonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -76,16 +78,16 @@ public List allList(HttpServletRequest request)throws Exception { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, - HttpServletRequest request) { + 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 = roleService.batchSetStatus(status, ids); if(res > 0) { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } } 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 b2267602..cc975cdc 100644 --- a/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java +++ b/api/src/main/java/com/wansensoft/api/serialNumber/SerialNumberController.java @@ -10,6 +10,7 @@ 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; @@ -46,7 +47,7 @@ public SerialNumberController(SerialNumberService serialNumberService, DepotHead */ @PostMapping("/batAddSerialNumber") @ApiOperation(value = "批量添加序列号") - public Response batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServletRequest request) { + public String batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception{ Map objectMap = new HashMap<>(); String materialCode = jsonObject.getString("materialCode"); String serialNumberPrefix = jsonObject.getString("serialNumberPrefix"); @@ -54,11 +55,11 @@ public Response batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServl String remark = jsonObject.getString("remark"); int insert = serialNumberService.batAddSerialNumber(materialCode,serialNumberPrefix,batAddTotal,remark); if(insert > 0) { - return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else if(insert == -1) { - return Response.responseMsg(ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, 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 ba650422..340dc6c8 100644 --- a/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java +++ b/api/src/main/java/com/wansensoft/api/supplier/SupplierController.java @@ -10,7 +10,7 @@ import com.wansensoft.utils.BaseResponseInfo; import com.wansensoft.utils.ErpInfo; import com.wansensoft.utils.ExcelUtils; -import com.wansensoft.utils.Response; +import com.wansensoft.utils.ResponseJsonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -45,7 +45,7 @@ public SupplierController(SupplierService supplierService, UserBusinessService u @GetMapping(value = "/checkIsNameAndTypeExist") @ApiOperation(value = "检查名称和类型是否存在") - public Response > checkIsNameAndTypeExist(@RequestParam Long id, + public String checkIsNameAndTypeExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name, @RequestParam(value ="type") String type, HttpServletRequest request)throws Exception { @@ -56,7 +56,7 @@ public Response > checkIsNameAndTypeExist(@RequestParam Long } else { objectMap.put("status", false); } - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } /** @@ -204,15 +204,16 @@ public JSONArray findBySelectRetail(HttpServletRequest request) { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, - HttpServletRequest request) { + 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, 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 053aa5fe..1c7ee3b2 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.Response; +import com.wansensoft.utils.ResponseJsonUtil; 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 Response batchSetStatus(@RequestBody JSONObject jsonObject, + 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + 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 index ef06968b..af0a04a0 100644 --- a/api/src/main/java/com/wansensoft/api/unit/UnitController.java +++ b/api/src/main/java/com/wansensoft/api/unit/UnitController.java @@ -5,13 +5,16 @@ 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.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") @@ -53,15 +56,16 @@ public BaseResponseInfo getAllList(HttpServletRequest request) { */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, - HttpServletRequest request) { + 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, 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 4c956aa5..49505521 100644 --- a/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java +++ b/api/src/main/java/com/wansensoft/api/user/UserBusinessController.java @@ -5,7 +5,8 @@ import com.wansensoft.service.user.UserService; import com.wansensoft.service.userBusiness.UserBusinessService; import com.wansensoft.utils.BaseResponseInfo; -import com.wansensoft.utils.Response; +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.*; @@ -64,9 +65,9 @@ public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId */ @GetMapping(value = "/checkIsValueExist") @ApiOperation(value = "校验存在") - public Response checkIsValueExist(@RequestParam(value ="type", required = false) String type, - @RequestParam(value ="keyId", required = false) String keyId, - HttpServletRequest request) { + 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) { @@ -74,7 +75,7 @@ public Response checkIsValueExist(@RequestParam(value ="type", required = false) } else { objectMap.put("id", null); } - return Response.responseData(objectMap); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } /** 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 f34c8d15..fa96b706 100644 --- a/api/src/main/java/com/wansensoft/api/user/UserController.java +++ b/api/src/main/java/com/wansensoft/api/user/UserController.java @@ -96,15 +96,17 @@ public BaseResponseInfo weixinLogin(@RequestBody JSONObject jsonObject, @PostMapping(value = "/weixinBind") @ApiOperation(value = "绑定微信") - public Response weixinBind(@RequestBody JSONObject jsonObject) { + 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } @@ -144,7 +146,7 @@ public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse r @PostMapping(value = "/resetPwd") @ApiOperation(value = "重置密码") - public Response resetPwd(@RequestBody JSONObject jsonObject, + public String resetPwd(@RequestBody JSONObject jsonObject, HttpServletRequest request) throws Exception { Map objectMap = new HashMap<>(); Long id = jsonObject.getLong("id"); @@ -152,15 +154,15 @@ public Response resetPwd(@RequestBody JSONObject jsonObject, String md5Pwd = Tools.md5Encryp(password); int update = userService.resetPwd(md5Pwd, id); if(update > 0) { - return Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, SUCCESS, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code); } } @PutMapping(value = "/updatePwd") @ApiOperation(value = "更新密码") - public Response updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { + public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { Integer flag = 0; Map objectMap = new HashMap(); try { @@ -180,15 +182,15 @@ public Response updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest } objectMap.put("status", flag); if(flag > 0) { - return Response.responseData(info); + return ResponseJsonUtil.returnJson(objectMap, info, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + 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 Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ERROR, ErpInfo.ERROR.code); } } @@ -396,15 +398,16 @@ public BaseResponseInfo randomImage(HttpServletResponse response,@PathVariable S */ @PostMapping(value = "/batchSetStatus") @ApiOperation(value = "批量设置状态") - public Response batchSetStatus(@RequestBody JSONObject jsonObject, + public String 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 Response.responseMsg(ErpInfo.OK.name, ErpInfo.OK.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); } else { - return Response.responseMsg(ErpInfo.ERROR.name, ErpInfo.ERROR.code); + return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); } } diff --git a/service/src/main/java/com/wansensoft/service/CommonService.java b/service/src/main/java/com/wansensoft/service/CommonService.java index 66f5133b..a9a4eed9 100644 --- a/service/src/main/java/com/wansensoft/service/CommonService.java +++ b/service/src/main/java/com/wansensoft/service/CommonService.java @@ -77,10 +77,6 @@ public Long getUserId(HttpServletRequest request) { return userId; } - public Role getRoleWithoutTenant(Long roleId) { - return roleMapperEx.getRoleWithoutTenant(roleId); - } - public Material getMaterial(long id) { Material result=null; try{ 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 4c0245ec..b93c6438 100644 --- a/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadService.java +++ b/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadService.java @@ -129,6 +129,4 @@ int debtListCount(Long organId, String materialParam, String number, String begi String getBillCategory(String subType); List selectByConditionDepotHead(RetailOutboundDto retailOutboundDto); - - String getCreatorByRoleType(String roleType, String userId); } \ 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 f7f86dc2..469a33bf 100644 --- a/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadServiceImpl.java +++ b/service/src/main/java/com/wansensoft/service/depotHead/DepotHeadServiceImpl.java @@ -65,9 +65,7 @@ public class DepotHeadServiceImpl extends ServiceImpl getFinishDepositMapByNumberList(List numberList) { Map finishDepositMap = new HashMap<>(); if(!numberList.isEmpty()) { @@ -1344,7 +1306,7 @@ public List selectByConditionDepotHead(RetailOutboundDto retai try{ String depotIds = String.valueOf(depotService.findDepotByCurrentUserTest(String.valueOf(retailOutboundDto.getCreator()))); String [] depotArray=depotIds.split(","); - String [] creatorArray = getCreatorArray(retailOutboundDto.getRoleType(), String.valueOf(retailOutboundDto.getCreator())); + 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 diff --git a/service/src/main/java/com/wansensoft/service/user/UserServiceImpl.java b/service/src/main/java/com/wansensoft/service/user/UserServiceImpl.java index 06cb8d85..0ed59b52 100644 --- a/service/src/main/java/com/wansensoft/service/user/UserServiceImpl.java +++ b/service/src/main/java/com/wansensoft/service/user/UserServiceImpl.java @@ -9,6 +9,8 @@ import com.wansensoft.entities.user.UserBusiness; import com.wansensoft.entities.user.UserEx; import com.wansensoft.entities.user.UserExample; +import com.wansensoft.mappers.role.RoleMapper; +import com.wansensoft.mappers.role.RoleMapperEx; import com.wansensoft.mappers.user.UserMapper; import com.wansensoft.mappers.user.UserMapperEx; import com.wansensoft.service.CommonService; @@ -53,25 +55,23 @@ public class UserServiceImpl extends ServiceImpl implements Us private final LogService logService; private final TenantService tenantService; private final UserBusinessService userBusinessService; - private final CommonService commonService; private final FunctionService functionService; private final PlatformConfigService platformConfigService; private final RedisService redisService; - private final RedisUtil redisUtil; + private final RoleMapperEx roleMapperEx; - public UserServiceImpl(UserMapper userMapper, UserMapperEx userMapperEx, OrgaUserRelService orgaUserRelService, LogService logService, TenantService tenantService, UserBusinessService userBusinessService, CommonService commonService, FunctionService functionService, PlatformConfigService platformConfigService, RedisService redisService, RedisUtil redisUtil) { + public UserServiceImpl(UserMapper userMapper, UserMapperEx userMapperEx, OrgaUserRelService orgaUserRelService, LogService logService, TenantService tenantService, UserBusinessService userBusinessService, FunctionService functionService, PlatformConfigService platformConfigService, RedisService redisService, RoleMapperEx roleMapperEx) { this.userMapper = userMapper; this.userMapperEx = userMapperEx; this.orgaUserRelService = orgaUserRelService; this.logService = logService; this.tenantService = tenantService; this.userBusinessService = userBusinessService; - this.commonService = commonService; + this.roleMapperEx = roleMapperEx; this.functionService = functionService; this.platformConfigService = platformConfigService; this.redisService = redisService; - this.redisUtil = redisUtil; } public User getUser(long id) { @@ -765,13 +765,13 @@ public List getOrganizationUserTree() { */ @Transactional(value = "transactionManager", rollbackFor = Exception.class) public Role getRoleTypeByUserId(long userId) { - Role role = new Role(); + List list = userBusinessService.getBasicData(String.valueOf(userId), "UserRole"); + String roleId = "null"; UserBusiness ub = null; if(!list.isEmpty()) { ub = list.get(0); String values = ub.getValue(); - String roleId = null; if(values!=null) { values = values.replaceAll("\\[\\]",",").replace("[","").replace("]",""); } @@ -779,8 +779,8 @@ public Role getRoleTypeByUserId(long userId) { if(valueArray.length>0) { roleId = valueArray[0]; } - role = commonService.getRoleWithoutTenant(Long.parseLong(roleId)); } + Role role = roleMapperEx.getRoleWithoutTenant(Long.valueOf(roleId)); return role; } diff --git a/utils/src/main/java/com/wansensoft/utils/ErpInfo.java b/utils/src/main/java/com/wansensoft/utils/ErpInfo.java index cb255485..0785c539 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 String code; + public final int code; public final String name; - public String getCode() { + public int getCode() { return code; } @@ -30,7 +30,7 @@ public String getName() { /** * 定义枚举构造函数 */ - ErpInfo(String code, String name) { + ErpInfo(int code, String name) { this.code = code; this.name = name; } From f4b67445994fe29cb892b5e8ab39aa8507f8a554 Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:31:07 +0800 Subject: [PATCH 6/7] annotation not use code --- .../api/config/MybatisPlusConfig.java | 156 ++++++++++++++++++ .../api/config/PluginConfiguration.java | 71 ++++++++ .../wansensoft/api/config/Swagger2Config.java | 44 +++++ 3 files changed, 271 insertions(+) create mode 100644 api/src/main/java/com/wansensoft/api/config/MybatisPlusConfig.java create mode 100644 api/src/main/java/com/wansensoft/api/config/PluginConfiguration.java create mode 100644 api/src/main/java/com/wansensoft/api/config/Swagger2Config.java diff --git a/api/src/main/java/com/wansensoft/api/config/MybatisPlusConfig.java b/api/src/main/java/com/wansensoft/api/config/MybatisPlusConfig.java new file mode 100644 index 00000000..77fa1a0e --- /dev/null +++ b/api/src/main/java/com/wansensoft/api/config/MybatisPlusConfig.java @@ -0,0 +1,156 @@ +package com.wansensoft.api.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor; +import com.wansensoft.utils.Tools; +import jakarta.servlet.http.HttpServletRequest; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.LongValue; +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(HttpServletRequest request) { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); + interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new TenantLineHandler() { + @Override + public Expression getTenantId() { + String token = request.getHeader("X-Access-Token"); + Long tenantId = Tools.getTenantIdByToken(token); + if (tenantId!=0L) { + return new LongValue(tenantId); + } else { + //超管 + return null; + } + } + + // 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件 + @Override + public boolean ignoreTable(String tableName) { + //获取开启状态 + boolean res = true; + String token = request.getHeader("X-Access-Token"); + Long tenantId = Tools.getTenantIdByToken(token); + if (tenantId!=0L) { + // 这里可以判断是否过滤表 + if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName) + || "jsh_user_business".equals(tableName) || "jsh_function".equals(tableName) + || "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) { + res = true; + } else { + res = false; + } + } + return res; + } + })); + + + // 如果用了分页插件注意先 add TenantLineInnerInterceptor 再 add PaginationInnerInterceptor + // 用了分页插件必须设置 MybatisConfiguration#useDeprecatedExecutor = false + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } + +// @Bean +// public PaginationInnerInterceptor paginationInterceptor(HttpServletRequest request) { +// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); +// +// PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(); +// List sqlParserList = new ArrayList<>(); +// TenantSqlParser tenantSqlParser = new TenantSqlParser(); +// tenantSqlParser.setTenantHandler(new TenantHandler() { +// @Override +// public Expression getTenantId() { +// String token = request.getHeader("X-Access-Token"); +// Long tenantId = Tools.getTenantIdByToken(token); +// if (tenantId!=0L) { +// return new LongValue(tenantId); +// } else { +// //超管 +// return null; +// } +// } +// +// @Override +// public String getTenantIdColumn() { +// return "tenant_id"; +// } +// +// @Override +// public boolean doTableFilter(String tableName) { +// //获取开启状态 +// Boolean res = true; +// String token = request.getHeader("X-Access-Token"); +// Long tenantId = Tools.getTenantIdByToken(token); +// if (tenantId!=0L) { +// // 这里可以判断是否过滤表 +// if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName) +// || "jsh_user_business".equals(tableName) || "jsh_function".equals(tableName) +// || "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) { +// res = true; +// } else { +// res = false; +// } +// } +// return res; +// } +// }); +// +// sqlParserList.add(tenantSqlParser); +// paginationInterceptor.setSqlParserList(sqlParserList); +// paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() { +// @Override +// public boolean doFilter(MetaObject metaObject) { +// MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject); +// // 过滤自定义查询此时无租户信息约束出现 +// if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserByWeixinOpenId".equals(ms.getId())) { +// return true; +// } else if ("com.jsh.erp.datasource.mappers.UserMapperEx.updateUserWithWeixinOpenId".equals(ms.getId())) { +// return true; +// } else if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())) { +// return true; +// } else if ("com.jsh.erp.datasource.mappers.UserMapperEx.disableUserByLimit".equals(ms.getId())) { +// return true; +// } else if ("com.jsh.erp.datasource.mappers.RoleMapperEx.getRoleWithoutTenant".equals(ms.getId())) { +// return true; +// } else if ("com.jsh.erp.datasource.mappers.LogMapperEx.insertLogWithUserId".equals(ms.getId())) { +// return true; +// } +// return false; +// } +// }); +// return paginationInterceptor; +// } + + /** + * 相当于顶部的: + * {@code @MapperScan("com.wansensoft.erp.datasource.mappers*")} + * 这里可以扩展,比如使用配置文件来配置扫描Mapper的路径 + */ +// @Bean +// public MapperScannerConfigurer mapperScannerConfigurer() { +// MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer(); +// scannerConfigurer.setBasePackage("com.wansensoft.mappers*"); +// return scannerConfigurer; +// } + + /** + * 性能分析拦截器,不建议生产使用 + */ +// @Bean +// public PerformanceInterceptor performanceInterceptor(){ +// return new PerformanceInterceptor(); +// } + +} diff --git a/api/src/main/java/com/wansensoft/api/config/PluginConfiguration.java b/api/src/main/java/com/wansensoft/api/config/PluginConfiguration.java new file mode 100644 index 00000000..2cfe2ef3 --- /dev/null +++ b/api/src/main/java/com/wansensoft/api/config/PluginConfiguration.java @@ -0,0 +1,71 @@ +//package com.wansensoft.api.config; +// +//import com.gitee.starblues.core.RuntimeMode; +//import com.gitee.starblues.integration.DefaultIntegrationConfiguration; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.boot.context.properties.ConfigurationProperties; +//import org.springframework.stereotype.Component; +///** +// * +// */ +//@Component +//@ConfigurationProperties(prefix = "plugin") +//public class PluginConfiguration extends DefaultIntegrationConfiguration { +// /** +// * 运行模式 +// * 开发环境: development、dev +// * 生产/部署 环境: deployment、prod +// */ +// @Value("${runMode:dev}") +// private String runMode; +// +// @Value("${pluginPath:plugins}") +// private String pluginPath; +// +// @Value("${pluginConfigFilePath:pluginConfigs}") +// private String pluginConfigFilePath; +// +// @Override +// public RuntimeMode environment() { +// return RuntimeMode.byName(runMode); +// } +// +// @Override +// public String mainPackage() { +// return null; +// } +// +// public String getRunMode() { +// return runMode; +// } +// +// public void setRunMode(String runMode) { +// this.runMode = runMode; +// } +// +// +// public String getPluginPath() { +// return pluginPath; +// } +// +// public void setPluginPath(String pluginPath) { +// this.pluginPath = pluginPath; +// } +// +// public String getPluginConfigFilePath() { +// return pluginConfigFilePath; +// } +// +// public void setPluginConfigFilePath(String pluginConfigFilePath) { +// this.pluginConfigFilePath = pluginConfigFilePath; +// } +// +// @Override +// public String toString() { +// return "PluginArgConfiguration{" + +// "runMode='" + runMode + '\'' + +// ", pluginPath='" + pluginPath + '\'' + +// ", pluginConfigFilePath='" + pluginConfigFilePath + '\'' + +// '}'; +// } +//} diff --git a/api/src/main/java/com/wansensoft/api/config/Swagger2Config.java b/api/src/main/java/com/wansensoft/api/config/Swagger2Config.java new file mode 100644 index 00000000..fb4dd2e8 --- /dev/null +++ b/api/src/main/java/com/wansensoft/api/config/Swagger2Config.java @@ -0,0 +1,44 @@ +package com.wansensoft.api.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * 插件集成配置 + * + * @author jishenghua + * @version 1.0 + */ +@Configuration +@EnableSwagger2 +public class Swagger2Config { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(this.apiInfo()) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("WanSen ERP Restful Api") + .description("WanSen ERP接口描述") + .termsOfServiceUrl("http://127.0.0.1") + .contact(new Contact("WanSen ERP", "", "")) + .version("1.0.1") + .build(); + } + +} From c5e32fe2e4d6e0f618506cc8bafed6758b442ce2 Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 6 Sep 2023 00:31:53 +0800 Subject: [PATCH 7/7] update ComponentScan --- api/src/main/java/com/wansensoft/api/ErpApplication.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/wansensoft/api/ErpApplication.java b/api/src/main/java/com/wansensoft/api/ErpApplication.java index 9f8973ec..613478da 100644 --- a/api/src/main/java/com/wansensoft/api/ErpApplication.java +++ b/api/src/main/java/com/wansensoft/api/ErpApplication.java @@ -13,7 +13,8 @@ @EnableScheduling @MapperScan("com.wansensoft.mappers") -@SpringBootApplication(scanBasePackages = {"com.wansensoft"}) +@ComponentScan("com.wansensoft") +@SpringBootApplication public class ErpApplication { public static void main(String[] args) throws IOException { @@ -23,4 +24,5 @@ public static void main(String[] args) throws IOException { + environment.getProperty("server.port") + "/wansenerp/doc.html"); System.out.println("您还需启动前端服务,启动命令:yarn run serve 或 npm run serve,测试用户:wansenerp,密码:123456"); } + }