添加全局配置服务

This commit is contained in:
liuchengqian 2022-06-15 18:01:58 +08:00
parent 0478ffa213
commit 18074cf605
9 changed files with 581 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package com.xkrs.controller;
import com.xkrs.service.ConfigGlobalService;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Map;
/**
* 全局配置服务
*/
@RestController
public class ConfigGlobalController {
@Resource
private ConfigGlobalService configGlobalService;
/**
* 用户全局配置服务
*/
@PostMapping("/configGlobalUser")
public String configGlobalUser(@Nullable @RequestBody Map<String, Long> configMap) {
return configGlobalService.configGlobalUser(configMap);
}
/**
* 火情信息全局配置服务
*/
@PostMapping("/configGlobalFirePoint")
public String configGlobalFirePoint(@Nullable @RequestBody Map<String, Long> configMap) {
return configGlobalService.configGlobalFirePoint(configMap);
}
/**
* 短信全局配置服务
*/
@PostMapping("/configGlobalSMS")
public String configGlobalSMS(@Nullable @RequestBody Map<String, Long> configMap) {
return configGlobalService.configGlobalSMS(configMap);
}
}

View File

@ -0,0 +1,11 @@
package com.xkrs.dao;
import com.xkrs.model.entity.ConfigGlobalFirePointEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface ConfigGlobalFirePointDao extends JpaRepository<ConfigGlobalFirePointEntity, Long>, JpaSpecificationExecutor<ConfigGlobalFirePointEntity> {
}

View File

@ -0,0 +1,10 @@
package com.xkrs.dao;
import com.xkrs.model.entity.ConfigGlobalSMSEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface ConfigGlobalSMSDao extends JpaRepository<ConfigGlobalSMSEntity, Long>, JpaSpecificationExecutor<ConfigGlobalSMSEntity> {
}

View File

@ -0,0 +1,10 @@
package com.xkrs.dao;
import com.xkrs.model.entity.ConfigGlobalUserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface ConfigGlobalUserDao extends JpaRepository<ConfigGlobalUserEntity, Long>, JpaSpecificationExecutor<ConfigGlobalUserEntity> {
}

View File

@ -0,0 +1,83 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* 火情信息全局配置信息
*/
@Entity
@Table(name = "config_global_fire_point")
public class ConfigGlobalFirePointEntity implements Serializable {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "config_global_fire_point_seq_gen")
@SequenceGenerator(name = "config_global_fire_point_seq_gen", sequenceName = "config_global_fire_point_id_seq", allocationSize = 1)
private Long id;
/**
* 过期后能否获取今日火情信息
*/
private Long todayAbleWhenExpired;
/**
* 过期后能否获取历史火情信息
*/
private Long historyAbleWhenExpired;
/**
* 过期后能否获取统计分析数据
*/
private Long statisticsAbleWhenExpired;
/**
* 过期后能否使用导航功能
*/
private Long navigateAbleWhenExpired;
public ConfigGlobalFirePointEntity() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getTodayAbleWhenExpired() {
return todayAbleWhenExpired;
}
public void setTodayAbleWhenExpired(Long todayAbleWhenExpired) {
this.todayAbleWhenExpired = todayAbleWhenExpired;
}
public Long getHistoryAbleWhenExpired() {
return historyAbleWhenExpired;
}
public void setHistoryAbleWhenExpired(Long historyAbleWhenExpired) {
this.historyAbleWhenExpired = historyAbleWhenExpired;
}
public Long getStatisticsAbleWhenExpired() {
return statisticsAbleWhenExpired;
}
public void setStatisticsAbleWhenExpired(Long statisticsAbleWhenExpired) {
this.statisticsAbleWhenExpired = statisticsAbleWhenExpired;
}
public Long getNavigateAbleWhenExpired() {
return navigateAbleWhenExpired;
}
public void setNavigateAbleWhenExpired(Long navigateAbleWhenExpired) {
this.navigateAbleWhenExpired = navigateAbleWhenExpired;
}
}

View File

