xiaoyong931011
2022-07-08 e7f9932f6d5bb67dac0de33e9d52d439d9a1a6bf
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java
@@ -25,11 +25,11 @@
    @Override
    public Result seeWebSetInfo() {
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        long belongId = userlogin.getBelongId() == null ? 0L : userlogin.getBelongId();
        long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId();
        AdminSeeWebSetInfoVo adminSeeWebSetInfoVo = new AdminSeeWebSetInfoVo();
        QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("belong_id",belongId);
        List<WebSetEntity> webSetEntities = this.baseMapper.selectList(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());
@@ -44,20 +44,13 @@
    @Override
    public Result updateWebSet(AdminUpdateWebSetDto adminUpdateWebSetDto) {
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        long belongId = userlogin.getBelongId() == null ? 0L : userlogin.getBelongId();
        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();
        QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("belong_id",belongId);
        objectQueryWrapper.eq("company_id",companyId);
        WebSetEntity webSetEntity = this.baseMapper.selectOne(objectQueryWrapper);
//        WebSetEntity webSetEntity = this.baseMapper.selectById(id);
        if(ObjectUtil.isEmpty(webSetEntity)){
            WebSetEntity webSetEntityAdd = new WebSetEntity();
            webSetEntityAdd.setWebTitle(webTitle);
@@ -70,20 +63,16 @@
            if(StrUtil.isNotEmpty(webPic)){
                webSetEntityAdd.setWebPic(webPic);
            }
            webSetEntityAdd.setBelongId(belongId);
            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("保存成功");
    }