123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package com.fdkankan.manage.service.impl;
- import cn.dev33.satoken.stp.StpUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.fdkankan.manage.common.PageInfo;
- import com.fdkankan.manage.common.ResultCode;
- import com.fdkankan.manage.entity.AuthorizeInstall;
- import com.fdkankan.manage.entity.AuthorizeModeling;
- import com.fdkankan.manage.exception.BusinessException;
- import com.fdkankan.manage.mapper.IAuthorizeInstallMapper;
- import com.fdkankan.manage.service.IAuthorizeInstallService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.fdkankan.manage.vo.request.AuthorizeParam;
- import com.fdkankan.reg.RegCodeUtil;
- import com.fdkankan.reg.dto.MachineRegDto;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.stereotype.Service;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author
- * @since 2023-07-07
- */
- @Service
- public class AuthorizeInstallServiceImpl extends ServiceImpl<IAuthorizeInstallMapper, AuthorizeInstall> implements IAuthorizeInstallService {
- @Override
- public Object pageList(AuthorizeParam param) {
- LambdaQueryWrapper<AuthorizeInstall> wrapper = new LambdaQueryWrapper<>();
- if(StringUtils.isNotBlank(param.getCustomerName())){
- wrapper.like(AuthorizeInstall::getCustomerName,param.getCustomerName());
- }
- if(param.getCustomerType() == null){
- wrapper.eq(AuthorizeInstall::getCustomerType,param.getCustomerType());
- }
- if(param.getUseType() == null){
- wrapper.eq(AuthorizeInstall::getUseType,param.getUseType());
- }
- if(StringUtils.isNotBlank(param.getAuthorizeKey())){
- wrapper.like(AuthorizeInstall::getAuthorizeKey,param.getAuthorizeKey());
- }
- if(StringUtils.isNotBlank(param.getMachineUuid())){
- wrapper.like(AuthorizeInstall::getMachineUuid,param.getMachineUuid());
- }
- wrapper.orderByDesc(AuthorizeInstall::getCreateTime);
- Page<AuthorizeInstall> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
- return PageInfo.PageInfo(page);
- }
- @Override
- public AuthorizeInstall addOrUpdate(AuthorizeInstall param) {
- param.setSysUserId(Long.valueOf((String) StpUtil.getLoginId()));
- if(param.getId() == null){
- //获取机器UUID,机器名称
- MachineRegDto machineRegDto = RegCodeUtil.ParseMachineCode(param.getMachineCode());
- if(machineRegDto == null){
- throw new BusinessException(ResultCode.READ_MACHINE_CODE_ERROR);
- }
- param.setMachineUuid( machineRegDto.getUuid());
- param.setMachineName( machineRegDto.getComputerName());
- try {
- String authorizeKey = RegCodeUtil.GenRegeditCode(param.getMachineCode());
- if(StringUtils.isBlank(authorizeKey)){
- throw new BusinessException(ResultCode.GET_MACHINE_CODE_ERROR);
- }
- param.setAuthorizeKey(authorizeKey);
- }catch (Exception e){
- throw new BusinessException(ResultCode.GET_MACHINE_CODE_ERROR);
- }
- }
- this.saveOrUpdate(param);
- return param;
- }
- }
|