From 93e281b3cc60c8d24a0ed5547d3d399c03f9bab6 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 10 Jun 2022 18:03:52 +0800
Subject: [PATCH] 20220606
---
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/WebSetServiceImpl.java | 36 ++++++++++++++++++++++++++++++------
1 files changed, 30 insertions(+), 6 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..8904e67 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,7 +24,11 @@
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);
@@ -37,20 +43,38 @@
@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)){
--
Gitblit v1.9.1