#机器人的二维码模块

This commit is contained in:
2026-05-14 14:53:29 +08:00
parent 40c5db2fe7
commit 45a5ce1e8e
32 changed files with 1344 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
package com.maibu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maibu.core.business.sys_robot_qrcode.SysQrCode;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysQrCodeMapper extends BaseMapper<SysQrCode> {
}

View File

@@ -0,0 +1,9 @@
package com.maibu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maibu.core.business.sys_robot_qrcode.SysRobotConfig;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysRobotConfigMapper extends BaseMapper<SysRobotConfig> {
}

View File

@@ -0,0 +1,10 @@
package com.maibu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maibu.core.business.sys_robot_qrcode.SysRobotCountry;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysRobotCountryMapper extends BaseMapper<SysRobotCountry> {
}

View File

@@ -0,0 +1,9 @@
package com.maibu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maibu.core.business.sys_robot_qrcode.SysRobotModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysRobotModelMapper extends BaseMapper<SysRobotModel> {
}

View File

@@ -0,0 +1,9 @@
package com.maibu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maibu.core.business.sys_robot_qrcode.SysRobotProvince;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysRobotProvinceMapper extends BaseMapper<SysRobotProvince> {
}

View File

@@ -0,0 +1,9 @@
package com.maibu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maibu.core.business.sys_robot_qrcode.SysRobotType;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysRobotTypeMapper extends BaseMapper<SysRobotType> {
}

View File

@@ -0,0 +1,25 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maibu.core.business.sys_robot_qrcode.SysQrCode;
import java.util.List;
public interface ISysQrCodeService extends IService<SysQrCode> {
IPage<SysQrCode> selectQrCodePage(IPage<SysQrCode> page, SysQrCode qrCode);
List<SysQrCode> selectQrCodeList(SysQrCode qrCode);
String generateUniqueSerialNumber(Long modelId, Long configId, Long countryId, Long provinceId);
SysQrCode generateQrCodeWithImage(Long modelId, Long configId, Long typeId,
Long countryId, Long provinceId);
SysQrCode selectBySerialNumber(String serialNumber);
boolean bindDevice(Long qrCodeId, Long deviceId);
boolean unbindDevice(Long qrCodeId);
}

View File

@@ -0,0 +1,16 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maibu.core.business.sys_robot_qrcode.SysRobotConfig;
import java.util.List;
public interface ISysRobotConfigService extends IService<SysRobotConfig> {
IPage<SysRobotConfig> selectPage(IPage<SysRobotConfig> page, SysRobotConfig config);
List<SysRobotConfig> selectList(SysRobotConfig config);
boolean checkStoreValueUnique(SysRobotConfig config);
}

View File

@@ -0,0 +1,16 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maibu.core.business.sys_robot_qrcode.SysRobotCountry;
import java.util.List;
public interface ISysRobotCountryService extends IService<SysRobotCountry> {
IPage<SysRobotCountry> selectPage(IPage<SysRobotCountry> page, SysRobotCountry country);
List<SysRobotCountry> selectList(SysRobotCountry country);
boolean checkStoreValueUnique(SysRobotCountry country);
}

View File

@@ -0,0 +1,16 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maibu.core.business.sys_robot_qrcode.SysRobotModel;
import java.util.List;
public interface ISysRobotModelService extends IService<SysRobotModel> {
IPage<SysRobotModel> selectPage(IPage<SysRobotModel> page, SysRobotModel model);
List<SysRobotModel> selectList(SysRobotModel model);
boolean checkStoreValueUnique(SysRobotModel model);
}

View File

@@ -0,0 +1,16 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maibu.core.business.sys_robot_qrcode.SysRobotProvince;
import java.util.List;
public interface ISysRobotProvinceService extends IService<SysRobotProvince> {
IPage<SysRobotProvince> selectPage(IPage<SysRobotProvince> page, SysRobotProvince province);
List<SysRobotProvince> selectList(SysRobotProvince province);
boolean checkStoreValueUnique(SysRobotProvince province);
}

View File

