|
@@ -0,0 +1,71 @@
|
|
|
+package com.simuwang.manage.service.impl;
|
|
|
+
|
|
|
+import com.simuwang.base.mapper.daq.UserChannelMappingMapper;
|
|
|
+import com.simuwang.base.pojo.dos.UserChannelMappingDO;
|
|
|
+import com.simuwang.base.pojo.vo.UserChannelMappingVO;
|
|
|
+import com.simuwang.manage.service.UserChannelMappingService;
|
|
|
+import com.simuwang.shiro.utils.UserUtils;
|
|
|
+import com.smppw.common.pojo.ResultVo;
|
|
|
+import com.smppw.common.pojo.enums.status.ResultCode;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class UserChannelMappingServiceImpl implements UserChannelMappingService {
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(UserChannelMappingServiceImpl.class);
|
|
|
+ @Autowired
|
|
|
+ private UserChannelMappingMapper userChannelMappingMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultVo saveUserChannel(UserChannelMappingVO userChannelMappingVO) {
|
|
|
+ ResultVo vo = new ResultVo(ResultCode.SAVE_SUCCESS.getCode());
|
|
|
+ List<Integer> channelIdList = userChannelMappingVO.getChannelIdList();
|
|
|
+ Integer userId = userChannelMappingVO.getUserId();
|
|
|
+ Integer loginUserId = UserUtils.getLoginUser().getUserId();
|
|
|
+ try{
|
|
|
+ List<UserChannelMappingDO> userChannelMappingDOS = new ArrayList<>();
|
|
|
+ if(channelIdList.isEmpty()){
|
|
|
+ //表示删除
|
|
|
+ userChannelMappingMapper.removeUserChannel(userId,loginUserId);
|
|
|
+ }
|
|
|
+ for (Integer channelId : channelIdList) {
|
|
|
+ UserChannelMappingDO userChannelMappingDO = new UserChannelMappingDO();
|
|
|
+ userChannelMappingDO.setUserId(userId);
|
|
|
+ userChannelMappingDO.setChannelId(channelId);
|
|
|
+ userChannelMappingDO.setCreatetime(new Date());
|
|
|
+ UserChannelMappingDO oldUserChannelMappingDO = userChannelMappingMapper.selectUserChannelMappingDO(userChannelMappingDO);
|
|
|
+ if(oldUserChannelMappingDO != null){
|
|
|
+ userChannelMappingDO.setId(oldUserChannelMappingDO.getId());
|
|
|
+ userChannelMappingDO.setCreatorid(oldUserChannelMappingDO.getCreatorid());
|
|
|
+ userChannelMappingDO.setCreatetime(oldUserChannelMappingDO.getCreatetime());
|
|
|
+ }
|
|
|
+ userChannelMappingDO.setIsvalid(1);
|
|
|
+ userChannelMappingDO.setUpdaterid(loginUserId);
|
|
|
+ userChannelMappingDO.setUpdatetime(new Date());
|
|
|
+ userChannelMappingDOS.add(userChannelMappingDO);
|
|
|
+ }
|
|
|
+ userChannelMappingMapper.insertOrUpdate(userChannelMappingDOS);
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error(e.getMessage(),e);
|
|
|
+ vo.setCode(ResultCode.SAVE_FAILED.getCode());
|
|
|
+ vo.setMsg(e.getMessage());
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultVo getUserChannel(Integer userId) {
|
|
|
+ List<Integer> channelIdList = userChannelMappingMapper.getUserChannelId(userId);
|
|
|
+ UserChannelMappingVO userChannelMappingVO = new UserChannelMappingVO();
|
|
|
+ userChannelMappingVO.setChannelIdList(channelIdList);
|
|
|
+ userChannelMappingVO.setUserId(userId);
|
|
|
+ return new ResultVo(userChannelMappingVO);
|
|
|
+ }
|
|
|
+}
|