mirror of https://gitee.com/stylefeng/roses
【7.6.0】【table width】初始化用户列自定义配置的类
parent
2179497996
commit
255ebe935a
|
@ -0,0 +1,55 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.controller;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||||
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||||
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||||
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.entity.SysTableWidth;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.pojo.request.SysTableWidthRequest;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.service.SysTableWidthService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度控制器
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@ApiResource(name = "业务中表的宽度")
|
||||||
|
public class SysTableWidthController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysTableWidthService sysTableWidthService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户针对某个业务的table的列宽配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@GetResource(name = "获取用户针对某个业务的table的列宽配置", path = "/sysTableWidth/getUserConfig")
|
||||||
|
public ResponseData<SysTableWidth> getUserConfig(
|
||||||
|
@Validated(SysTableWidthRequest.detail.class) SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
return new SuccessResponseData<>(sysTableWidthService.detail(sysTableWidthRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@PostResource(name = "添加", path = "/sysTableWidth/setTableWidth")
|
||||||
|
public ResponseData<SysTableWidth> setTableWidth(
|
||||||
|
@RequestBody @Validated(SysTableWidthRequest.add.class) SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
sysTableWidthService.setTableWidth(sysTableWidthRequest);
|
||||||
|
return new SuccessResponseData<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.entity;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
|
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 lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度实例类
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@TableName("sys_table_width")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysTableWidth extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "table_width_id", type = IdType.ASSIGN_ID)
|
||||||
|
@ChineseDescription("主键id")
|
||||||
|
private Long tableWidthId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务标识的编码,例如:PROJECT_TABLE
|
||||||
|
*/
|
||||||
|
@TableField("field_business_code")
|
||||||
|
@ChineseDescription("业务标识的编码,例如:PROJECT_TABLE")
|
||||||
|
private String fieldBusinessCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度记录的类型:1-全体员工,2-个人独有
|
||||||
|
*/
|
||||||
|
@TableField("field_type")
|
||||||
|
@ChineseDescription("宽度记录的类型:1-全体员工,2-个人独有")
|
||||||
|
private Integer fieldType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属用户id
|
||||||
|
*/
|
||||||
|
@TableField("user_id")
|
||||||
|
@ChineseDescription("所属用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义列是否显示、宽度、顺序和列的锁定,一段json
|
||||||
|
*/
|
||||||
|
@TableField("table_width_json")
|
||||||
|
@ChineseDescription("自定义列是否显示、宽度、顺序和列的锁定,一段json")
|
||||||
|
private String tableWidthJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户号
|
||||||
|
*/
|
||||||
|
@TableField("tenant_id")
|
||||||
|
@ChineseDescription("租户号")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||||
|
*
|
||||||
|
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||||
|
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||||
|
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||||
|
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||||
|
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||||
|
*/
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段配置类型
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/2/23 23:43
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum FieldTypeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局配置
|
||||||
|
*/
|
||||||
|
TOTAL(1, "全局配置"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人独有
|
||||||
|
*/
|
||||||
|
USER(2, "个人独有");
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
FieldTypeEnum(Integer code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.enums;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度异常相关枚举
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum SysTableWidthExceptionEnum implements AbstractExceptionEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询结果不存在
|
||||||
|
*/
|
||||||
|
SYS_TABLE_WIDTH_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误编码
|
||||||
|
*/
|
||||||
|
private final String errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示用户信息
|
||||||
|
*/
|
||||||
|
private final String userTip;
|
||||||
|
|
||||||
|
SysTableWidthExceptionEnum(String errorCode, String userTip) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.userTip = userTip;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.mapper;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.entity.SysTableWidth;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度 Mapper 接口
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
public interface SysTableWidthMapper extends BaseMapper<SysTableWidth> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="cn.stylefeng.roses.kernel.sys.modular.tablewidth.mapper.SysTableWidthMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,39 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格宽度信息的配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/2/23 22:34
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TableWidthItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段编码,例如:projectName
|
||||||
|
*/
|
||||||
|
private String fieldCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段编码,例如:项目名称
|
||||||
|
*/
|
||||||
|
private String fieldName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否显示字段,true显示,false-不显示
|
||||||
|
*/
|
||||||
|
private Boolean showFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段展示宽度
|
||||||
|
*/
|
||||||
|
private Integer width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 该字段是否锁定列
|
||||||
|
*/
|
||||||
|
private Boolean lockFlag;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.pojo.request;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度封装类
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class SysTableWidthRequest extends BaseRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("主键id")
|
||||||
|
private Long tableWidthId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务标识的编码,例如:PROJECT_TABLE
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "业务标识的编码不能为空", groups = {detail.class, add.class})
|
||||||
|
@ChineseDescription("业务标识的编码,例如:PROJECT_TABLE")
|
||||||
|
private String fieldBusinessCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 宽度记录的类型:1-全体员工,2-个人独有
|
||||||
|
*/
|
||||||
|
@NotNull(message = "宽度记录的类型不能为空", groups = {add.class})
|
||||||
|
@ChineseDescription("宽度记录的类型:1-全体员工,2-个人独有")
|
||||||
|
private Integer fieldType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属用户id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("所属用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义列是否显示、宽度、顺序和列的锁定,一段json
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "详情json不能为空", groups = {add.class})
|
||||||
|
@ChineseDescription("自定义列是否显示、宽度、顺序和列的锁定,一段json")
|
||||||
|
private String tableWidthJson;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.service;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.entity.SysTableWidth;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.pojo.request.SysTableWidthRequest;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度 服务类
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
public interface SysTableWidthService extends IService<SysTableWidth> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @param sysTableWidthRequest 请求参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
void setTableWidth(SysTableWidthRequest sysTableWidthRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param sysTableWidthRequest 请求参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
void del(SysTableWidthRequest sysTableWidthRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param sysTableWidthRequest 请求参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
void edit(SysTableWidthRequest sysTableWidthRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询详情
|
||||||
|
*
|
||||||
|
* @param sysTableWidthRequest 请求参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
SysTableWidth detail(SysTableWidthRequest sysTableWidthRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取列表
|
||||||
|
*
|
||||||
|
* @param sysTableWidthRequest 请求参数
|
||||||
|
* @return List<SysTableWidth> 返回结果
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
List<SysTableWidth> findList(SysTableWidthRequest sysTableWidthRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取列表(带分页)
|
||||||
|
*
|
||||||
|
* @param sysTableWidthRequest 请求参数
|
||||||
|
* @return PageResult<SysTableWidth> 返回结果
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
PageResult<SysTableWidth> findPage(SysTableWidthRequest sysTableWidthRequest);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
package cn.stylefeng.roses.kernel.sys.modular.tablewidth.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.entity.SysTableWidth;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.enums.FieldTypeEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.enums.SysTableWidthExceptionEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.mapper.SysTableWidthMapper;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.pojo.request.SysTableWidthRequest;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.tablewidth.service.SysTableWidthService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务中表的宽度业务实现层
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysTableWidthServiceImpl extends ServiceImpl<SysTableWidthMapper, SysTableWidth> implements SysTableWidthService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void setTableWidth(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
SysTableWidth sysTableWidth = new SysTableWidth();
|
||||||
|
BeanUtil.copyProperties(sysTableWidthRequest, sysTableWidth);
|
||||||
|
|
||||||
|
// 当前用户id
|
||||||
|
Long currentUserId = LoginContext.me().getLoginUser().getUserId();
|
||||||
|
|
||||||
|
// 如果是保存个人的信息,设置上用户id
|
||||||
|
if (FieldTypeEnum.USER.getCode().equals(sysTableWidthRequest.getFieldType())) {
|
||||||
|
sysTableWidth.setUserId(currentUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果设置的是全局的,则把个人配置的全都删掉
|
||||||
|
else {
|
||||||
|
LambdaQueryWrapper<SysTableWidth> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysTableWidth::getFieldBusinessCode, sysTableWidthRequest.getFieldBusinessCode());
|
||||||
|
this.remove(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先删除再保存
|
||||||
|
String fieldBusinessCode = sysTableWidthRequest.getFieldBusinessCode();
|
||||||
|
Integer fieldType = sysTableWidthRequest.getFieldType();
|
||||||
|
Long userId = sysTableWidthRequest.getUserId();
|
||||||
|
|
||||||
|
LambdaQueryWrapper<SysTableWidth> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotEmpty(fieldBusinessCode), SysTableWidth::getFieldBusinessCode, fieldBusinessCode);
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotEmpty(fieldType), SysTableWidth::getFieldType, fieldType);
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotEmpty(userId), SysTableWidth::getUserId, userId);
|
||||||
|
this.remove(queryWrapper);
|
||||||
|
|
||||||
|
this.save(sysTableWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void del(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
SysTableWidth sysTableWidth = this.querySysTableWidth(sysTableWidthRequest);
|
||||||
|
this.removeById(sysTableWidth.getTableWidthId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void edit(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
SysTableWidth sysTableWidth = this.querySysTableWidth(sysTableWidthRequest);
|
||||||
|
BeanUtil.copyProperties(sysTableWidthRequest, sysTableWidth);
|
||||||
|
this.updateById(sysTableWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysTableWidth detail(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
|
||||||
|
// 获取当前人,在这个业务下,是否有生成过配置
|
||||||
|
LambdaQueryWrapper<SysTableWidth> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SysTableWidth::getUserId, LoginContext.me().getLoginUser().getUserId());
|
||||||
|
wrapper.eq(SysTableWidth::getFieldBusinessCode, sysTableWidthRequest.getFieldBusinessCode());
|
||||||
|
|
||||||
|
SysTableWidth sysTableWidth = this.getOne(wrapper, false);
|
||||||
|
|
||||||
|
// 如果存在配置,则直接返回
|
||||||
|
if (sysTableWidth != null) {
|
||||||
|
return sysTableWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果不存在配置,则去查找当前项目是否存在全局的配置
|
||||||
|
LambdaQueryWrapper<SysTableWidth> wrapper2 = new LambdaQueryWrapper<>();
|
||||||
|
wrapper2.eq(SysTableWidth::getFieldBusinessCode, sysTableWidthRequest.getFieldBusinessCode());
|
||||||
|
wrapper2.eq(SysTableWidth::getFieldType, FieldTypeEnum.TOTAL.getCode());
|
||||||
|
SysTableWidth totalTableWidth = this.getOne(wrapper2, false);
|
||||||
|
if (totalTableWidth != null) {
|
||||||
|
return totalTableWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有个人配置,也没有全局配置,返回空
|
||||||
|
return new SysTableWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<SysTableWidth> findPage(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
LambdaQueryWrapper<SysTableWidth> wrapper = createWrapper(sysTableWidthRequest);
|
||||||
|
Page<SysTableWidth> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||||
|
return PageResultFactory.createPageResult(sysRolePage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysTableWidth> findList(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
LambdaQueryWrapper<SysTableWidth> wrapper = this.createWrapper(sysTableWidthRequest);
|
||||||
|
return this.list(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取信息
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
private SysTableWidth querySysTableWidth(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
SysTableWidth sysTableWidth = this.getById(sysTableWidthRequest.getTableWidthId());
|
||||||
|
if (ObjectUtil.isEmpty(sysTableWidth)) {
|
||||||
|
throw new ServiceException(SysTableWidthExceptionEnum.SYS_TABLE_WIDTH_NOT_EXISTED);
|
||||||
|
}
|
||||||
|
return sysTableWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建查询wrapper
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2023/02/23 22:21
|
||||||
|
*/
|
||||||
|
private LambdaQueryWrapper<SysTableWidth> createWrapper(SysTableWidthRequest sysTableWidthRequest) {
|
||||||
|
LambdaQueryWrapper<SysTableWidth> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
Long tableWidthId = sysTableWidthRequest.getTableWidthId();
|
||||||
|
String fieldBusinessCode = sysTableWidthRequest.getFieldBusinessCode();
|
||||||
|
Integer fieldType = sysTableWidthRequest.getFieldType();
|
||||||
|
Long userId = sysTableWidthRequest.getUserId();
|
||||||
|
String tableWidthJson = sysTableWidthRequest.getTableWidthJson();
|
||||||
|
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotNull(tableWidthId), SysTableWidth::getTableWidthId, tableWidthId);
|
||||||
|
queryWrapper.like(ObjectUtil.isNotEmpty(fieldBusinessCode), SysTableWidth::getFieldBusinessCode, fieldBusinessCode);
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotNull(fieldType), SysTableWidth::getFieldType, fieldType);
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotNull(userId), SysTableWidth::getUserId, userId);
|
||||||
|
queryWrapper.like(ObjectUtil.isNotEmpty(tableWidthJson), SysTableWidth::getTableWidthJson, tableWidthJson);
|
||||||
|
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue