mirror of https://gitee.com/stylefeng/roses
【config】整理config模块的字段和业务
parent
0e7cb3897e
commit
fd374e81fa
|
@ -27,6 +27,54 @@ public class SysConfigController {
|
||||||
@Resource
|
@Resource
|
||||||
private SysConfigService sysConfigService;
|
private SysConfigService sysConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加系统参数配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:11
|
||||||
|
*/
|
||||||
|
@PostResource(name = "添加系统参数配置", path = "/sysConfig/add")
|
||||||
|
public ResponseData add(@RequestBody @Validated(SysConfigParam.add.class) SysConfigParam sysConfigParam) {
|
||||||
|
sysConfigService.add(sysConfigParam);
|
||||||
|
return new SuccessResponseData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑系统参数配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:11
|
||||||
|
*/
|
||||||
|
@PostResource(name = "编辑系统参数配置", path = "/sysConfig/edit")
|
||||||
|
public ResponseData edit(@RequestBody @Validated(SysConfigParam.edit.class) SysConfigParam sysConfigParam) {
|
||||||
|
sysConfigService.edit(sysConfigParam);
|
||||||
|
return new SuccessResponseData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除系统参数配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:11
|
||||||
|
*/
|
||||||
|
@PostResource(name = "删除系统参数配置", path = "/sysConfig/delete")
|
||||||
|
public ResponseData delete(@RequestBody @Validated(SysConfigParam.delete.class) SysConfigParam sysConfigParam) {
|
||||||
|
sysConfigService.delete(sysConfigParam);
|
||||||
|
return new SuccessResponseData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看系统参数配置
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:12
|
||||||
|
*/
|
||||||
|
@GetResource(name = "查看系统参数配置", path = "/sysConfig/detail")
|
||||||
|
public ResponseData detail(@Validated(SysConfigParam.detail.class) SysConfigParam sysConfigParam) {
|
||||||
|
return new SuccessResponseData(sysConfigService.detail(sysConfigParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询配置列表
|
* 分页查询配置列表
|
||||||
*
|
*
|
||||||
|
@ -49,53 +97,6 @@ public class SysConfigController {
|
||||||
return new SuccessResponseData(sysConfigService.list(sysConfigParam));
|
return new SuccessResponseData(sysConfigService.list(sysConfigParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看系统参数配置
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:12
|
|
||||||
*/
|
|
||||||
@GetResource(name = "查看系统参数配置", path = "/sysConfig/detail")
|
|
||||||
public ResponseData detail(@Validated(SysConfigParam.detail.class) SysConfigParam sysConfigParam) {
|
|
||||||
return new SuccessResponseData(sysConfigService.detail(sysConfigParam));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加系统参数配置
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:11
|
|
||||||
*/
|
|
||||||
@PostResource(name = "添加系统参数配置", path = "/sysConfig/add")
|
|
||||||
public ResponseData add(@RequestBody @Validated(SysConfigParam.add.class) SysConfigParam sysConfigParam) {
|
|
||||||
sysConfigService.add(sysConfigParam);
|
|
||||||
return new SuccessResponseData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除系统参数配置
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:11
|
|
||||||
*/
|
|
||||||
@PostResource(name = "删除系统参数配置", path = "/sysConfig/delete")
|
|
||||||
public ResponseData delete(@RequestBody @Validated(SysConfigParam.delete.class) SysConfigParam sysConfigParam) {
|
|
||||||
sysConfigService.delete(sysConfigParam);
|
|
||||||
return new SuccessResponseData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑系统参数配置
|
|
||||||
*
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:11
|
|
||||||
*/
|
|
||||||
@PostResource(name = "编辑系统参数配置", path = "/sysConfig/edit")
|
|
||||||
public ResponseData edit(@RequestBody @Validated(SysConfigParam.edit.class) SysConfigParam sysConfigParam) {
|
|
||||||
sysConfigService.edit(sysConfigParam);
|
|
||||||
return new SuccessResponseData();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,11 @@ Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
||||||
*/
|
*/
|
||||||
package cn.stylefeng.roses.kernel.config.modular.entity;
|
package cn.stylefeng.roses.kernel.config.modular.entity;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@ -48,29 +48,29 @@ public class SysConfig extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(value = "config_id", type = IdType.ASSIGN_ID)
|
||||||
private Long id;
|
private Long configId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
@TableField("name")
|
@TableField("config_name")
|
||||||
private String name;
|
private String configName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码
|
* 编码
|
||||||
*/
|
*/
|
||||||
@TableField("code")
|
@TableField("config_code")
|
||||||
private String code;
|
private String configCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性值
|
* 属性值
|
||||||
*/
|
*/
|
||||||
@TableField("value")
|
@TableField("config_value")
|
||||||
private String value;
|
private String configValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否是系统参数(Y-是,N-否)
|
* 是否是系统参数:Y-是,N-否
|
||||||
*/
|
*/
|
||||||
@TableField("sys_flag")
|
@TableField("sys_flag")
|
||||||
private String sysFlag;
|
private String sysFlag;
|
||||||
|
@ -82,10 +82,10 @@ public class SysConfig extends BaseEntity {
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态(字典 1正常 2停用)
|
* 状态:1-正常,2停用
|
||||||
*/
|
*/
|
||||||
@TableField("status")
|
@TableField("status_flag")
|
||||||
private Integer status;
|
private Integer statusFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常量所属分类的编码,来自于“常量的分类”字典
|
* 常量所属分类的编码,来自于“常量的分类”字典
|
||||||
|
@ -94,7 +94,7 @@ public class SysConfig extends BaseEntity {
|
||||||
private String groupCode;
|
private String groupCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否删除(Y-已删除,N-未删除)
|
* 是否删除:Y-被删除,N-未删除
|
||||||
*/
|
*/
|
||||||
@TableField("del_flag")
|
@TableField("del_flag")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
|
@ -1,27 +1,3 @@
|
||||||
/*
|
|
||||||
Copyright [2020] [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-separation
|
|
||||||
5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
|
|
||||||
6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
|
|
||||||
*/
|
|
||||||
package cn.stylefeng.roses.kernel.config.modular.param;
|
package cn.stylefeng.roses.kernel.config.modular.param;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
|
@ -45,29 +21,29 @@ public class SysConfigParam extends BaseRequest {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "id不能为空,请检查id参数", groups = {edit.class, delete.class, detail.class})
|
@NotNull(message = "configId不能为空", groups = {edit.class, delete.class, detail.class})
|
||||||
private Long id;
|
private Long configId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "名称不能为空,请检查name参数", groups = {add.class, edit.class})
|
@NotBlank(message = "名称不能为空", groups = {add.class, edit.class})
|
||||||
private String name;
|
private String configName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码
|
* 编码
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "编码不能为空,请检查code参数", groups = {add.class, edit.class})
|
@NotBlank(message = "编码不能为空", groups = {add.class, edit.class})
|
||||||
private String code;
|
private String configCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 值
|
* 配置值
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "值不能为空,请检查value参数", groups = {add.class, edit.class})
|
@NotBlank(message = "配置值不能为空", groups = {add.class, edit.class})
|
||||||
private String value;
|
private String configValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否是系统参数(Y-是,N-否)
|
* 是否是系统参数:Y-是,N-否
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "是否是系统参数不能为空,请检查sysFlag参数", groups = {add.class, edit.class})
|
@NotBlank(message = "是否是系统参数不能为空,请检查sysFlag参数", groups = {add.class, edit.class})
|
||||||
@FlagValue(message = "是否是系统参数格式错误,正确格式应该Y或者N,请检查sysFlag参数", groups = {add.class, edit.class})
|
@FlagValue(message = "是否是系统参数格式错误,正确格式应该Y或者N,请检查sysFlag参数", groups = {add.class, edit.class})
|
||||||
|
@ -78,9 +54,15 @@ public class SysConfigParam extends BaseRequest {
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态:1-正常,2停用
|
||||||
|
*/
|
||||||
|
private Integer statusFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常量所属分类的编码,来自于“常量的分类”字典
|
* 常量所属分类的编码,来自于“常量的分类”字典
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "值不能为空,请检查value参数", groups = {add.class, edit.class})
|
@NotBlank(message = "量所属分类的编码不能为空", groups = {add.class, edit.class})
|
||||||
private String groupCode;
|
private String groupCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
||||||
*/
|
*/
|
||||||
package cn.stylefeng.roses.kernel.config.modular.service;
|
package cn.stylefeng.roses.kernel.config.modular.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.param.SysConfigParam;
|
import cn.stylefeng.roses.kernel.config.modular.param.SysConfigParam;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -39,6 +39,43 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface SysConfigService extends IService<SysConfig> {
|
public interface SysConfigService extends IService<SysConfig> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加系统参数配置
|
||||||
|
*
|
||||||
|
* @param sysConfigParam 添加参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:14
|
||||||
|
*/
|
||||||
|
void add(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑系统参数配置
|
||||||
|
*
|
||||||
|
* @param sysConfigParam 编辑参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:15
|
||||||
|
*/
|
||||||
|
void edit(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除系统参数配置
|
||||||
|
*
|
||||||
|
* @param sysConfigParam 删除参数
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:15
|
||||||
|
*/
|
||||||
|
void delete(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看系统参数配置
|
||||||
|
*
|
||||||
|
* @param sysConfigParam 查看参数
|
||||||
|
* @return 系统参数配置
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2020/4/14 11:15
|
||||||
|
*/
|
||||||
|
SysConfig detail(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询系统参数配置
|
* 查询系统参数配置
|
||||||
*
|
*
|
||||||
|
@ -59,41 +96,4 @@ public interface SysConfigService extends IService<SysConfig> {
|
||||||
*/
|
*/
|
||||||
List<SysConfig> list(SysConfigParam sysConfigParam);
|
List<SysConfig> list(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看系统参数配置
|
|
||||||
*
|
|
||||||
* @param sysConfigParam 查看参数
|
|
||||||
* @return 系统参数配置
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:15
|
|
||||||
*/
|
|
||||||
SysConfig detail(SysConfigParam sysConfigParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加系统参数配置
|
|
||||||
*
|
|
||||||
* @param sysConfigParam 添加参数
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:14
|
|
||||||
*/
|
|
||||||
void add(SysConfigParam sysConfigParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除系统参数配置
|
|
||||||
*
|
|
||||||
* @param sysConfigParam 删除参数
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:15
|
|
||||||
*/
|
|
||||||
void delete(SysConfigParam sysConfigParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑系统参数配置
|
|
||||||
*
|
|
||||||
* @param sysConfigParam 编辑参数
|
|
||||||
* @author fengshuonan
|
|
||||||
* @date 2020/4/14 11:15
|
|
||||||
*/
|
|
||||||
void edit(SysConfigParam sysConfigParam);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,26 @@ package cn.stylefeng.roses.kernel.config.modular.service.impl;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.mapper.SysConfigMapper;
|
|
||||||
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService;
|
|
||||||
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 cn.stylefeng.roses.kernel.config.api.context.ConfigContext;
|
import cn.stylefeng.roses.kernel.config.api.context.ConfigContext;
|
||||||
import cn.stylefeng.roses.kernel.config.api.exception.ConfigException;
|
import cn.stylefeng.roses.kernel.config.api.exception.ConfigException;
|
||||||
import cn.stylefeng.roses.kernel.config.api.exception.enums.ConfigExceptionEnum;
|
|
||||||
import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
||||||
|
import cn.stylefeng.roses.kernel.config.modular.mapper.SysConfigMapper;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.param.SysConfigParam;
|
import cn.stylefeng.roses.kernel.config.modular.param.SysConfigParam;
|
||||||
|
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
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.factory.PageResultFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||||
|
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.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.stylefeng.roses.kernel.config.api.exception.enums.ConfigExceptionEnum.CONFIG_NOT_EXIST;
|
||||||
import static cn.stylefeng.roses.kernel.config.api.exception.enums.ConfigExceptionEnum.CONFIG_SYS_CAN_NOT_DELETE;
|
import static cn.stylefeng.roses.kernel.config.api.exception.enums.ConfigExceptionEnum.CONFIG_SYS_CAN_NOT_DELETE;
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +35,71 @@ import static cn.stylefeng.roses.kernel.config.api.exception.enums.ConfigExcepti
|
||||||
@Service
|
@Service
|
||||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
|
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void add(SysConfigParam sysConfigParam) {
|
||||||
|
|
||||||
|
// 1.构造实体
|
||||||
|
SysConfig sysConfig = new SysConfig();
|
||||||
|
BeanUtil.copyProperties(sysConfigParam, sysConfig);
|
||||||
|
sysConfig.setStatusFlag(StatusEnum.ENABLE.getCode());
|
||||||
|
|
||||||
|
// 2.保存到库中
|
||||||
|
this.save(sysConfig);
|
||||||
|
|
||||||
|
// 3.添加对应context
|
||||||
|
ConfigContext.me().putConfig(sysConfigParam.getConfigCode(), sysConfigParam.getConfigValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void edit(SysConfigParam sysConfigParam) {
|
||||||
|
|
||||||
|
// 1.根据id获取常量信息
|
||||||
|
SysConfig sysConfig = this.querySysConfig(sysConfigParam);
|
||||||
|
|
||||||
|
// 2.请求参数转化为实体
|
||||||
|
BeanUtil.copyProperties(sysConfigParam, sysConfig);
|
||||||
|
// 不能修改状态,用修改状态接口修改状态
|
||||||
|
sysConfig.setStatusFlag(null);
|
||||||
|
|
||||||
|
// 3.更新记录
|
||||||
|
this.updateById(sysConfig);
|
||||||
|
|
||||||
|
// 4.更新对应常量context
|
||||||
|
ConfigContext.me().putConfig(sysConfigParam.getConfigCode(), sysConfigParam.getConfigValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(SysConfigParam sysConfigParam) {
|
||||||
|
|
||||||
|
// 1.根据id获取常量
|
||||||
|
SysConfig sysConfig = this.querySysConfig(sysConfigParam);
|
||||||
|
if (sysConfig == null) {
|
||||||
|
String userTip = StrUtil.format(CONFIG_NOT_EXIST.getUserTip(), "id: " + sysConfigParam.getConfigId());
|
||||||
|
throw new ConfigException(CONFIG_NOT_EXIST, userTip);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.不能删除系统参数
|
||||||
|
if (YesOrNotEnum.Y.getCode().equals(sysConfig.getSysFlag())) {
|
||||||
|
throw new ConfigException(CONFIG_SYS_CAN_NOT_DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.设置状态为已删除
|
||||||
|
sysConfig.setStatusFlag(StatusEnum.DISABLE.getCode());
|
||||||
|
sysConfig.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||||
|
this.updateById(sysConfig);
|
||||||
|
|
||||||
|
// 4.删除对应context
|
||||||
|
ConfigContext.me().deleteConfig(sysConfigParam.getConfigCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysConfig detail(SysConfigParam sysConfigParam) {
|
||||||
|
return this.querySysConfig(sysConfigParam);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<SysConfig> page(SysConfigParam sysConfigParam) {
|
public PageResult<SysConfig> page(SysConfigParam sysConfigParam) {
|
||||||
LambdaQueryWrapper<SysConfig> wrapper = createWrapper(sysConfigParam);
|
LambdaQueryWrapper<SysConfig> wrapper = createWrapper(sysConfigParam);
|
||||||
|
@ -47,63 +113,6 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
return this.list(wrapper);
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SysConfig detail(SysConfigParam sysConfigParam) {
|
|
||||||
return this.querySysConfig(sysConfigParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(SysConfigParam sysConfigParam) {
|
|
||||||
|
|
||||||
// 1.构造实体
|
|
||||||
SysConfig sysConfig = new SysConfig();
|
|
||||||
BeanUtil.copyProperties(sysConfigParam, sysConfig);
|
|
||||||
sysConfig.setStatus(StatusEnum.ENABLE.getCode());
|
|
||||||
|
|
||||||
// 2.保存到库中
|
|
||||||
this.save(sysConfig);
|
|
||||||
|
|
||||||
// 3.添加对应context
|
|
||||||
ConfigContext.me().putConfig(sysConfigParam.getCode(), sysConfigParam.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(SysConfigParam sysConfigParam) {
|
|
||||||
|
|
||||||
// 1.根据id获取常量
|
|
||||||
SysConfig sysConfig = this.querySysConfig(sysConfigParam);
|
|
||||||
|
|
||||||
// 2.不能删除系统参数
|
|
||||||
if (YesOrNotEnum.Y.getCode().equals(sysConfig.getSysFlag())) {
|
|
||||||
throw new ConfigException(CONFIG_SYS_CAN_NOT_DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3.设置状态为已删除
|
|
||||||
sysConfig.setStatus(StatusEnum.DISABLE.getCode());
|
|
||||||
this.updateById(sysConfig);
|
|
||||||
|
|
||||||
// 4.删除对应context
|
|
||||||
ConfigContext.me().deleteConfig(sysConfigParam.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void edit(SysConfigParam sysConfigParam) {
|
|
||||||
|
|
||||||
// 1.根据id获取常量信息
|
|
||||||
SysConfig sysConfig = this.querySysConfig(sysConfigParam);
|
|
||||||
|
|
||||||
// 2.请求参数转化为实体
|
|
||||||
BeanUtil.copyProperties(sysConfigParam, sysConfig);
|
|
||||||
// 不能修改状态,用修改状态接口修改状态
|
|
||||||
sysConfig.setStatus(null);
|
|
||||||
|
|
||||||
// 3.更新记录
|
|
||||||
this.updateById(sysConfig);
|
|
||||||
|
|
||||||
// 4.更新对应常量context
|
|
||||||
ConfigContext.me().putConfig(sysConfigParam.getCode(), sysConfigParam.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统参数配置
|
* 获取系统参数配置
|
||||||
*
|
*
|
||||||
|
@ -111,10 +120,10 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
* @date 2020/4/14 11:19
|
* @date 2020/4/14 11:19
|
||||||
*/
|
*/
|
||||||
private SysConfig querySysConfig(SysConfigParam sysConfigParam) {
|
private SysConfig querySysConfig(SysConfigParam sysConfigParam) {
|
||||||
SysConfig sysConfig = this.getById(sysConfigParam.getId());
|
SysConfig sysConfig = this.getById(sysConfigParam.getConfigId());
|
||||||
if (ObjectUtil.isEmpty(sysConfig)) {
|
if (ObjectUtil.isEmpty(sysConfig) || sysConfig.getDelFlag().equals(YesOrNotEnum.Y.getCode())) {
|
||||||
String userTip = StrUtil.format(ConfigExceptionEnum.CONFIG_NOT_EXIST.getUserTip(), "id: " + sysConfigParam.getId());
|
String userTip = StrUtil.format(CONFIG_NOT_EXIST.getUserTip(), "id: " + sysConfigParam.getConfigId());
|
||||||
throw new ConfigException(ConfigExceptionEnum.CONFIG_NOT_EXIST, userTip);
|
throw new ConfigException(CONFIG_NOT_EXIST, userTip);
|
||||||
}
|
}
|
||||||
return sysConfig;
|
return sysConfig;
|
||||||
}
|
}
|
||||||
|
@ -130,13 +139,13 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
|
|
||||||
if (ObjectUtil.isNotNull(sysConfigParam)) {
|
if (ObjectUtil.isNotNull(sysConfigParam)) {
|
||||||
// 如果名称不为空,则带上名称搜素搜条件
|
// 如果名称不为空,则带上名称搜素搜条件
|
||||||
if (ObjectUtil.isNotEmpty(sysConfigParam.getName())) {
|
if (ObjectUtil.isNotEmpty(sysConfigParam.getConfigName())) {
|
||||||
queryWrapper.like(SysConfig::getName, sysConfigParam.getName());
|
queryWrapper.like(SysConfig::getConfigName, sysConfigParam.getConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果常量编码不为空,则带上常量编码搜素搜条件
|
// 如果常量编码不为空,则带上常量编码搜素搜条件
|
||||||
if (ObjectUtil.isNotEmpty(sysConfigParam.getCode())) {
|
if (ObjectUtil.isNotEmpty(sysConfigParam.getConfigCode())) {
|
||||||
queryWrapper.like(SysConfig::getCode, sysConfigParam.getCode());
|
queryWrapper.like(SysConfig::getConfigCode, sysConfigParam.getConfigCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果分类编码不为空,则带上分类编码
|
// 如果分类编码不为空,则带上分类编码
|
||||||
|
|
Loading…
Reference in New Issue