ClientAuthService.java 1002 B

12345678910111213141516171819202122232425262728293031323334
  1. package com.yaozhitech.spring5.service;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Service;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.yaozhitech.spring5.domain.Client;
  6. import com.yaozhitech.spring5.domain.ClientAuth;
  7. import com.yaozhitech.spring5.mapper.ClientAuthMapper;
  8. import com.yaozhitech.spring5.mapper.ClientMapper;
  9. @Service
  10. public class ClientAuthService {
  11. @Autowired
  12. private ClientAuthMapper authClientMapper;
  13. @Autowired
  14. private ClientMapper clientMapper;
  15. public Boolean isAllowed(String service, String allowClient, String secret) {
  16. Client client = clientMapper.selectOne(new QueryWrapper<Client>().eq("name", allowClient).eq("secret", secret));
  17. if (client == null) {
  18. return false;
  19. }
  20. ClientAuth authClient = authClientMapper.selectOne(new QueryWrapper<ClientAuth>()
  21. .eq("service", service)
  22. .eq("allow_client", allowClient));
  23. return authClient != null;
  24. }
  25. }