Commit 982466bc authored by lcl's avatar lcl

u and a

parent 2337ae84
...@@ -71,6 +71,16 @@ public class SysConfigController extends BaseController { ...@@ -71,6 +71,16 @@ public class SysConfigController extends BaseController {
*/ */
@GetMapping(value = "/configKey/{configKey}") @GetMapping(value = "/configKey/{configKey}")
public R<Void> getConfigKey(@PathVariable String configKey) { public R<Void> getConfigKey(@PathVariable String configKey) {
return R.ok(configService.selectConfigValueByKey(configKey));
}
/**
* 根据参数键名查询参数值
*
* @param configKey 参数Key
*/
@GetMapping(value = "/{configKey}")
public R<SysConfig> getConfig(@PathVariable String configKey) {
return R.ok(configService.selectConfigByKey(configKey)); return R.ok(configService.selectConfigByKey(configKey));
} }
...@@ -161,4 +171,13 @@ public class SysConfigController extends BaseController { ...@@ -161,4 +171,13 @@ public class SysConfigController extends BaseController {
DskAccessTokenVO dskAccessTokenVO = configService.getDskAccessToken(); DskAccessTokenVO dskAccessTokenVO = configService.getDskAccessToken();
return R.ok(dskAccessTokenVO); return R.ok(dskAccessTokenVO);
} }
/**
* 根据键修改值
*/
@PutMapping(value = "/updateValue")
public R<Void> updateByConfigKey(@RequestBody SysConfig config) {
configService.updateByConfigKey(config);
return R.ok();
}
} }
package com.dsk.cscec.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.cscec.domain.SysPush;
import com.dsk.cscec.service.ISysPushService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 系统推送(SysPush)表控制层
*
* @author lcl
* @since 2023-12-14 10:09:24
*/
@RestController
@RequestMapping("sysPush")
public class SysPushController extends BaseController {
/**
* 服务对象
*/
@Autowired
private ISysPushService baseService;
/**
* 推送分页列表
*/
@GetMapping("/pageList")
public TableDataInfo<SysPush> pageList(SysPush bean, PageQuery query) {
return baseService.pageList(bean, query);
}
/**
* 添加推送人
*/
@PostMapping
public R<Void> add(@RequestBody SysPush bean) {
return toAjax(baseService.save(bean));
}
/**
* 修改推送状态
*/
@PutMapping("/updateStatus")
public R<Void> updateStatus(@RequestBody SysPush bean) {
return toAjax(baseService.update(Wrappers.<SysPush>lambdaUpdate()
.set(SysPush::getStatus, bean.getStatus()).eq(SysPush::getId, bean.getId())));
}
/**
* 删除推送人
*/
@DeleteMapping("/{id}")
public R<Void> del(@PathVariable Long id) {
return toAjax(baseService.removeById(id));
}
}
package com.dsk.cscec.domain;
import java.util.Date;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
* 系统推送(SysPush)表实体类
*
* @author lcl
* @since 2023-12-14 10:09:24
*/
@Data
public class SysPush implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id")
private Long id;
/**
* 推送类型编码
*/
private String pushTypeCode;
/**
* 推送类型
*/
private String pushType;
/**
* 姓名
*/
private String name;
/**
* 联系方式
*/
private String contact;
/**
* 状态 0:正常 1:停用
*/
private Integer status;
private Date createTime;
private String tanentId;
}
package com.dsk.cscec.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.cscec.domain.SysPush;
/**
* 系统推送(SysPush)表数据库访问层
*
* @author lcl
* @since 2023-12-14 10:09:24
*/
public interface SysPushMapper extends BaseMapper<SysPush> {
}
package com.dsk.cscec.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.cscec.domain.SysPush;
/**
* 系统推送(SysPush)表服务接口
*
* @author lcl
* @since 2023-12-14 10:09:24
*/
public interface ISysPushService extends IService<SysPush> {
TableDataInfo<SysPush> pageList(SysPush bean, PageQuery query);
}
package com.dsk.cscec.service.impl;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.common.exception.ServiceException;
import com.dsk.cscec.mapper.SysPushMapper;
import com.dsk.cscec.domain.SysPush;
import com.dsk.cscec.service.ISysPushService;
import jodd.bean.BeanException;
import org.springframework.stereotype.Service;
/**
* 系统推送(SysPush)表服务实现类
*
* @author lcl
* @since 2023-12-14 10:09:24
*/
@Service
public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> implements ISysPushService {
@Override
public TableDataInfo<SysPush> pageList(SysPush bean, PageQuery query) {
if(ObjectUtils.isEmpty(bean.getPushTypeCode())) throw new BeanException("推送类型code不能为空!");
return TableDataInfo.build(baseMapper.selectPage(query.build(), Wrappers.<SysPush>lambdaQuery()
.eq(SysPush::getPushTypeCode, bean.getPushTypeCode())
.orderByDesc(SysPush::getCreateTime)));
}
}
...@@ -48,7 +48,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo ...@@ -48,7 +48,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
private final StringBuilder failureMsg = new StringBuilder(); private final StringBuilder failureMsg = new StringBuilder();
public SysUserImportListener(Boolean isUpdateSupport) { public SysUserImportListener(Boolean isUpdateSupport) {
String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword"); String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigValueByKey("sys.user.initPassword");
this.userService = SpringUtils.getBean(ISysUserService.class); this.userService = SpringUtils.getBean(ISysUserService.class);
this.deptService = SpringUtils.getBean(ISysDeptService.class); this.deptService = SpringUtils.getBean(ISysDeptService.class);
this.roleService = SpringUtils.getBean(ISysRoleService.class); this.roleService = SpringUtils.getBean(ISysRoleService.class);
......
...@@ -31,7 +31,14 @@ public interface ISysConfigService { ...@@ -31,7 +31,14 @@ public interface ISysConfigService {
* @param configKey 参数键名 * @param configKey 参数键名
* @return 参数键值 * @return 参数键值
*/ */
String selectConfigByKey(String configKey); String selectConfigValueByKey(String configKey);
/**
* 根据键名查询参数配置信息
*
* @param configKey 参数键名
* @return 参数键值
*/
SysConfig selectConfigByKey(String configKey);
/** /**
* 获取验证码开关 * 获取验证码开关
...@@ -102,4 +109,7 @@ public interface ISysConfigService { ...@@ -102,4 +109,7 @@ public interface ISysConfigService {
boolean checkConfigKeyUnique(SysConfig config); boolean checkConfigKeyUnique(SysConfig config);
DskAccessTokenVO getDskAccessToken(); DskAccessTokenVO getDskAccessToken();
void updateByConfigKey(SysConfig config);
} }
...@@ -87,7 +87,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { ...@@ -87,7 +87,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
*/ */
@Cacheable(cacheNames = CacheNames.SYS_CONFIG, key = "#configKey") @Cacheable(cacheNames = CacheNames.SYS_CONFIG, key = "#configKey")
@Override @Override
public String selectConfigByKey(String configKey) { public String selectConfigValueByKey(String configKey) {
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
.eq(SysConfig::getConfigKey, configKey)); .eq(SysConfig::getConfigKey, configKey));
if (ObjectUtil.isNotNull(retConfig)) { if (ObjectUtil.isNotNull(retConfig)) {
...@@ -96,6 +96,18 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { ...@@ -96,6 +96,18 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
/**
* 根据键名查询参数配置信息
*
* @param configKey 参数key
* @return 参数键值
*/
@Override
public SysConfig selectConfigByKey(String configKey) {
return baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
.eq(SysConfig::getConfigKey, configKey));
}
/** /**
* 获取验证码开关 * 获取验证码开关
* *
...@@ -103,7 +115,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { ...@@ -103,7 +115,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
*/ */
@Override @Override
public boolean selectCaptchaEnabled() { public boolean selectCaptchaEnabled() {
String captchaEnabled = SpringUtils.getAopProxy(this).selectConfigByKey("sys.account.captchaEnabled"); String captchaEnabled = SpringUtils.getAopProxy(this).selectConfigValueByKey("sys.account.captchaEnabled");
if (StringUtils.isEmpty(captchaEnabled)) { if (StringUtils.isEmpty(captchaEnabled)) {
return true; return true;
} }
...@@ -296,6 +308,16 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { ...@@ -296,6 +308,16 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
return BeanUtil.toBean(dataObj, DskAccessTokenVO.class); return BeanUtil.toBean(dataObj, DskAccessTokenVO.class);
} }
@Override
public void updateByConfigKey(SysConfig config) {
int update = baseMapper.update(config, Wrappers.<SysConfig>lambdaUpdate()
.set(SysConfig::getConfigValue, config.getConfigValue())
.eq(SysConfig::getConfigKey, config.getConfigKey()));
if(update == 0){
throw new ServiceException("修改失败!");
}
}
/** /**
* 根据参数 key 获取参数值 * 根据参数 key 获取参数值
* *
...@@ -304,7 +326,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService { ...@@ -304,7 +326,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
*/ */
@Override @Override
public String getConfigValue(String configKey) { public String getConfigValue(String configKey) {
return SpringUtils.getAopProxy(this).selectConfigByKey(configKey); return SpringUtils.getAopProxy(this).selectConfigValueByKey(configKey);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment