¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.system.entity.MdmCountConfig; |
| | | import com.vci.ubcs.system.mapper.MdmCountConfigMapper; |
| | | import com.vci.ubcs.system.service.IMdmCountConfigService; |
| | | import com.vci.ubcs.system.vo.MdmCountConfigVO; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.Date; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * ä¸»æ°æ®ç»è®¡é¦é¡µé
ç½®æå¡ |
| | | * @author ludc |
| | | * @date 2023/10/17 14:45 |
| | | */ |
| | | @Service |
| | | public class MdmCountConfigServiceImpl extends ServiceImpl<MdmCountConfigMapper, MdmCountConfig> implements IMdmCountConfigService { |
| | | |
| | | /** |
| | | * ä¿åç¨æ·é
ç½®çä¸»æ°æ®ç»è®¡é¡¹ |
| | | * @param mdmCountConfigVO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveMdmCountConfig(MdmCountConfigVO mdmCountConfigVO) throws ServiceException{ |
| | | if(Func.isEmpty(mdmCountConfigVO) || Func.isBlank(mdmCountConfigVO.getUserId().toString())){ |
| | | throw new ServiceException("ä¸»æ°æ®ç»è®¡é
ç½®ä¿åæ¶ç¼ºå°å¿
å¡«åæ°!"); |
| | | } |
| | | boolean res = false; |
| | | if (mdmCountConfigVO.getMdmNameList().isEmpty()) { |
| | | return true; |
| | | } |
| | | try { |
| | | String mdmNames = mdmCountConfigVO.getMdmNameList().stream().collect(Collectors.joining(",")); |
| | | MdmCountConfig mdmCountConfigDB = getMdmCountConfig(mdmCountConfigVO.getUserId().toString()); |
| | | MdmCountConfig mdmCountConfig = new MdmCountConfig(); |
| | | //æ°å¢ |
| | | if(Func.isEmpty(mdmCountConfigDB)){ |
| | | mdmCountConfig.setUserId(mdmCountConfigVO.getUserId()); |
| | | }else { |
| | | //ä¿®æ¹ |
| | | Func.copy(mdmCountConfigDB,mdmCountConfig); |
| | | } |
| | | mdmCountConfig.setMdmName(mdmNames); |
| | | res = this.saveOrUpdate(mdmCountConfig); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("é
ç½®ä¿å失败,åå ï¼"+e.getCause()); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åç¨æ·æé£äºä¸»æ°æ®ç»è®¡é
ç½®å¨é¦é¡µ |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MdmCountConfig getMdmCountConfig(String userId) { |
| | | LambdaQueryWrapper<MdmCountConfig> wrapper = Wrappers.<MdmCountConfig>query(). |
| | | lambda().eq(MdmCountConfig::getUserId, userId); |
| | | return this.getOne(wrapper); |
| | | } |
| | | |
| | | } |