@@ -0,0 +1,16 @@
package com.maibu.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.maibu.core.business.sys_robot_qrcode.SysRobotType;
import java.util.List;
public interface ISysRobotTypeService extends IService<SysRobotType> {
IPage<SysRobotType> selectPage(IPage<SysRobotType> page, SysRobotType type);
List<SysRobotType> selectList(SysRobotType type);
boolean checkStoreValueUnique(SysRobotType type);
}

View File

@@ -0,0 +1,202 @@
package com.maibu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.maibu.core.business.sys_robot_qrcode.*;
import com.maibu.mapper.*;
import com.maibu.service.ISysQrCodeService;
import com.maibu.utils.MinioUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Slf4j
@Service
public class SysQrCodeServiceImpl extends ServiceImpl<SysQrCodeMapper, SysQrCode> implements ISysQrCodeService {
@Autowired
private SysRobotModelMapper robotModelMapper;
@Autowired
private SysRobotConfigMapper robotConfigMapper;
@Autowired
private SysRobotTypeMapper robotTypeMapper;
@Autowired
private SysRobotCountryMapper robotCountryMapper;
@Autowired
private SysRobotProvinceMapper robotProvinceMapper;
@Autowired
private MinioUtil minioUtil;
@Override
public IPage<SysQrCode> selectQrCodePage(IPage<SysQrCode> page, SysQrCode qrCode) {
LambdaQueryWrapper<SysQrCode> wrapper = new LambdaQueryWrapper<>();
wrapper.like(qrCode.getSerialNumber() != null, SysQrCode::getSerialNumber, qrCode.getSerialNumber())
.eq(qrCode.getModelId() != null, SysQrCode::getModelId, qrCode.getModelId())
.eq(qrCode.getConfigId() != null, SysQrCode::getConfigId, qrCode.getConfigId())
.eq(qrCode.getTypeId() != null, SysQrCode::getTypeId, qrCode.getTypeId())
.eq(qrCode.getCountryId() != null, SysQrCode::getCountryId, qrCode.getCountryId())
.eq(qrCode.getProvinceId() != null, SysQrCode::getProvinceId, qrCode.getProvinceId())
.eq(qrCode.getStatus() != null, SysQrCode::getStatus, qrCode.getStatus())
.eq(qrCode.getDeviceId() != null, SysQrCode::getDeviceId, qrCode.getDeviceId())
.orderByDesc(SysQrCode::getCreateTime);
return this.page(page, wrapper);
}
@Override
public List<SysQrCode> selectQrCodeList(SysQrCode qrCode) {
LambdaQueryWrapper<SysQrCode> wrapper = new LambdaQueryWrapper<>();
wrapper.like(qrCode.getSerialNumber() != null, SysQrCode::getSerialNumber, qrCode.getSerialNumber())
.eq(qrCode.getModelId() != null, SysQrCode::getModelId, qrCode.getModelId())
.eq(qrCode.getConfigId() != null, SysQrCode::getConfigId, qrCode.getConfigId())
.eq(qrCode.getTypeId() != null, SysQrCode::getTypeId, qrCode.getTypeId())
.eq(qrCode.getCountryId() != null, SysQrCode::getCountryId, qrCode.getCountryId())
.eq(qrCode.getProvinceId() != null, SysQrCode::getProvinceId, qrCode.getProvinceId())
.eq(qrCode.getStatus() != null, SysQrCode::getStatus, qrCode.getStatus())
.orderByDesc(SysQrCode::getCreateTime);
return this.list(wrapper);
}
@Override
public String generateUniqueSerialNumber(Long modelId, Long configId, Long countryId, Long provinceId) {
SysRobotModel model = robotModelMapper.selectById(modelId);
SysRobotConfig config = robotConfigMapper.selectById(configId);
SysRobotCountry country = robotCountryMapper.selectById(countryId);
SysRobotProvince province = robotProvinceMapper.selectById(provinceId);
if (model == null || config == null || country == null || province == null) {
throw new RuntimeException("基础数据不存在");
}
StringBuilder serialNumber = new StringBuilder();
serialNumber.append(model.getStoreValue());
serialNumber.append(config.getStoreValue());
serialNumber.append("-");
serialNumber.append(country.getStoreValue());
serialNumber.append("-");
serialNumber.append(province.getStoreValue());
serialNumber.append("-");
long timestamp = System.currentTimeMillis();
String uuid = UUID.randomUUID().toString().replace("-", "").substring(0, 16);
serialNumber.append(timestamp).append("-").append(uuid);
LambdaQueryWrapper<SysQrCode> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysQrCode::getSerialNumber, serialNumber.toString());
if (this.count(wrapper) > 0) {
return generateUniqueSerialNumber(modelId, configId, countryId, provinceId);
}
return serialNumber.toString();
}
@Override
@Transactional(rollbackFor = Exception.class)
public SysQrCode generateQrCodeWithImage(Long modelId, Long configId, Long typeId,
Long countryId, Long provinceId) {
String serialNumber = generateUniqueSerialNumber(modelId, configId, countryId, provinceId);
String qrCodeUrl = generateAndUploadQrImage(serialNumber);
SysQrCode qrCode = new SysQrCode();
qrCode.setSerialNumber(serialNumber);
qrCode.setModelId(modelId);
qrCode.setConfigId(configId);
qrCode.setTypeId(typeId);
qrCode.setCountryId(countryId);
qrCode.setProvinceId(provinceId);
qrCode.setQrCodeUrl(qrCodeUrl);
qrCode.setQrCodeContent(serialNumber);
qrCode.setStatus(0);
this.save(qrCode);
return qrCode;
}
private String generateAndUploadQrImage(String serialNumber) {
try {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.ERROR_CORRECTION, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel.H);
BitMatrix bitMatrix = qrCodeWriter.encode(serialNumber, BarcodeFormat.QR_CODE, 300, 300, hints);
BufferedImage image = MatrixToImageWriter.toBufferedImage(bitMatrix);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "PNG", baos);
byte[] imageBytes = baos.toByteArray();
String objectName = "qrcode/" + serialNumber + ".png";
ByteArrayInputStream bais = new ByteArrayInputStream(imageBytes);
minioUtil.uploadFile(objectName, bais, "image/png");
return minioUtil.getPublicUrl(objectName);
} catch (Exception e) {
log.error("生成二维码图片并上传MinIO失败: {}", serialNumber, e);
throw new RuntimeException("生成二维码图片失败", e);
}
}
@Override
public SysQrCode selectBySerialNumber(String serialNumber) {
LambdaQueryWrapper<SysQrCode> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysQrCode::getSerialNumber, serialNumber);
return this.getOne(wrapper);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean bindDevice(Long qrCodeId, Long deviceId) {
SysQrCode qrCode = this.getById(qrCodeId);
if (qrCode == null) {
throw new RuntimeException("二维码不存在");
}
if (qrCode.getStatus() == 1) {
throw new RuntimeException("二维码已绑定设备");
}
qrCode.setDeviceId(deviceId);
qrCode.setStatus(1);
qrCode.setBindTime(LocalDateTime.now());
return this.updateById(qrCode);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean unbindDevice(Long qrCodeId) {
SysQrCode qrCode = this.getById(qrCodeId);
if (qrCode == null) {
throw new RuntimeException("二维码不存在");
}
qrCode.setDeviceId(null);
qrCode.setStatus(0);
qrCode.setBindTime(null);
return this.updateById(qrCode);
}
}

