简化代码,对于QueryWrapper的操作,不再重复判断条件!

This commit is contained in:
dataprince 2023-12-24 21:07:51 +08:00
parent c8643dc779
commit 64fea077c2
22 changed files with 273 additions and 505 deletions

View File

@ -13,7 +13,6 @@ public class RuoYiApplication
{
public static void main(String[] args)
{
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ RuoYi-Flex启动成功 ლ(´ڡ`ლ)゙ \n" +
" ███████ ██ ██ ██ ████████ ██ \n" +

View File

@ -93,7 +93,7 @@ redisson:
--- # 监控中心客户端配置
spring.boot.admin.client:
# 增加客户端开关
enabled: true
enabled: false
url: http://localhost:9090/admin
instance:
service-host-type: IP
@ -104,7 +104,7 @@ spring.boot.admin.client:
powerjob:
worker:
# 如何开启调度中心请查看文档教程
enabled: true
enabled: false
# 需要先在 powerjob 登录页执行应用注册后才能使用
app-name: ruoyi-worker
# 28080 端口 随着主应用端口飘逸 避免集群冲突

View File

@ -1,6 +1,7 @@
oms.env=dev
####### Database properties(Configure according to the the environment) #######
spring.datasource.remote.hibernate.properties.hibernate.dialect=tech.powerjob.server.persistence.config.dialect.PowerJobPGDialect
spring.datasource.core.driver-class-name=org.postgresql.Driver
spring.datasource.core.jdbc-url=jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.core.username=postgres

View File

@ -3,6 +3,7 @@ package com.ruoyi.mf.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
@ -11,20 +12,23 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import com.ruoyi.mf.domain.Goods;
import com.ruoyi.mf.mapper.GoodsMapper;
import static com.ruoyi.mf.domain.table.GoodsTableDef.GOODS;
import com.ruoyi.mf.mapper.CustomerMapper;
import com.ruoyi.mf.domain.Customer;
import com.ruoyi.mf.domain.bo.CustomerBo;
import com.ruoyi.mf.domain.vo.CustomerVo;
import com.ruoyi.mf.service.ICustomerService;
import static com.ruoyi.mf.domain.table.CustomerTableDef.CUSTOMER;
/**
@ -34,8 +38,7 @@ import static com.ruoyi.mf.domain.table.CustomerTableDef.CUSTOMER;
* 2023-12-06
*/
@Service
public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Customer> implements ICustomerService
{
public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Customer> implements ICustomerService {
@Resource
private CustomerMapper customerMapper;
@Resource
@ -48,17 +51,9 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
private QueryWrapper buildQueryWrapper(CustomerBo customerBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotBlank(customerBo.getCustomerName())) {
queryWrapper.and(CUSTOMER.CUSTOMER_NAME.like(customerBo.getCustomerName()));
}
if (StringUtils.isNotBlank(customerBo.getPhonenumber())) {
queryWrapper.and(CUSTOMER.PHONENUMBER.eq(customerBo.getPhonenumber()));
}
if (StringUtils.isNotBlank(customerBo.getGender())) {
queryWrapper.and(CUSTOMER.GENDER.eq(customerBo.getGender()));
}
return queryWrapper;
}
@ -69,8 +64,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
* @return 客户主表
*/
@Override
public CustomerVo selectById(Long customerId)
{
public CustomerVo selectById(Long customerId) {
return customerMapper.selectOneWithRelationsByQueryAs(query().where(CUSTOMER.CUSTOMER_ID.eq(customerId)), CustomerVo.class);
}
@ -82,8 +76,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
* @return 客户主表集合
*/
@Override
public List<CustomerVo> selectList(CustomerBo customerBo)
{
public List<CustomerVo> selectList(CustomerBo customerBo) {
QueryWrapper queryWrapper = buildQueryWrapper(customerBo);
return customerMapper.selectListWithRelationsByQueryAs(queryWrapper, CustomerVo.class);
}
@ -95,8 +88,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
* @return 分页客户主表集合
*/
@Override
public TableDataInfo<CustomerVo> selectPage(CustomerBo customerBo)
{
public TableDataInfo<CustomerVo> selectPage(CustomerBo customerBo) {
QueryWrapper queryWrapper = buildQueryWrapper(customerBo);
Page<CustomerVo> page = customerMapper.paginateWithRelationsAs(PageQuery.build(), queryWrapper, CustomerVo.class);
return TableDataInfo.build(page);
@ -110,8 +102,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
*/
@Transactional
@Override
public boolean insert(CustomerBo customerBo)
{
public boolean insert(CustomerBo customerBo) {
Customer customer = MapstructUtils.convert(customerBo, Customer.class);
boolean inserted = this.save(customer);//使用全局配置的雪花算法主键生成器生成ID值
@ -129,8 +120,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
*/
@Transactional
@Override
public boolean update(CustomerBo customerBo)
{
public boolean update(CustomerBo customerBo) {
Customer customer = MapstructUtils.convert(customerBo, Customer.class);
if (ObjectUtil.isNotNull(customer) && ObjectUtil.isNotNull(customer.getCustomerId())) {
boolean updated = this.updateById(customer);
@ -151,8 +141,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
*/
@Transactional
@Override
public boolean deleteByIds(Long[] customerIds)
{
public boolean deleteByIds(Long[] customerIds) {
QueryWrapper queryWrapper = QueryWrapper.create().from(GOODS).where(GOODS.CUSTOMER_ID.in(Arrays.asList(customerIds)));
goodsMapper.deleteByQuery(queryWrapper);
return this.removeByIds(Arrays.asList(customerIds));
@ -163,20 +152,16 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome
*
* @param customer 客户主表对象
*/
private boolean insertGoods(Customer customer)
{
private boolean insertGoods(Customer customer) {
List<Goods> goodsList = customer.getGoodsList();
Long customerId = customer.getCustomerId();
if (StringUtils.isNotNull(goodsList))
{
if (StringUtils.isNotNull(goodsList)) {
List<Goods> list = new ArrayList<>();
for (Goods goods : goodsList)
{
for (Goods goods : goodsList) {
goods.setCustomerId(customerId);
list.add(goods);
}
if (list.size() > 0)
{
if (list.size() > 0) {
return goodsMapper.insertBatch(list) > 0;
}
}

View File

@ -3,15 +3,10 @@ package com.ruoyi.mf.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -30,8 +25,7 @@ import static com.ruoyi.mf.domain.table.MfProductTableDef.MF_PRODUCT;
* 2023-11-23
*/
@Service
public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfProduct> implements IMfProductService
{
public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfProduct> implements IMfProductService {
@Resource
private MfProductMapper mfProductMapper;
@ -42,17 +36,9 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
private QueryWrapper buildQueryWrapper(MfProductBo mfProductBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotBlank(mfProductBo.getProductName())) {
queryWrapper.and(MF_PRODUCT.PRODUCT_NAME.like(mfProductBo.getProductName()));
}
if (mfProductBo.getOrderNum() != null) {
queryWrapper.and(MF_PRODUCT.ORDER_NUM.eq(mfProductBo.getOrderNum()));
}
if (StringUtils.isNotBlank(mfProductBo.getStatus())) {
queryWrapper.and(MF_PRODUCT.STATUS.eq(mfProductBo.getStatus()));
}
return queryWrapper;
}
@ -63,8 +49,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 产品树
*/
@Override
public MfProductVo selectById(Long productId)
{
public MfProductVo selectById(Long productId) {
return this.getOneAs(query().where(MF_PRODUCT.PRODUCT_ID.eq(productId)), MfProductVo.class);
}
@ -75,8 +60,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 产品树集合
*/
@Override
public List<MfProductVo> selectList(MfProductBo mfProductBo)
{
public List<MfProductVo> selectList(MfProductBo mfProductBo) {
QueryWrapper queryWrapper = buildQueryWrapper(mfProductBo);
return this.listAs(queryWrapper, MfProductVo.class);
}
@ -89,8 +73,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 结果:true 操作成功false 操作失败
*/
@Override
public boolean insert(MfProductBo mfProductBo)
{
public boolean insert(MfProductBo mfProductBo) {
MfProduct mfProduct = MapstructUtils.convert(mfProductBo, MfProduct.class);
return this.save(mfProduct);//使用全局配置的雪花算法主键生成器生成ID值
@ -103,8 +86,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 结果:true 更新成功false 更新失败
*/
@Override
public boolean update(MfProductBo mfProductBo)
{
public boolean update(MfProductBo mfProductBo) {
MfProduct mfProduct = MapstructUtils.convert(mfProductBo, MfProduct.class);
boolean updated = this.updateById(mfProduct);
@ -119,8 +101,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
*/
@Transactional
@Override
public boolean deleteByIds(Long[] productIds)
{
public boolean deleteByIds(Long[] productIds) {
return this.removeByIds(Arrays.asList(productIds));
}

View File

@ -2,11 +2,11 @@ package com.ruoyi.mf.service.impl;
import java.util.Arrays;
import java.util.List;
import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
@ -28,8 +28,7 @@ import static com.ruoyi.mf.domain.table.MfStudentTableDef.MF_STUDENT;
* 2023-11-22
*/
@Service
public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStudent> implements IMfStudentService
{
public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStudent> implements IMfStudentService {
@Resource
private MfStudentMapper mfStudentMapper;
@ -40,14 +39,8 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
private QueryWrapper buildQueryWrapper(MfStudentBo mfStudentBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotBlank(mfStudentBo.getStudentName())) {
queryWrapper.and(MF_STUDENT.STUDENT_NAME.like(mfStudentBo.getStudentName()));
}
if (StringUtils.isNotBlank(mfStudentBo.getStudentStatus())) {
queryWrapper.and(MF_STUDENT.STUDENT_STATUS.eq(mfStudentBo.getStudentStatus()));
}
return queryWrapper;
}
@ -58,8 +51,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 学生信息表
*/
@Override
public MfStudentVo selectById(Long studentId)
{
public MfStudentVo selectById(Long studentId) {
return this.getOneAs(query().where(MF_STUDENT.STUDENT_ID.eq(studentId)), MfStudentVo.class);
}
@ -70,8 +62,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 学生信息表集合
*/
@Override
public List<MfStudentVo> selectList(MfStudentBo mfStudentBo)
{
public List<MfStudentVo> selectList(MfStudentBo mfStudentBo) {
QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo);
return this.listAs(queryWrapper, MfStudentVo.class);
}
@ -84,8 +75,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
*/
@Override
//@UseDataSource("ds2")
public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo)
{
public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo) {
QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo);
Page<MfStudentVo> page = this.pageAs(PageQuery.build(), queryWrapper, MfStudentVo.class);
return TableDataInfo.build(page);
@ -98,8 +88,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 结果:true 操作成功false 操作失败
*/
@Override
public boolean insert(MfStudentBo mfStudentBo)
{
public boolean insert(MfStudentBo mfStudentBo) {
MfStudent mfStudent = MapstructUtils.convert(mfStudentBo, MfStudent.class);
return this.save(mfStudent);//使用全局配置的雪花算法主键生成器生成ID值
@ -112,8 +101,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 结果:true 更新成功false 更新失败
*/
@Override
public boolean update(MfStudentBo mfStudentBo)
{
public boolean update(MfStudentBo mfStudentBo) {
MfStudent mfStudent = MapstructUtils.convert(mfStudentBo, MfStudent.class);
boolean updated = this.updateById(mfStudent);
@ -128,8 +116,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
*/
@Transactional
@Override
public boolean deleteByIds(Long[] studentIds)
{
public boolean deleteByIds(Long[] studentIds) {
return this.removeByIds(Arrays.asList(studentIds));
}

View File

@ -64,6 +64,7 @@ public class GenController extends BaseController
GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
//table.setColumns(list);
Map<String, Object> map = new HashMap<>();
map.put("info", table);
map.put("rows", list);

View File

@ -54,10 +54,12 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
{
@Resource
private GenTableMapper genTableMapper;
@Resource
private GenTableColumnMapper genTableColumnMapper;
@Resource
private IGenTableColumnService genTableColumnService;
@Override
public QueryWrapper query() {
return super.query().from(GEN_TABLE);
@ -238,6 +240,9 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
Map<String, String> dataMap = new LinkedHashMap<>();
// 查询表信息
GenTable table = selectGenTableById(tableId);
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
table.setColumns(list);
//设置生成的sys_menu6条记录的主键值
setMenuIds(table);
// 设置主子表信息
@ -287,6 +292,8 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
{
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(table.getTableId());
table.setColumns(list);
// 设置主子表信息
setSubTable(table);
//设置生成的sys_menu6条记录的主键值
@ -402,6 +409,8 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
{
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(table.getTableId());
table.setColumns(list);
// 设置主子表信息
setSubTable(table);
//设置生成的sys_menu6条记录的主键值

View File

@ -10,6 +10,7 @@ import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
#if($table.crud || $table.sub)
import com.ruoyi.common.orm.core.domain.BaseEntity;
#elseif($table.tree)
@ -32,6 +33,9 @@ import com.ruoyi.common.orm.core.domain.TreeEntity;
@Table(value = "${tableName}")
public class ${ClassName} extends ${Entity}
{
@Serial
private static final long serialVersionUID = 1L;
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
@ -41,7 +45,7 @@ public class ${ClassName} extends ${Entity}
#if($column.javaField=='version')
@Column(version = true)
#end
#if($column.isPk==1)
#if($column.isPk=='1')
@Id
#end
private $column.javaType $column.javaField;

View File

@ -57,7 +57,6 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper,
private QueryWrapper buildQueryWrapper(${ClassName}Bo ${className}Bo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
#foreach($column in $columns)
#if($column.query)
#set($queryType=$column.queryType)
@ -68,19 +67,9 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper,
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($mpMethod=$column.queryType.toLowerCase())
#if($queryType != 'BETWEEN')
#if($javaType == 'String')
#set($condition='StringUtils.isNotBlank('+${className}+'Bo.get'+$AttrName+'())')
#else
#set($condition=${className}+'Bo.get'+$AttrName+'() != null')
#end
if ($condition) {
queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.get$AttrName()));
}
#else
Map<String, Object> params = ${className}Bo.getParams();
if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) {
queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(params.get("begin$AttrName"), params.get("end$AttrName")));
}
queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.getParams().get("begin$AttrName"), ${className}Bo.getParams().get("end$AttrName")));
#end
#end
#end

View File

@ -14,7 +14,6 @@ import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.redis.utils.CacheUtils;
import com.ruoyi.system.domain.bo.SysConfigBo;
import com.ruoyi.system.domain.vo.SysConfigVo;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@ -87,30 +86,17 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
/**
* 构造查询条件
*
* @param config
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysConfigBo config) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(config.getConfigName())) {
queryWrapper.and(SYS_CONFIG.CONFIG_NAME.like(config.getConfigName()));
}
if (StringUtils.isNotEmpty(config.getConfigType())) {
queryWrapper.and(SYS_CONFIG.CONFIG_TYPE.eq(config.getConfigType()));
}
if (StringUtils.isNotEmpty(config.getConfigKey())) {
queryWrapper.and(SYS_CONFIG.CONFIG_KEY.like(config.getConfigKey()));
}
if (StringUtils.isNotEmpty((String) config.getParams().get("beginTime"))) {
queryWrapper.and(SYS_CONFIG.CREATE_TIME.ge(config.getParams().get("beginTime")));
}
if (StringUtils.isNotEmpty((String) config.getParams().get("endTime"))) {
queryWrapper.and(SYS_CONFIG.CREATE_TIME.le(config.getParams().get("endTime")));
}
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_CONFIG.CONFIG_NAME.like(config.getConfigName()))
.and(SYS_CONFIG.CONFIG_TYPE.eq(config.getConfigType()))
.and(SYS_CONFIG.CONFIG_KEY.like(config.getConfigKey()))
.and(SYS_CONFIG.CREATE_TIME.between(config.getParams().get("beginTime"), config.getParams().get("endTime")));
return queryWrapper;
}

View File

@ -67,23 +67,13 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysDeptBo deptBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
queryWrapper.where(SYS_DEPT.DEL_FLAG.eq(0));
if (ObjectUtil.isNotNull(deptBo.getDeptId())) {
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptBo.getDeptId()));
}
if (ObjectUtil.isNotNull(deptBo.getParentId())) {
queryWrapper.and(SYS_DEPT.PARENT_ID.eq(deptBo.getParentId()));
}
if (StringUtils.isNotNull(deptBo.getDeptName())) {
queryWrapper.and(SYS_DEPT.DEPT_NAME.like(deptBo.getDeptName()));
}
if (StringUtils.isNotNull(deptBo.getStatus())) {
queryWrapper.and(SYS_DEPT.STATUS.eq(deptBo.getStatus()));
}
queryWrapper.orderBy(SYS_DEPT.PARENT_ID.asc(),SYS_DEPT.ORDER_NUM.asc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
//where(SYS_DEPT.DEL_FLAG.eq(0));//逻辑删除字段mybatis-flex会自动添加该条件
.and(SYS_DEPT.DEPT_ID.eq(deptBo.getDeptId()))
.and(SYS_DEPT.PARENT_ID.eq(deptBo.getParentId()))
.and(SYS_DEPT.DEPT_NAME.like(deptBo.getDeptName()))
.and(SYS_DEPT.STATUS.eq(deptBo.getStatus()))
.orderBy(SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc());
return queryWrapper;
}
@ -173,30 +163,31 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override
public SysDeptVo selectDeptById(Long deptId) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0));
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptId));
return this.getOneAs(queryWrapper, SysDeptVo.class);//TODO:缺少parent_name
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_ID.eq(deptId));
return this.getOneAs(queryWrapper, SysDeptVo.class);
}
/**
* 根据 部门名称 查询记录数量
*
* @param deptName 部门名称
* @return 记录数量
*/
@Override
public long selectDeptCountByName(String deptName) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
return this.count(queryWrapper);
}
/**
* 根据 部门名称 查询部门信息
*
* @param deptName 部门名称
* @return 部门信息
*/
@Override
public SysDeptVo selectDeptByName(String deptName) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
return this.getOneAs(queryWrapper, SysDeptVo.class);
}
@ -212,7 +203,6 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
.select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT)
.where(SYS_DEPT.STATUS.eq("0"))
.and(SYS_DEPT.DEL_FLAG.eq(0))
.and(QueryMethods.findInSet(QueryMethods.number(deptId), SYS_DEPT.ANCESTORS).gt(0));
return deptMapper.selectObjectByQueryAs(queryWrapper, Integer.class);
@ -229,7 +219,6 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
QueryWrapper queryWrapper = QueryWrapper.create()
.select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT)
.where(SYS_DEPT.DEL_FLAG.eq(0))
.and(SYS_DEPT.PARENT_ID.eq(deptId));
int result = deptMapper.selectObjectByQueryAs(queryWrapper, Integer.class);
@ -247,8 +236,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
public boolean checkDeptNameUnique(SysDeptBo dept) {
Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0));
queryWrapper.and(SYS_DEPT.DEPT_NAME.eq(dept.getDeptName()));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_NAME.eq(dept.getDeptName()));
queryWrapper.and(SYS_DEPT.PARENT_ID.eq(dept.getParentId()));
SysDeptVo info = this.getOneAs(queryWrapper, SysDeptVo.class);

View File

@ -9,7 +9,6 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
@ -36,8 +35,7 @@ import static com.ruoyi.system.domain.table.SysDictDataTableDef.SYS_DICT_DATA;
*/
@RequiredArgsConstructor
@Service
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService
{
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService {
@Resource
private SysDictDataMapper dictDataMapper;
@ -48,19 +46,15 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
/**
* 构造查询条件
*
* @param dictDataBo
* @return QueryWrapper
*/
private QueryWrapper buildQueryWrapper(SysDictDataBo dictDataBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(dictDataBo.getDictType())) {
queryWrapper.and(SYS_DICT_DATA.DICT_TYPE.eq(dictDataBo.getDictType()));
}
if (StringUtils.isNotEmpty(dictDataBo.getDictLabel())) {
queryWrapper.and(SYS_DICT_DATA.DICT_LABEL.eq(dictDataBo.getDictLabel()));
}
queryWrapper.orderBy(SYS_DICT_DATA.DICT_SORT.asc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_DICT_DATA.DICT_TYPE.eq(dictDataBo.getDictType()))
.and(SYS_DICT_DATA.DICT_LABEL.eq(dictDataBo.getDictLabel()))
.orderBy(SYS_DICT_DATA.DICT_SORT.asc());
return queryWrapper;
}
@ -71,8 +65,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
* @return 字典数据集合信息
*/
@Override
public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictDataBo)
{
public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictDataBo) {
QueryWrapper queryWrapper = buildQueryWrapper(dictDataBo);
return this.listAs(queryWrapper, SysDictDataVo.class);
}
@ -98,8 +91,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
* @return 字典标签
*/
@Override
public String selectDictLabel(String dictType, String dictValue)
{
public String selectDictLabel(String dictType, String dictValue) {
QueryWrapper queryWrapper = QueryWrapper.create()
.select(SYS_DICT_DATA.DICT_LABEL)
.from(SYS_DICT_DATA)
@ -116,8 +108,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
* @return 字典数据
*/
@Override
public SysDictDataVo selectDictDataById(Long dictCode)
{
public SysDictDataVo selectDictDataById(Long dictCode) {
return this.getOneAs(query().where(SYS_DICT_DATA.DICT_CODE.eq(dictCode)), SysDictDataVo.class);
}
@ -159,10 +150,8 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
*/
@Override
@Transactional
public boolean deleteDictDataByIds(Long[] dictCodes)
{
for (Long dictCode : dictCodes)
{
public boolean deleteDictDataByIds(Long[] dictCodes) {
for (Long dictCode : dictCodes) {
SysDictDataVo data = selectDictDataById(dictCode);
CacheUtils.evict(CacheNames.SYS_DICT, data.getDictType());
}
@ -177,8 +166,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
*/
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType")
@Override
public boolean insertDictData(SysDictDataBo dataBo)
{
public boolean insertDictData(SysDictDataBo dataBo) {
SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class);
return this.save(data);
}
@ -191,8 +179,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
*/
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType")
@Override
public boolean updateDictData(SysDictDataBo dataBo)
{
public boolean updateDictData(SysDictDataBo dataBo) {
SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class);
return this.updateById(data);
}

View File

@ -45,8 +45,7 @@ import static com.ruoyi.system.domain.table.SysDictTypeTableDef.SYS_DICT_TYPE;
* @author dataprince数据小王子
*/
@Service
public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService, DictService
{
public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService, DictService {
@Resource
private ISysDictDataService sysDictDataService;
@ -57,25 +56,16 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
/**
* 构造查询条件
*
* @param dictTypeBo
* @return QueryWrapper
*/
private QueryWrapper buildQueryWrapper(SysDictTypeBo dictTypeBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(dictTypeBo.getDictName())) {
queryWrapper.and(SYS_DICT_TYPE.DICT_NAME.like(dictTypeBo.getDictName()));
}
if (StringUtils.isNotEmpty(dictTypeBo.getDictType())) {
queryWrapper.and(SYS_DICT_TYPE.DICT_TYPE.eq(dictTypeBo.getDictType()));
}
if (StringUtils.isNotEmpty((String) dictTypeBo.getParams().get("beginTime")) ) {
queryWrapper.and(SYS_DICT_TYPE.CREATE_TIME.ge(dictTypeBo.getParams().get("beginTime")));
}
if (StringUtils.isNotEmpty((String) dictTypeBo.getParams().get("endTime")) ) {
queryWrapper.and(SYS_DICT_TYPE.CREATE_TIME.le(dictTypeBo.getParams().get("endTime")));
}
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_DICT_TYPE.DICT_NAME.like(dictTypeBo.getDictName()))
.and(SYS_DICT_TYPE.DICT_TYPE.eq(dictTypeBo.getDictType()))
.and(SYS_DICT_TYPE.CREATE_TIME.between(dictTypeBo.getParams().get("beginTime"), dictTypeBo.getParams().get("endTime")));
return queryWrapper;
}
@ -86,8 +76,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 字典类型集合信息
*/
@Override
public List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictTypeBo)
{
public List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictTypeBo) {
QueryWrapper queryWrapper = buildQueryWrapper(dictTypeBo);
return this.listAs(queryWrapper, SysDictTypeVo.class);
@ -112,8 +101,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 字典类型集合信息
*/
@Override
public List<SysDictTypeVo> selectDictTypeAll()
{
public List<SysDictTypeVo> selectDictTypeAll() {
return this.listAs(query(), SysDictTypeVo.class);
}
@ -125,11 +113,9 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
*/
@Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
@Override
public List<SysDictDataVo> selectDictDataByType(String dictType)
{
public List<SysDictDataVo> selectDictDataByType(String dictType) {
List<SysDictDataVo> lists = sysDictDataService.selectDictDataByType(dictType);
if (StringUtils.isNotEmpty(lists))
{
if (StringUtils.isNotEmpty(lists)) {
return lists;
}
return null;
@ -142,8 +128,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 字典类型
*/
@Override
public SysDictTypeVo selectDictTypeById(Long dictId)
{
public SysDictTypeVo selectDictTypeById(Long dictId) {
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_ID.eq(dictId)), SysDictTypeVo.class);
}
@ -154,8 +139,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 字典类型
*/
@Override
public SysDictTypeVo selectDictTypeByType(String dictType)
{
public SysDictTypeVo selectDictTypeByType(String dictType) {
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_TYPE.eq(dictType)), SysDictTypeVo.class);
}
@ -167,13 +151,10 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
*/
@Override
@Transactional
public boolean deleteDictTypeByIds(Long[] dictIds)
{
for (Long dictId : dictIds)
{
public boolean deleteDictTypeByIds(Long[] dictIds) {
for (Long dictId : dictIds) {
SysDictTypeVo dictType = selectDictTypeById(dictId);
if (sysDictDataService.countDictDataByType(dictType.getDictType()) > 0)
{
if (sysDictDataService.countDictDataByType(dictType.getDictType()) > 0) {
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
@ -185,8 +166,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* 重置字典缓存数据
*/
@Override
public void resetDictCache()
{
public void resetDictCache() {
CacheUtils.clear(CacheNames.SYS_DICT);
}
@ -198,12 +178,10 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
*/
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#sysDictTypeBo.dictType")
@Override
public List<SysDictDataVo> insertDictType(SysDictTypeBo sysDictTypeBo)
{
public List<SysDictDataVo> insertDictType(SysDictTypeBo sysDictTypeBo) {
SysDictType dict = MapstructUtils.convert(sysDictTypeBo, SysDictType.class);
boolean saved = this.save(dict);
if (saved)
{
if (saved) {
// 新增 type 下无 data 数据 返回空防止缓存穿透
return new ArrayList<>();
}
@ -219,8 +197,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#dictTypeBo.dictType")
@Override
@Transactional
public List<SysDictDataVo> updateDictType(SysDictTypeBo dictTypeBo)
{
public List<SysDictDataVo> updateDictType(SysDictTypeBo dictTypeBo) {
SysDictType dict = MapstructUtils.convert(dictTypeBo, SysDictType.class);
SysDictTypeVo oldDict = selectDictTypeById(dict.getDictId());
if (!oldDict.getDictType().equals(dict.getDictType())) {
@ -228,8 +205,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
}
boolean updated = this.updateById(dict);
if (updated)
{
if (updated) {
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
return sysDictDataService.selectDictDataByType(dict.getDictType());
}
@ -243,12 +219,10 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 结果
*/
@Override
public boolean checkDictTypeUnique(SysDictTypeBo dictTypeBo)
{
public boolean checkDictTypeUnique(SysDictTypeBo dictTypeBo) {
Long dictId = StringUtils.isNull(dictTypeBo.getDictId()) ? -1L : dictTypeBo.getDictId();
SysDictType dictType = this.getOne(query().where(SYS_DICT_TYPE.DICT_TYPE.eq(dictTypeBo.getDictType())));
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
{
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;

View File

@ -5,7 +5,6 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil;
import com.mybatisflex.core.paginate.Page;
@ -44,8 +43,7 @@ import static com.ruoyi.system.domain.table.SysLogininforTableDef.SYS_LOGININFOR
@RequiredArgsConstructor
@Slf4j
@Service
public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMapper, SysLogininfor> implements ISysLogininforService
{
public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMapper, SysLogininfor> implements ISysLogininforService {
@Override
public QueryWrapper query() {
@ -109,8 +107,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
* @param logininforBo 访问日志对象
*/
@Override
public void insertLogininfor(SysLogininforBo logininforBo)
{
public void insertLogininfor(SysLogininforBo logininforBo) {
SysLogininfor logininfor = MapstructUtils.convert(logininforBo, SysLogininfor.class);
logininfor.setLoginTime(new Date());
this.save(logininfor);
@ -125,23 +122,12 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
private QueryWrapper buildQueryWrapper(SysLogininforBo logininforBo) {
QueryWrapper queryWrapper = QueryWrapper.create()
.select(SYS_LOGININFOR.INFO_ID, SYS_LOGININFOR.USER_NAME, SYS_LOGININFOR.IPADDR, SYS_LOGININFOR.LOGIN_LOCATION, SYS_LOGININFOR.BROWSER, SYS_LOGININFOR.OS, SYS_LOGININFOR.STATUS, SYS_LOGININFOR.MSG, SYS_LOGININFOR.LOGIN_TIME)
.from(SYS_LOGININFOR);
if (StringUtils.isNotEmpty(logininforBo.getIpaddr())) {
queryWrapper.and(SYS_LOGININFOR.IPADDR.like(logininforBo.getIpaddr()));
}
if (StringUtils.isNotEmpty(logininforBo.getStatus())) {
queryWrapper.and(SYS_LOGININFOR.STATUS.eq(logininforBo.getStatus()));
}
if (ObjectUtil.isNotNull(logininforBo.getUserName())) {
queryWrapper.and(SYS_LOGININFOR.USER_NAME.like(logininforBo.getUserName()));
}
Map<String, Object> params = logininforBo.getParams();
if (params.get("beginTime") != null && params.get("endTime") != null) {
queryWrapper.and(SYS_LOGININFOR.LOGIN_TIME.between(params.get("beginTime"), params.get("endTime")));
}
queryWrapper.orderBy(SYS_LOGININFOR.INFO_ID.desc());
.from(SYS_LOGININFOR)
.and(SYS_LOGININFOR.IPADDR.like(logininforBo.getIpaddr()))
.and(SYS_LOGININFOR.STATUS.eq(logininforBo.getStatus()))
.and(SYS_LOGININFOR.USER_NAME.like(logininforBo.getUserName()))
.and(SYS_LOGININFOR.LOGIN_TIME.between(logininforBo.getParams().get("beginTime"), logininforBo.getParams().get("endTime")))
.orderBy(SYS_LOGININFOR.INFO_ID.desc());
return queryWrapper;
}
@ -152,8 +138,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
* @return 登录记录集合
*/
@Override
public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininforBo)
{
public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininforBo) {
QueryWrapper queryWrapper = buildQueryWrapper(logininforBo);
return this.listAs(queryWrapper, SysLogininforVo.class);
}
@ -174,13 +159,13 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
/**
* 批量删除系统登录日志
* delete from sys_logininfor where info_id in
*
* @param infoIds 需要删除的登录日志ID
* @return 结果:true 删除成功false 删除失败
*/
@Override
@Transactional
public boolean deleteLogininforByIds(Long[] infoIds)
{
public boolean deleteLogininforByIds(Long[] infoIds) {
return this.removeByIds(Arrays.asList(infoIds));
}
@ -190,8 +175,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
* 返回结果true 删除成功false 删除失败
*/
@Override
public boolean cleanLogininfor()
{
public boolean cleanLogininfor() {
QueryWrapper queryWrapper = query().from(SYS_LOGININFOR).where(SYS_LOGININFOR.INFO_ID.gt(0));
return this.remove(queryWrapper);
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@ -74,18 +75,11 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
}
private QueryWrapper buildQueryWrapper(SysMenuBo menuBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(menuBo.getMenuName())) {
queryWrapper.and(SYS_MENU.MENU_NAME.like(menuBo.getMenuName()));
}
if (StringUtils.isNotEmpty(menuBo.getVisible())) {
queryWrapper.and(SYS_MENU.VISIBLE.eq(menuBo.getVisible()));
}
if (StringUtils.isNotEmpty(menuBo.getStatus())) {
queryWrapper.and(SYS_MENU.STATUS.eq(menuBo.getStatus()));
}
queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_MENU.MENU_NAME.like(menuBo.getMenuName()))
.and(SYS_MENU.VISIBLE.eq(menuBo.getVisible()))
.and(SYS_MENU.STATUS.eq(menuBo.getStatus()))
.orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc());
return queryWrapper;
}
@ -206,10 +200,10 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
}
private QueryWrapper buildMenuTreeQueryWrapper() {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
queryWrapper.and(SYS_MENU.MENU_TYPE.in(UserConstants.TYPE_DIR, UserConstants.TYPE_MENU));
queryWrapper.and(SYS_MENU.STATUS.eq(UserConstants.MENU_NORMAL));
queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_MENU.MENU_TYPE.in(UserConstants.TYPE_DIR, UserConstants.TYPE_MENU))
.and(SYS_MENU.STATUS.eq(UserConstants.MENU_NORMAL))
.orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc());
return queryWrapper;
}

View File

@ -3,11 +3,9 @@ package com.ruoyi.system.service.impl;
import java.util.Arrays;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
@ -33,6 +31,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
@Resource
private SysNoticeMapper noticeMapper;
@Override
public QueryWrapper query() {
return super.query().from(SYS_NOTICE);
@ -56,18 +55,10 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysNoticeBo noticeBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(noticeBo.getNoticeTitle())) {
queryWrapper.and(SYS_NOTICE.NOTICE_TITLE.like(noticeBo.getNoticeTitle()));
}
if (StringUtils.isNotEmpty(noticeBo.getNoticeType())) {
queryWrapper.and(SYS_NOTICE.NOTICE_TYPE.eq(noticeBo.getNoticeType()));
}
if (ObjectUtil.isNotNull(noticeBo.getCreateBy())) {
queryWrapper.and(SYS_NOTICE.CREATE_BY.like(noticeBo.getCreateBy()));
}
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_NOTICE.NOTICE_TITLE.like(noticeBo.getNoticeTitle()))
.and(SYS_NOTICE.NOTICE_TYPE.eq(noticeBo.getNoticeType()))
.and(SYS_NOTICE.CREATE_BY.like(noticeBo.getCreateBy()));
return queryWrapper;
}

View File

@ -5,12 +5,9 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.ip.AddressUtils;
import com.ruoyi.common.log.event.OperLogEvent;
import com.ruoyi.common.orm.core.page.PageQuery;
@ -34,8 +31,7 @@ import static com.ruoyi.system.domain.table.SysOperLogTableDef.SYS_OPER_LOG;
* @author dataprince数据小王子
*/
@Service
public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService
{
public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService {
@Override
public QueryWrapper query() {
return super.query().from(SYS_OPER_LOG);
@ -61,8 +57,7 @@ public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, Sys
* @param operLogBo 操作日志对象
*/
@Override
public void insertOperlog(SysOperLogBo operLogBo)
{
public void insertOperlog(SysOperLogBo operLogBo) {
SysOperLog operLog = MapstructUtils.convert(operLogBo, SysOperLog.class);
operLog.setOperTime(new Date());
this.save(operLog);
@ -75,36 +70,15 @@ public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, Sys
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysOperLogBo operLogBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(operLogBo.getTitle())) {
queryWrapper.and(SYS_OPER_LOG.TITLE.like(operLogBo.getTitle()));
}
if (ObjectUtil.isNotEmpty(operLogBo.getBusinessType())) {
queryWrapper.and(SYS_OPER_LOG.BUSINESS_TYPE.eq(operLogBo.getBusinessType()));
}
if (ArrayUtil.isNotEmpty(operLogBo.getBusinessTypes())) {
queryWrapper.and(SYS_OPER_LOG.BUSINESS_TYPE.in(Arrays.asList(operLogBo.getBusinessTypes())));
}
if (StringUtils.isNotNull(operLogBo.getStatus())) {
queryWrapper.and(SYS_OPER_LOG.STATUS.eq(operLogBo.getStatus()));
}
if (StringUtils.isNotNull(operLogBo.getOperName())) {
queryWrapper.and(SYS_OPER_LOG.OPER_NAME.eq(operLogBo.getOperName()));
}
if (StringUtils.isNotEmpty(operLogBo.getOperIp())) {
queryWrapper.and(SYS_OPER_LOG.OPER_IP.like(operLogBo.getOperIp()));
}
Map<String, Object> params = operLogBo.getParams();
if (params.get("beginTime") != null && params.get("endTime") != null) {
queryWrapper.and(SYS_OPER_LOG.OPER_TIME.between(params.get("beginTime"), params.get("endTime")));
}
queryWrapper.orderBy(SYS_OPER_LOG.OPER_ID.desc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_OPER_LOG.TITLE.like(operLogBo.getTitle()))
.and(SYS_OPER_LOG.BUSINESS_TYPE.eq(operLogBo.getBusinessType()))
.and(SYS_OPER_LOG.BUSINESS_TYPE.in(Arrays.asList(operLogBo.getBusinessTypes())))
.and(SYS_OPER_LOG.STATUS.eq(operLogBo.getStatus()))
.and(SYS_OPER_LOG.OPER_NAME.eq(operLogBo.getOperName()))
.and(SYS_OPER_LOG.OPER_IP.like(operLogBo.getOperIp()))
.and(SYS_OPER_LOG.OPER_TIME.between(operLogBo.getParams().get("beginTime"), operLogBo.getParams().get("endTime")))
.orderBy(SYS_OPER_LOG.OPER_ID.desc());
return queryWrapper;
}
@ -115,8 +89,7 @@ public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, Sys
* @return 操作日志集合
*/
@Override
public List<SysOperLogVo> selectOperLogList(SysOperLogBo operLogBo)
{
public List<SysOperLogVo> selectOperLogList(SysOperLogBo operLogBo) {
QueryWrapper queryWrapper = buildQueryWrapper(operLogBo);
return this.listAs(queryWrapper, SysOperLogVo.class);
}
@ -137,12 +110,12 @@ public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, Sys
/**
* 批量删除系统操作日志
* delete from sys_oper_log where oper_id in
*
* @param operIds 需要删除的操作日志ID
* @return 结果:true 删除成功false 删除失败
*/
@Override
public boolean deleteOperLogByIds(Long[] operIds)
{
public boolean deleteOperLogByIds(Long[] operIds) {
return this.removeByIds(Arrays.asList(operIds));
}
@ -153,8 +126,7 @@ public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, Sys
* @return 操作日志对象
*/
@Override
public SysOperLogVo selectOperLogById(Long operId)
{
public SysOperLogVo selectOperLogById(Long operId) {
QueryWrapper queryWrapper = query();
queryWrapper.where(SYS_OPER_LOG.OPER_ID.eq(operId));
return this.getOneAs(queryWrapper, SysOperLogVo.class);
@ -165,8 +137,7 @@ public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, Sys
* delete from sys_oper_log where oper_id>0
*/
@Override
public boolean cleanOperLog()
{
public boolean cleanOperLog() {
QueryWrapper queryWrapper = query().from(SYS_OPER_LOG).where(SYS_OPER_LOG.OPER_ID.gt(0));
return this.remove(queryWrapper);
}

View File

@ -78,18 +78,11 @@ public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper,
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysOssConfigBo bo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(bo.getConfigKey())) {
queryWrapper.and(SYS_OSS_CONFIG.CONFIG_KEY.eq(bo.getConfigKey()));
}
if (StringUtils.isNotEmpty(bo.getBucketName())) {
queryWrapper.and(SYS_OSS_CONFIG.BUCKET_NAME.like(bo.getBucketName()));
}
if (ObjectUtil.isNotNull(bo.getStatus())) {
queryWrapper.and(SYS_OSS_CONFIG.STATUS.eq(bo.getStatus()));
}
queryWrapper.orderBy(SYS_OSS_CONFIG.OSS_CONFIG_ID.asc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_OSS_CONFIG.CONFIG_KEY.eq(bo.getConfigKey()))
.and(SYS_OSS_CONFIG.BUCKET_NAME.like(bo.getBucketName()))
.and(SYS_OSS_CONFIG.STATUS.eq(bo.getStatus()))
.orderBy(SYS_OSS_CONFIG.OSS_CONFIG_ID.asc());
return queryWrapper;
}

View File

@ -58,28 +58,14 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
}
private QueryWrapper buildQueryWrapper(SysOssBo bo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(bo.getFileName())) {
queryWrapper.where(SYS_OSS.FILE_NAME.like(bo.getFileName()));
}
if (StringUtils.isNotEmpty(bo.getOriginalName())) {
queryWrapper.and(SYS_OSS.ORIGINAL_NAME.like(bo.getOriginalName()));
}
if (StringUtils.isNotEmpty(bo.getFileSuffix())) {
queryWrapper.and(SYS_OSS.FILE_SUFFIX.eq(bo.getFileSuffix()));
}
if (StringUtils.isNotEmpty(bo.getUrl())) {
queryWrapper.and(SYS_OSS.URL.eq(bo.getUrl()));
}
Map<String, Object> params = bo.getParams();
if (params.get("beginCreateTime") != null && params.get("endCreateTime") != null) {
queryWrapper.and(SYS_OSS.CREATE_TIME.between(params.get("beginCreateTime"), params.get("endCreateTime")));
}
if (StringUtils.isNotEmpty(bo.getService())) {
queryWrapper.and(SYS_OSS.SERVICE.eq(bo.getService()));
}
queryWrapper.orderBy(SYS_OSS.OSS_ID.asc());
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.where(SYS_OSS.FILE_NAME.like(bo.getFileName()))
.and(SYS_OSS.ORIGINAL_NAME.like(bo.getOriginalName()))
.and(SYS_OSS.FILE_SUFFIX.eq(bo.getFileSuffix()))
.and(SYS_OSS.URL.eq(bo.getUrl()))
.and(SYS_OSS.CREATE_TIME.between(bo.getParams().get("beginCreateTime"), bo.getParams().get("endCreateTime")))
.and(SYS_OSS.SERVICE.eq(bo.getService()))
.orderBy(SYS_OSS.OSS_ID.asc());
return queryWrapper;
}
@ -127,7 +113,6 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
}
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
@Override
public SysOssVo getById(Long ossId) {

View File

@ -33,8 +33,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* @author dataprince数据小王子
*/
@Service
public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost> implements ISysPostService
{
public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost> implements ISysPostService {
@Resource
private ISysUserPostService userPostService;
@ -45,22 +44,15 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
/**
* 根据postBo构建QueryWrapper查询条件
*
* @param postBo
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysPostBo postBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotEmpty(postBo.getPostCode())) {
queryWrapper.and(SYS_POST.POST_CODE.like(postBo.getPostCode()));
}
if (StringUtils.isNotEmpty(postBo.getStatus())) {
queryWrapper.and(SYS_POST.STATUS.eq(postBo.getStatus()));
}
if (StringUtils.isNotEmpty(postBo.getPostName())) {
queryWrapper.and(SYS_POST.POST_NAME.like(postBo.getPostName()));
}
QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_POST.POST_CODE.like(postBo.getPostCode()))
.and(SYS_POST.STATUS.eq(postBo.getStatus()))
.and(SYS_POST.POST_NAME.like(postBo.getPostName()));
return queryWrapper;
}
@ -71,8 +63,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 岗位信息集合
*/
@Override
public List<SysPostVo> selectPostList(SysPostBo postBo)
{
public List<SysPostVo> selectPostList(SysPostBo postBo) {
QueryWrapper queryWrapper = buildQueryWrapper(postBo);
return this.listAs(queryWrapper, SysPostVo.class);
}
@ -96,8 +87,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 岗位列表
*/
@Override
public List<SysPostVo> selectPostAll()
{
public List<SysPostVo> selectPostAll() {
return this.listAs(query(), SysPostVo.class);
}
@ -108,8 +98,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 角色对象信息
*/
@Override
public SysPostVo selectPostById(Long postId)
{
public SysPostVo selectPostById(Long postId) {
return this.getOneAs(query().where(SYS_POST.POST_ID.eq(postId)), SysPostVo.class);
}
@ -120,8 +109,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 选中岗位ID列表
*/
@Override
public List<Long> selectPostListByUserId(Long userId)
{
public List<Long> selectPostListByUserId(Long userId) {
/*select p.post_id
from sys_post p
left join sys_user_post up on up.post_id = p.post_id
@ -164,12 +152,10 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 结果
*/
@Override
public boolean checkPostNameUnique(SysPostBo post)
{
public boolean checkPostNameUnique(SysPostBo post) {
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = this.getOne(query().where(SYS_POST.POST_NAME.eq(post.getPostName())));
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@ -182,12 +168,10 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 结果
*/
@Override
public boolean checkPostCodeUnique(SysPostBo post)
{
public boolean checkPostCodeUnique(SysPostBo post) {
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = this.getOne(query().where(SYS_POST.POST_CODE.eq(post.getPostCode())));
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@ -212,8 +196,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 结果:true 删除成功false 删除失败
*/
@Override
public boolean deletePostById(Long postId)
{
public boolean deletePostById(Long postId) {
return this.removeById(postId);
}
@ -225,13 +208,10 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
*/
@Override
@Transactional
public boolean deletePostByIds(Long[] postIds)
{
for (Long postId : postIds)
{
public boolean deletePostByIds(Long[] postIds) {
for (Long postId : postIds) {
SysPostVo post = selectPostById(postId);
if (userPostService.countUserPostById(postId) > 0)
{
if (userPostService.countUserPostById(postId) > 0) {
throw new ServiceException(String.format("%1$s已分配不能删除", post.getPostName()));
}
}
@ -245,8 +225,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return true 操作成功false 操作失败
*/
@Override
public boolean insertPost(SysPostBo postBo)
{
public boolean insertPost(SysPostBo postBo) {
SysPost sysPost = MapstructUtils.convert(postBo, SysPost.class);
return this.save(sysPost);
}
@ -258,8 +237,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
* @return 结果:true 更新成功false 更新失败
*/
@Override
public boolean updatePost(SysPostBo postBo)
{
public boolean updatePost(SysPostBo postBo) {
SysPost sysPost = MapstructUtils.convert(postBo, SysPost.class);
return this.updateById(sysPost);
}

View File

@ -74,28 +74,13 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.from(SYS_ROLE.as("r"))
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0));
if (ObjectUtil.isNotNull(roleBo.getRoleId())) {
queryWrapper.and(SYS_ROLE.ROLE_ID.eq(roleBo.getRoleId()));
}
if (StringUtils.isNotEmpty(roleBo.getRoleName())) {
queryWrapper.and(SYS_ROLE.ROLE_NAME.like(roleBo.getRoleName()));
}
if (StringUtils.isNotEmpty(roleBo.getStatus())) {
queryWrapper.and(SYS_ROLE.STATUS.eq(roleBo.getStatus()));
}
if (StringUtils.isNotEmpty(roleBo.getRoleKey())) {
queryWrapper.and(SYS_ROLE.ROLE_KEY.like(roleBo.getRoleKey()));
}
Map<String, Object> params = roleBo.getParams();
if (params.get("beginTime") != null && params.get("endTime") != null) {
queryWrapper.and(SYS_ROLE.CREATE_TIME.between(params.get("beginTime"), params.get("endTime")));
}
queryWrapper.orderBy(SYS_ROLE.ROLE_SORT.asc());
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.and(SYS_ROLE.ROLE_ID.eq(roleBo.getRoleId()))
.and(SYS_ROLE.ROLE_NAME.like(roleBo.getRoleName()))
.and(SYS_ROLE.STATUS.eq(roleBo.getStatus()))
.and(SYS_ROLE.ROLE_KEY.like(roleBo.getRoleKey()))
.and(SYS_ROLE.CREATE_TIME.between(roleBo.getParams().get("beginTime"), roleBo.getParams().get("endTime")))
.orderBy(SYS_ROLE.ROLE_SORT.asc());
return queryWrapper;
}
@ -143,9 +128,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.from(SYS_ROLE.as("r"))
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0))
.and(SYS_USER_ROLE.USER_ID.eq(userId));
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.where(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> userRoles = this.listAs(queryWrapper, SysRoleVo.class);
List<SysRoleVo> roles = selectRoleAll();
@ -203,9 +187,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.from(SYS_ROLE.as("r"))
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0))
.and(SYS_USER_ROLE.USER_ID.eq(userId));
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.where(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> perms = this.listAs(queryWrapper, SysRoleVo.class);
//List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
Set<String> permsSet = new HashSet<>();
@ -270,8 +253,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
@Override
public boolean checkRoleNameUnique(SysRoleBo roleBo) {
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_NAME.eq(roleBo.getRoleName()))
.and(SYS_ROLE.DEL_FLAG.eq(0));
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_NAME.eq(roleBo.getRoleName()));
SysRole info = this.getOne(queryWrapper);
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
@ -288,8 +270,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
@Override
public boolean checkRoleKeyUnique(SysRoleBo roleBo) {
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_KEY.eq(roleBo.getRoleKey()))
.and(SYS_ROLE.DEL_FLAG.eq(0));
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_KEY.eq(roleBo.getRoleKey()));
SysRole info = this.getOne(queryWrapper);
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;