#增加系统参数配置模块
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
package com.maibu.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.maibu.core.controller.BaseController;
|
||||||
|
import com.maibu.core.domain.AjaxResult;
|
||||||
|
import com.maibu.core.domain.entity.SysParam;
|
||||||
|
import com.maibu.service.SysParamService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统参数管理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/param")
|
||||||
|
public class SysParamController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysParamService sysParamService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统参数列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult list() {
|
||||||
|
try {
|
||||||
|
return AjaxResult.success(sysParamService.list());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或者修改系统参数
|
||||||
|
*/
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
public AjaxResult save(@RequestBody List<SysParam> sysParams) {
|
||||||
|
try {
|
||||||
|
return AjaxResult.success(sysParamService.save(sysParams));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("新增修改系统参数出错", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,3 +1,28 @@
|
|||||||
|
system.param.systemName.name = 系统名称
|
||||||
|
system.param.systemName.desc = 系统名称
|
||||||
|
|
||||||
|
system.param.defaultStationName.name = 默认场站
|
||||||
|
system.param.defaultStationName.desc = "默认场站
|
||||||
|
|
||||||
|
system.param.defaultLanguage.name = 默认语言
|
||||||
|
system.param.defaultLanguage.desc = 默认语言
|
||||||
|
|
||||||
|
system.param.defaultZoneId.name = 默认时区
|
||||||
|
system.param.defaultZoneId.desc = 默认时区
|
||||||
|
|
||||||
|
system.param.daylightSavingTime.name = 夏令时
|
||||||
|
system.param.daylightSavingTime.desc = 夏令时
|
||||||
|
|
||||||
|
system.param.defaultUnit.name = 默认单位
|
||||||
|
system.param.defaultUnit.desc = 默认单位
|
||||||
|
|
||||||
|
system.param.defaultDateFormat.name = 默认日期格式
|
||||||
|
system.param.defaultDateFormat.desc = 默认日期格式
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#\u9519\u8BEF\u6D88\u606F
|
#\u9519\u8BEF\u6D88\u606F
|
||||||
not.null=* \u5FC5\u987B\u586B\u5199
|
not.null=* \u5FC5\u987B\u586B\u5199
|
||||||
user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF
|
user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||||
|
|||||||
@@ -1,3 +1,32 @@
|
|||||||
|
system.param.systemName.name = System Name
|
||||||
|
system.param.systemName.desc = System Name
|
||||||
|
|
||||||
|
system.param.defaultStationName.name = Default Station
|
||||||
|
system.param.defaultStationName.desc = Default Station
|
||||||
|
|
||||||
|
system.param.defaultLanguage.name = Default Language
|
||||||
|
system.param.defaultLanguage.desc = Default Language
|
||||||
|
|
||||||
|
system.param.defaultZoneId.name = Default Zone
|
||||||
|
system.param.defaultZoneId.desc = Default Zone
|
||||||
|
|
||||||
|
system.param.daylightSavingTime.name = Daylight Saving Time
|
||||||
|
system.param.daylightSavingTime.desc = Daylight Saving Time
|
||||||
|
|
||||||
|
system.param.defaultUnit.name = Default Unit
|
||||||
|
system.param.defaultUnit.desc = Default Unit
|
||||||
|
|
||||||
|
system.param.defaultDateFormat.name = Default Date Format
|
||||||
|
system.param.defaultDateFormat.desc = Default Date Format
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#\u9519\u8BEF\u6D88\u606F
|
#\u9519\u8BEF\u6D88\u606F
|
||||||
not.null=* \u5FC5\u987B\u586B\u5199
|
not.null=* \u5FC5\u987B\u586B\u5199
|
||||||
user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF
|
user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||||
|
|||||||
@@ -1,3 +1,31 @@
|
|||||||
|
system.param.systemName.name = 系统名称
|
||||||
|
system.param.systemName.desc = 系统名称
|
||||||
|
|
||||||
|
system.param.defaultStationName.name = 默认场站
|
||||||
|
system.param.defaultStationName.desc = "默认场站
|
||||||
|
|
||||||
|
system.param.defaultLanguage.name = 默认语言
|
||||||
|
system.param.defaultLanguage.desc = 默认语言
|
||||||
|
|
||||||
|
system.param.defaultZoneId.name = 默认时区
|
||||||
|
system.param.defaultZoneId.desc = 默认时区
|
||||||
|
|
||||||
|
system.param.daylightSavingTime.name = 夏令时
|
||||||
|
system.param.daylightSavingTime.desc = 夏令时
|
||||||
|
|
||||||
|
system.param.defaultUnit.name = 默认单位
|
||||||
|
system.param.defaultUnit.desc = 默认单位
|
||||||
|
|
||||||
|
system.param.defaultDateFormat.name = 默认日期格式
|
||||||
|
system.param.defaultDateFormat.desc = 默认日期格式
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#\u9519\u8BEF\u6D88\u606F
|
#\u9519\u8BEF\u6D88\u606F
|
||||||
not.null=* \u5FC5\u987B\u586B\u5199
|
not.null=* \u5FC5\u987B\u586B\u5199
|
||||||
user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF
|
user.jcaptcha.error=\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.maibu.core.domain.entity;
|
||||||
|
|
||||||
|
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 com.maibu.core.domain.OrgNoUserDO;
|
||||||
|
import com.maibu.core.enums.SysParamType;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@TableName(value = "sys_param")
|
||||||
|
public class SysParam extends OrgNoUserDO {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private SysParamType paramType;
|
||||||
|
|
||||||
|
private String paramKey;
|
||||||
|
|
||||||
|
private String nameTranslateKey;
|
||||||
|
|
||||||
|
private String paramValue;
|
||||||
|
|
||||||
|
private String descTranslateKey;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String nameTranslate;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String descTranslate;
|
||||||
|
|
||||||
|
private String valueRange;
|
||||||
|
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.maibu.core.enums;
|
package com.maibu.core.enums;
|
||||||
|
|
||||||
import com.maibu.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.maibu.core.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum SysParamType {
|
||||||
|
|
||||||
|
site("site", "场站维度"),
|
||||||
|
|
||||||
|
org("org", "组织维度"),
|
||||||
|
|
||||||
|
global("global", "全局维度"),
|
||||||
|
|
||||||
|
personal("personal", "个人维度");
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,34 +1,64 @@
|
|||||||
package com.maibu.init;
|
package com.maibu.init;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import com.maibu.core.business.*;
|
import org.checkerframework.checker.units.qual.s;
|
||||||
import com.maibu.mapper.*;
|
|
||||||
import com.maibu.service.impl.IotDeviceCommonService;
|
|
||||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.maibu.constant.FastBeeConstant;
|
import com.maibu.constant.FastBeeConstant;
|
||||||
|
import com.maibu.core.business.AlarmOrderConfig;
|
||||||
|
import com.maibu.core.business.Device;
|
||||||
|
import com.maibu.core.business.DeviceModel;
|
||||||
|
import com.maibu.core.business.DevicePlan;
|
||||||
|
import com.maibu.core.business.DevicePlanTask;
|
||||||
|
import com.maibu.core.business.DeviceRunParam;
|
||||||
|
import com.maibu.core.business.ErrorIdentificationStandard;
|
||||||
|
import com.maibu.core.business.IoTCommonDevice;
|
||||||
|
import com.maibu.core.business.OrderModel;
|
||||||
|
import com.maibu.core.business.Product;
|
||||||
|
import com.maibu.core.domain.entity.SysParam;
|
||||||
import com.maibu.core.domain.entity.SysSite;
|
import com.maibu.core.domain.entity.SysSite;
|
||||||
import com.maibu.core.enums.DeviceTaskStaus;
|
import com.maibu.core.enums.DeviceTaskStaus;
|
||||||
import com.maibu.influxdb.util.InfluxDBUtil;
|
import com.maibu.influxdb.util.InfluxDBUtil;
|
||||||
|
import com.maibu.mapper.AlarmOrderConfigMapper;
|
||||||
|
import com.maibu.mapper.DevicePlanMapper;
|
||||||
|
import com.maibu.mapper.DevicePlanTaskMapper;
|
||||||
|
import com.maibu.mapper.DeviceProductMapper;
|
||||||
|
import com.maibu.mapper.DeviceRunParamMapper;
|
||||||
|
import com.maibu.mapper.ErrorIdentificationStandardMapper;
|
||||||
|
import com.maibu.mapper.IotDeviceCommonMapper;
|
||||||
|
import com.maibu.mapper.OrderModelMapper;
|
||||||
|
import com.maibu.mapper.SysDeviceModelMapper;
|
||||||
|
import com.maibu.mapper.SysParamMapper;
|
||||||
|
import com.maibu.mapper.SysSiteMapper;
|
||||||
import com.maibu.memory.GlobalMemory;
|
import com.maibu.memory.GlobalMemory;
|
||||||
import com.maibu.memory.SiteMemory;
|
import com.maibu.memory.SiteMemory;
|
||||||
import com.maibu.mqtt.MqttClientUtil;
|
|
||||||
import com.maibu.mybatis.LambdaQueryWrapperX;
|
import com.maibu.mybatis.LambdaQueryWrapperX;
|
||||||
import com.maibu.service.DevicePlanTaskMonitorService;
|
import com.maibu.service.DevicePlanTaskMonitorService;
|
||||||
import com.maibu.service.DeviceThreadService;
|
import com.maibu.service.DeviceThreadService;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import com.maibu.service.impl.IotDeviceCommonService;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -81,6 +111,7 @@ public class InitThread implements ApplicationRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ErrorIdentificationStandardMapper errorIdentificationStandardMapper;
|
private ErrorIdentificationStandardMapper errorIdentificationStandardMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private OrderModelMapper orderModelMapper;
|
private OrderModelMapper orderModelMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AlarmOrderConfigMapper alarmOrderConfigMapper;
|
private AlarmOrderConfigMapper alarmOrderConfigMapper;
|
||||||
@@ -88,6 +119,12 @@ public class InitThread implements ApplicationRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IotDeviceCommonService commonService;
|
private IotDeviceCommonService commonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceLoader resourceLoader;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysParamMapper sysParamMapper;
|
||||||
|
|
||||||
@Value("${influxdb.url}")
|
@Value("${influxdb.url}")
|
||||||
private String influxDBUrl;
|
private String influxDBUrl;
|
||||||
|
|
||||||
@@ -119,12 +156,15 @@ public class InitThread implements ApplicationRunner {
|
|||||||
private String mqttClientId;
|
private String mqttClientId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws MqttException {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
recoverMemory();
|
recoverMemory();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() throws MqttException {
|
private void init() throws Exception {
|
||||||
|
//初始化系统参数
|
||||||
|
initSystemParam();
|
||||||
|
|
||||||
// 初始化InfluxDBUtil
|
// 初始化InfluxDBUtil
|
||||||
GlobalMemory.influxDBUtil = new InfluxDBUtil(influxDBUrl, influxDBToken, influxDBOrg, influxDBBucket);
|
GlobalMemory.influxDBUtil = new InfluxDBUtil(influxDBUrl, influxDBToken, influxDBOrg, influxDBBucket);
|
||||||
|
|
||||||
@@ -317,4 +357,38 @@ public class InitThread implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initSystemParam() throws IOException {
|
||||||
|
LambdaQueryWrapper<SysParam> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<SysParam> list = sysParamMapper.selectList(queryWrapper);
|
||||||
|
try {
|
||||||
|
// 读取resource目录下的dsystemParam.json文件
|
||||||
|
org.springframework.core.io.Resource resource = resourceLoader
|
||||||
|
.getResource("classpath:systemParam.json");
|
||||||
|
// 使用fastjson2转换为DeviceConfig对象
|
||||||
|
String jsonContent;
|
||||||
|
jsonContent = IoUtil.readUtf8(resource.getInputStream());
|
||||||
|
List<SysParam> params = JSON.parseArray(jsonContent, SysParam.class);
|
||||||
|
List<SysParam> saveList = new ArrayList<>();
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
saveList.addAll(params);
|
||||||
|
} else {
|
||||||
|
Map<String, SysParam> map = list.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
SysParam::getParamKey,
|
||||||
|
sysParam -> sysParam));
|
||||||
|
if (!CollectionUtils.isEmpty(params)) {
|
||||||
|
params.forEach(x -> {
|
||||||
|
if (!map.containsKey(x.getParamKey())) {
|
||||||
|
saveList.add(x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sysParamMapper.saveOrUpdateBatch(saveList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("初始化系统参数失败", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
65
maibu-netty-server/src/main/resources/systemParam.json
Normal file
65
maibu-netty-server/src/main/resources/systemParam.json
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "systemName",
|
||||||
|
"nameTranslateKey": "system.param.systemName.name",
|
||||||
|
"paramValue": "光伏机器人环境感知服务平台",
|
||||||
|
"descTranslateKey": "system.param.systemName.desc",
|
||||||
|
"dataType": "String",
|
||||||
|
"range": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "defaultStationName",
|
||||||
|
"nameTranslateKey": "system.param.defaultStationName.name",
|
||||||
|
"paramValue": "",
|
||||||
|
"descTranslateKey": "system.param.defaultStationName.desc",
|
||||||
|
"dataType": "String",
|
||||||
|
"range": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "defaultLanguage",
|
||||||
|
"nameTranslateKey": "system.param.defaultLanguage.name",
|
||||||
|
"paramValue": "zh_CN",
|
||||||
|
"descTranslateKey": "system.param.defaultLanguage.desc",
|
||||||
|
"dataType": "String",
|
||||||
|
"range": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "defaultZoneId",
|
||||||
|
"nameTranslateKey": "system.param.defaultZoneId.name",
|
||||||
|
"paramValue": "Asia/Shanghai",
|
||||||
|
"descTranslateKey": "system.param.defaultZoneId.desc",
|
||||||
|
"dataType": "String",
|
||||||
|
"range": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "daylightSavingTime",
|
||||||
|
"nameTranslateKey": "system.param.daylightSavingTime.name",
|
||||||
|
"paramValue": "true",
|
||||||
|
"descTranslateKey": "system.param.daylightSavingTime.desc",
|
||||||
|
"dataType": "Boolean",
|
||||||
|
"range": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "defaultUnit",
|
||||||
|
"nameTranslateKey": "system.param.defaultUnit.name",
|
||||||
|
"paramValue": "公制",
|
||||||
|
"descTranslateKey": "system.param.defaultUnit.desc",
|
||||||
|
"dataType": "String",
|
||||||
|
"range": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paramType": "global",
|
||||||
|
"paramKey": "defaultDateFormat",
|
||||||
|
"nameTranslateKey": "system.param.defaultDateFormat.name",
|
||||||
|
"paramValue": "YYYY-MM-DD HH:mm:ss",
|
||||||
|
"descTranslateKey": "system.param.defaultDateFormat.desc",
|
||||||
|
"dataType": "String",
|
||||||
|
"range": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.maibu.mapper;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.maibu.core.domain.entity.SysParam;
|
||||||
|
import com.maibu.mybatis.mapper.BaseMapperX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备历史状态
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface SysParamMapper extends BaseMapperX<SysParam> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.maibu.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.maibu.core.domain.entity.SysParam;
|
||||||
|
import com.maibu.core.enums.SysParamType;
|
||||||
|
import com.maibu.mapper.SysParamMapper;
|
||||||
|
import com.maibu.utils.MessageUtils;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysParamService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysParamMapper sysParamMapper;
|
||||||
|
|
||||||
|
public Map<SysParamType, List<SysParam>> list() {
|
||||||
|
LambdaQueryWrapper<SysParam> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<SysParam> sysParams = sysParamMapper.selectList(queryWrapper);
|
||||||
|
translateSysParam(sysParams);
|
||||||
|
Map<SysParamType, List<SysParam>> result = sysParams.stream()
|
||||||
|
.collect(Collectors.groupingBy(SysParam::getParamType));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void translateSysParam(List<SysParam> sysParams) {
|
||||||
|
if (!CollectionUtils.isEmpty(sysParams)) {
|
||||||
|
sysParams.forEach(x -> {
|
||||||
|
x.setNameTranslate(MessageUtils.message(x.getNameTranslateKey()));
|
||||||
|
x.setDescTranslate(MessageUtils.message(x.getDescTranslateKey()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean save(List<SysParam> sysParam) {
|
||||||
|
return sysParamMapper.saveOrUpdateBatch(sysParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,15 +1,6 @@
|
|||||||
package com.maibu.service;
|
package com.maibu.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import java.util.List;
|
||||||
import com.maibu.core.business.Device;
|
|
||||||
import com.maibu.core.domain.entity.SysRole;
|
|
||||||
import com.maibu.core.domain.entity.SysSite;
|
|
||||||
import com.maibu.core.domain.model.LoginUser;
|
|
||||||
import com.maibu.exception.ServiceException;
|
|
||||||
import com.maibu.mapper.SysRegionMapper;
|
|
||||||
import com.maibu.mapper.SysSiteMapper;
|
|
||||||
import com.maibu.memory.GlobalMemory;
|
|
||||||
import com.maibu.memory.SiteMemory;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -17,8 +8,13 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import java.util.List;
|
import com.maibu.core.domain.entity.SysRole;
|
||||||
|
import com.maibu.core.domain.entity.SysSite;
|
||||||
|
import com.maibu.core.domain.model.LoginUser;
|
||||||
|
import com.maibu.mapper.SysSiteMapper;
|
||||||
|
import com.maibu.memory.GlobalMemory;
|
||||||
|
import com.maibu.memory.SiteMemory;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SysSiteService {
|
public class SysSiteService {
|
||||||
|
|||||||
Reference in New Issue
Block a user