package com.xcong.farmer.cms.modules.system.service.Impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xcong.farmer.cms.common.response.Result; import com.xcong.farmer.cms.conversion.WebSettingConversion; import com.xcong.farmer.cms.modules.system.dto.SetWebSettingDto; import com.xcong.farmer.cms.modules.system.entity.UserEntity; import com.xcong.farmer.cms.modules.system.entity.WebSettingEntity; import com.xcong.farmer.cms.modules.system.mapper.WebSetMapper; import com.xcong.farmer.cms.modules.system.service.IWebSettingService; 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; @Service @Slf4j public class WebSettingServiceImpl extends ServiceImpl implements IWebSettingService { @Override public Result getWebSetting() { Long companyId = LoginUserUtil.getCompanyId(); WebSettingEntity webSetting = this.baseMapper.selectByCompanyId(companyId); if (webSetting == null) { webSetting = new WebSettingEntity(); } AdminSeeWebSetInfoVo adminSeeWebSetInfoVo = WebSettingConversion.INSTANCE.entityToVo(webSetting); return Result.ok(adminSeeWebSetInfoVo); } @Override public Result setWebSetting(SetWebSettingDto setWebSettingDto) { Long companyId = LoginUserUtil.getCompanyId(); WebSettingEntity webSetting = WebSettingConversion.INSTANCE.dtoToEntity(setWebSettingDto); webSetting.setCompanyId(companyId); if (setWebSettingDto.getId() == null) { WebSettingEntity hasExist = this.baseMapper.selectByCompanyId(companyId); if (hasExist != null) { webSetting.setId(hasExist.getId()); this.baseMapper.updateById(webSetting); } else { this.baseMapper.insert(webSetting); } } else { this.baseMapper.updateById(webSetting); } return Result.ok("保存成功"); } }