¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.MdcUserProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.mapper.MdcUserProductionMapper; |
| | | import org.jeecg.modules.system.model.ProductionIdModel; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.IMdcUserProductionService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: ç¨æ·äº§çº¿è¡¨ |
| | | * @author: LiuS |
| | | * @create: 2023-03-27 11:58 |
| | | */ |
| | | @Service |
| | | public class MdcUserProductionServiceImpl extends ServiceImpl<MdcUserProductionMapper, MdcUserProduction> implements IMdcUserProductionService { |
| | | |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·idæ¥è¯¢äº§çº¿ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public List<ProductionIdModel> queryProductionIdsOfUser(String userId) { |
| | | LambdaQueryWrapper<MdcUserProduction> queryUserPro = new LambdaQueryWrapper<>(); |
| | | LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>(); |
| | | try { |
| | | queryUserPro.eq(MdcUserProduction::getUserId, userId); |
| | | List<String> proIdList = new ArrayList<>(); |
| | | List<ProductionIdModel> proIdModelList = new ArrayList<>(); |
| | | List<MdcUserProduction> userProList = this.list(queryUserPro); |
| | | if (userProList != null && !userProList.isEmpty()) { |
| | | for (MdcUserProduction userProduction : userProList) { |
| | | proIdList.add(userProduction.getProId()); |
| | | } |
| | | queryPro.in(MdcProduction::getId, proIdList); |
| | | List<MdcProduction> proList = mdcProductionService.list(queryPro); |
| | | if (proList != null && !proList.isEmpty()) { |
| | | for (MdcProduction mdcProduction : proList) { |
| | | proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction)); |
| | | } |
| | | } |
| | | return proIdModelList; |
| | | } |
| | | } catch (Exception e) { |
| | | e.fillInStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿idéå |
| | | */ |
| | | @Override |
| | | public List<String> queryProductionIdsByUserId(String userId) { |
| | | return this.baseMapper.queryProductionIdsByUserId(userId); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ä¸ç»è½¦é´idæ¥è¯¢ç¨æ·äº§çº¿ä¿¡æ¯ |
| | | * @param productionIds |
| | | */ |
| | | @Override |
| | | public List<MdcUserProduction> queryByProductionIds(List<String> productionIds){ |
| | | if (!productionIds.isEmpty()){ |
| | | return super.list(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, productionIds)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean removeByCollection(List<MdcUserProduction> mdcUserProductions) { |
| | | if(mdcUserProductions == null || mdcUserProductions.isEmpty()) |
| | | return false; |
| | | if(mdcUserProductions.size() == 1){ |
| | | return super.removeById(mdcUserProductions.get(0).getId()); |
| | | } |
| | | List<String> ids = new ArrayList<>(); |
| | | mdcUserProductions.forEach(item -> { |
| | | ids.add(item.getId()); |
| | | }); |
| | | return super.removeByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * è·åå·²åé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> getUserPermsByGroupId(String proId){ |
| | | return super.getBaseMapper().getUserPermsByGroupId(proId); |
| | | } |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> getUserNonPermsByGroupId(String proId){ |
| | | return super.getBaseMapper().getUserNonPermsByGroupId(proId); |
| | | } |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ· |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> getUserNonPermsByDeviceId(String proId){ |
| | | return super.getBaseMapper().getUserNonPermsByDeviceId(proId); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUser> getUserPermsByDeviceId(String proId) { |
| | | return super.getBaseMapper().getUserPermsByDeviceId(proId); |
| | | } |
| | | |
| | | /** |
| | | * éè¿è½¦é´idä¸å²ä½idçéç¨æ· |
| | | * @param post |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> queryByPostAndProId(String post, String proId){ |
| | | return super.getBaseMapper().queryByPostAndProId(post, proId); |
| | | } |
| | | |
| | | @Override |
| | | public MdcUserProduction getByUserIdAndGroupId(String userId, String proId){ |
| | | if(StrUtil.isEmpty(userId) || StrUtil.isEmpty(proId)) |
| | | return null; |
| | | List<MdcUserProduction> list = super.lambdaQuery().eq(MdcUserProduction::getUserId, userId).eq(MdcUserProduction::getProId, proId).list(); |
| | | if(list == null || list.isEmpty()) |
| | | return null; |
| | | return list.get(0); |
| | | } |
| | | } |