@ -0,0 +1,150 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* 短信全局配置信息
*/
@Entity
@Table(name = "config_global_sms")
public class ConfigGlobalSMSEntity implements Serializable {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "config_global_sms_seq_gen")
@SequenceGenerator(name = "config_global_sms_seq_gen", sequenceName = "config_global_sms_id_seq", allocationSize = 1)
private Long id;
/**
* 过期后能否接收短信
* 0不能
* 1
*/
private Long smsAbleWhenExpired;
/**
* 省过期前能否提前通知
*/
private Long proAnAbleBeforeExpired;
/**
* 省过期前提前几天短信通知
*/
private Long proAnDayBeforeExpired;
/**
* 市过期前能否提前通知
*/
private Long cityAnAbleBeforeExpired;
/**
* 市过期前提前几天短信通知
*/
private Long cityAnDayBeforeExpired;
/**
* 区县过期前能否提前通知
*/
private Long countyAnAbleBeforeExpired;
/**
* 区县过期前提前几天短信通知
*/
private Long countyAnDayBeforeExpired;
/**
* 街道过期前能否提前通知
*/
private Long streetAnAbleBeforeExpired;
/**
* 街道过期前提前几天短信通知
*/
private Long streetAnDayBeforeExpired;
public ConfigGlobalSMSEntity() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getSmsAbleWhenExpired() {
return smsAbleWhenExpired;
}
public void setSmsAbleWhenExpired(Long smsAbleWhenExpired) {
this.smsAbleWhenExpired = smsAbleWhenExpired;
}
public Long getProAnAbleBeforeExpired() {
return proAnAbleBeforeExpired;
}
public void setProAnAbleBeforeExpired(Long proAnAbleBeforeExpired) {
this.proAnAbleBeforeExpired = proAnAbleBeforeExpired;
}
public Long getProAnDayBeforeExpired() {
return proAnDayBeforeExpired;
}
public void setProAnDayBeforeExpired(Long proAnDayBeforeExpired) {
this.proAnDayBeforeExpired = proAnDayBeforeExpired;
}
public Long getCityAnAbleBeforeExpired() {
return cityAnAbleBeforeExpired;
}
public void setCityAnAbleBeforeExpired(Long cityAnAbleBeforeExpired) {
this.cityAnAbleBeforeExpired = cityAnAbleBeforeExpired;
}
public Long getCityAnDayBeforeExpired() {
return cityAnDayBeforeExpired;
}
public void setCityAnDayBeforeExpired(Long cityAnDayBeforeExpired) {
this.cityAnDayBeforeExpired = cityAnDayBeforeExpired;
}
public Long getCountyAnAbleBeforeExpired() {
return countyAnAbleBeforeExpired;
}
public void setCountyAnAbleBeforeExpired(Long countyAnAbleBeforeExpired) {
this.countyAnAbleBeforeExpired = countyAnAbleBeforeExpired;
}
public Long getCountyAnDayBeforeExpired() {
return countyAnDayBeforeExpired;
}
public void setCountyAnDayBeforeExpired(Long countyAnDayBeforeExpired) {
this.countyAnDayBeforeExpired = countyAnDayBeforeExpired;
}
public Long getStreetAnAbleBeforeExpired() {
return streetAnAbleBeforeExpired;
}
public void setStreetAnAbleBeforeExpired(Long streetAnAbleBeforeExpired) {
this.streetAnAbleBeforeExpired = streetAnAbleBeforeExpired;
}
public Long getStreetAnDayBeforeExpired() {
return streetAnDayBeforeExpired;
}
public void setStreetAnDayBeforeExpired(Long streetAnDayBeforeExpired) {
this.streetAnDayBeforeExpired = streetAnDayBeforeExpired;
}
}

View File

