diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/controller/BmConfigController.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/controller/BmConfigController.java index 4a693e68..0e64c327 100644 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/controller/BmConfigController.java +++ b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/controller/BmConfigController.java @@ -1,169 +1,113 @@ package com.bonus.material.screen.controller; -import com.bonus.common.core.utils.poi.ExcelUtil; -import com.bonus.common.core.web.controller.BaseController; -import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.common.core.web.page.TableDataInfo; -import com.bonus.common.log.annotation.SysLog; +import java.util.List; +import javax.servlet.http.HttpServletResponse; import com.bonus.common.log.enums.OperaType; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.bonus.common.log.annotation.SysLog; import com.bonus.common.security.annotation.RequiresPermissions; -import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.screen.domain.BmConfig; import com.bonus.material.screen.service.IBmConfigService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.List; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.page.TableDataInfo; /** - * 参数配置 信息操作处理 + * 功能参数配置Controller * - * @author bonus + * @author xsheng + * @date 2024-09-26 */ +@Api(tags = "功能参数配置接口") @RestController @RequestMapping("/config") -@Slf4j -public class BmConfigController extends BaseController { - +public class BmConfigController extends BaseController +{ @Autowired private IBmConfigService bmConfigService; /** - * 获取参数配置列表 + * 查询功能参数配置列表 */ - - -// @ApiOperation("获取参数配置列表") - @RequiresPermissions("material:config:list") + @ApiOperation(value = "查询功能参数配置列表") + @RequiresPermissions("screen:config:list") @GetMapping("/list") - @SysLog(title = "参数配置", businessType = OperaType.QUERY,logType = 0,module = "系统管理->参数配置") -// @ApiResponses(value = { -// @ApiResponse(code = 200, message = "成功", response = TableDataInfo.class), -// @ApiResponse(code = 400, message = "无效的ID"), -// @ApiResponse(code = 404, message = "未找到用户") -// }) - public TableDataInfo list(BmConfig config) { - try{ - startPage(); - List list = bmConfigService.selectConfigList(config); - return getDataTable(list); - }catch (Exception e){ - log.error(e.toString(),e); - } - return getDataTableError(new ArrayList()); + public TableDataInfo list(BmConfig bmConfig) + { + startPage(); + List list = bmConfigService.selectBmConfigList(bmConfig); + return getDataTable(list); } - @RequiresPermissions("material:config:export") + /** + * 导出功能参数配置列表 + */ + @ApiOperation(value = "导出功能参数配置列表") + @RequiresPermissions("screen:config:export") + @SysLog(title = "功能参数配置", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出功能参数配置") @PostMapping("/export") - @SysLog(title = "参数配置", businessType = OperaType.EXPORT,logType = 0,module = "系统管理->参数配置") - public void export(HttpServletResponse response, BmConfig config) { - try{ - List list = bmConfigService.selectConfigList(config); - ExcelUtil util = new ExcelUtil(BmConfig.class); - util.exportExcel(response, list, "参数数据"); - }catch (Exception e){ - ExcelUtil util = new ExcelUtil(BmConfig.class); - util.exportExcel(response, new ArrayList(), "参数数据"); - log.error(e.toString(),e); - } + public void export(HttpServletResponse response, BmConfig bmConfig) + { + List list = bmConfigService.selectBmConfigList(bmConfig); + ExcelUtil util = new ExcelUtil(BmConfig.class); + util.exportExcel(response, list, "功能参数配置数据"); } /** - * 根据参数编号获取详细信息 + * 获取功能参数配置详细信息 */ - @GetMapping(value = "/{configId}") - public AjaxResult getInfo(@PathVariable Long configId) { - try{ - return success(bmConfigService.selectConfigById(configId)); - }catch (Exception e){ - log.error(e.toString(),e); - return error("系统异常"); - } + @ApiOperation(value = "获取功能参数配置详细信息") + @RequiresPermissions("screen:config:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(bmConfigService.selectBmConfigById(id)); } /** - * 根据参数键名查询参数值 + * 新增功能参数配置 */ - @GetMapping(value = "/configKey/{configKey}") - public AjaxResult getConfigKey(@PathVariable String configKey) { - try{ - return success(bmConfigService.selectConfigByKey(configKey)); - }catch (Exception e){ - log.error(e.toString(),e); - return error("系统异常"); - } - } - - /** - * 新增参数配置 - */ - @RequiresPermissions("material:config:add") - @SysLog(title = "参数配置", businessType = OperaType.INSERT,logType = 0,module = "系统管理->参数配置") + @ApiOperation(value = "新增功能参数配置") + @RequiresPermissions("screen:config:add") + @SysLog(title = "功能参数配置", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增功能参数配置") @PostMapping - public AjaxResult add(@Validated @RequestBody BmConfig config) { - try{ - if (!bmConfigService.checkConfigKeyUnique(config)) { - return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); - } - config.setCreateBy(SecurityUtils.getUsername()); - return toAjax(bmConfigService.insertConfig(config)); - }catch (Exception e){ - log.error(e.toString(),e); - return error("系统异常"); - } + public AjaxResult add(@RequestBody BmConfig bmConfig) + { + return toAjax(bmConfigService.insertBmConfig(bmConfig)); } /** - * 修改参数配置 + * 修改功能参数配置 */ - @RequiresPermissions("material:config:edit") + @ApiOperation(value = "修改功能参数配置") + @RequiresPermissions("screen:config:edit") + @SysLog(title = "功能参数配置", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改功能参数配置") @PutMapping - @SysLog(title = "参数配置", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->参数配置") - public AjaxResult edit(@Validated @RequestBody BmConfig config) { - try{ - if (!bmConfigService.checkConfigKeyUnique(config)) { - return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); - } - config.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(bmConfigService.updateConfig(config)); - }catch (Exception e){ - log.error(e.toString(),e); - return error("系统异常"); - } + public AjaxResult edit(@RequestBody BmConfig bmConfig) + { + return toAjax(bmConfigService.updateBmConfig(bmConfig)); } /** - * 删除参数配置 + * 删除功能参数配置 */ - @RequiresPermissions("material:config:remove") - @SysLog(title = "参数配置", businessType = OperaType.DELETE,logType = 0,module = "系统管理->参数配置") - @DeleteMapping("/{configIds}") - public AjaxResult remove(@PathVariable Long[] configIds) { - try{ - bmConfigService.deleteConfigByIds(configIds); - return success(); - }catch (Exception e){ - log.error(e.toString(),e); - return error("系统异常"); - } - } - - /** - * 刷新参数缓存 - */ - @RequiresPermissions("material:config:remove") - @DeleteMapping("/refreshCache") - @SysLog(title = "参数配置", businessType = OperaType.FLASH,logType = 0,module = "系统管理->参数配置",details = "刷新参数缓存") - public AjaxResult refreshCache() { - try{ - bmConfigService.resetConfigCache(); - return success(); - }catch (Exception e){ - log.error(e.toString(),e); - return error("系统异常"); - } + @ApiOperation(value = "删除功能参数配置") + @RequiresPermissions("screen:config:remove") + @SysLog(title = "功能参数配置", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除功能参数配置") + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(bmConfigService.deleteBmConfigByIds(ids)); } } diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/BmConfig.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/BmConfig.java index 4d639bc7..98a40708 100644 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/BmConfig.java +++ b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/BmConfig.java @@ -1,115 +1,37 @@ package com.bonus.material.screen.domain; import com.bonus.common.core.annotation.Excel; -import com.bonus.common.core.annotation.Excel.ColumnType; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; import com.bonus.common.core.web.domain.BaseEntity; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; /** - * 参数配置表 bm_config + * 功能参数配置对象 bm_config * - * @author bonus + * @author xsheng + * @date 2024-09-26 */ + + +@Data +@ToString public class BmConfig extends BaseEntity { private static final long serialVersionUID = 1L; - //用于excel导出的序号一列,不需要业务逻辑处理 - @Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT) - int sequence; - /** 参数主键 */ - @Excel(name = "参数主键", cellType = ColumnType.NUMERIC) - private Long configId; - - /** 参数名称 */ - @Excel(name = "参数名称") - private String configName; + private Long id; /** 参数键名 */ @Excel(name = "参数键名") - private String configKey; + @ApiModelProperty(value = "参数键名") + private String itemName; /** 参数键值 */ @Excel(name = "参数键值") - private String configValue; + @ApiModelProperty(value = "参数键值") + private String itemValue; - /** 系统内置(Y是 N否) */ - @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") - private String configType; - public Long getConfigId() - { - return configId; - } - - public void setConfigId(Long configId) - { - this.configId = configId; - } - - @NotBlank(message = "参数名称不能为空") - @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") - public String getConfigName() - { - return configName; - } - - public void setConfigName(String configName) - { - this.configName = configName; - } - - @NotBlank(message = "参数键名长度不能为空") - @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") - public String getConfigKey() - { - return configKey; - } - - public void setConfigKey(String configKey) - { - this.configKey = configKey; - } - - @NotBlank(message = "参数键值不能为空") - @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") - public String getConfigValue() - { - return configValue; - } - - public void setConfigValue(String configValue) - { - this.configValue = configValue; - } - - public String getConfigType() - { - return configType; - } - - public void setConfigType(String configType) - { - this.configType = configType; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("configId", getConfigId()) - .append("configName", getConfigName()) - .append("configKey", getConfigKey()) - .append("configValue", getConfigValue()) - .append("configType", getConfigType()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } } diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/MetaVo.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/MetaVo.java deleted file mode 100644 index 11abdb78..00000000 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/MetaVo.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.bonus.material.screen.domain.vo; - -import com.bonus.common.core.utils.StringUtils; - -/** - * 路由显示信息 - * - * @author bonus - */ -public class MetaVo -{ - /** - * 设置该路由在侧边栏和面包屑中展示的名字 - */ - private String title; - - /** - * 设置该路由的图标,对应路径src/assets/icons/svg - */ - private String icon; - - /** - * 设置为true,则不会被 缓存 - */ - private boolean noCache; - - /** - * 内链地址(http(s)://开头) - */ - private String link; - - public MetaVo() - { - } - - public MetaVo(String title, String icon) - { - this.title = title; - this.icon = icon; - } - - public MetaVo(String title, String icon, boolean noCache) - { - this.title = title; - this.icon = icon; - this.noCache = noCache; - } - - public MetaVo(String title, String icon, String link) - { - this.title = title; - this.icon = icon; - this.link = link; - } - - public MetaVo(String title, String icon, boolean noCache, String link) - { - this.title = title; - this.icon = icon; - this.noCache = noCache; - if (StringUtils.ishttp(link)) - { - this.link = link; - } - } - - public boolean isNoCache() - { - return noCache; - } - - public void setNoCache(boolean noCache) - { - this.noCache = noCache; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public String getIcon() - { - return icon; - } - - public void setIcon(String icon) - { - this.icon = icon; - } - - public String getLink() - { - return link; - } - - public void setLink(String link) - { - this.link = link; - } -} diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/RouterVo.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/RouterVo.java deleted file mode 100644 index d937964b..00000000 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/RouterVo.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.bonus.material.screen.domain.vo; - -import com.fasterxml.jackson.annotation.JsonInclude; - -import java.util.List; - -/** - * 路由配置信息 - * - * @author bonus - */ -@JsonInclude(JsonInclude.Include.NON_EMPTY) -public class RouterVo -{ - /** - * 路由名字 - */ - private String name; - - /** - * 路由地址 - */ - private String path; - - /** - * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现 - */ - private boolean hidden; - - /** - * 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击 - */ - private String redirect; - - /** - * 组件地址 - */ - private String component; - - /** - * 路由参数:如 {"id": 1, "name": "ry"} - */ - private String query; - - /** - * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 - */ - private Boolean alwaysShow; - - /** - * 其他元素 - */ - private MetaVo meta; - - /** - * 子路由 - */ - private List children; - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public String getPath() - { - return path; - } - - public void setPath(String path) - { - this.path = path; - } - - public boolean getHidden() - { - return hidden; - } - - public void setHidden(boolean hidden) - { - this.hidden = hidden; - } - - public String getRedirect() - { - return redirect; - } - - public void setRedirect(String redirect) - { - this.redirect = redirect; - } - - public String getComponent() - { - return component; - } - - public void setComponent(String component) - { - this.component = component; - } - - public String getQuery() - { - return query; - } - - public void setQuery(String query) - { - this.query = query; - } - - public Boolean getAlwaysShow() - { - return alwaysShow; - } - - public void setAlwaysShow(Boolean alwaysShow) - { - this.alwaysShow = alwaysShow; - } - - public MetaVo getMeta() - { - return meta; - } - - public void setMeta(MetaVo meta) - { - this.meta = meta; - } - - public List getChildren() - { - return children; - } - - public void setChildren(List children) - { - this.children = children; - } -} diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/TreeSelect.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/TreeSelect.java deleted file mode 100644 index 855e91fe..00000000 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/domain/vo/TreeSelect.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.bonus.material.screen.domain.vo; - -import com.bonus.system.api.domain.SysDept; -import com.bonus.system.api.domain.SysMenu; -import com.fasterxml.jackson.annotation.JsonInclude; - -import java.io.Serializable; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Treeselect树结构实体类 - * - * @author bonus - */ -public class TreeSelect implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 节点ID - */ - private Long id; - - /** - * 节点名称 - */ - private String label; - - private String status; - - - /** - * 子节点 - */ - @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List children; - - public TreeSelect() { - - } - - public TreeSelect(SysDept dept) { - this.id = dept.getDeptId(); - this.status = dept.getStatus(); - this.label = dept.getDeptName(); - this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); - } - - public TreeSelect(SysMenu menu) { - this.id = menu.getMenuId(); - this.label = menu.getMenuName(); - this.status = menu.getStatus(); - this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } -} diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/mapper/BmConfigMapper.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/mapper/BmConfigMapper.java index fe993d73..f61f5fe9 100644 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/mapper/BmConfigMapper.java +++ b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/mapper/BmConfigMapper.java @@ -1,76 +1,61 @@ package com.bonus.material.screen.mapper; -import com.bonus.material.screen.domain.BmConfig; import java.util.List; +import com.bonus.material.screen.domain.BmConfig; /** - * 参数配置 数据层 + * 功能参数配置Mapper接口 * - * @author bonus + * @author xsheng + * @date 2024-09-26 */ -public interface BmConfigMapper +public interface BmConfigMapper { /** - * 查询参数配置信息 + * 查询功能参数配置 * - * @param config 参数配置信息 - * @return 参数配置信息 + * @param id 功能参数配置主键 + * @return 功能参数配置 */ - public BmConfig selectConfig(BmConfig config); + public BmConfig selectBmConfigById(Long id); /** - * 通过ID查询配置 + * 查询功能参数配置列表 * - * @param configId 参数ID - * @return 参数配置信息 + * @param bmConfig 功能参数配置 + * @return 功能参数配置集合 */ - public BmConfig selectConfigById(Long configId); + public List selectBmConfigList(BmConfig bmConfig); /** - * 查询参数配置列表 + * 新增功能参数配置 * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - public List selectConfigList(BmConfig config); - - /** - * 根据键名查询参数配置信息 - * - * @param configKey 参数键名 - * @return 参数配置信息 - */ - public BmConfig checkConfigKeyUnique(String configKey); - - /** - * 新增参数配置 - * - * @param config 参数配置信息 + * @param bmConfig 功能参数配置 * @return 结果 */ - public int insertConfig(BmConfig config); + public int insertBmConfig(BmConfig bmConfig); /** - * 修改参数配置 + * 修改功能参数配置 * - * @param config 参数配置信息 + * @param bmConfig 功能参数配置 * @return 结果 */ - public int updateConfig(BmConfig config); + public int updateBmConfig(BmConfig bmConfig); /** - * 删除参数配置 + * 删除功能参数配置 * - * @param configId 参数ID + * @param id 功能参数配置主键 * @return 结果 */ - public int deleteConfigById(Long configId); + public int deleteBmConfigById(Long id); /** - * 批量删除参数信息 + * 批量删除功能参数配置 * - * @param configIds 需要删除的参数ID + * @param ids 需要删除的数据主键集合 * @return 结果 */ - public int deleteConfigByIds(Long[] configIds); -} \ No newline at end of file + public int deleteBmConfigByIds(Long[] ids); +} diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/IBmConfigService.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/IBmConfigService.java index 23a48c2d..2a06c3ff 100644 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/IBmConfigService.java +++ b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/IBmConfigService.java @@ -1,83 +1,61 @@ package com.bonus.material.screen.service; +import java.util.List; import com.bonus.material.screen.domain.BmConfig; -import java.util.List; - /** - * 参数配置 服务层 + * 功能参数配置Service接口 * - * @author bonus + * @author xsheng + * @date 2024-09-26 */ -public interface IBmConfigService +public interface IBmConfigService { /** - * 查询参数配置信息 + * 查询功能参数配置 * - * @param configId 参数配置ID - * @return 参数配置信息 + * @param id 功能参数配置主键 + * @return 功能参数配置 */ - public BmConfig selectConfigById(Long configId); + public BmConfig selectBmConfigById(Long id); /** - * 根据键名查询参数配置信息 + * 查询功能参数配置列表 * - * @param configKey 参数键名 - * @return 参数键值 + * @param bmConfig 功能参数配置 + * @return 功能参数配置集合 */ - public String selectConfigByKey(String configKey); + public List selectBmConfigList(BmConfig bmConfig); /** - * 查询参数配置列表 + * 新增功能参数配置 * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - public List selectConfigList(BmConfig config); - - /** - * 新增参数配置 - * - * @param config 参数配置信息 + * @param bmConfig 功能参数配置 * @return 结果 */ - public int insertConfig(BmConfig config); + public int insertBmConfig(BmConfig bmConfig); /** - * 修改参数配置 + * 修改功能参数配置 * - * @param config 参数配置信息 + * @param bmConfig 功能参数配置 * @return 结果 */ - public int updateConfig(BmConfig config); + public int updateBmConfig(BmConfig bmConfig); /** - * 批量删除参数信息 + * 批量删除功能参数配置 * - * @param configIds 需要删除的参数ID - */ - public void deleteConfigByIds(Long[] configIds); - - /** - * 加载参数缓存数据 - */ - public void loadingConfigCache(); - - /** - * 清空参数缓存数据 - */ - public void clearConfigCache(); - - /** - * 重置参数缓存数据 - */ - public void resetConfigCache(); - - /** - * 校验参数键名是否唯一 - * - * @param config 参数信息 + * @param ids 需要删除的功能参数配置主键集合 * @return 结果 */ - public boolean checkConfigKeyUnique(BmConfig config); + public int deleteBmConfigByIds(Long[] ids); + + /** + * 删除功能参数配置信息 + * + * @param id 功能参数配置主键 + * @return 结果 + */ + public int deleteBmConfigById(Long id); } diff --git a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/impl/BmConfigServiceImpl.java b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/impl/BmConfigServiceImpl.java index 486dfbd9..8e4209e4 100644 --- a/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/impl/BmConfigServiceImpl.java +++ b/bonus-modules/bonus-material-screen/src/main/java/com/bonus/material/screen/service/impl/BmConfigServiceImpl.java @@ -1,213 +1,96 @@ package com.bonus.material.screen.service.impl; -import com.bonus.common.core.constant.CacheConstants; -import com.bonus.common.core.constant.UserConstants; -import com.bonus.common.core.exception.ServiceException; -import com.bonus.common.core.text.Convert; -import com.bonus.common.core.utils.StringUtils; -import com.bonus.common.redis.service.RedisService; -import com.bonus.material.screen.domain.BmConfig; -import com.bonus.material.screen.mapper.BmConfigMapper; -import com.bonus.material.screen.service.IBmConfigService; +import java.util.List; +import com.bonus.common.core.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; -import java.util.Collection; -import java.util.List; +import com.bonus.material.screen.mapper.BmConfigMapper; +import com.bonus.material.screen.domain.BmConfig; +import com.bonus.material.screen.service.IBmConfigService; /** - * 参数配置 服务层实现 + * 功能参数配置Service业务层处理 * - * @author bonus + * @author xsheng + * @date 2024-09-26 */ @Service -public class BmConfigServiceImpl implements IBmConfigService +public class BmConfigServiceImpl implements IBmConfigService { @Autowired private BmConfigMapper bmConfigMapper; - @Autowired - private RedisService redisService; - /** - * 项目启动时,初始化参数到缓存 - */ - @PostConstruct - public void init() - { - loadingConfigCache(); - } - - /** - * 查询参数配置信息 + * 查询功能参数配置 * - * @param configId 参数配置ID - * @return 参数配置信息 + * @param id 功能参数配置主键 + * @return 功能参数配置 */ @Override - public BmConfig selectConfigById(Long configId) + public BmConfig selectBmConfigById(Long id) { - BmConfig config = new BmConfig(); - config.setConfigId(configId); - return bmConfigMapper.selectConfig(config); + return bmConfigMapper.selectBmConfigById(id); } /** - * 根据键名查询参数配置信息 + * 查询功能参数配置列表 * - * @param configKey 参数key - * @return 参数键值 + * @param bmConfig 功能参数配置 + * @return 功能参数配置 */ @Override - public String selectConfigByKey(String configKey) + public List selectBmConfigList(BmConfig bmConfig) { - String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey))); - if (StringUtils.isNotEmpty(configValue)) - { - return configValue; - } - BmConfig config = new BmConfig(); - config.setConfigKey(configKey); - BmConfig retConfig = bmConfigMapper.selectConfig(config); - if (StringUtils.isNotNull(retConfig)) - { - redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); - return retConfig.getConfigValue(); - } - return StringUtils.EMPTY; + return bmConfigMapper.selectBmConfigList(bmConfig); } /** - * 查询参数配置列表 + * 新增功能参数配置 * - * @param config 参数配置信息 - * @return 参数配置集合 - */ - @Override - public List selectConfigList(BmConfig config) - { - return bmConfigMapper.selectConfigList(config); - } - - /** - * 新增参数配置 - * - * @param config 参数配置信息 + * @param bmConfig 功能参数配置 * @return 结果 */ @Override - public int insertConfig(BmConfig config) + public int insertBmConfig(BmConfig bmConfig) { - int row = bmConfigMapper.insertConfig(config); - if (row > 0) - { - redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } - return row; + bmConfig.setCreateTime(DateUtils.getNowDate()); + return bmConfigMapper.insertBmConfig(bmConfig); } /** - * 修改参数配置 + * 修改功能参数配置 * - * @param config 参数配置信息 + * @param bmConfig 功能参数配置 * @return 结果 */ @Override - public int updateConfig(BmConfig config) + public int updateBmConfig(BmConfig bmConfig) { - BmConfig temp = bmConfigMapper.selectConfigById(config.getConfigId()); - if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) - { - redisService.deleteObject(getCacheKey(temp.getConfigKey())); - } - - int row = bmConfigMapper.updateConfig(config); - if (row > 0) - { - redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } - return row; + bmConfig.setUpdateTime(DateUtils.getNowDate()); + return bmConfigMapper.updateBmConfig(bmConfig); } /** - * 批量删除参数信息 + * 批量删除功能参数配置 * - * @param configIds 需要删除的参数ID - */ - @Override - public void deleteConfigByIds(Long[] configIds) - { - for (Long configId : configIds) - { - BmConfig config = selectConfigById(configId); - if (StringUtils.equals(UserConstants.YES, config.getConfigType())) - { - throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); - } - bmConfigMapper.deleteConfigById(configId); - redisService.deleteObject(getCacheKey(config.getConfigKey())); - } - } - - /** - * 加载参数缓存数据 - */ - @Override - public void loadingConfigCache() - { - List configsList = bmConfigMapper.selectConfigList(new BmConfig()); - for (BmConfig config : configsList) - { - redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } - } - - /** - * 清空参数缓存数据 - */ - @Override - public void clearConfigCache() - { - Collection keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*"); - redisService.deleteObject(keys); - } - - /** - * 重置参数缓存数据 - */ - @Override - public void resetConfigCache() - { - clearConfigCache(); - loadingConfigCache(); - } - - /** - * 校验参数键名是否唯一 - * - * @param config 参数配置信息 + * @param ids 需要删除的功能参数配置主键 * @return 结果 */ @Override - public boolean checkConfigKeyUnique(BmConfig config) + public int deleteBmConfigByIds(Long[] ids) { - Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); - BmConfig info = bmConfigMapper.checkConfigKeyUnique(config.getConfigKey()); - if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) - { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; + return bmConfigMapper.deleteBmConfigByIds(ids); } /** - * 设置cache key + * 删除功能参数配置信息 * - * @param configKey 参数键 - * @return 缓存键key + * @param id 功能参数配置主键 + * @return 结果 */ - private String getCacheKey(String configKey) + @Override + public int deleteBmConfigById(Long id) { - return CacheConstants.SYS_CONFIG_KEY + configKey; + return bmConfigMapper.deleteBmConfigById(id); } } diff --git a/bonus-modules/bonus-material-screen/src/main/resources/mapper/material/screen/BmConfigMapper.xml b/bonus-modules/bonus-material-screen/src/main/resources/mapper/material/screen/BmConfigMapper.xml index eb908d57..1740c110 100644 --- a/bonus-modules/bonus-material-screen/src/main/resources/mapper/material/screen/BmConfigMapper.xml +++ b/bonus-modules/bonus-material-screen/src/main/resources/mapper/material/screen/BmConfigMapper.xml @@ -3,115 +3,74 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - + + + + - + - - - select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark - from sys_config + + + select id, item_name, item_value, create_by, create_time, update_by, update_time from bm_config - - - - - - and config_id = #{configId} - - - and config_key = #{configKey} - - - - - + + + and item_name like concat('%', #{itemName}, '%') + and item_value = #{itemValue} + - + + where id = #{id} - - - - - - - insert into sys_config ( - config_name, - config_key, - config_value, - config_type, - create_by, - remark, - create_time - )values( - #{configName}, - #{configKey}, - #{configValue}, - #{configType}, - #{createBy}, - #{remark}, - sysdate() - ) + + + insert into bm_config + + item_name, + item_value, + create_by, + create_time, + update_by, + update_time, + + + #{itemName}, + #{itemValue}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + - - - update sys_config - - config_name = #{configName}, - config_key = #{configKey}, - config_value = #{configValue}, - config_type = #{configType}, - update_by = #{updateBy}, - remark = #{remark}, - update_time = sysdate() - - where config_id = #{configId} + + + update bm_config + + item_name = #{itemName}, + item_value = #{itemValue}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} - - - delete from sys_config where config_id = #{configId} + + + delete from bm_config where id = #{id} - - - delete from sys_config where config_id in - - #{configId} + + + delete from bm_config where id in + + #{id} - \ No newline at end of file