JySceneAuthServiceImpl.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.entity.JySceneUserAuth;
  7. import com.fdkankan.manage.mapper.IJySceneAuthMapper;
  8. import com.fdkankan.manage.service.IJySceneAuthService;
  9. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  10. import com.fdkankan.manage.service.IJySceneUserAuthService;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import java.util.ArrayList;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.stream.Collectors;
  17. /**
  18. * <p>
  19. * 服务实现类
  20. * </p>
  21. *
  22. * @author
  23. * @since 2023-08-30
  24. */
  25. @Service
  26. public class JySceneAuthServiceImpl extends ServiceImpl<IJySceneAuthMapper, JySceneAuth> implements IJySceneAuthService {
  27. @Override
  28. public JySceneAuth getByNum(String num) {
  29. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  30. wrapper.eq(JySceneAuth::getNum,num);
  31. return this.getOne(wrapper);
  32. }
  33. @Override
  34. public HashMap<String, JySceneAuth> getByNumList(List<String> numList) {
  35. HashMap<String, JySceneAuth> map = new HashMap<>();
  36. if(numList.isEmpty()){
  37. return map;
  38. }
  39. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  40. wrapper.in(JySceneAuth::getNum,numList);
  41. List<JySceneAuth> list = this.list(wrapper);
  42. list.forEach(e -> map.put(e.getNum(),e));
  43. return map;
  44. }
  45. @Override
  46. public List<String> getOpenNumList() {
  47. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  48. wrapper.eq(JySceneAuth::getAuthType,1);
  49. List<JySceneAuth> list = this.list(wrapper);
  50. if(list.isEmpty()){
  51. return new ArrayList<>();
  52. }
  53. return list.stream().map(JySceneAuth::getNum).collect(Collectors.toList());
  54. }
  55. @Override
  56. public List<String> getNumListByPlatform(Integer platformId, Integer authType) {
  57. List<JySceneAuth> list = this.getBaseMapper().getNumListByPlatform(platformId,authType);
  58. return list.stream().map(JySceneAuth::getNum).collect(Collectors.toList());
  59. }
  60. @Override
  61. public void updateAuthTypeByNum(String num, Integer authType) {
  62. JySceneAuth auth = this.getByNum(num);
  63. if(auth == null){
  64. auth = new JySceneAuth(authType);
  65. auth.setNum(num);
  66. this.save(auth);
  67. return;
  68. }
  69. LambdaUpdateWrapper<JySceneAuth> wrapper = new LambdaUpdateWrapper<>();
  70. wrapper.eq(JySceneAuth::getNum,num);
  71. wrapper.set(JySceneAuth::getAuthType,authType);
  72. this.update(wrapper);
  73. }
  74. @Override
  75. public void updateAuthTypeByCaseId(Integer caseId, Integer authType) {
  76. JySceneAuth auth = this.getByCaseId(caseId);
  77. if(auth == null){
  78. auth = new JySceneAuth(authType);
  79. auth.setCaseId(caseId);
  80. this.save(auth);
  81. return;
  82. }
  83. LambdaUpdateWrapper<JySceneAuth> wrapper = new LambdaUpdateWrapper<>();
  84. wrapper.eq(JySceneAuth::getCaseId,caseId);
  85. wrapper.set(JySceneAuth::getAuthType,authType);
  86. this.update(wrapper);
  87. }
  88. @Override
  89. public JySceneAuth getByCaseId(Integer caseId) {
  90. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  91. wrapper.eq(JySceneAuth::getCaseId,caseId);
  92. return this.getOne(wrapper);
  93. }
  94. @Override
  95. public List<JySceneAuth> getAllCase() {
  96. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  97. wrapper.isNotNull(JySceneAuth::getCaseId);
  98. return this.list(wrapper);
  99. }
  100. @Autowired
  101. IJySceneUserAuthService jySceneUserAuthService;
  102. @Override
  103. public void delByNumList(List<String> numList) {
  104. if(numList.isEmpty()){
  105. return;
  106. }
  107. LambdaQueryWrapper<JySceneAuth> wrapper = new LambdaQueryWrapper<>();
  108. wrapper.in(JySceneAuth::getNum,numList);
  109. this.remove(wrapper);
  110. LambdaQueryWrapper<JySceneUserAuth> wrapper2 = new LambdaQueryWrapper<>();
  111. wrapper2.in(JySceneUserAuth::getNum,numList);
  112. jySceneUserAuthService.remove(wrapper2);
  113. }
  114. }