From 0841189aa3e92f0d3d0263ba1923a5c2e88a0b42 Mon Sep 17 00:00:00 2001 From: sws <15810472099@163.com> Date: 星期二, 27 九月 2022 14:32:18 +0800 Subject: [PATCH] 11 --- src/main/java/com/lf/server/controller/data/DictController.java | 215 +++++++++-- pom.xml | 11 src/main/java/com/lf/server/controller/data/MenusController.java | 132 +++++- /dev/null | 18 - src/main/java/com/lf/server/config/SwaggerConfig.java | 23 + src/main/java/com/lf/server/controller/data/DepController.java | 136 +++++- src/main/java/com/lf/server/controller/data/StyleController.java | 194 ++++++++-- src/main/java/com/lf/server/entity/all/ResponseMsg.java | 107 +++++ src/main/java/com/lf/server/controller/BaseController.java | 38 ++ src/main/java/com/lf/server/controller/data/DirController.java | 112 ++++- src/main/java/com/lf/server/config/ShiroConfig.java | 2 src/main/java/com/lf/server/entity/all/HttpStatus.java | 86 ++++ src/main/resources/application.yml | 3 13 files changed, 865 insertions(+), 212 deletions(-) diff --git a/pom.xml b/pom.xml index e530f2a..63b73f7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>2.7.3</version> + <version>2.3.0.RELEASE</version> <relativePath/> </parent> @@ -131,17 +131,22 @@ <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.1</version> + </dependency> <!--swagger--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> - <version>3.0.0</version> + <version>2.9.2</version> </dependency> <!--swagger ui--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> - <version>3.0.0</version> + <version>2.9.2</version> </dependency> <!--<dependency> <groupId>org.thymeleaf.extras</groupId> diff --git a/src/main/java/com/lf/server/config/ShiroConfig.java b/src/main/java/com/lf/server/config/ShiroConfig.java index 6aa922b..2e87af7 100644 --- a/src/main/java/com/lf/server/config/ShiroConfig.java +++ b/src/main/java/com/lf/server/config/ShiroConfig.java @@ -24,7 +24,7 @@ * @author */ @SuppressWarnings("ALL") -@Configuration +//@Configuration public class ShiroConfig { @ConfigurationProperties(prefix = "spring.datasource") @Bean diff --git a/src/main/java/com/lf/server/config/SwaggerConfig.java b/src/main/java/com/lf/server/config/SwaggerConfig.java index f4fab0a..b5d9fd2 100644 --- a/src/main/java/com/lf/server/config/SwaggerConfig.java +++ b/src/main/java/com/lf/server/config/SwaggerConfig.java @@ -1,6 +1,13 @@ package com.lf.server.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.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; /** @@ -10,5 +17,19 @@ @Configuration @EnableSwagger2 public class SwaggerConfig { - // + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("com.lf.server.controller")) + .paths(PathSelectors.any()).build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("Spring Boot鎺ュ彛API") + .description("Spring Boot绀轰緥鎺ュ彛API") + .version("1.0").build(); + } } diff --git a/src/main/java/com/lf/server/config/WebMVCConfig.java b/src/main/java/com/lf/server/config/WebMVCConfig.java deleted file mode 100644 index 15daa78..0000000 --- a/src/main/java/com/lf/server/config/WebMVCConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.lf.server.config; - -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -/** - * WebMVCConfig - * @author www - */ -public class WebMVCConfig extends WebMvcConfigurerAdapter { - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("swagger-ui.html") - .addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**") - .addResourceLocations("classpath:/META-INF/resources/webjars/"); - } -} diff --git a/src/main/java/com/lf/server/controller/BaseController.java b/src/main/java/com/lf/server/controller/BaseController.java new file mode 100644 index 0000000..402979a --- /dev/null +++ b/src/main/java/com/lf/server/controller/BaseController.java @@ -0,0 +1,38 @@ +package com.lf.server.controller; + +import com.lf.server.entity.all.HttpStatus; +import com.lf.server.entity.all.ResponseMsg; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Controller鍩虹被 + * @author www + */ +public class BaseController { + public Log log = LogFactory.getLog(getClass()); + + public <T> ResponseMsg<T> success(T result) { + return new ResponseMsg<T>(HttpStatus.OK, result); + } + + public <T> ResponseMsg<T> success(String msg, T result) { + return new ResponseMsg<T>(HttpStatus.OK, msg, result); + } + + public <T> ResponseMsg<T> success(int count, T result) { + return new ResponseMsg<T>(HttpStatus.OK, count, result); + } + + public <T> ResponseMsg<T> success(String msg, int count, T result) { + return new ResponseMsg<T>(HttpStatus.OK, msg, count, result); + } + + public <T> ResponseMsg<T> fail(T result) { + return new ResponseMsg<T>(HttpStatus.ERROR, result); + } + + public <T> ResponseMsg<T> fail(String msg, T result) { + return new ResponseMsg<T>(HttpStatus.ERROR, msg, result); + } +} diff --git a/src/main/java/com/lf/server/controller/data/DepController.java b/src/main/java/com/lf/server/controller/data/DepController.java index 2782eb1..7fcbbf0 100644 --- a/src/main/java/com/lf/server/controller/data/DepController.java +++ b/src/main/java/com/lf/server/controller/data/DepController.java @@ -1,7 +1,14 @@ package com.lf.server.controller.data; +import com.lf.server.controller.BaseController; +import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.data.DepEntity; +import com.lf.server.entity.data.DictEntity; import com.lf.server.service.data.DepService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -13,53 +20,116 @@ * @date 2022-09-23 */ +@Api(tags = "缁勭粐鏈烘瀯") @RestController @RequestMapping("/dep") -public class DepController { +public class DepController extends BaseController { @Autowired DepService depService; - @RequestMapping(value ="/insertDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertDep(DepEntity depEntity){ + @ApiOperation(value = "鎻掑叆鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DepEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.data.DepEntity", paramType = "body", example = "") + }) + @RequestMapping(value = "/insertDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insertDep(DepEntity depEntity) { + try { + int count = depService.insertDep(depEntity); - return depService.insertDep(depEntity); - } - - @RequestMapping(value ="/insertDes", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertDes(@RequestBody List<DepEntity> depEntity){ - - return depService.insertDeps(depEntity); - } - @ResponseBody - @RequestMapping(value ="/deleteDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteDep(int id){ - return depService.deleteDep(id); - } - - - @RequestMapping(value ="/deleteDeps", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteDeps(@RequestBody List<Integer> ids){ - if(!ids.isEmpty()){ - return depService.deleteDeps(ids); - }else { - return -1; + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); } } + @ApiOperation(value = "鎻掑叆澶氭潯鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DepEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.data.DepEntity", paramType = "body", example = "") + }) + @RequestMapping(value = "/insertDes", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insertDes(@RequestBody List<DepEntity> depEntity) { + try { + int count = depService.insertDeps(depEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteDep") + public ResponseMsg<Integer> deleteDep(int id) { + try { + int count = depService.deleteDep(id); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎澶氭潯鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteDeps") + public ResponseMsg<Integer> deleteDeps(List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + int count = depService.deleteDeps(ids); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鏇存柊涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "depEntity", value = "涓婚敭ID闆嗗悎", dataType = "DepEntity", paramType = "body", example = "") + }) @ResponseBody - @RequestMapping(value ="/updateDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer updateDep(DepEntity depEntity){ - return depService.updateDep(depEntity); + @RequestMapping(value = "/updateDep", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> updateDep(DepEntity depEntity) { + try { + int count = depService.updateDep(depEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } - @GetMapping(value ="/selectDep") - public DepEntity selectDep(int id){ - return depService.selectDep(id); + @ApiOperation(value = "鏍规嵁ID鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectDep") + public ResponseMsg<DepEntity> selectDep(int id) { + try { + DepEntity de = depService.selectDep(id); + return success(de); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } - @GetMapping(value ="/selectDepAll") - public List<DepEntity> selectDepAll( ){ - return depService.selectDepAll( ); + @ApiOperation(value = "鏌ヨ鎵�鏈夋暟鎹�") + @GetMapping(value = "/selectDepAll") + public ResponseMsg<List<DepEntity>> selectDepAll() { + try { + List<DepEntity> list = depService.selectDepAll(); + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } } diff --git a/src/main/java/com/lf/server/controller/data/DictController.java b/src/main/java/com/lf/server/controller/data/DictController.java index c61167f..c4ad7af 100644 --- a/src/main/java/com/lf/server/controller/data/DictController.java +++ b/src/main/java/com/lf/server/controller/data/DictController.java @@ -1,6 +1,8 @@ package com.lf.server.controller.data; +import com.lf.server.controller.BaseController; +import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.data.DictEntity; import com.lf.server.service.data.DictService; import io.swagger.annotations.Api; @@ -14,87 +16,194 @@ /** * 瀛楀吀绠$悊 - * @author sws + * @author SWS + WWW * @date 2022-09.26 */ -@Api(tags = "DictController", description = "瀛楀吀绠$悊") +@Api(tags = "瀛楀吀绠$悊") @RestController -@RequestMapping("/Dict") -public class DictController { +@RequestMapping("/dict") +public class DictController extends BaseController { @Autowired DictService dictService; - @ApiOperation(value = "鏌ヨ璁板綍鏁�", notes = "鏌ヨ璁板綍鏁�") + @ApiOperation(value = "鏌ヨ璁板綍鏁�") @ApiImplicitParams({ @ApiImplicitParam(name = "tab", value = "琛ㄥ悕", dataType = "String", paramType = "query", required = false, example = "sys_dict") }) @GetMapping({"/selectCount"}) - public Integer selectCount(String tab) { - return dictService.selectCount(tab); + public ResponseMsg<Integer> selectCount(String tab) { + try { + int count = dictService.selectCount(tab); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } - @ApiOperation(value = "鍒嗛〉鏌ヨ", notes = "鍒嗛〉鏌ヨ") + @ApiOperation(value = "鍒嗛〉鏌ヨ") @ApiImplicitParams({ - @ApiImplicitParam(name = "tab", value = "琛ㄥ悕", dataType = "String", paramType = "query", required = false, example = "sys_dict"), - @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", required = false, example = "10"), - @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉绱㈠紩锛堜粠0寮�濮嬶級", dataType = "Integer", paramType = "query", required = false, example = "0") + @ApiImplicitParam(name = "tab", value = "琛ㄥ悕", dataType = "String", paramType = "query", example = "sys_dict"), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉绱㈠紩锛堜粠0寮�濮嬶級", dataType = "Integer", paramType = "query", example = "0") }) @GetMapping(value = "/selectByPage") - public List<DictEntity> selectByPage(String tab, Integer pageSize, Integer pageIndex) { - if (pageSize < 1 || pageIndex < 0) { - return null; - } + public ResponseMsg<List<DictEntity>> selectByPage(String tab, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 0) { + return fail("鍒嗛〉鏁板皬浜�1鎴栧垎椤电储寮曞皬浜�0", null); + } - return dictService.selectByPage(tab, pageSize, pageSize * pageIndex); - } + List<DictEntity> rs = dictService.selectByPage(tab, pageSize, pageSize * pageIndex); - @RequestMapping(value = "/insertDict", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertDict(DictEntity dictEntity) { - - return dictService.insertDict(dictEntity); - } - - @RequestMapping(value = "/insertDicts", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertDicts(@RequestBody List<DictEntity> dictEntity) { - - return dictService.insertDicts(dictEntity); - } - - @ResponseBody - @RequestMapping(value = "/deleteDict", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteStyle(int id) { - return dictService.deleteDict(id); - } - - - @RequestMapping(value = "/deleteDicts", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteDicts(@RequestBody List<Integer> ids) { - if (!ids.isEmpty()) { - return dictService.deleteDicts(ids); - } else { - return -1; + return success(rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); } } - @ResponseBody - @RequestMapping(value = "/updateDict", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer updateDict(DictEntity dictEntity) { - return dictService.updateDict(dictEntity); + @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @ApiImplicitParams({ + @ApiImplicitParam(name = "tab", value = "琛ㄥ悕", dataType = "String", paramType = "query", example = "sys_dict"), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉绱㈠紩锛堜粠0寮�濮嬶級", dataType = "Integer", paramType = "query", example = "0") + }) + @GetMapping(value = "/selectByPageAndCount") + public ResponseMsg<List<DictEntity>> selectByPageAndCount(String tab, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 0) { + return fail("鍒嗛〉鏁板皬浜�1鎴栧垎椤电储寮曞皬浜�0", null); + } + + int count = dictService.selectCount(tab); + if (count == 0) { + return success(0, null); + } + + List<DictEntity> rs = dictService.selectByPage(tab, pageSize, pageSize * pageIndex); + + return success(count, rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } + @ApiOperation(value = "鎻掑叆瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "dictEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.data.DictEntity", paramType = "body", example = "") + }) + @PostMapping(value = "/insertDict", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insertDict(DictEntity dictEntity) { + try { + int count = dictService.insertDict(dictEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鎻掑叆澶氭潯瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "dictEntity", value = "瀛楀吀瀹炰綋绫婚泦鍚�", dataType = "List<DictEntity>", paramType = "body", example = "") + }) + @PostMapping(value = "/insertDicts", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insertDicts(@RequestBody List<DictEntity> dictEntity) { + try { + int count = dictService.insertDicts(dictEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎涓�鏉″瓧鍏�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteDict") + public ResponseMsg<Integer> deleteDict(int id) { + try { + int count = dictService.deleteDict(id); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎澶氭潯瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "瀛楀吀ID闆嗗悎", dataType = "List<Integer>", paramType = "query", example = "1,2") + }) + @GetMapping(value = "/deleteDicts") + public ResponseMsg<Integer> deleteDicts(List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + int count = dictService.deleteDicts(ids); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鏇存柊涓�鏉″瓧鍏�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "dictEntity", value = "瀛楀吀ID闆嗗悎", dataType = "DictEntity", paramType = "body", example = "") + }) + @ResponseBody + @PostMapping(value = "/updateDict", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> updateDict(DictEntity dictEntity) { + try { + int count = dictService.updateDict(dictEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鏍规嵁ID鏌ヨ瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1") + }) @GetMapping(value = "/selectDict") - public DictEntity selectDict(int id) { - return dictService.selectDict(id); + public ResponseMsg<DictEntity> selectDict(int id) { + try { + DictEntity de = dictService.selectDict(id); + + return success(de); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } + @ApiOperation(value = "鏌ヨ鎵�鏈夊瓧鍏�") @GetMapping(value = "/selectDictAll") - public List<DictEntity> selectDictAll() { - return dictService.selectDictAll(); + public ResponseMsg<List<DictEntity>> selectDictAll() { + try { + List<DictEntity> list = dictService.selectDictAll(); + + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } - + @ApiOperation(value = "鏌ヨ瀛楀吀涓殑鎵�鏈夎〃鍚�") @GetMapping(value = "/selectDictTab") - public List<DictEntity> selectDictTab() { - return dictService.selectDictTab(); + public ResponseMsg<List<DictEntity>> selectDictTab() { + try { + List<DictEntity> list = dictService.selectDictTab(); + + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } } diff --git a/src/main/java/com/lf/server/controller/data/DirController.java b/src/main/java/com/lf/server/controller/data/DirController.java index d66fab8..536d063 100644 --- a/src/main/java/com/lf/server/controller/data/DirController.java +++ b/src/main/java/com/lf/server/controller/data/DirController.java @@ -1,7 +1,13 @@ package com.lf.server.controller.data; +import com.lf.server.controller.BaseController; +import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.data.DirEntity; import com.lf.server.service.data.DirService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -12,59 +18,101 @@ * @author sws * @date 2022-09-22 */ - +@Api(tags = "鐩綍绠$悊") @RestController @RequestMapping("/dir") -public class DirController { +public class DirController extends BaseController { @Autowired DirService dirService; + @ApiOperation(value = "鎻掑叆鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DirEntity", value = "鐩綍瀹炰綋绫�", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "") + }) @RequestMapping(value = "/insertDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertDir(DirEntity dirEntity) { + public ResponseMsg<Integer> insertDir(DirEntity dirEntity) { + try { + int count = dirService.insertDir(dirEntity); - return dirService.insertDir(dirEntity); + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } - + @ApiOperation(value = "鎻掑叆澶氭潯鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "DirEntity", value = "鐩綍瀹炰綋绫�", dataType = "com.lf.server.entity.data.DirEntity", paramType = "body", example = "") + }) @RequestMapping(value = "/insertDirs", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertDirs(@RequestBody List<DirEntity> dirEntity) { + public ResponseMsg<Integer> insertDirs(@RequestBody List<DirEntity> dirEntity) { + try { + int count = dirService.insertDirs(dirEntity); - return dirService.insertDirs(dirEntity); - } - - @ResponseBody - @RequestMapping(value = "/deleteDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteDir(int id) { - - return dirService.deleteDir(id); - } - - - @RequestMapping(value = "/deleteDirs", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteDirs(@RequestBody List<Integer> ids) { - - if (!ids.isEmpty()) { - - return dirService.deleteDirs(ids); - - } else { - - return -1; + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); } } - @ResponseBody - @RequestMapping(value = "/updateDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer updateDir(DirEntity dirEntity) { + @ApiOperation(value = "鍒犻櫎涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteDir") + public ResponseMsg<Integer> deleteDir(int id) { + try { + int count = dirService.deleteDir(id); - return dirService.updateDir(dirEntity); + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } + @ApiOperation(value = "鍒犻櫎澶氭潯鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "涓婚敭ID闆嗗悎", dataType = "List<Integer>", paramType = "query", example = "1,2") + }) + @GetMapping(value = "/deleteDirs") + public ResponseMsg<Integer> deleteDirs( List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + int count = dirService.deleteDirs(ids); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + @ApiOperation(value = "鏇存柊涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "dirEntity", value = "涓婚敭ID闆嗗悎", dataType = "DictEntity", paramType = "body", example = "") + }) + @ResponseBody + @RequestMapping(value = "/updateDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> updateDir(DirEntity dirEntity) { + try { + int count = dirService.updateDir(dirEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鏍规嵁ID鏌ヨ鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) @ResponseBody @RequestMapping(value = "/selectDir", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") public DirEntity selectDir(int id) { return dirService.selectDir(id); } - + @ApiOperation(value = "鏌ヨ鎵�鏈夋暟鎹�") @GetMapping(value = "/selectDirAll") public List<DirEntity> selectDirAll() { diff --git a/src/main/java/com/lf/server/controller/data/MenusController.java b/src/main/java/com/lf/server/controller/data/MenusController.java index 867341c..862ad01 100644 --- a/src/main/java/com/lf/server/controller/data/MenusController.java +++ b/src/main/java/com/lf/server/controller/data/MenusController.java @@ -1,7 +1,14 @@ package com.lf.server.controller.data; +import com.lf.server.controller.BaseController; +import com.lf.server.entity.all.ResponseMsg; +import com.lf.server.entity.data.DictEntity; import com.lf.server.entity.data.MenusEntity; import com.lf.server.service.data.MenusService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -13,54 +20,117 @@ * @date 2022-09-23 */ +@Api(tags= "鑿滃崟绠$悊") @RestController @RequestMapping("/Menu") -public class MenusController { +public class MenusController extends BaseController { @Autowired MenusService menuService; + @ApiOperation(value = "鎻掑叆涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "MenusEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.data.MenusEntity", paramType = "body", example = "") + }) @RequestMapping(value = "/insertMenu", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertMenu(MenusEntity menusEntity) { - - return menuService.insertMenu(menusEntity); - } - - @RequestMapping(value = "/insertMenus", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertMenus(@RequestBody List<MenusEntity> menusEntity) { - - return menuService.insertMenus(menusEntity); - } - - @ResponseBody - @RequestMapping(value = "/deleteMenu", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteMenu(int id) { - return menuService.deleteMenu(id); - } - - - @RequestMapping(value = "/deleteMenus", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteMenus(@RequestBody List<Integer> ids) { - if (!ids.isEmpty()) { - return menuService.deleteMenus(ids); - } else { - return -1; + public ResponseMsg<Integer> insertMenu(MenusEntity menusEntity) { + try { + int count = menuService.insertMenu(menusEntity); + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); } } + @ApiOperation(value = "鎻掑叆澶氭潯鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "MenusEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.data.MenusEntity", paramType = "body", example = "") + }) + @RequestMapping(value = "/insertMenus", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insertMenus(@RequestBody List<MenusEntity> menusEntity) { + try { + int count = menuService.insertMenus(menusEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteMenu") + public ResponseMsg<Integer> deleteMenu(int id) { + try { + int count = menuService.deleteMenu(id); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎澶氭潯鏁版嵁") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "涓婚敭ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteMenus") + public ResponseMsg<Integer> deleteMenus( List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + int count = menuService.deleteMenus(ids); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鏇存柊涓�鏉℃暟鎹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "MenusEntity", value = "鑿滃崟ID闆嗗悎", dataType = "MenusEntity", paramType = "body", example = "") + }) @ResponseBody @RequestMapping(value = "/updateMenu", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer updateMenu(MenusEntity menusEntity) { - return menuService.updateMenu(menusEntity); + public ResponseMsg<Integer> updateMenu(MenusEntity menusEntity) { + try { + int count = menuService.updateMenu(menusEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } + @ApiOperation(value = "鏍规嵁ID鏌ヨ瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1") + }) @GetMapping(value = "/selectMenu") - public MenusEntity selectMenu(int id) { - return menuService.selectMenu(id); + public ResponseMsg<MenusEntity> selectMenu(int id) { + try { + MenusEntity menusEntity = menuService.selectMenu(id); + + return success(menusEntity); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } + @ApiOperation(value = "鏌ヨ鎵�鏈夊瓧鍏�") @GetMapping(value = "/selectMenuAll") - public List<MenusEntity> selectMenuAll() { - return menuService.selectMenuAll(); + public ResponseMsg<List<MenusEntity>> selectMenuAll() { + try { + List<MenusEntity> list = menuService.selectMenuAll(); + + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } } \ No newline at end of file diff --git a/src/main/java/com/lf/server/controller/data/StyleController.java b/src/main/java/com/lf/server/controller/data/StyleController.java index e8fec4d..acb6d95 100644 --- a/src/main/java/com/lf/server/controller/data/StyleController.java +++ b/src/main/java/com/lf/server/controller/data/StyleController.java @@ -1,8 +1,14 @@ package com.lf.server.controller.data; +import com.lf.server.controller.BaseController; +import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.data.DictEntity; import com.lf.server.entity.data.StyleEntity; import com.lf.server.service.data.StyleService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -13,68 +19,182 @@ * @author sws * @date 2022-09.26 */ - +@Api(tags = "鏍峰紡绠$悊") @RestController @RequestMapping("/Style") -public class StyleController { +public class StyleController extends BaseController { @Autowired StyleService styleService; + @ApiOperation(value = "鏌ヨ璁板綍鏁�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", required = false, example = "sys_style") + }) @GetMapping({"/selectCount"}) - public Integer selectCount(String name) { - return styleService.selectCount(name); + public ResponseMsg<Integer> selectCount(String name) { + try { + int count = styleService.selectCount(name); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } + @ApiOperation(value = "鍒嗛〉鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", required = false, example = "sys_style"), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉绱㈠紩锛堜粠0寮�濮嬶級", dataType = "Integer", paramType = "query", example = "0") + }) @GetMapping(value = "/selectByPage") - public List<StyleEntity> selectByPage(String name, Integer pageSize, Integer pageIndex) { - if (pageSize < 1 || pageIndex < 0) { - return null; + public ResponseMsg<List<StyleEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 0) { + return fail("鍒嗛〉鏁板皬浜�1鎴栧垎椤电储寮曞皬浜�0", null); + } + + List<StyleEntity> rs = styleService.selectByPage(name, pageSize, pageSize * pageIndex); + + return success(rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); } - return styleService.selectByPage(name, pageSize, pageSize * pageIndex); } + @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = "sys_style"), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉绱㈠紩锛堜粠0寮�濮嬶級", dataType = "Integer", paramType = "query", example = "0") + }) + + @GetMapping(value = "/selectByPageAndCount") + public ResponseMsg<List<StyleEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 0) { + return fail("鍒嗛〉鏁板皬浜�1鎴栧垎椤电储寮曞皬浜�0", null); + } + + int count = styleService.selectCount(name); + if (count == 0) { + return success(0, null); + } + + List<StyleEntity> rs = styleService.selectByPage(name, pageSize, pageSize * pageIndex); + + return success(count, rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @ApiOperation(value = "鎻掑叆瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "StyleEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "List<StyleEntity>", paramType = "body", example = "") + }) @RequestMapping(value = "/insertStyle", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertStyle(StyleEntity styleEntity) { + public ResponseMsg<Integer> insertStyle(StyleEntity styleEntity) { + try { + int count = styleService.insertStyle(styleEntity); - return styleService.insertStyle(styleEntity); - } - - @RequestMapping(value = "/insertStyles", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer insertStyles(@RequestBody List<StyleEntity> styleEntity) { - - return styleService.insertStyles(styleEntity); - } - - @ResponseBody - @RequestMapping(value = "/deleteStyle", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteStyle(int id) { - return styleService.deleteStyle(id); - } - - - @RequestMapping(value = "/deleteStyles", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer deleteStyles(@RequestBody List<Integer> ids) { - if (!ids.isEmpty()) { - return styleService.deleteStyles(ids); - } else { - return -1; + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); } } + @ApiOperation(value = "鎻掑叆澶氭潯瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "StyleEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.data.StyleEntity", paramType = "body", example = "") + }) + @RequestMapping(value = "/insertStyles", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insertStyles(@RequestBody List<StyleEntity> styleEntity) { + try { + int count = styleService.insertStyles(styleEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎涓�鏉″瓧鍏�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteStyle") + public ResponseMsg<Integer> deleteStyle(int id) { + try { + int count = styleService.deleteStyle(id); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鍒犻櫎澶氭潯瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/deleteStyles") + public ResponseMsg<Integer> deleteStyles( List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + int count = styleService.deleteStyles(ids); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } + } + + @ApiOperation(value = "鏇存柊涓�鏉″瓧鍏�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "styleEntity", value = "瀛楀吀ID闆嗗悎", dataType = "StyleEntity", paramType = "body", example = "") + }) @ResponseBody @RequestMapping(value = "/updateStyle", method = RequestMethod.POST, produces = "application/json; charset=UTF-8") - public Integer updateStyle(StyleEntity styleEntity) { - return styleService.updateStyle(styleEntity); + public ResponseMsg<Integer> updateStyle(StyleEntity styleEntity) { + try { + int count = styleService.updateStyle(styleEntity); + + return success(count); + } catch (Exception ex) { + return fail(ex.getMessage(), -1); + } } + @ApiOperation(value = "鏍规嵁ID鏌ヨ瀛楀吀") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1") + }) @GetMapping(value = "/selectStyle") - public StyleEntity selectStyle(int id) { - return styleService.selectStyle(id); + public ResponseMsg<StyleEntity> selectStyle(int id) { + try { + StyleEntity styleEntity = styleService.selectStyle(id); + ; + + return success(styleEntity); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } + @ApiOperation(value = "鏌ヨ鎵�鏈夊瓧鍏�") @GetMapping(value = "/selectStyleAll") - public List<StyleEntity> selectStyleAll() { - return styleService.selectStyleAll(); + public ResponseMsg<List<StyleEntity>> selectStyleAll() { + + try { + List<StyleEntity> list = styleService.selectStyleAll(); + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } } } \ No newline at end of file diff --git a/src/main/java/com/lf/server/entity/all/HttpStatus.java b/src/main/java/com/lf/server/entity/all/HttpStatus.java new file mode 100644 index 0000000..0651d1a --- /dev/null +++ b/src/main/java/com/lf/server/entity/all/HttpStatus.java @@ -0,0 +1,86 @@ +package com.lf.server.entity.all; + +/** + * HttpStatus + * @author + */ +public enum HttpStatus { + OK(200,"璇锋眰鎴愬姛"), + + BAD_REQUEST(400,"璇锋眰鏃犳晥"), + + UNAUTHORIZED(401,"鏈粡鎺堟潈璁块棶"), + + NOT_FOUND(404,"鏈嶅姟璇锋眰鏈壘鍒�"), + + NODATA_FOUND(404404,"鏁版嵁鏈壘鍒�"), + + ERROR(500,"绯荤粺閿欒"), + + UNIQUE_ERROR(500100,"鏁版嵁鍞竴鎬ч敊璇�,瀛樺湪閲嶅鐨勬暟鎹�"), + + VALIDATE_ERROR(500101,"鍙傛暟鏍¢獙閿欒"), + + TOKEN_ERROR(500102,"token閿欒"), + + NO_LOGIN_ERROR(500104,"鐢ㄦ埛鏈櫥闄�"), + + LOGIN_ERROR(500105,"鐢ㄦ埛鐧婚檰澶辫触"), + + NO_AUTH_ERROR(500106,"鏃犳潈闄愯闂�"), + + LOGIN_USER_ERROR(500107,"鐢ㄦ埛鍚嶉敊璇�"), + + LOGIN_PWD_ERROR(500108,"鐢ㄦ埛瀵嗙爜閿欒"), + + USER_LOCK_ERROR(500109,"鐢ㄦ埛琚攣瀹�"), + + PWD_NONSTANDARD(500111,"鐢ㄦ埛瀵嗙爜涓嶅悎瑙勮寖"), + + ACCOUNT_TYPE_ERROR(500112,"鐢ㄦ埛璐﹀彿绫诲瀷涓嶅尮閰�"), + + EMAIL_NONSTANDARD(500113,"閭鏍煎紡閿欒锛�"), + + PHONE_NONSTANDARD(500114,"鐢佃瘽鏍煎紡閿欒锛�"), + + DATA_NO_AUTH_ERROR(500115,"鏁版嵁涓嶅湪鏌ヨ鑼冨洿鍐�"), + + LOGIN_PWD_EXPIRE(500116,"瀵嗙爜杩囨湡"), + + WORK_FLOW_SUBMIT_ERROR(500200,"娴佺▼鎻愪氦閿欒"), + + WORK_FLOW_APPROVAL_ERROR(500201,"娴佺▼瀹℃牳閿欒"), + + WORK_FLOW_REJECT_ERROR(500202,"娴佺▼閫�鍥為敊璇�"), + + WORK_FLOW_CANCEL_ERROR(500203,"娴佺▼鍙栨秷閿欒"), + + WORK_FLOW_NO_EXIST(500204,"涓嶅瓨鍦ㄦ祦绋嬪巻鍙茶褰�"), + + EMAIL_CONFIG_ERROR(500300,"閭鏈厤缃�"), + + JST_CONFIG_ERROR(500301,"鍗虫椂閫氭湭閰嶇疆"), + + JST_ACCOUNT_ERROR(500302,"鍗虫椂璐﹀彿閿欒"), + + SECRET_KEY_ERROR(500304,"瀵嗛挜鏈厤缃敊璇�"), + + DB_DEL_NODATA_ERROR(500401,"鍒犻櫎0鏉℃暟鎹�"); + + private HttpStatus(int value, String msg) { + this.value = value; + this.msg = msg; + } + + private int value; + + private String msg; + + public int getValue() { + return value; + } + + public String getMsg() { + return msg; + } +} diff --git a/src/main/java/com/lf/server/entity/all/ResponseMsg.java b/src/main/java/com/lf/server/entity/all/ResponseMsg.java new file mode 100644 index 0000000..d687d36 --- /dev/null +++ b/src/main/java/com/lf/server/entity/all/ResponseMsg.java @@ -0,0 +1,107 @@ +package com.lf.server.entity.all; + +/** + * 鍝嶅簲娑堟伅 + * @author www + * @param <T> + */ +public class ResponseMsg<T> { + public ResponseMsg() { + this.time = System.currentTimeMillis(); + } + + public ResponseMsg(HttpStatus code, T result) { + this.code = code.getValue(); + this.msg = this.code == 200 ? "鎴愬姛" : "澶辫触"; + this.result = result; + this.time = System.currentTimeMillis(); + } + + public ResponseMsg(HttpStatus code, String msg, T result) { + this.code = code.getValue(); + this.msg = msg; + this.result = result; + this.time = System.currentTimeMillis(); + } + + public ResponseMsg(int code, String msg, T result, long time) { + this.code = code; + this.msg = msg; + this.result = result; + this.time = time; + } + + public ResponseMsg(HttpStatus code, int count, T result) { + this.code = code.getValue(); + this.msg = this.code == 200 ? "鎴愬姛" : "澶辫触"; + this.count = count; + this.result = result; + this.time = System.currentTimeMillis(); + } + + public ResponseMsg(HttpStatus code, String msg, int count, T result) { + this.code = code.getValue(); + this.msg = msg; + this.count = count; + this.result = result; + this.time = System.currentTimeMillis(); + } + + public ResponseMsg(int code, String msg, int count, T result, long time) { + this.code = code; + this.msg = msg; + this.count = count; + this.result = result; + this.time = time; + } + + private int code; + + private String msg; + + private int count; + + private T result; + + private long time; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public T getResult() { + return result; + } + + public void setResult(T result) { + this.result = result; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d2c3d6c..254ec56 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,9 +7,6 @@ context-path: /land spring: - mvc: - pathmatch: - matching-strategy: ant_path_matcher datasource: username : postgres password: postgres -- Gitblit v1.9.3