| | |
| | | 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; |
| | |
| | | public class WebSetServiceImpl extends ServiceImpl<WebSetMapper, WebSetEntity> implements IWebSetService { |
| | | @Override |
| | | public Result seeWebSetInfo() { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | AdminSeeWebSetInfoVo adminSeeWebSetInfoVo = new AdminSeeWebSetInfoVo(); |
| | | QueryWrapper<WebSetEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("belong_id",belongId); |
| | | List<WebSetEntity> webSetEntities = this.baseMapper.selectList(new QueryWrapper<>()); |
| | | if(CollUtil.isNotEmpty(webSetEntities)){ |
| | | WebSetEntity webSetEntity = webSetEntities.get(0); |
| | |
| | | |
| | | @Override |
| | | public Result updateWebSet(AdminUpdateWebSetDto adminUpdateWebSetDto) { |
| | | Long id = adminUpdateWebSetDto.getId() == null ? 0L : adminUpdateWebSetDto.getId(); |
| | | WebSetEntity webSetEntity = this.baseMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(webSetEntity)){ |
| | | return Result.fail("网页设置不存在"); |
| | | } |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | String webTitle = adminUpdateWebSetDto.getWebTitle(); |
| | | if(StrUtil.isEmpty(webTitle)){ |
| | | return Result.fail("请输入网页标题"); |
| | | } |
| | | webSetEntity.setWebTitle(webTitle); |
| | | 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); |
| | | WebSetEntity webSetEntity = this.baseMapper.selectOne(objectQueryWrapper); |
| | | // WebSetEntity webSetEntity = this.baseMapper.selectById(id); |
| | | if(ObjectUtil.isEmpty(webSetEntity)){ |
| | | WebSetEntity webSetEntityAdd = new WebSetEntity(); |
| | | webSetEntityAdd.setWebTitle(webTitle); |
| | | webSetEntityAdd.setWebKeyword(webKeyword); |
| | | String webRemark = adminUpdateWebSetDto.getWebRemark(); |
| | | if(StrUtil.isNotEmpty(webRemark)){ |
| | | webSetEntityAdd.setWebRemark(webRemark); |
| | | } |
| | | String webPic = adminUpdateWebSetDto.getWebPic(); |
| | | if(StrUtil.isNotEmpty(webPic)){ |
| | | webSetEntityAdd.setWebPic(webPic); |
| | | } |
| | | webSetEntityAdd.setBelongId(belongId); |
| | | this.baseMapper.insert(webSetEntityAdd); |
| | | return Result.ok("保存成功"); |
| | | } |
| | | webSetEntity.setWebTitle(webTitle); |
| | | webSetEntity.setWebKeyword(webKeyword); |
| | | String webRemark = adminUpdateWebSetDto.getWebRemark(); |
| | | if(StrUtil.isNotEmpty(webRemark)){ |