From 8b0e6e11b6c7d4906907501c41dc893dcfcf5ae2 Mon Sep 17 00:00:00 2001 From: zhaonengzhi Date: Tue, 17 Aug 2021 19:30:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9C=81=E4=BB=BD?= =?UTF-8?q?=E7=AE=A1=E7=90=86,=20=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BA=E5=A4=9A=E6=9D=A1=E4=BB=B6=20Signed?= =?UTF-8?q?-off-by:=20zhaonengzhi=20=20=E5=B7=B2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=20=20=20=20=20=20=20src/main/java/com/fc/?= =?UTF-8?q?v2/common/base/BaseController.java=20=E5=B7=B2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=20=20=20=20=20=20=20src/main/java/com/fc/v2/common?= =?UTF-8?q?/domain/ResultTable.java=20=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20?= =?UTF-8?q?=20=20=20=20=20src/main/java/com/fc/v2/controller/admin/SysArea?= =?UTF-8?q?Controller.java=20=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20=20=20=20?= =?UTF-8?q?=20=20src/main/java/com/fc/v2/controller/admin/SysCityControlle?= =?UTF-8?q?r.java=20=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20=20=20=20=20=20src?= =?UTF-8?q?/main/java/com/fc/v2/controller/admin/SysProvinceController.jav?= =?UTF-8?q?a=20=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20=20=20=20=20=20src/main?= =?UTF-8?q?/java/com/fc/v2/controller/admin/SysStreetController.java=20?= =?UTF-8?q?=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20=20=20=20=20=20src/main/jav?= =?UTF-8?q?a/com/fc/v2/model/custom/Tablepar.java=20=E5=B7=B2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=20=20=20=20=20=20=20src/main/resources/templates/a?= =?UTF-8?q?dmin/province/sysArea/list.html=20=E5=B7=B2=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20=20=20=20=20=20=20=20src/main/resources/templates/admin/prov?= =?UTF-8?q?ince/sysCity/list.html=20=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20?= =?UTF-8?q?=20=20=20=20=20src/main/resources/templates/admin/province/sysP?= =?UTF-8?q?rovince/list.html=20=E5=B7=B2=E4=BF=AE=E6=94=B9=20=20=20=20=20?= =?UTF-8?q?=20=20=20src/main/resources/templates/admin/province/sysStreet/?= =?UTF-8?q?list.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fc/v2/common/base/BaseController.java | 208 +++++++++++------- .../com/fc/v2/common/domain/ResultTable.java | 31 ++- .../controller/admin/SysAreaController.java | 58 ++--- .../controller/admin/SysCityController.java | 54 ++--- .../admin/SysProvinceController.java | 54 ++--- .../controller/admin/SysStreetController.java | 52 ++--- .../java/com/fc/v2/model/custom/Tablepar.java | 133 +++++++---- .../admin/province/sysArea/list.html | 20 +- .../admin/province/sysCity/list.html | 18 +- .../admin/province/sysProvince/list.html | 18 +- .../admin/province/sysStreet/list.html | 18 +- 11 files changed, 371 insertions(+), 293 deletions(-) diff --git a/src/main/java/com/fc/v2/common/base/BaseController.java b/src/main/java/com/fc/v2/common/base/BaseController.java index d6b492e..b943759 100644 --- a/src/main/java/com/fc/v2/common/base/BaseController.java +++ b/src/main/java/com/fc/v2/common/base/BaseController.java @@ -5,174 +5,216 @@ import com.fc.v2.common.conf.V2Config; import com.fc.v2.common.domain.AjaxResult; import com.fc.v2.common.domain.ResuTree; import com.fc.v2.common.domain.ResultTable; +import com.fc.v2.model.custom.Tablepar; import com.fc.v2.service.*; +import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; + import java.text.SimpleDateFormat; import java.util.Date; /** * web层通用数据处理 -* @ClassName: BaseController -* @author fuce -* @date 2018年8月18日 -* + * + * @author fuce + * @ClassName: BaseController + * @date 2018年8月18日 */ @Controller -public class BaseController -{ - //系统用户 - @Autowired - public ITSysUserService sysUserService; - - //系统角色 - @Autowired - public ITSysRoleService sysRoleService; - - //权限 - @Autowired - public ITSysPermissionService sysPermissionService; - - //日志操作 - @Autowired - public ITSysOperLogService sysOperLogService; - //公告 - @Autowired - public ITSysNoticeService sysNoticeService; +public class BaseController { + + /** + * 系统用户 + */ + @Autowired + public ITSysUserService sysUserService; + + /** + * 系统角色 + */ + @Autowired + public ITSysRoleService sysRoleService; + + /** + * 权限 + */ + @Autowired + public ITSysPermissionService sysPermissionService; + + /** + * 日志操作 + */ + @Autowired + public ITSysOperLogService sysOperLogService; + + /** + * 公告 + */ + @Autowired + public ITSysNoticeService sysNoticeService; /** * 文件上传 */ - @Autowired - public ITSysFileService sysFileService; - //配置文件 - @Autowired - public V2Config v2Config; + @Autowired + public ITSysFileService sysFileService; + + /** + * 配置文件 + */ + @Autowired + public V2Config v2Config; /** * 将前台传递过来的日期格式的字符串,自动转化为Date类型 + * + * @param binder */ @InitBinder - public void initBinder(WebDataBinder binder) - { + public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); } - /** * 响应返回结果 - * + * * @param rows 影响行数 * @return 操作结果 */ - protected AjaxResult toAjax(int rows) - { + protected AjaxResult toAjax(int rows) { return rows > 0 ? success() : error(); } /** * 返回成功 + * + * @return */ - public AjaxResult success() - { + public AjaxResult success() { return AjaxResult.success(); } /** * 返回失败消息 + * + * @return */ - public AjaxResult error() - { + public AjaxResult error() { return AjaxResult.error(); } /** * 返回成功消息 + * + * @param message + * @return */ - public AjaxResult success(String message) - { + public AjaxResult success(String message) { return AjaxResult.success(message); } - /** * 返回失败消息 + * + * @param message + * @return */ - public AjaxResult error(String message) - { + public AjaxResult error(String message) { return AjaxResult.error(message); } /** * 返回错误码消息 + * + * @param code + * @param message + * @return */ - public AjaxResult error(int code, String message) - { + public AjaxResult error(int code, String message) { return AjaxResult.error(code, message); } - + /** * 返回object数据 + * + * @param code + * @param data + * @return */ - public AjaxResult retobject(int code, Object data) - { + public AjaxResult retobject(int code, Object data) { return AjaxResult.successData(code, data); } /** * 页面跳转 + * + * @param url + * @return */ - public String redirect(String url) - { - return StrUtil.format("redirect:{}", url); + public String redirect(String url) { + return StrUtil.format("redirect:{}", url); } + /** + * 设置请求分页数据 + */ + protected void startPage() { + Tablepar tablepar = Tablepar.buildPageRequest(); + + int pageNum = tablepar.getPage(); + int pageSize = tablepar.getLimit(); + if (pageNum != 0 && pageSize != 0) { + PageHelper.startPage(pageNum, pageSize, tablepar.getOrderByColumn()); + } + } - - -/** - * Describe: 返回 Tree 数据 - * Param data - * Return Tree数据 - * */ - protected static ResuTree dataTree(Object data){ - ResuTree resuTree = new ResuTree(); - resuTree.setData(data); - return resuTree; + /** + * 返回 Tree 数据 + * + * @param data + * @return + */ + protected static ResuTree dataTree(Object data) { + ResuTree resuTree = new ResuTree(); + resuTree.setData(data); + return resuTree; } + /** - * Describe: 返回数据表格数据 分页 - * Param data - * Return 表格分页数据 - * */ - protected static ResultTable pageTable(Object data, long count){ - return ResultTable.pageTable(count,data); + * 返回数据表格数据 + * + * @param data 表格分页数据 + * @param count + * @return + */ + protected static ResultTable pageTable(Object data, long count) { + return ResultTable.pageTable(count, data); } /** - * Describe: 返回数据表格数据 - * Param data - * Return 表格分页数据 - * */ - protected static ResultTable dataTable(Object data){ + * 返回数据表格数据 + * + * @param data 表格分页数据 + * @return + */ + protected static ResultTable dataTable(Object data) { return ResultTable.dataTable(data); } /** - * Describe: 返回树状表格数据 分页 - * Param data - * Return 表格分页数据 - * */ - protected static ResultTable treeTable(Object data){ + * 返回树状表格数据 + * + * @param data 表格分页数据 + * @return + */ + protected static ResultTable treeTable(Object data) { return ResultTable.dataTable(data); } - - - - + } diff --git a/src/main/java/com/fc/v2/common/domain/ResultTable.java b/src/main/java/com/fc/v2/common/domain/ResultTable.java index 8161df0..45c6892 100644 --- a/src/main/java/com/fc/v2/common/domain/ResultTable.java +++ b/src/main/java/com/fc/v2/common/domain/ResultTable.java @@ -1,24 +1,31 @@ package com.fc.v2.common.domain; +/** + * 分页结果的封装 + * + * @author zhaonz + * @Date 20210815 + */ public class ResultTable { - /** + + /** * 状态码 - * */ + */ private Integer code; /** * 提示消息 - * */ + */ private String msg; /** * 消息总量 - * */ + */ private Long count; /** * 数据对象 - * */ + */ private Object data; public Integer getCode() { @@ -55,8 +62,12 @@ public class ResultTable { /** * 构 建 - * */ - public static ResultTable pageTable(long count,Object data){ + * + * @param count + * @param data + * @return + */ + public static ResultTable pageTable(long count, Object data) { ResultTable resultTable = new ResultTable(); resultTable.setData(data); resultTable.setCode(0); @@ -64,7 +75,11 @@ public class ResultTable { return resultTable; } - public static ResultTable dataTable(Object data){ + /** + * @param data + * @return + */ + public static ResultTable dataTable(Object data) { ResultTable resultTable = new ResultTable(); resultTable.setData(data); resultTable.setCode(0); diff --git a/src/main/java/com/fc/v2/controller/admin/SysAreaController.java b/src/main/java/com/fc/v2/controller/admin/SysAreaController.java index b8af90a..a97512d 100644 --- a/src/main/java/com/fc/v2/controller/admin/SysAreaController.java +++ b/src/main/java/com/fc/v2/controller/admin/SysAreaController.java @@ -3,13 +3,13 @@ package com.fc.v2.controller.admin; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.fc.v2.common.base.BaseController; import com.fc.v2.common.domain.AjaxResult; +import com.fc.v2.common.domain.ResultTable; +import com.fc.v2.common.log.Log; import com.fc.v2.model.auto.TSysArea; import com.fc.v2.model.auto.TSysCity; -import com.fc.v2.model.custom.Tablepar; import com.fc.v2.service.ITSysAreaService; import com.fc.v2.service.ITSysCityService; import com.fc.v2.util.StringUtils; -import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.*; public class SysAreaController extends BaseController { private String prefix = "admin/province/sysArea"; + @Autowired private ITSysAreaService sysAreaService; @@ -59,32 +60,29 @@ public class SysAreaController extends BaseController { /** * list集合 * - * @param tablepar - * @param searchText + * @param tSysArea * @return - * @author fuce - * @Date 2019年11月11日 下午4:04:53 */ - //@Log(title = "地区设置集合查询", action = "111") + @Log(title = "地区设置集合查询", action = "list") @ApiOperation(value = "分页跳转", notes = "分页跳转") @GetMapping("/list") @RequiresPermissions("gen:sysArea:list") @ResponseBody - public Object list(Tablepar tablepar, String searchText) { - + public ResultTable list(TSysArea tSysArea) { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.orderByAsc("id"); - - queryWrapper.like(StringUtils.isNotEmpty(searchText), "area_name", searchText); - - PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); + queryWrapper.eq(StringUtils.isNotEmpty(tSysArea.getAreaCode()), "area_code", tSysArea.getAreaCode()); + queryWrapper.like(StringUtils.isNotEmpty(tSysArea.getAreaName()), "area_name", tSysArea.getAreaName()); + startPage(); PageInfo page = new PageInfo(sysAreaService.selectTSysAreaList(queryWrapper)); return pageTable(page.getList(), page.getTotal()); } /** * 新增跳转 + * + * @param modelMap + * @return */ @ApiOperation(value = "新增跳转", notes = "新增跳转") @GetMapping("/add") @@ -102,18 +100,13 @@ public class SysAreaController extends BaseController { * @author fuce * @Date 2019年11月11日 下午4:04:41 */ - //@Log(title = "地区设置新增", action = "111") + @Log(title = "地区设置新增", action = "add") @ApiOperation(value = "新增", notes = "新增") @PostMapping("/add") @RequiresPermissions("gen:sysArea:add") @ResponseBody public AjaxResult add(TSysArea sysArea) { - int b = sysAreaService.insertTSysArea(sysArea); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysAreaService.insertTSysArea(sysArea)); } /** @@ -122,18 +115,13 @@ public class SysAreaController extends BaseController { * @param ids * @return */ - //@Log(title = "地区设置删除", action = "111") + @Log(title = "地区设置删除", action = "remove") @ApiOperation(value = "删除", notes = "删除") @DeleteMapping("/remove") @RequiresPermissions("gen:sysArea:remove") @ResponseBody public AjaxResult remove(String ids) { - int b = sysAreaService.deleteTSysAreaByIds(ids); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysAreaService.deleteTSysAreaByIds(ids)); } /** @@ -146,12 +134,7 @@ public class SysAreaController extends BaseController { @PostMapping("/checkNameUnique") @ResponseBody public int checkNameUnique(TSysArea sysArea) { - int b = sysAreaService.checkNameUnique(sysArea); - if (b > 0) { - return 1; - } else { - return 0; - } + return sysAreaService.checkNameUnique(sysArea) > 0 ? 1 : 0; } @@ -173,8 +156,11 @@ public class SysAreaController extends BaseController { /** * 修改保存 + * + * @param record + * @return */ - //@Log(title = "地区设置修改", action = "111") + @Log(title = "地区设置修改", action = "editSave") @ApiOperation(value = "修改保存", notes = "修改保存") @RequiresPermissions("gen:sysArea:edit") @PostMapping("/edit") @@ -182,6 +168,4 @@ public class SysAreaController extends BaseController { public AjaxResult editSave(TSysArea record) { return toAjax(sysAreaService.updateTSysArea(record)); } - - } diff --git a/src/main/java/com/fc/v2/controller/admin/SysCityController.java b/src/main/java/com/fc/v2/controller/admin/SysCityController.java index 977daa0..5db1074 100644 --- a/src/main/java/com/fc/v2/controller/admin/SysCityController.java +++ b/src/main/java/com/fc/v2/controller/admin/SysCityController.java @@ -3,12 +3,13 @@ package com.fc.v2.controller.admin; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.fc.v2.common.domain.ResultTable; +import com.fc.v2.common.log.Log; import com.fc.v2.model.auto.TSysCity; import com.fc.v2.model.auto.TSysProvince; import com.fc.v2.service.ITSysCityService; import com.fc.v2.service.ITSysProvinceService; import com.fc.v2.util.StringUtils; -import com.github.pagehelper.PageHelper; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.*; import com.github.pagehelper.PageInfo; import com.fc.v2.common.base.BaseController; import com.fc.v2.common.domain.AjaxResult; -import com.fc.v2.model.custom.Tablepar; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -35,6 +35,7 @@ import io.swagger.annotations.ApiOperation; public class SysCityController extends BaseController { private String prefix = "admin/province/sysCity"; + @Autowired private ITSysCityService sysCityService; @@ -57,23 +58,20 @@ public class SysCityController extends BaseController { /** * 城市设置list * - * @param tablepar - * @param searchText + * @param tSysCity * @return */ - //@Log(title = "城市设置集合查询", action = "111") + @Log(title = "城市设置集合查询", action = "/list") @ApiOperation(value = "分页查询", notes = "分页查询") @GetMapping("/list") @RequiresPermissions("gen:sysCity:list") @ResponseBody - public Object list(Tablepar tablepar, String searchText) { - + public ResultTable list(TSysCity tSysCity) { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.orderByAsc("id"); - queryWrapper.like(StringUtils.isNotEmpty(searchText), "city_name", searchText); - - PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); + queryWrapper.eq(StringUtils.isNotEmpty(tSysCity.getCityCode()), "city_code", tSysCity.getCityCode()); + queryWrapper.like(StringUtils.isNotEmpty(tSysCity.getCityName()), "city_name", tSysCity.getCityName()); + startPage(); PageInfo page = new PageInfo(sysCityService.selectTSysCityList(queryWrapper)); return pageTable(page.getList(), page.getTotal()); } @@ -98,18 +96,13 @@ public class SysCityController extends BaseController { * @param sysCity * @return */ - //@Log(title = "城市设置新增", action = "111") + @Log(title = "城市设置新增", action = "add") @ApiOperation(value = "新增", notes = "新增") @PostMapping("/add") @RequiresPermissions("gen:sysCity:add") @ResponseBody public AjaxResult add(TSysCity sysCity) { - int b = sysCityService.insertTSysCity(sysCity); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysCityService.insertTSysCity(sysCity)); } /** @@ -118,36 +111,26 @@ public class SysCityController extends BaseController { * @param ids * @return */ - //@Log(title = "城市设置删除", action = "111") + @Log(title = "城市设置删除", action = "remove") @ApiOperation(value = "删除", notes = "删除") @DeleteMapping("/remove") @RequiresPermissions("gen:sysCity:remove") @ResponseBody public AjaxResult remove(String ids) { - int b = sysCityService.deleteTSysCityByIds(ids); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysCityService.deleteTSysCityByIds(ids)); } /** * 检查 * - * @param tsysUser + * @param sysCity * @return */ @ApiOperation(value = "检查Name唯一", notes = "检查Name唯一") @PostMapping("/checkNameUnique") @ResponseBody public int checkNameUnique(TSysCity sysCity) { - int b = sysCityService.checkNameUnique(sysCity); - if (b > 0) { - return 1; - } else { - return 0; - } + return sysCityService.checkNameUnique(sysCity) > 0 ? 1 : 0; } @@ -169,8 +152,11 @@ public class SysCityController extends BaseController { /** * 修改保存 + * + * @param record + * @return */ - //@Log(title = "城市设置修改", action = "111") + @Log(title = "城市设置修改", action = "editSave") @ApiOperation(value = "修改保存", notes = "修改保存") @RequiresPermissions("gen:sysCity:edit") @PostMapping("/edit") @@ -178,6 +164,4 @@ public class SysCityController extends BaseController { public AjaxResult editSave(TSysCity record) { return toAjax(sysCityService.updateTSysCity(record)); } - - } diff --git a/src/main/java/com/fc/v2/controller/admin/SysProvinceController.java b/src/main/java/com/fc/v2/controller/admin/SysProvinceController.java index cef0ddc..1010ee3 100644 --- a/src/main/java/com/fc/v2/controller/admin/SysProvinceController.java +++ b/src/main/java/com/fc/v2/controller/admin/SysProvinceController.java @@ -1,10 +1,11 @@ package com.fc.v2.controller.admin; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.fc.v2.common.domain.ResultTable; +import com.fc.v2.common.log.Log; import com.fc.v2.model.auto.TSysProvince; import com.fc.v2.service.ITSysProvinceService; import com.fc.v2.util.StringUtils; -import com.github.pagehelper.PageHelper; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.*; import com.github.pagehelper.PageInfo; import com.fc.v2.common.base.BaseController; import com.fc.v2.common.domain.AjaxResult; -import com.fc.v2.model.custom.Tablepar; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -30,6 +30,7 @@ import io.swagger.annotations.ApiOperation; public class SysProvinceController extends BaseController { private String prefix = "admin/province/sysProvince"; + @Autowired private ITSysProvinceService sysProvinceService; @@ -49,27 +50,22 @@ public class SysProvinceController extends BaseController { } /** - * list查询 + * 省份列表 * - * @param tablepar - * @param searchText + * @param tSysProvince * @return - * @author fuce - * @Date 2019年11月11日 下午4:10:39 */ - //@Log(title = "省份表集合查询", action = "111") + @Log(title = "省份表集合查询", action = "list") @ApiOperation(value = "分页查询", notes = "分页查询") @GetMapping("/list") @RequiresPermissions("gen:sysProvince:list") @ResponseBody - public Object list(Tablepar tablepar, String searchText) { - + public ResultTable list(TSysProvince tSysProvince) { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.orderByAsc("id"); - queryWrapper.like(StringUtils.isNotEmpty(searchText), "province_name", searchText); - - PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); + queryWrapper.eq(StringUtils.isNotEmpty(tSysProvince.getProvinceCode()), "province_code", tSysProvince.getProvinceCode()); + queryWrapper.like(StringUtils.isNotEmpty(tSysProvince.getProvinceName()), "province_name", tSysProvince.getProvinceName()); + startPage(); PageInfo page = new PageInfo(sysProvinceService.selectTSysProvinceList(queryWrapper)); return pageTable(page.getList(), page.getTotal()); } @@ -96,18 +92,13 @@ public class SysProvinceController extends BaseController { * @author fuce * @Date 2019年11月11日 下午4:10:26 */ - //@Log(title = "省份表新增", action = "111") + @Log(title = "省份表新增", action = "add") @ApiOperation(value = "新增", notes = "新增") @PostMapping("/add") @RequiresPermissions("gen:sysProvince:add") @ResponseBody public AjaxResult add(TSysProvince sysProvince) { - int b = sysProvinceService.insertTSysProvince(sysProvince); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysProvinceService.insertTSysProvince(sysProvince)); } /** @@ -116,18 +107,13 @@ public class SysProvinceController extends BaseController { * @param ids * @return */ - //@Log(title = "省份表删除", action = "111") + @Log(title = "省份表删除", action = "remove") @ApiOperation(value = "删除", notes = "删除") @DeleteMapping("/remove") @RequiresPermissions("gen:sysProvince:remove") @ResponseBody public AjaxResult remove(String ids) { - int b = sysProvinceService.deleteTSysProvinceByIds(ids); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysProvinceService.deleteTSysProvinceByIds(ids)); } /** @@ -140,12 +126,7 @@ public class SysProvinceController extends BaseController { @PostMapping("/checkNameUnique") @ResponseBody public int checkNameUnique(TSysProvince sysProvince) { - int b = sysProvinceService.checkNameUnique(sysProvince); - if (b > 0) { - return 1; - } else { - return 0; - } + return sysProvinceService.checkNameUnique(sysProvince) > 0 ? 1 : 0; } @@ -160,17 +141,16 @@ public class SysProvinceController extends BaseController { @GetMapping("/edit/{id}") public String edit(@PathVariable("id") Long id, ModelMap mmap) { mmap.put("SysProvince", sysProvinceService.selectTSysProvinceById(id)); - return prefix + "/edit"; } /** * 修改保存 - * + * * @param record * @return */ - //@Log(title = "省份表修改", action = "111") + @Log(title = "省份表修改", action = "editSave") @ApiOperation(value = "修改保存", notes = "修改保存") @RequiresPermissions("gen:sysProvince:edit") @PostMapping("/edit") diff --git a/src/main/java/com/fc/v2/controller/admin/SysStreetController.java b/src/main/java/com/fc/v2/controller/admin/SysStreetController.java index 021e1c2..05dbd02 100644 --- a/src/main/java/com/fc/v2/controller/admin/SysStreetController.java +++ b/src/main/java/com/fc/v2/controller/admin/SysStreetController.java @@ -3,12 +3,13 @@ package com.fc.v2.controller.admin; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.fc.v2.common.domain.ResultTable; +import com.fc.v2.common.log.Log; import com.fc.v2.model.auto.TSysArea; import com.fc.v2.model.auto.TSysStreet; import com.fc.v2.service.ITSysAreaService; import com.fc.v2.service.ITSysStreetService; import com.fc.v2.util.StringUtils; -import com.github.pagehelper.PageHelper; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.*; import com.github.pagehelper.PageInfo; import com.fc.v2.common.base.BaseController; import com.fc.v2.common.domain.AjaxResult; -import com.fc.v2.model.custom.Tablepar; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,8 +34,10 @@ import io.swagger.annotations.ApiOperation; public class SysStreetController extends BaseController { private String prefix = "admin/province/sysStreet"; + @Autowired private ITSysStreetService sysStreetService; + @Autowired private ITSysAreaService sysAreaService; @@ -53,25 +55,22 @@ public class SysStreetController extends BaseController { } /** - * list查询 + * 街道查询 * - * @param tablepar - * @param searchText + * @param tSysStreet * @return */ - //@Log(title = "街道设置集合查询", action = "111") + @Log(title = "街道设置集合查询", action = "list") @ApiOperation(value = "分页查询", notes = "分页查询") @GetMapping("/list") @RequiresPermissions("gen:sysStreet:list") @ResponseBody - public Object list(Tablepar tablepar, String searchText) { - + public ResultTable list(TSysStreet tSysStreet) { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.orderByAsc("id"); - queryWrapper.like(StringUtils.isNotEmpty(searchText), "street_name", searchText); - - PageHelper.startPage(tablepar.getPage(), tablepar.getLimit()); + queryWrapper.eq(StringUtils.isNotEmpty(tSysStreet.getStreetCode()), "street_code", tSysStreet.getStreetCode()); + queryWrapper.like(StringUtils.isNotEmpty(tSysStreet.getStreetName()), "street_name", tSysStreet.getStreetName()); + startPage(); PageInfo page = new PageInfo(sysStreetService.selectTSysStreetList(queryWrapper)); return pageTable(page.getList(), page.getTotal()); } @@ -98,18 +97,13 @@ public class SysStreetController extends BaseController { * @author fuce * @Date 2019年11月11日 下午4:13:37 */ - //@Log(title = "街道设置新增", action = "111") + @Log(title = "街道设置新增", action = "add") @ApiOperation(value = "新增", notes = "新增") @PostMapping("/add") @RequiresPermissions("gen:sysStreet:add") @ResponseBody public AjaxResult add(TSysStreet sysStreet) { - int b = sysStreetService.insertTSysStreet(sysStreet); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysStreetService.insertTSysStreet(sysStreet)); } /** @@ -118,18 +112,13 @@ public class SysStreetController extends BaseController { * @param ids * @return */ - //@Log(title = "街道设置删除", action = "111") + @Log(title = "街道设置删除", action = "remove") @ApiOperation(value = "删除", notes = "删除") @DeleteMapping("/remove") @RequiresPermissions("gen:sysStreet:remove") @ResponseBody public AjaxResult remove(String ids) { - int b = sysStreetService.deleteTSysStreetByIds(ids); - if (b > 0) { - return success(); - } else { - return error(); - } + return toAjax(sysStreetService.deleteTSysStreetByIds(ids)); } /** @@ -142,12 +131,7 @@ public class SysStreetController extends BaseController { @PostMapping("/checkNameUnique") @ResponseBody public int checkNameUnique(TSysStreet sysStreet) { - int b = sysStreetService.checkNameUnique(sysStreet); - if (b > 0) { - return 1; - } else { - return 0; - } + return sysStreetService.checkNameUnique(sysStreet) > 0 ? 1 : 0; } @@ -173,7 +157,7 @@ public class SysStreetController extends BaseController { * @param record * @return */ - //@Log(title = "街道设置修改", action = "111") + @Log(title = "街道设置修改", action = "editSave") @ApiOperation(value = "修改保存", notes = "修改保存") @RequiresPermissions("gen:sysStreet:edit") @PostMapping("/edit") @@ -181,6 +165,4 @@ public class SysStreetController extends BaseController { public AjaxResult editSave(TSysStreet record) { return toAjax(sysStreetService.updateTSysStreet(record)); } - - } diff --git a/src/main/java/com/fc/v2/model/custom/Tablepar.java b/src/main/java/com/fc/v2/model/custom/Tablepar.java index 983390b..e7a3a7a 100644 --- a/src/main/java/com/fc/v2/model/custom/Tablepar.java +++ b/src/main/java/com/fc/v2/model/custom/Tablepar.java @@ -1,50 +1,101 @@ package com.fc.v2.model.custom; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fc.v2.util.ServletUtils; +import com.fc.v2.util.StringUtils; +import sun.security.pkcs11.wrapper.Constants; + +import javax.servlet.http.HttpServletRequest; +import javax.xml.ws.spi.http.HttpContext; + /** * boostrap table post 参数 - * @author fc * + * @author fc */ public class Tablepar { - private int page;//页码 - private int limit;//数量 - private String orderByColumn;//排序字段 - private String isAsc;//排序字符 asc desc - private String searchText;//列表table里面的搜索 - - public int getPage() { - return page; - } - - public void setPage(int page) { - this.page = page; - } - - public int getLimit() { - return limit; - } - - public void setLimit(int limit) { - this.limit = limit; - } - - public String getOrderByColumn() { - return orderByColumn; - } - public void setOrderByColumn(String orderByColumn) { - this.orderByColumn = orderByColumn; - } - public String getIsAsc() { - return isAsc; - } - public void setIsAsc(String isAsc) { - this.isAsc = isAsc; - } - public String getSearchText() { - return searchText; - } - public void setSearchText(String searchText) { - this.searchText = searchText; - } + + /** + * 页码 + */ + private int page; + + /** + * 数量 + */ + private int limit; + + /** + * 排序字段 + */ + private String orderByColumn; + + /** + * 排序字符 asc desc + */ + private String isAsc; + + /** + * 列表table里面的搜索 + */ + private String searchText; + + /** + * 获取layui table的分页参数 + * + * @return + */ + public static Tablepar buildPageRequest() { + Tablepar tablepar = new Tablepar(); + //第几页 + tablepar.setPage(ServletUtils.getParameterToInt("page", 0)); + tablepar.setLimit(ServletUtils.getParameterToInt("limit", 0)); + tablepar.setOrderByColumn(ServletUtils.getParameter("orderByColumn")); + tablepar.setIsAsc(ServletUtils.getParameter("isAsc")); + return tablepar; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public int getLimit() { + return limit; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public String getOrderByColumn() { + if (StringUtils.isEmpty(orderByColumn)) { + return ""; + } + return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; + } + + public void setOrderByColumn(String orderByColumn) { + this.orderByColumn = orderByColumn; + } + + public String getIsAsc() { + return isAsc; + } + + public void setIsAsc(String isAsc) { + this.isAsc = isAsc; + } + + public String getSearchText() { + return searchText; + } + + public void setSearchText(String searchText) { + this.searchText = searchText; + } } diff --git a/src/main/resources/templates/admin/province/sysArea/list.html b/src/main/resources/templates/admin/province/sysArea/list.html index 68b0329..89e00f9 100644 --- a/src/main/resources/templates/admin/province/sysArea/list.html +++ b/src/main/resources/templates/admin/province/sysArea/list.html @@ -8,10 +8,16 @@
- +
- +
+ + +
+ +
+ + +