JySceneAuthServiceImpl.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.fdkankan.manage.service.impl;
  2. import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  5. import com.fdkankan.manage.entity.JySceneAuth;
  6. import com.fdkankan.manage.mapper.IJySceneAuthMapper;
  7. import com.fdkankan.manage.service.IJySceneAuthService;
  8. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  9. import org.springframework.stereotype.Service;
  10. import java.util.HashMap;
  11. import java.util.List;
  12. /**
  13. * <p>
  14. * 服务实现类
  15. * </p>
  16. *
  17. * @author
  18. * @since 2023-08-30
  19. */
  20. @Service
  21. public class JySceneAuthServiceImpl extends ServiceImpl<IJySceneAuthMapper, JySceneAuth> implements IJySceneAuthService {
  22. @Override
  23. public JySceneAuth getByNum(String num) {
  24. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  25. wrapper.eq(JySceneAuth::getNum,num);
  26. return this.getOne(wrapper);
  27. }
  28. @Override
  29. public HashMap<String, JySceneAuth> getByNumList(List<String> numList) {
  30. HashMap<String, JySceneAuth> map = new HashMap<>();
  31. if(numList.isEmpty()){
  32. return map;
  33. }
  34. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  35. wrapper.in(JySceneAuth::getNum,numList);
  36. List<JySceneAuth> list = this.list(wrapper);
  37. list.forEach(e -> map.put(e.getNum(),e));
  38. return map;
  39. }
  40. @Override
  41. public void updateAuthTypeByNum(String num, Integer authType) {
  42. JySceneAuth auth = this.getByNum(num);
  43. if(auth == null){
  44. auth = new JySceneAuth(authType);
  45. auth.setNum(num);
  46. this.save(auth);
  47. return;
  48. }
  49. LambdaUpdateWrapper<JySceneAuth> wrapper = new LambdaUpdateWrapper<>();
  50. wrapper.eq(JySceneAuth::getNum,num);
  51. wrapper.set(JySceneAuth::getAuthType,authType);
  52. this.update(wrapper);
  53. }
  54. }