View File

@@ -0,0 +1,45 @@
package com.maibu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maibu.core.business.sys_robot_qrcode.SysRobotConfig;
import com.maibu.mapper.SysRobotConfigMapper;
import com.maibu.service.ISysRobotConfigService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class SysRobotConfigServiceImpl extends ServiceImpl<SysRobotConfigMapper, SysRobotConfig> implements ISysRobotConfigService {
@Override
public IPage<SysRobotConfig> selectPage(IPage<SysRobotConfig> page, SysRobotConfig config) {
LambdaQueryWrapper<SysRobotConfig> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(config.getStoreValue()), SysRobotConfig::getStoreValue, config.getStoreValue())
.like(StringUtils.hasText(config.getDisplayName()), SysRobotConfig::getDisplayName, config.getDisplayName())
.eq(config.getStatus() != null, SysRobotConfig::getStatus, config.getStatus())
.orderByAsc(SysRobotConfig::getSortOrder);
return this.page(page, wrapper);
}
@Override
public List<SysRobotConfig> selectList(SysRobotConfig config) {
LambdaQueryWrapper<SysRobotConfig> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(config.getStoreValue()), SysRobotConfig::getStoreValue, config.getStoreValue())
.like(StringUtils.hasText(config.getDisplayName()), SysRobotConfig::getDisplayName, config.getDisplayName())
.eq(config.getStatus() != null, SysRobotConfig::getStatus, config.getStatus())
.orderByAsc(SysRobotConfig::getSortOrder);
return this.list(wrapper);
}
@Override
public boolean checkStoreValueUnique(SysRobotConfig config) {
LambdaQueryWrapper<SysRobotConfig> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysRobotConfig::getStoreValue, config.getStoreValue());
if (config.getId() != null) {
wrapper.ne(SysRobotConfig::getId, config.getId());
}
return this.count(wrapper) == 0;
}
}

