字典值查询
parent
15462ce0ba
commit
773a323d84
|
@ -6,8 +6,16 @@ package com.jwl.driver.server.constant;
|
|||
|
||||
public class Constants {
|
||||
|
||||
//短信验证码redis存储的前缀
|
||||
public static String MESSAGE_CODE_PREFIX = "code_";
|
||||
|
||||
//短信验证码的模板
|
||||
public static String MESSAGE_TEMPLATE = "SMS_198880447";
|
||||
|
||||
//是否有效-有效
|
||||
public static String IS_ACTIVE_TRUE = "0";
|
||||
|
||||
//是否有效-无效
|
||||
public static String IS_ACTIVE_FALSE = "1";
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package com.jwl.driver.server.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.jwl.driver.server.response.BaseResponse;
|
||||
import com.jwl.driver.server.service.ITdSysConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -13,8 +21,33 @@ import org.springframework.stereotype.Controller;
|
|||
* @author Automated procedures
|
||||
* @since 2023-08-10
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("//tdSysConfig")
|
||||
@Api(tags = "字典值配置")
|
||||
@RestController
|
||||
@RequestMapping("/tdSysConfig")
|
||||
@Slf4j
|
||||
public class TdSysConfigController {
|
||||
|
||||
@Autowired
|
||||
private ITdSysConfigService configService;
|
||||
|
||||
/**
|
||||
* 根据配置key和carTypeId获取配置信息,配置与车型无关则carTypeId为-1
|
||||
*/
|
||||
@ApiOperation("根据配置key和carTypeId获取配置信息,配置与车型无关则carTypeId为-1")
|
||||
@GetMapping(value = "/queryConfigByKey")
|
||||
public BaseResponse queryConfigByKey(@RequestParam("configKey") String configKey,@RequestParam("carTypeId") Integer carTypeId) {
|
||||
return BaseResponse.success(configService.queryConfigByKey(configKey,carTypeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置key和carTypeId获取配置值,配置与车型无关则carTypeId为-1
|
||||
*/
|
||||
@ApiOperation("根据配置key获取配置值")
|
||||
@GetMapping(value = "/queryConfigValueByKey")
|
||||
public BaseResponse<String> queryConfigValueByKey(@RequestParam("configKey") String configKey,@RequestParam("carTypeId") Integer carTypeId) {
|
||||
|
||||
return BaseResponse.success(configService.queryConfigValueByKey(configKey,carTypeId));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public class GlobalExceptionHandler {
|
|||
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public BaseResponse<?> businessException(BusinessException e) {
|
||||
e.printStackTrace();
|
||||
return BaseResponse.fail(e.getCode(), null, e.getMessage());
|
||||
}
|
||||
|
||||
|
@ -48,6 +49,7 @@ public class GlobalExceptionHandler {
|
|||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public BaseResponse<?> exception(Exception e) {
|
||||
e.printStackTrace();
|
||||
return BaseResponse.fail(StatusEnum.FAIL.getCode(), null, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,19 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface ITdSysConfigService extends IService<TdSysConfig> {
|
||||
|
||||
/**
|
||||
* 根据配置key和carTypeId获取配置信息,配置与车型无关则carTypeId为-1
|
||||
* @param configKey
|
||||
* @param carTypeId
|
||||
* @return
|
||||
*/
|
||||
TdSysConfig queryConfigByKey(String configKey, Integer carTypeId);
|
||||
|
||||
/**
|
||||
* 根据配置key和carTypeId获取配置值,配置与车型无关则carTypeId为-1
|
||||
* @param configKey
|
||||
* @param carTypeId
|
||||
* @return
|
||||
*/
|
||||
String queryConfigValueByKey(String configKey,Integer carTypeId);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.jwl.driver.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jwl.driver.server.constant.Constants;
|
||||
import com.jwl.driver.server.entity.TdSysConfig;
|
||||
import com.jwl.driver.server.mapper.TdSysConfigMapper;
|
||||
import com.jwl.driver.server.service.ITdSysConfigService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统配置表; 服务实现类
|
||||
|
@ -15,6 +21,32 @@ import org.springframework.stereotype.Service;
|
|||
* @since 2023-08-10
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TdSysConfigServiceImpl extends ServiceImpl<TdSysConfigMapper, TdSysConfig> implements ITdSysConfigService {
|
||||
|
||||
@Override
|
||||
public TdSysConfig queryConfigByKey(String configKey, Integer carTypeId) {
|
||||
log.info("获取系统配置参数,configKey:{}", configKey);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LambdaQueryWrapper<TdSysConfig> queryWrapper = new QueryWrapper<TdSysConfig>().lambda()
|
||||
.eq(TdSysConfig::getCarTypeId,carTypeId)
|
||||
.eq(TdSysConfig::getConfigKey, configKey)
|
||||
.eq(TdSysConfig::getIsActive, Constants.IS_ACTIVE_TRUE);
|
||||
return getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryConfigValueByKey(String configKey, Integer carTypeId) {
|
||||
log.info("获取系统配置参数,configKey:{}", configKey);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LambdaQueryWrapper<TdSysConfig> queryWrapper = new QueryWrapper<TdSysConfig>().lambda()
|
||||
.eq(TdSysConfig::getCarTypeId,carTypeId)
|
||||
.eq(TdSysConfig::getConfigKey, configKey)
|
||||
.eq(TdSysConfig::getIsActive, Constants.IS_ACTIVE_TRUE);
|
||||
TdSysConfig config = getOne(queryWrapper);
|
||||
if(null == config) {
|
||||
return null;
|
||||
}
|
||||
return config.getConfigValue();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue