AuthorizeInstallServiceImpl.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.fdkankan.manage.service.impl;
  2. import cn.dev33.satoken.stp.StpUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.fdkankan.manage.common.PageInfo;
  6. import com.fdkankan.manage.common.ResultCode;
  7. import com.fdkankan.manage.entity.AuthorizeInstall;
  8. import com.fdkankan.manage.entity.AuthorizeModeling;
  9. import com.fdkankan.manage.exception.BusinessException;
  10. import com.fdkankan.manage.mapper.IAuthorizeInstallMapper;
  11. import com.fdkankan.manage.service.IAuthorizeInstallService;
  12. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  13. import com.fdkankan.manage.vo.request.AuthorizeParam;
  14. import com.fdkankan.reg.RegCodeUtil;
  15. import com.fdkankan.reg.dto.MachineRegDto;
  16. import org.apache.commons.lang3.StringUtils;
  17. import org.springframework.stereotype.Service;
  18. /**
  19. * <p>
  20. * 服务实现类
  21. * </p>
  22. *
  23. * @author
  24. * @since 2023-07-07
  25. */
  26. @Service
  27. public class AuthorizeInstallServiceImpl extends ServiceImpl<IAuthorizeInstallMapper, AuthorizeInstall> implements IAuthorizeInstallService {
  28. @Override
  29. public Object pageList(AuthorizeParam param) {
  30. LambdaQueryWrapper<AuthorizeInstall> wrapper = new LambdaQueryWrapper<>();
  31. if(StringUtils.isNotBlank(param.getCustomerName())){
  32. wrapper.like(AuthorizeInstall::getCustomerName,param.getCustomerName());
  33. }
  34. if(param.getCustomerType() == null){
  35. wrapper.eq(AuthorizeInstall::getCustomerType,param.getCustomerType());
  36. }
  37. if(param.getUseType() == null){
  38. wrapper.eq(AuthorizeInstall::getUseType,param.getUseType());
  39. }
  40. if(StringUtils.isNotBlank(param.getAuthorizeKey())){
  41. wrapper.like(AuthorizeInstall::getAuthorizeKey,param.getAuthorizeKey());
  42. }
  43. if(StringUtils.isNotBlank(param.getMachineUuid())){
  44. wrapper.like(AuthorizeInstall::getMachineUuid,param.getMachineUuid());
  45. }
  46. wrapper.orderByDesc(AuthorizeInstall::getCreateTime);
  47. Page<AuthorizeInstall> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
  48. return PageInfo.PageInfo(page);
  49. }
  50. @Override
  51. public AuthorizeInstall addOrUpdate(AuthorizeInstall param) {
  52. param.setSysUserId(Long.valueOf((String) StpUtil.getLoginId()));
  53. if(param.getId() == null){
  54. //获取机器UUID,机器名称
  55. MachineRegDto machineRegDto = RegCodeUtil.ParseMachineCode(param.getMachineCode());
  56. if(machineRegDto == null){
  57. throw new BusinessException(ResultCode.READ_MACHINE_CODE_ERROR);
  58. }
  59. param.setMachineUuid( machineRegDto.getUuid());
  60. param.setMachineName( machineRegDto.getComputerName());
  61. try {
  62. String authorizeKey = RegCodeUtil.GenRegeditCode(param.getMachineCode());
  63. if(StringUtils.isBlank(authorizeKey)){
  64. throw new BusinessException(ResultCode.GET_MACHINE_CODE_ERROR);
  65. }
  66. param.setAuthorizeKey(authorizeKey);
  67. }catch (Exception e){
  68. throw new BusinessException(ResultCode.GET_MACHINE_CODE_ERROR);
  69. }
  70. }
  71. this.saveOrUpdate(param);
  72. return param;
  73. }
  74. }