From c62383ff51f0c0813f1c386db2c7118c3519b947 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Mon, 28 Aug 2023 09:10:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BB=A3=E7=A0=81=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysTableHeadController.java | 95 +++++++++++++++++++ .../api/dao/system/SysTableHeadMapper.java | 5 + .../api/entity/system/SysTableHeadEntity.java | 18 +++- .../api/req/system/SysTableHeadRequest.java | 76 +++++++++++++++ .../service/system/SysTableHeadService.java | 24 +++++ src/main/resources/application-dev.yml | 2 +- .../mapper/system/SysTableHeadMapper.xml | 72 +++++++++----- 7 files changed, 264 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/glxp/api/controller/system/SysTableHeadController.java create mode 100644 src/main/java/com/glxp/api/req/system/SysTableHeadRequest.java diff --git a/src/main/java/com/glxp/api/controller/system/SysTableHeadController.java b/src/main/java/com/glxp/api/controller/system/SysTableHeadController.java new file mode 100644 index 00000000..caa793d3 --- /dev/null +++ b/src/main/java/com/glxp/api/controller/system/SysTableHeadController.java @@ -0,0 +1,95 @@ +package com.glxp.api.controller.system; + + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageInfo; +import com.glxp.api.annotation.AuthRuleAnnotation; +import com.glxp.api.common.enums.ResultEnum; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.controller.BaseController; +import com.glxp.api.entity.system.SysTableHeadEntity; +import com.glxp.api.req.system.DeleteRequest; +import com.glxp.api.req.system.SysTableHeadRequest; +import com.glxp.api.service.system.SysTableHeadService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 设备表头字段 + */ +@Slf4j +@RestController +public class SysTableHeadController extends BaseController { + + @Resource + SysTableHeadService sysTableHeadService; + + @AuthRuleAnnotation("") + @GetMapping("/udiwms/sys/table/head/filter") + public BaseResponse filterPreInorder(SysTableHeadRequest sysTableHeadRequest) { + List list = sysTableHeadService.filterList(sysTableHeadRequest); + PageInfo pageInfo = new PageInfo(list); + return ResultVOUtils.page(pageInfo); + } + + @AuthRuleAnnotation("") + @GetMapping("/udiwms/sys/table/head/find") + public BaseResponse findByPage(SysTableHeadRequest sysTableHeadRequest) { + if (StrUtil.isEmpty(sysTableHeadRequest.getPageCode())) { + return ResultVOUtils.error(500, "页面标识不能为空!"); + } + List list = sysTableHeadService.list(new QueryWrapper().eq("pageCode", sysTableHeadRequest.getPageCode())); + return ResultVOUtils.success(list); + } + + + @AuthRuleAnnotation("") + @PostMapping("/udiwms/sys/table/head/save") + public BaseResponse save(@RequestBody SysTableHeadEntity sysTableHeadEntity, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + boolean b = sysTableHeadService.save(sysTableHeadEntity); + if (!b) { + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + return ResultVOUtils.success("添加成功!"); + } + + @AuthRuleAnnotation("") + @PostMapping("/udiwms/sys/table/head/update") + public BaseResponse update(@RequestBody SysTableHeadEntity sysTableHeadEntity, + BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + boolean b = sysTableHeadService.updateById(sysTableHeadEntity); + if (!b) { + return ResultVOUtils.error(ResultEnum.NOT_NETWORK); + } + return ResultVOUtils.success("修改成功!"); + } + + @AuthRuleAnnotation("") + @PostMapping("/udiwms/sys/table/head/delete") + public BaseResponse deleteById(@RequestBody DeleteRequest deleteRequest) { + boolean b = sysTableHeadService.removeById(deleteRequest.getId()); + if (b) + return ResultVOUtils.success("删除成功"); + else { + return ResultVOUtils.error(500, "删除失败"); + } + } +} diff --git a/src/main/java/com/glxp/api/dao/system/SysTableHeadMapper.java b/src/main/java/com/glxp/api/dao/system/SysTableHeadMapper.java index c1209ab3..145d9b46 100644 --- a/src/main/java/com/glxp/api/dao/system/SysTableHeadMapper.java +++ b/src/main/java/com/glxp/api/dao/system/SysTableHeadMapper.java @@ -3,8 +3,13 @@ package com.glxp.api.dao.system; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.api.dao.BaseMapperPlus; import com.glxp.api.entity.system.SysTableHeadEntity; +import com.glxp.api.req.system.SysTableHeadRequest; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface SysTableHeadMapper extends BaseMapperPlus { + + List filterList(SysTableHeadRequest sysTableHeadRequest); } diff --git a/src/main/java/com/glxp/api/entity/system/SysTableHeadEntity.java b/src/main/java/com/glxp/api/entity/system/SysTableHeadEntity.java index c9932366..7b0190b8 100644 --- a/src/main/java/com/glxp/api/entity/system/SysTableHeadEntity.java +++ b/src/main/java/com/glxp/api/entity/system/SysTableHeadEntity.java @@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; + import java.io.Serializable; import java.util.Date; + import lombok.Data; @Data @@ -15,10 +17,16 @@ public class SysTableHeadEntity implements Serializable { private Integer id; /** - * 前端页面 + * 前端页面名称 + */ + @TableField(value = "pageName") + private String pageName; + + /** + * 前端页面标识 */ - @TableField(value = "page") - private String page; + @TableField(value = "pageCode") + private String pageCode; /** * 所属后端返回类 @@ -60,7 +68,7 @@ public class SysTableHeadEntity implements Serializable { * 当内容过长被隐藏时显示 tooltip */ @TableField(value = "overflow") - private Byte overflow; + private Boolean overflow; /** * 排序顺序 @@ -72,7 +80,7 @@ public class SysTableHeadEntity implements Serializable { * 是否启用自定义排序 */ @TableField(value = "customSort") - private Byte customSort; + private Boolean customSort; /** * 备注 diff --git a/src/main/java/com/glxp/api/req/system/SysTableHeadRequest.java b/src/main/java/com/glxp/api/req/system/SysTableHeadRequest.java new file mode 100644 index 00000000..db9ad0b8 --- /dev/null +++ b/src/main/java/com/glxp/api/req/system/SysTableHeadRequest.java @@ -0,0 +1,76 @@ +package com.glxp.api.req.system; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.glxp.api.util.page.ListPageRequest; +import lombok.Data; + +import java.util.Date; + +@Data +public class SysTableHeadRequest extends ListPageRequest { + + private Integer id; + + /** + * 前端页面名称 + */ + private String pageName; + + /** + * 前端页面标识 + */ + private String pageCode; + + /** + * 所属后端返回类 + */ + private String response; + + /** + * 显示的标题 + */ + private String label; + + /** + * 字段名 + */ + private String prop; + + /** + * 对应列的宽度 + */ + private Double width; + + /** + * 是否显示 + */ + private String isShow; + + /** + * 自适应宽度 + */ + private String isAuto; + + /** + * 当内容过长被隐藏时显示 tooltip + */ + private Boolean overflow; + + + /** + * 是否启用自定义排序 + */ + private Boolean customSort; + + /** + * 备注 + */ + private String remark; + + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/src/main/java/com/glxp/api/service/system/SysTableHeadService.java b/src/main/java/com/glxp/api/service/system/SysTableHeadService.java index 4ed95258..b85f2854 100644 --- a/src/main/java/com/glxp/api/service/system/SysTableHeadService.java +++ b/src/main/java/com/glxp/api/service/system/SysTableHeadService.java @@ -1,13 +1,37 @@ package com.glxp.api.service.system; +import cn.hutool.core.util.StrUtil; +import com.github.pagehelper.PageHelper; +import com.glxp.api.req.system.SysTableHeadRequest; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.glxp.api.entity.system.SysTableHeadEntity; import com.glxp.api.dao.system.SysTableHeadMapper; +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + @Service public class SysTableHeadService extends ServiceImpl { + @Resource + SysTableHeadMapper sysTableHeadMapper; + + public List filterList(SysTableHeadRequest sysTableHeadRequest) { + if (sysTableHeadRequest == null) { + return Collections.emptyList(); + } + if (sysTableHeadRequest.getPage() != null) { + int offset = (sysTableHeadRequest.getPage() - 1) * sysTableHeadRequest.getLimit(); + PageHelper.offsetPage(offset, sysTableHeadRequest.getLimit()); + } + + return sysTableHeadMapper.filterList(sysTableHeadRequest); + + } + } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 873706a3..b2df4abe 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,7 +4,7 @@ server: spring: datasource: driver-class-name: com.p6spy.engine.spy.P6SpyDriver - jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_wmd?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true username: root password: 123456 hikari: diff --git a/src/main/resources/mybatis/mapper/system/SysTableHeadMapper.xml b/src/main/resources/mybatis/mapper/system/SysTableHeadMapper.xml index c0b4b814..25af366d 100644 --- a/src/main/resources/mybatis/mapper/system/SysTableHeadMapper.xml +++ b/src/main/resources/mybatis/mapper/system/SysTableHeadMapper.xml @@ -1,26 +1,54 @@ - - - - - - - - - - - - - - - - - - - - id, page, response, `label`, prop, width, isShow, isAuto, overflow, sort, customSort, - remark, updateTime - + + + + + + + + + + + + + + + + + + + + + id,pageName, pageCode, response, `label`, prop, width, isShow, isAuto, overflow, sort, customSort, + remark, updateTime + + + +