| | |
| | | package com.lf.server.controller.data; |
| | | |
| | | |
| | | import com.lf.server.controller.BaseController; |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.service.data.DictService; |
| | |
| | | * @author SWS + WWW |
| | | * @date 2022-09.26 |
| | | */ |
| | | @Api(tags = "字典管理") |
| | | @Api(tags = "数据管理\\字典管理") |
| | | @RestController |
| | | @RequestMapping("/dict") |
| | | public class DictController extends BaseController { |
| | | @Autowired |
| | | DictService dictService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "tab", value = "表名", dataType = "String", paramType = "query", required = false, example = "sys_dict") |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @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") |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<DictEntity>> selectByPage(String tab, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 0) { |
| | | return fail("分页数小于1或分页索引小于0", null); |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | List<DictEntity> rs = dictService.selectByPage(tab, pageSize, pageSize * pageIndex); |
| | | List<DictEntity> rs = dictService.selectByPage(tab, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @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") |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @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); |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = dictService.selectCount(tab); |
| | |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<DictEntity> rs = dictService.selectByPage(tab, pageSize, pageSize * pageIndex); |
| | | List<DictEntity> rs = dictService.selectByPage(tab, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @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) { |
| | | public ResponseMsg<Integer> insertDict(@RequestBody DictEntity dictEntity) { |
| | | try { |
| | | int count = dictService.insertDict(dictEntity); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入多条字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dictEntity", value = "字典实体类集合", dataType = "List<DictEntity>", paramType = "body", example = "") |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "删除一条字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "字典ID", dataType = "Integer", paramType = "query", example = "1") |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @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) { |
| | | public ResponseMsg<Integer> deleteDicts(@RequestParam List<Integer> ids) { |
| | | try { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return fail("id数组不能为空", -1); |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @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) { |
| | | public ResponseMsg<Integer> updateDict(@RequestBody DictEntity dictEntity) { |
| | | try { |
| | | int count = dictService.updateDict(dictEntity); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "字典ID", dataType = "Integer", paramType = "query", example = "1") |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询所有字典") |
| | | @GetMapping(value = "/selectDictAll") |
| | | public ResponseMsg<List<DictEntity>> selectDictAll() { |
| | |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询字典中的所有表名") |
| | | @GetMapping(value = "/selectDictTab") |
| | | public ResponseMsg<List<DictEntity>> selectDictTab() { |