From 05f3eec8ba39fb05eac09d8d3f2930cd77dd41f7 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 12 Jul 2022 11:39:30 +0800
Subject: [PATCH] 20220606
---
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java | 45 +++++++++++++++++++++++++++++----------------
1 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java
index f48276f..ed8d8bc 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java
+++ b/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,29 +43,36 @@
@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 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();
+ Long id = adminUpdateWebSetDto.getId() == null ? 0L : adminUpdateWebSetDto.getId();
+ 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);
+ 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.setCompanyId(companyId);
+ this.baseMapper.insert(webSetEntityAdd);
+ return Result.ok("保存成功");
}
webSetEntity.setWebTitle(webTitle);
- String webKeyword = adminUpdateWebSetDto.getWebKeyword();
- if(StrUtil.isEmpty(webKeyword)){
- return Result.fail("请输入网页关键字");
- }
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("保存成功");
}
--
Gitblit v1.9.1