View File

@@ -0,0 +1,45 @@
package com.maibu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maibu.core.business.sys_robot_qrcode.SysRobotCountry;
import com.maibu.mapper.SysRobotCountryMapper;
import com.maibu.service.ISysRobotCountryService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class SysRobotCountryServiceImpl extends ServiceImpl<SysRobotCountryMapper, SysRobotCountry> implements ISysRobotCountryService {
@Override
public IPage<SysRobotCountry> selectPage(IPage<SysRobotCountry> page, SysRobotCountry country) {
LambdaQueryWrapper<SysRobotCountry> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(country.getStoreValue()), SysRobotCountry::getStoreValue, country.getStoreValue())
.like(StringUtils.hasText(country.getDisplayName()), SysRobotCountry::getDisplayName, country.getDisplayName())
.eq(country.getStatus() != null, SysRobotCountry::getStatus, country.getStatus())
.orderByAsc(SysRobotCountry::getSortOrder);
return this.page(page, wrapper);
}
@Override
public List<SysRobotCountry> selectList(SysRobotCountry country) {
LambdaQueryWrapper<SysRobotCountry> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(country.getStoreValue()), SysRobotCountry::getStoreValue, country.getStoreValue())
.like(StringUtils.hasText(country.getDisplayName()), SysRobotCountry::getDisplayName, country.getDisplayName())
.eq(country.getStatus() != null, SysRobotCountry::getStatus, country.getStatus())
.orderByAsc(SysRobotCountry::getSortOrder);
return this.list(wrapper);
}
@Override
public boolean checkStoreValueUnique(SysRobotCountry country) {
LambdaQueryWrapper<SysRobotCountry> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysRobotCountry::getStoreValue, country.getStoreValue());
if (country.getId() != null) {
wrapper.ne(SysRobotCountry::getId, country.getId());
}
return this.count(wrapper) == 0;
}
}

View File

@@ -0,0 +1,45 @@
package com.maibu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maibu.core.business.sys_robot_qrcode.SysRobotModel;
import com.maibu.mapper.SysRobotModelMapper;
import com.maibu.service.ISysRobotModelService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class SysRobotModelServiceImpl extends ServiceImpl<SysRobotModelMapper, SysRobotModel> implements ISysRobotModelService {
@Override
public IPage<SysRobotModel> selectPage(IPage<SysRobotModel> page, SysRobotModel model) {
LambdaQueryWrapper<SysRobotModel> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(model.getStoreValue()), SysRobotModel::getStoreValue, model.getStoreValue())
.like(StringUtils.hasText(model.getDisplayName()), SysRobotModel::getDisplayName, model.getDisplayName())
.eq(model.getStatus() != null, SysRobotModel::getStatus, model.getStatus())
.orderByAsc(SysRobotModel::getSortOrder);
return this.page(page, wrapper);
}
@Override
public List<SysRobotModel> selectList(SysRobotModel model) {
LambdaQueryWrapper<SysRobotModel> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(model.getStoreValue()), SysRobotModel::getStoreValue, model.getStoreValue())
.like(StringUtils.hasText(model.getDisplayName()), SysRobotModel::getDisplayName, model.getDisplayName())
.eq(model.getStatus() != null, SysRobotModel::getStatus, model.getStatus())
.orderByAsc(SysRobotModel::getSortOrder);
return this.list(wrapper);
}
@Override
public boolean checkStoreValueUnique(SysRobotModel model) {
LambdaQueryWrapper<SysRobotModel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysRobotModel::getStoreValue, model.getStoreValue());
if (model.getId() != null) {
wrapper.ne(SysRobotModel::getId, model.getId());
}
return this.count(wrapper) == 0;
}
}