@ -0,0 +1,46 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* 用户全局配置信息
*/
@Entity
@Table(name = "config_global_user")
public class ConfigGlobalUserEntity implements Serializable {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "config_global_user_seq_gen")
@SequenceGenerator(name = "config_global_user_seq_gen", sequenceName = "config_global_user_id_seq", allocationSize = 1)
private Long id;
/**
* 过期后能否继续登录
* 0不能登录
* 1能够登录
*/
private Long loginAbleWhenExpired;
public ConfigGlobalUserEntity() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getLoginAbleWhenExpired() {
return loginAbleWhenExpired;
}
public void setLoginAbleWhenExpired(Long loginAbleWhenExpired) {
this.loginAbleWhenExpired = loginAbleWhenExpired;
}
}

View File

@ -0,0 +1,25 @@
package com.xkrs.service;
import java.util.Map;
/**
* 全局配置服务
*/
public interface ConfigGlobalService {
/**
* 用户全局配置服务
*/
String configGlobalUser(Map<String, Long> configMap);
/**
* 火情信息全局配置服务
*/
String configGlobalFirePoint(Map<String, Long> configMap);
/**
* 短信全局配置服务
*/
String configGlobalSMS(Map<String, Long> configMap);
}

View File

@ -0,0 +1,201 @@
package com.xkrs.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.ConfigGlobalFirePointDao;
import com.xkrs.dao.ConfigGlobalSMSDao;
import com.xkrs.dao.ConfigGlobalUserDao;
import com.xkrs.model.entity.ConfigGlobalFirePointEntity;
import com.xkrs.model.entity.ConfigGlobalSMSEntity;
import com.xkrs.model.entity.ConfigGlobalUserEntity;
import com.xkrs.service.ConfigGlobalService;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* 全局配置服务
*/
@Service
public class ConfigGlobalServiceImpl implements ConfigGlobalService {
private final Locale locale = LocaleContextHolder.getLocale();
/**
* 用户全局配置信息
*/
@Resource
private ConfigGlobalUserDao configGlobalUserDao;
/**
* 火情信息全局配置信息
*/
@Resource
private ConfigGlobalFirePointDao configGlobalFirePointDao;
/**
* 短信全局配置信息
*/
@Resource
private ConfigGlobalSMSDao configGlobalSMSDao;
/**
* 用户全局配置服务
*/
@Override
public String configGlobalUser(Map<String, Long> configMap) {
if (configMap == null) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
}
Long loginAbleWhenExpired = configMap.get("LoginAbleWhenExpired");
List<ConfigGlobalUserEntity> configGlobalUserEntityList = configGlobalUserDao.findAll();
if (configGlobalUserEntityList.isEmpty()) {
ConfigGlobalUserEntity configGlobalUserEntity = new ConfigGlobalUserEntity();
configGlobalUserEntity.setLoginAbleWhenExpired(loginAbleWhenExpired);
configGlobalUserDao.save(configGlobalUserEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
}
ConfigGlobalUserEntity configGlobalUserEntity = configGlobalUserEntityList.get(0);
if (loginAbleWhenExpired != null) {
if (configGlobalUserEntity.getLoginAbleWhenExpired() == null || configGlobalUserEntity.getLoginAbleWhenExpired().longValue() != loginAbleWhenExpired.longValue()) {
configGlobalUserEntity.setLoginAbleWhenExpired(loginAbleWhenExpired);
}
}
configGlobalUserDao.save(configGlobalUserEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
}
/**
* 火情信息全局配置服务
*/
@Override
public String configGlobalFirePoint(Map<String, Long> configMap) {
if (configMap == null) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
}
Long todayAbleWhenExpired = configMap.get("TodayAbleWhenExpired");
Long historyAbleWhenExpired = configMap.get("HistoryAbleWhenExpired");
Long statisticsAbleWhenExpired = configMap.get("StatisticsAbleWhenExpired");
Long navigateAbleWhenExpired = configMap.get("NavigateAbleWhenExpired");
List<ConfigGlobalFirePointEntity> configGlobalFirePointEntityList = configGlobalFirePointDao.findAll();
if (configGlobalFirePointEntityList.isEmpty()) {
ConfigGlobalFirePointEntity configGlobalFirePointEntity = new ConfigGlobalFirePointEntity();
configGlobalFirePointEntity.setTodayAbleWhenExpired(todayAbleWhenExpired);
configGlobalFirePointEntity.setHistoryAbleWhenExpired(historyAbleWhenExpired);
configGlobalFirePointEntity.setStatisticsAbleWhenExpired(statisticsAbleWhenExpired);
configGlobalFirePointEntity.setNavigateAbleWhenExpired(navigateAbleWhenExpired);
configGlobalFirePointDao.save(configGlobalFirePointEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
}
ConfigGlobalFirePointEntity configGlobalFirePointEntity = configGlobalFirePointEntityList.get(0);
if (todayAbleWhenExpired != null) {
if (configGlobalFirePointEntity.getTodayAbleWhenExpired() == null || configGlobalFirePointEntity.getTodayAbleWhenExpired().longValue() != todayAbleWhenExpired.longValue()) {
configGlobalFirePointEntity.setTodayAbleWhenExpired(todayAbleWhenExpired);
}
}
if (historyAbleWhenExpired != null) {
if (configGlobalFirePointEntity.getHistoryAbleWhenExpired() == null || configGlobalFirePointEntity.getHistoryAbleWhenExpired().longValue() != historyAbleWhenExpired.longValue()) {
configGlobalFirePointEntity.setHistoryAbleWhenExpired(historyAbleWhenExpired);
}
}
if (statisticsAbleWhenExpired != null) {
if (configGlobalFirePointEntity.getStatisticsAbleWhenExpired() == null || configGlobalFirePointEntity.getStatisticsAbleWhenExpired().longValue() != statisticsAbleWhenExpired.longValue()) {
configGlobalFirePointEntity.setStatisticsAbleWhenExpired(statisticsAbleWhenExpired);
}
}
if (navigateAbleWhenExpired != null) {
if (configGlobalFirePointEntity.getNavigateAbleWhenExpired() == null || configGlobalFirePointEntity.getNavigateAbleWhenExpired().longValue() != navigateAbleWhenExpired.longValue()) {
configGlobalFirePointEntity.setNavigateAbleWhenExpired(navigateAbleWhenExpired);
}
}
configGlobalFirePointDao.save(configGlobalFirePointEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
}
/**
* 短信全局配置服务
*/
@Override
public String configGlobalSMS(Map<String, Long> configMap) {
if (configMap == null) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
}
Long smsAbleWhenExpired = configMap.get("SmsAbleWhenExpired");
Long proAnAbleBeforeExpired = configMap.get("ProAnAbleBeforeExpired");
Long proAnDayBeforeExpired = configMap.get("ProAnDayBeforeExpired");
Long cityAnAbleBeforeExpired = configMap.get("CityAnAbleBeforeExpired");
Long cityAnDayBeforeExpired = configMap.get("CityAnDayBeforeExpired");
Long countyAnAbleBeforeExpired = configMap.get("CountyAnAbleBeforeExpired");
Long countyAnDayBeforeExpired = configMap.get("CountyAnDayBeforeExpired");
Long streetAnAbleBeforeExpired = configMap.get("StreetAnAbleBeforeExpired");
Long streetAnDayBeforeExpired = configMap.get("StreetAnDayBeforeExpired");
List<ConfigGlobalSMSEntity> configGlobalSMSEntityList = configGlobalSMSDao.findAll();
if (configGlobalSMSEntityList.isEmpty()) {
ConfigGlobalSMSEntity configGlobalSMSEntity = new ConfigGlobalSMSEntity();
configGlobalSMSEntity.setSmsAbleWhenExpired(smsAbleWhenExpired);
configGlobalSMSEntity.setProAnAbleBeforeExpired(proAnAbleBeforeExpired);
configGlobalSMSEntity.setProAnDayBeforeExpired(proAnDayBeforeExpired);
configGlobalSMSEntity.setCityAnAbleBeforeExpired(cityAnAbleBeforeExpired);
configGlobalSMSEntity.setCityAnDayBeforeExpired(cityAnDayBeforeExpired);
configGlobalSMSEntity.setCountyAnAbleBeforeExpired(countyAnAbleBeforeExpired);
configGlobalSMSEntity.setCountyAnDayBeforeExpired(countyAnDayBeforeExpired);
configGlobalSMSEntity.setStreetAnAbleBeforeExpired(streetAnAbleBeforeExpired);
configGlobalSMSEntity.setStreetAnDayBeforeExpired(streetAnDayBeforeExpired);
configGlobalSMSDao.save(configGlobalSMSEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
}
ConfigGlobalSMSEntity configGlobalSMSEntity = configGlobalSMSEntityList.get(0);
if (smsAbleWhenExpired != null) {
if (configGlobalSMSEntity.getSmsAbleWhenExpired() == null || configGlobalSMSEntity.getSmsAbleWhenExpired().longValue() != smsAbleWhenExpired.longValue()) {
configGlobalSMSEntity.setSmsAbleWhenExpired(smsAbleWhenExpired);
}
}
if (proAnAbleBeforeExpired != null) {
if (configGlobalSMSEntity.getProAnAbleBeforeExpired() == null || configGlobalSMSEntity.getProAnAbleBeforeExpired().longValue() != proAnAbleBeforeExpired.longValue()) {
configGlobalSMSEntity.setProAnAbleBeforeExpired(proAnAbleBeforeExpired);
}
}
if (proAnDayBeforeExpired != null) {
if (configGlobalSMSEntity.getProAnDayBeforeExpired() == null || configGlobalSMSEntity.getProAnDayBeforeExpired().longValue() != proAnDayBeforeExpired.longValue()) {
configGlobalSMSEntity.setProAnDayBeforeExpired(proAnDayBeforeExpired);
}
}
if (cityAnAbleBeforeExpired != null) {
if (configGlobalSMSEntity.getCityAnAbleBeforeExpired() == null || configGlobalSMSEntity.getCityAnAbleBeforeExpired().longValue() != cityAnAbleBeforeExpired.longValue()) {
configGlobalSMSEntity.setCityAnAbleBeforeExpired(cityAnAbleBeforeExpired);
}
}
if (cityAnDayBeforeExpired != null) {
if (configGlobalSMSEntity.getCityAnDayBeforeExpired() == null || configGlobalSMSEntity.getCityAnDayBeforeExpired().longValue() != cityAnDayBeforeExpired.longValue()) {
configGlobalSMSEntity.setCityAnDayBeforeExpired(cityAnDayBeforeExpired);
}
}
if (countyAnAbleBeforeExpired != null) {
if (configGlobalSMSEntity.getCountyAnAbleBeforeExpired() == null || configGlobalSMSEntity.getCountyAnAbleBeforeExpired().longValue() != countyAnAbleBeforeExpired.longValue()) {
configGlobalSMSEntity.setCountyAnAbleBeforeExpired(countyAnAbleBeforeExpired);
}
}
if (countyAnDayBeforeExpired != null) {
if (configGlobalSMSEntity.getCountyAnDayBeforeExpired() == null || configGlobalSMSEntity.getCountyAnDayBeforeExpired().longValue() != countyAnDayBeforeExpired.longValue()) {
configGlobalSMSEntity.setCountyAnDayBeforeExpired(countyAnDayBeforeExpired);
}
}
if (streetAnAbleBeforeExpired != null) {
if (configGlobalSMSEntity.getStreetAnAbleBeforeExpired() == null || configGlobalSMSEntity.getStreetAnAbleBeforeExpired().longValue() != streetAnAbleBeforeExpired.longValue()) {
configGlobalSMSEntity.setStreetAnAbleBeforeExpired(streetAnAbleBeforeExpired);
}
}
if (streetAnDayBeforeExpired != null) {
if (configGlobalSMSEntity.getStreetAnDayBeforeExpired() == null || configGlobalSMSEntity.getStreetAnDayBeforeExpired().longValue() != streetAnDayBeforeExpired.longValue()) {
configGlobalSMSEntity.setStreetAnDayBeforeExpired(streetAnDayBeforeExpired);
}
}
configGlobalSMSDao.save(configGlobalSMSEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
}
}