SysUserPlantServiceImpl.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) 2016-2019 人人开源 All rights reserved.
  3. * <p>
  4. * https://www.renren.io
  5. * <p>
  6. * 版权所有,侵权必究!
  7. */
  8. package io.renren.modules.sys.service.impl;
  9. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  10. import io.renren.common.utils.MapUtils;
  11. import io.renren.modules.sys.dao.SysUserPlantDao;
  12. import io.renren.modules.sys.entity.SysUserPlantEntity;
  13. import io.renren.modules.sys.service.SysUserPlantService;
  14. import org.springframework.stereotype.Service;
  15. import java.util.List;
  16. /**
  17. * 用户与角色对应关系
  18. *
  19. * @author Mark 735032128@qq.com
  20. */
  21. @Service("sysUserPlantService")
  22. public class SysUserPlantServiceImpl extends ServiceImpl<SysUserPlantDao, SysUserPlantEntity> implements SysUserPlantService {
  23. @Override
  24. public void saveOrUpdate(Long userId, List<Long> plantIdList) {
  25. //先删除用户与角色关系
  26. this.removeByMap(new MapUtils().put("user_id", userId));
  27. if (plantIdList == null || plantIdList.size() == 0) {
  28. return;
  29. }
  30. //保存用户与角色关系
  31. for (Long plantId : plantIdList) {
  32. SysUserPlantEntity sysUserPlantEntity = new SysUserPlantEntity();
  33. sysUserPlantEntity.setUserId(userId);
  34. sysUserPlantEntity.setPlantId(plantId);
  35. this.save(sysUserPlantEntity);
  36. }
  37. }
  38. @Override
  39. public List<String> queryPlantNameList(Long userId) {
  40. return baseMapper.queryPlantNameList(userId);
  41. }
  42. @Override
  43. public List<Long> queryPlantIdList(Long userId) {
  44. return baseMapper.queryPlantIdList(userId);
  45. }
  46. @Override
  47. public int deleteBatch(Long[] plantIds) {
  48. return baseMapper.deleteBatch(plantIds);
  49. }
  50. }