View File

@@ -0,0 +1,45 @@
package com.maibu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maibu.core.business.sys_robot_qrcode.SysRobotProvince;
import com.maibu.mapper.SysRobotProvinceMapper;
import com.maibu.service.ISysRobotProvinceService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class SysRobotProvinceServiceImpl extends ServiceImpl<SysRobotProvinceMapper, SysRobotProvince> implements ISysRobotProvinceService {
@Override
public IPage<SysRobotProvince> selectPage(IPage<SysRobotProvince> page, SysRobotProvince province) {
LambdaQueryWrapper<SysRobotProvince> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(province.getStoreValue()), SysRobotProvince::getStoreValue, province.getStoreValue())
.like(StringUtils.hasText(province.getDisplayName()), SysRobotProvince::getDisplayName, province.getDisplayName())
.eq(province.getStatus() != null, SysRobotProvince::getStatus, province.getStatus())
.orderByAsc(SysRobotProvince::getSortOrder);
return this.page(page, wrapper);
}
@Override
public List<SysRobotProvince> selectList(SysRobotProvince province) {
LambdaQueryWrapper<SysRobotProvince> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(province.getStoreValue()), SysRobotProvince::getStoreValue, province.getStoreValue())
.like(StringUtils.hasText(province.getDisplayName()), SysRobotProvince::getDisplayName, province.getDisplayName())
.eq(province.getStatus() != null, SysRobotProvince::getStatus, province.getStatus())
.orderByAsc(SysRobotProvince::getSortOrder);
return this.list(wrapper);
}
@Override
public boolean checkStoreValueUnique(SysRobotProvince province) {
LambdaQueryWrapper<SysRobotProvince> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysRobotProvince::getStoreValue, province.getStoreValue());
if (province.getId() != null) {
wrapper.ne(SysRobotProvince::getId, province.getId());
}
return this.count(wrapper) == 0;
}
}

View File

@@ -0,0 +1,45 @@
package com.maibu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maibu.core.business.sys_robot_qrcode.SysRobotType;
import com.maibu.mapper.SysRobotTypeMapper;
import com.maibu.service.ISysRobotTypeService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class SysRobotTypeServiceImpl extends ServiceImpl<SysRobotTypeMapper, SysRobotType> implements ISysRobotTypeService {
@Override
public IPage<SysRobotType> selectPage(IPage<SysRobotType> page, SysRobotType type) {
LambdaQueryWrapper<SysRobotType> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(type.getStoreValue()), SysRobotType::getStoreValue, type.getStoreValue())
.like(StringUtils.hasText(type.getDisplayName()), SysRobotType::getDisplayName, type.getDisplayName())
.eq(type.getStatus() != null, SysRobotType::getStatus, type.getStatus())
.orderByAsc(SysRobotType::getSortOrder);
return this.page(page, wrapper);
}
@Override
public List<SysRobotType> selectList(SysRobotType type) {
LambdaQueryWrapper<SysRobotType> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.hasText(type.getStoreValue()), SysRobotType::getStoreValue, type.getStoreValue())
.like(StringUtils.hasText(type.getDisplayName()), SysRobotType::getDisplayName, type.getDisplayName())
.eq(type.getStatus() != null, SysRobotType::getStatus, type.getStatus())
.orderByAsc(SysRobotType::getSortOrder);
return this.list(wrapper);
}
@Override
public boolean checkStoreValueUnique(SysRobotType type) {
LambdaQueryWrapper<SysRobotType> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysRobotType::getStoreValue, type.getStoreValue());
if (type.getId() != null) {
wrapper.ne(SysRobotType::getId, type.getId());
}
return this.count(wrapper) == 0;
}
}