jiangping
2023-10-13 5ec73adcca1d7f2b96c623cfdc66e309958ae2bf
server/service/src/main/java/com/doumee/service/business/impl/WebParamServiceImpl.java
@@ -1,6 +1,8 @@
package com.doumee.service.business.impl;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
@@ -14,6 +16,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,6 +64,16 @@
        return webParam;
    }
    @Override
    public WebParam findOneNew() {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        QueryWrapper<WebParam> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(WebParam::getCompanyId,user.getCompanyId());
        wrapper.last(" limit 1  ");
        WebParam webParam = webParamMapper.selectOne(wrapper);
        return webParam;
    }
    @Override
    public void renew(UpdateWebParamDTO updateWebParamDTO) {
@@ -84,6 +97,30 @@
            webParamMapper.updateById(webParam);
        }
    }
    @Override
    public void  renewUpdate(UpdateWebParamDTO updateWebParamDTO){
        if(StringUtils.isBlank(updateWebParamDTO.getNewParam())){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        QueryWrapper<WebParam> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(WebParam::getCompanyId,user.getCompanyId());
        wrapper.last(" limit 1  ");
        WebParam webParam = webParamMapper.selectOne(wrapper);
        if(Objects.isNull(webParam)){
            webParam = new WebParam();
            BeanUtils.copyProperties(updateWebParamDTO,webParam);
            webParam.setCreateTime(new Date());
            webParam.setDeleted(Constants.ZERO);
            webParam.setCompanyId(user.getCompanyId());
            webParam.setCreateUser(user.getId());
            webParamMapper.insert(webParam);
        }else{
            BeanUtils.copyProperties(updateWebParamDTO,webParam);
            webParam.setUpdateUser(user.getId());
            webParam.setUpdateTime(new Date());
            webParamMapper.updateById(webParam);
        }
    }
}