xiaoyong931011
2022-07-07 bc43681f185af1edf833cf6c94833cb1cdd44a8e
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java
@@ -4,9 +4,11 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.modules.system.dto.AdminUpdateWebSetDto;
import com.xcong.farmer.cms.modules.system.entity.UserEntity;
import com.xcong.farmer.cms.modules.system.entity.WebSetEntity;
import com.xcong.farmer.cms.modules.system.mapper.WebSetMapper;
import com.xcong.farmer.cms.modules.system.service.IWebSetService;
import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
import com.xcong.farmer.cms.modules.system.vo.AdminSeeWebSetInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -22,8 +24,12 @@
public class WebSetServiceImpl extends ServiceImpl<WebSetMapper, WebSetEntity> implements IWebSetService {
    @Override
    public Result seeWebSetInfo() {
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId();
        AdminSeeWebSetInfoVo adminSeeWebSetInfoVo = new AdminSeeWebSetInfoVo();
        List<WebSetEntity> webSetEntities = this.baseMapper.selectList(new QueryWrapper<>());
        QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("company_id",companyId);
        List<WebSetEntity> webSetEntities = this.baseMapper.selectList(objectQueryWrapper);
        if(CollUtil.isNotEmpty(webSetEntities)){
            WebSetEntity webSetEntity = webSetEntities.get(0);
            adminSeeWebSetInfoVo.setId(webSetEntity.getId());
@@ -37,16 +43,14 @@
    @Override
    public Result updateWebSet(AdminUpdateWebSetDto adminUpdateWebSetDto) {
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId();
        String webTitle = adminUpdateWebSetDto.getWebTitle();
        if(StrUtil.isEmpty(webTitle)){
            return Result.fail("请输入网页标题");
        }
        String webKeyword = adminUpdateWebSetDto.getWebKeyword();
        if(StrUtil.isEmpty(webKeyword)){
            return Result.fail("请输入网页关键字");
        }
        Long id = adminUpdateWebSetDto.getId() == null ? 0L : adminUpdateWebSetDto.getId();
        WebSetEntity webSetEntity = this.baseMapper.selectById(id);
        QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("company_id",companyId);
        WebSetEntity webSetEntity = this.baseMapper.selectOne(objectQueryWrapper);
        if(ObjectUtil.isEmpty(webSetEntity)){
            WebSetEntity webSetEntityAdd = new WebSetEntity();
            webSetEntityAdd.setWebTitle(webTitle);
@@ -59,19 +63,16 @@
            if(StrUtil.isNotEmpty(webPic)){
                webSetEntityAdd.setWebPic(webPic);
            }
            webSetEntityAdd.setCompanyId(companyId);
            this.baseMapper.insert(webSetEntityAdd);
            return Result.ok("保存成功");
        }
        webSetEntity.setWebTitle(webTitle);
        webSetEntity.setWebKeyword(webKeyword);
        String webRemark = adminUpdateWebSetDto.getWebRemark();
        if(StrUtil.isNotEmpty(webRemark)){
            webSetEntity.setWebRemark(webRemark);
        }
        String webPic = adminUpdateWebSetDto.getWebPic();
        if(StrUtil.isNotEmpty(webPic)){
            webSetEntity.setWebPic(webPic);
        }
        this.baseMapper.updateById(webSetEntity);
        return Result.ok("保存成功");
    }