package com.nq.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.nq.common.ServerResponse;
|
import com.nq.dao.StockConfigMapper;
|
import com.nq.enums.EConfigKey;
|
import com.nq.pojo.StockConfig;
|
import com.nq.service.IStockConfigServices;
|
import org.apache.commons.lang3.math.NumberUtils;
|
import org.apache.http.util.TextUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
@Service
|
public class StockConfigServicesImpl implements IStockConfigServices {
|
|
@Resource
|
StockConfigMapper stockConfigMapper;
|
@Override
|
public ServerResponse updateStockConfig(StockConfig stockConfig) {
|
if(stockConfig.getCKey().equals(EConfigKey.AGENT_MAX_GRADE.getCode())){
|
try {
|
int number = Integer.parseInt(stockConfig.getCValue());
|
if(number <= 0){
|
return ServerResponse.createByErrorMsg("请输入有效等级");
|
}
|
} catch (NumberFormatException e) {
|
return ServerResponse.createByErrorMsg("请输入有效等级");
|
}
|
}
|
int ref = stockConfigMapper.updateById(stockConfig);
|
if(ref>0){
|
return ServerResponse.createBySuccessMsg("设置成功");
|
}
|
return ServerResponse.createByErrorMsg("设置失败");
|
}
|
|
@Override
|
public ServerResponse queryAll(String desc) {
|
if(TextUtils.isEmpty(desc)){
|
return ServerResponse.createBySuccess(stockConfigMapper.selectList(new QueryWrapper<>()));
|
}
|
QueryWrapper<StockConfig> queryWrapper = new QueryWrapper<>();
|
queryWrapper.like("c_desc",desc);
|
return ServerResponse.createBySuccess(stockConfigMapper.selectList(queryWrapper));
|
}
|
|
@Override
|
public StockConfig queryByKey(String key) {
|
QueryWrapper<StockConfig> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("c_key",key);
|
return stockConfigMapper.selectOne(queryWrapper);
|
}
|
}
|