|
|
@@ -3,6 +3,7 @@ package com.kym.service.impl;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
import com.kym.common.utils.ConfigUtil;
|
|
|
import com.kym.entity.Config;
|
|
|
@@ -11,7 +12,6 @@ import com.kym.entity.queryParams.ConfigQueryParam;
|
|
|
import com.kym.mapper.ConfigMapper;
|
|
|
import com.kym.service.ConfigService;
|
|
|
import com.kym.service.cache.PubSubService;
|
|
|
-import com.kym.service.mybatisplus.MyBaseServiceImpl;
|
|
|
import jakarta.annotation.PostConstruct;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -26,7 +26,7 @@ import java.util.Map;
|
|
|
* @date 2025-06-15T19:17:14.374702500
|
|
|
*/
|
|
|
@Service("configService")
|
|
|
-public class ConfigServiceImpl extends MyBaseServiceImpl<ConfigMapper, Config> implements ConfigService {
|
|
|
+public class ConfigServiceImpl extends MPJBaseServiceImpl<ConfigMapper, Config> implements ConfigService {
|
|
|
|
|
|
@Resource
|
|
|
private PubSubService pubSubService;
|
|
|
@@ -34,43 +34,47 @@ public class ConfigServiceImpl extends MyBaseServiceImpl<ConfigMapper, Config> i
|
|
|
@Override
|
|
|
public Number add(Config config) {
|
|
|
// config.setCompanyId(1)
|
|
|
- config.setStatus(true);
|
|
|
- var rows = insertIgnore(config);
|
|
|
+ config.setDelete(false);
|
|
|
+ var rows = save(config);
|
|
|
|
|
|
- if(rows>0){
|
|
|
+ if(rows){
|
|
|
pubSubService.publish(PubSubService.CHANNEL,
|
|
|
JSONUtil.toJsonStr(
|
|
|
Map.of("node", ConfigUtil.getNode(), "config", config)
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- return rows;
|
|
|
+ return config.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void modify(Config config) {
|
|
|
UpdateWrapper<Config> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.set("value", config.getValue());
|
|
|
+ updateWrapper.set("config_value", config.getConfigValue());
|
|
|
updateWrapper.set("remark", config.getRemark());
|
|
|
- updateWrapper.set("valueType", config.getValueType());
|
|
|
- updateWrapper.eq("key", config.getKey());
|
|
|
+ updateWrapper.set("value_type", config.getValueType());
|
|
|
+ updateWrapper.eq("config_key", config.getConfigKey());
|
|
|
update(updateWrapper);
|
|
|
|
|
|
pubSubService.publish(PubSubService.CHANNEL,
|
|
|
JSONUtil.toJsonStr(
|
|
|
Map.of("node", ConfigUtil.getNode(), "config", config)
|
|
|
));
|
|
|
+
|
|
|
+ log.debug( JSONUtil.toJsonStr(
|
|
|
+ Map.of("node", ConfigUtil.getNode(), "config", config)
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageBean<Config> list(ConfigQueryParam query) {
|
|
|
PageHelper.startPage(query.getPageNum(), query.getPageSize());
|
|
|
var list = lambdaQuery()
|
|
|
- .like(CommUtil.isNotEmptyAndNull(query.getKey()), Config::getKey, query.getKey())
|
|
|
- .like(CommUtil.isNotEmptyAndNull(query.getValue()), Config::getValue, query.getValue())
|
|
|
+ .like(CommUtil.isNotEmptyAndNull(query.getKey()), Config::getConfigKey, query.getKey())
|
|
|
+ .like(CommUtil.isNotEmptyAndNull(query.getValue()), Config::getConfigValue, query.getValue())
|
|
|
.like(CommUtil.isNotEmptyAndNull(query.getValueType()), Config::getValueType, query.getValueType())
|
|
|
.like(CommUtil.isNotEmptyAndNull(query.getRemark()), Config::getRemark, query.getRemark())
|
|
|
- .like(CommUtil.isNotEmptyAndNull(query.getStatus()), Config::isStatus, query.getStatus())
|
|
|
+ .like(CommUtil.isNotEmptyAndNull(query.getDelete()), Config::isDelete, query.getDelete())
|
|
|
.list();
|
|
|
return new PageBean<>(list);
|
|
|
}
|
|
|
@@ -83,9 +87,9 @@ public class ConfigServiceImpl extends MyBaseServiceImpl<ConfigMapper, Config> i
|
|
|
@Override
|
|
|
public void remove(long id) {
|
|
|
Config cfg = getById(id);
|
|
|
- cfg.setStatus(false);
|
|
|
+ cfg.setDelete(true);
|
|
|
UpdateWrapper<Config> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.set("status", false);
|
|
|
+ updateWrapper.set("is_delete", false);
|
|
|
updateWrapper.eq("id", id);
|
|
|
update(updateWrapper);
|
|
|
|
|
|
@@ -103,5 +107,18 @@ public class ConfigServiceImpl extends MyBaseServiceImpl<ConfigMapper, Config> i
|
|
|
ConfigUtil.initConfig(list);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void status(Config config) {
|
|
|
+ UpdateWrapper<Config> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.set("is_delete", config.isDelete());
|
|
|
+ updateWrapper.eq("id", config.getId());
|
|
|
+ update(updateWrapper);
|
|
|
+
|
|
|
+ pubSubService.publish(PubSubService.CHANNEL,
|
|
|
+ JSONUtil.toJsonStr(
|
|
|
+ Map.of("node", ConfigUtil.getNode(), "config", config)
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|