From 64fea077c2688fd6334214bace556d41c458683e Mon Sep 17 00:00:00 2001 From: dataprince Date: Sun, 24 Dec 2023 21:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E4=BA=8EQueryWrapper=E7=9A=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E9=87=8D=E5=A4=8D=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/RuoYiApplication.java | 1 - .../src/main/resources/application-dev.yml | 4 +- .../main/resources/application-dev.properties | 1 + .../mf/service/impl/CustomerServiceImpl.java | 59 ++++++-------- .../mf/service/impl/MfProductServiceImpl.java | 39 +++------- .../mf/service/impl/MfStudentServiceImpl.java | 33 +++----- .../generator/controller/GenController.java | 1 + .../service/GenTableServiceImpl.java | 11 ++- .../src/main/resources/vm/java/domain.java.vm | 10 ++- .../resources/vm/java/serviceImpl.java.vm | 37 ++++----- .../service/impl/SysConfigServiceImpl.java | 34 +++----- .../service/impl/SysDeptServiceImpl.java | 54 +++++-------- .../service/impl/SysDictDataServiceImpl.java | 55 +++++-------- .../service/impl/SysDictTypeServiceImpl.java | 78 +++++++------------ .../impl/SysLogininforServiceImpl.java | 46 ++++------- .../service/impl/SysMenuServiceImpl.java | 52 ++++++------- .../service/impl/SysNoticeServiceImpl.java | 21 ++--- .../service/impl/SysOperLogServiceImpl.java | 61 ++++----------- .../service/impl/SysOssConfigServiceImpl.java | 21 ++--- .../service/impl/SysOssServiceImpl.java | 37 +++------ .../service/impl/SysPostServiceImpl.java | 76 +++++++----------- .../service/impl/SysRoleServiceImpl.java | 47 ++++------- 22 files changed, 273 insertions(+), 505 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index b69b609..c522d26 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -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" + diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 36f0179..98296a0 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -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 端口 随着主应用端口飘逸 避免集群冲突 diff --git a/ruoyi-extra/ruoyi-powerjob-server/src/main/resources/application-dev.properties b/ruoyi-extra/ruoyi-powerjob-server/src/main/resources/application-dev.properties index 8f64ffd..a8fa651 100644 --- a/ruoyi-extra/ruoyi-powerjob-server/src/main/resources/application-dev.properties +++ b/ruoyi-extra/ruoyi-powerjob-server/src/main/resources/application-dev.properties @@ -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 diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java index b75da58..ecce1a8 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/CustomerServiceImpl.java @@ -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 implements ICustomerService -{ +public class CustomerServiceImpl extends BaseServiceImpl implements ICustomerService { @Resource private CustomerMapper customerMapper; @Resource @@ -48,17 +51,9 @@ public class CustomerServiceImpl extends BaseServiceImpl selectList(CustomerBo customerBo) - { + public List selectList(CustomerBo customerBo) { QueryWrapper queryWrapper = buildQueryWrapper(customerBo); return customerMapper.selectListWithRelationsByQueryAs(queryWrapper, CustomerVo.class); } @@ -95,8 +88,7 @@ public class CustomerServiceImpl extends BaseServiceImpl selectPage(CustomerBo customerBo) - { + public TableDataInfo selectPage(CustomerBo customerBo) { QueryWrapper queryWrapper = buildQueryWrapper(customerBo); Page page = customerMapper.paginateWithRelationsAs(PageQuery.build(), queryWrapper, CustomerVo.class); return TableDataInfo.build(page); @@ -110,8 +102,7 @@ public class CustomerServiceImpl extends BaseServiceImpl goodsList = customer.getGoodsList(); Long customerId = customer.getCustomerId(); - if (StringUtils.isNotNull(goodsList)) - { + if (StringUtils.isNotNull(goodsList)) { List list = new ArrayList<>(); - for (Goods goods : goodsList) - { + for (Goods goods : goodsList) { goods.setCustomerId(customerId); list.add(goods); } - if (list.size() > 0) - { - return goodsMapper.insertBatch(list)>0; + if (list.size() > 0) { + return goodsMapper.insertBatch(list) > 0; } } return true; diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java index 98eb8cd..1595583 100644 --- a/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java +++ b/ruoyi-modules/ruoyi-demo/src/main/java/com/ruoyi/mf/service/impl/MfProductServiceImpl.java @@ -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 implements IMfProductService -{ +public class MfProductServiceImpl extends BaseServiceImpl implements IMfProductService { @Resource private MfProductMapper mfProductMapper; @@ -42,17 +36,9 @@ public class MfProductServiceImpl extends BaseServiceImpl selectList(MfProductBo mfProductBo) - { + public List selectList(MfProductBo mfProductBo) { QueryWrapper queryWrapper = buildQueryWrapper(mfProductBo); return this.listAs(queryWrapper, MfProductVo.class); } @@ -89,8 +73,7 @@ public class MfProductServiceImpl extends BaseServiceImpl implements IMfStudentService -{ +public class MfStudentServiceImpl extends BaseServiceImpl implements IMfStudentService { @Resource private MfStudentMapper mfStudentMapper; @@ -40,14 +39,8 @@ public class MfStudentServiceImpl extends BaseServiceImpl selectList(MfStudentBo mfStudentBo) - { + public List selectList(MfStudentBo mfStudentBo) { QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); return this.listAs(queryWrapper, MfStudentVo.class); } @@ -84,8 +75,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl selectPage(MfStudentBo mfStudentBo) - { + public TableDataInfo selectPage(MfStudentBo mfStudentBo) { QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); Page page = this.pageAs(PageQuery.build(), queryWrapper, MfStudentVo.class); return TableDataInfo.build(page); @@ -98,8 +88,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl tables = genTableService.selectGenTableAll(); List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); + //table.setColumns(list); Map map = new HashMap<>(); map.put("info", table); map.put("rows", list); diff --git a/ruoyi-modules/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-modules/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java index 038b89e..917c861 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java +++ b/ruoyi-modules/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java @@ -54,10 +54,12 @@ public class GenTableServiceImpl extends BaseServiceImpl dataMap = new LinkedHashMap<>(); // 查询表信息 GenTable table = selectGenTableById(tableId); + List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); + table.setColumns(list); + //设置生成的sys_menu6条记录的主键值 setMenuIds(table); // 设置主子表信息 @@ -287,6 +292,8 @@ public class GenTableServiceImpl extends BaseServiceImpl list = genTableColumnService.selectGenTableColumnListByTableId(table.getTableId()); + table.setColumns(list); // 设置主子表信息 setSubTable(table); //设置生成的sys_menu6条记录的主键值 @@ -402,6 +409,8 @@ public class GenTableServiceImpl extends BaseServiceImpl list = genTableColumnService.selectGenTableColumnListByTableId(table.getTableId()); + table.setColumns(list); // 设置主子表信息 setSubTable(table); //设置生成的sys_menu6条记录的主键值 diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm index cdb3a2e..4c52ee7 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/domain.java.vm @@ -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,16 +33,19 @@ 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 */ #if($column.javaField=='delFlag') -@Column(isLogicDelete = true) + @Column(isLogicDelete = true) #end #if($column.javaField=='version') -@Column(version = true) + @Column(version = true) #end -#if($column.isPk==1) +#if($column.isPk=='1') @Id #end private $column.javaType $column.javaField; diff --git a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm index 73c8b3a..b76a28b 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/ruoyi-modules/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -57,32 +57,21 @@ 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) - #set($javaField=$column.javaField) - #set($javaType=$column.javaType) - #set($columnName=$column.columnName) - #set($capitalColumnName=$column.columnName.toUpperCase()) - #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 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"))); - } - #end +#if($column.query) + #set($queryType=$column.queryType) + #set($javaField=$column.javaField) + #set($javaType=$column.javaType) + #set($columnName=$column.columnName) + #set($capitalColumnName=$column.columnName.toUpperCase()) + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set($mpMethod=$column.queryType.toLowerCase()) + #if($queryType != 'BETWEEN') + queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.get$AttrName())); + #else + queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.getParams().get("begin$AttrName"), ${className}Bo.getParams().get("end$AttrName"))); #end +#end #end return queryWrapper; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index f7d8f5a..0d8c172 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -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; @@ -52,7 +51,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl selectConfigList(SysConfigBo config) { QueryWrapper queryWrapper = buildQueryWrapper(config); - return this.listAs(queryWrapper,SysConfigVo.class); + return this.listAs(queryWrapper, SysConfigVo.class); } /** @@ -136,7 +122,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl selectConfigPage(SysConfigBo config) { QueryWrapper queryWrapper = buildQueryWrapper(config); - Page page = this.pageAs(PageQuery.build(), queryWrapper,SysConfigVo.class); + Page page = this.pageAs(PageQuery.build(), queryWrapper, SysConfigVo.class); return TableDataInfo.build(page); } @@ -176,7 +162,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl * @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; } @@ -155,10 +145,10 @@ public class SysDeptServiceImpl extends BaseServiceImpl .leftJoin(SYS_ROLE_DEPT).as("rd").on(SYS_ROLE_DEPT.DEPT_ID.eq(SYS_DEPT.DEPT_ID)) .where(SYS_ROLE_DEPT.ROLE_ID.eq(roleId)); //部门树选择项是否关联显示 - if(ObjectUtil.isNotNull(role.getDeptCheckStrictly()) && role.getDeptCheckStrictly().equals(true)) { + if (ObjectUtil.isNotNull(role.getDeptCheckStrictly()) && role.getDeptCheckStrictly().equals(true)) { queryWrapper.and(SYS_DEPT.DEPT_ID.notIn(select(SYS_DEPT.PARENT_ID).from(SYS_DEPT).innerJoin(SYS_ROLE_DEPT).on(SYS_ROLE_DEPT.DEPT_ID.eq(SYS_DEPT.DEPT_ID).and(SYS_ROLE_DEPT.ROLE_ID.eq(roleId))))); } - queryWrapper.orderBy(SYS_DEPT.PARENT_ID.asc(),SYS_DEPT.ORDER_NUM.asc()); + queryWrapper.orderBy(SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc()); return this.listAs(queryWrapper, Long.class); @@ -173,31 +163,32 @@ public class SysDeptServiceImpl extends BaseServiceImpl @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")); - return this.getOneAs(queryWrapper,SysDeptVo.class); + QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0")); + return this.getOneAs(queryWrapper, SysDeptVo.class); } /** @@ -212,10 +203,9 @@ public class SysDeptServiceImpl extends BaseServiceImpl .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)); + .and(QueryMethods.findInSet(QueryMethods.number(deptId), SYS_DEPT.ANCESTORS).gt(0)); - return deptMapper.selectObjectByQueryAs(queryWrapper,Integer.class); + return deptMapper.selectObjectByQueryAs(queryWrapper, Integer.class); } /** @@ -229,10 +219,9 @@ public class SysDeptServiceImpl extends BaseServiceImpl 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); + int result = deptMapper.selectObjectByQueryAs(queryWrapper, Integer.class); return result > 0; } @@ -247,8 +236,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl 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); @@ -354,7 +342,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl //select * from sys_dept where find_in_set(#{deptId}, ancestors) QueryWrapper queryWrapper = QueryWrapper.create() .from(SYS_DEPT) - .where(QueryMethods.findInSet(QueryMethods.number(deptId),SYS_DEPT.ANCESTORS).gt(0)); + .where(QueryMethods.findInSet(QueryMethods.number(deptId), SYS_DEPT.ANCESTORS).gt(0)); List children = this.listAs(queryWrapper, SysDeptVo.class); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java index e1255c6..00e8224 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -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 implements ISysDictDataService -{ +public class SysDictDataServiceImpl extends BaseServiceImpl implements ISysDictDataService { @Resource private SysDictDataMapper dictDataMapper; @@ -48,19 +46,15 @@ public class SysDictDataServiceImpl extends BaseServiceImpl selectDictDataList(SysDictDataBo dictDataBo) - { + public List selectDictDataList(SysDictDataBo dictDataBo) { QueryWrapper queryWrapper = buildQueryWrapper(dictDataBo); return this.listAs(queryWrapper, SysDictDataVo.class); } @@ -93,20 +86,19 @@ public class SysDictDataServiceImpl extends BaseServiceImpl selectDictDataByType(String dictType){ - QueryWrapper queryWrapper=query().and(SYS_DICT_DATA.DICT_TYPE.eq(dictType)).orderBy(SYS_DICT_DATA.DICT_SORT.asc()); + public List selectDictDataByType(String dictType) { + QueryWrapper queryWrapper = query().and(SYS_DICT_DATA.DICT_TYPE.eq(dictType)).orderBy(SYS_DICT_DATA.DICT_SORT.asc()); return this.listAs(queryWrapper, SysDictDataVo.class); } @@ -159,10 +150,8 @@ public class SysDictDataServiceImpl extends BaseServiceImpl implements ISysDictTypeService, DictService -{ +public class SysDictTypeServiceImpl extends BaseServiceImpl implements ISysDictTypeService, DictService { @Resource private ISysDictDataService sysDictDataService; @@ -57,25 +56,16 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl selectDictTypeList(SysDictTypeBo dictTypeBo) - { + public List selectDictTypeList(SysDictTypeBo dictTypeBo) { QueryWrapper queryWrapper = buildQueryWrapper(dictTypeBo); return this.listAs(queryWrapper, SysDictTypeVo.class); @@ -112,8 +101,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl selectDictTypeAll() - { + public List selectDictTypeAll() { return this.listAs(query(), SysDictTypeVo.class); } @@ -125,11 +113,9 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl selectDictDataByType(String dictType) - { + public List selectDictDataByType(String dictType) { List lists = sysDictDataService.selectDictDataByType(dictType); - if (StringUtils.isNotEmpty(lists)) - { + if (StringUtils.isNotEmpty(lists)) { return lists; } return null; @@ -142,9 +128,8 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl 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 insertDictType(SysDictTypeBo sysDictTypeBo) - { + public List 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 updateDictType(SysDictTypeBo dictTypeBo) - { + public List 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 implements ISysLogininforService -{ +public class SysLogininforServiceImpl extends BaseServiceImpl implements ISysLogininforService { @Override public QueryWrapper query() { @@ -109,8 +107,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl 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()); - + .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) + .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 selectLogininforList(SysLogininforBo logininforBo) - { + public List selectLogininforList(SysLogininforBo logininforBo) { QueryWrapper queryWrapper = buildQueryWrapper(logininforBo); return this.listAs(queryWrapper, SysLogininforVo.class); } @@ -174,24 +159,23 @@ public class SysLogininforServiceImpl extends BaseServiceImpl0 - * 返回结果:true 删除成功,false 删除失败 + * delete from sys_logininfor where info_id>0 + * 返回结果: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); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index 8d396d3..5cc672a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -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; @@ -47,7 +48,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER; * @author dataprince数据小王子 */ @Service -public class SysMenuServiceImpl extends BaseServiceImpl implements ISysMenuService { +public class SysMenuServiceImpl extends BaseServiceImpl implements ISysMenuService { @Resource private SysMenuMapper menuMapper; @@ -73,19 +74,12 @@ public class SysMenuServiceImpl extends BaseServiceImpl i return selectMenuList(new SysMenuBo(), userId); } - 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()); - + private QueryWrapper buildQueryWrapper(SysMenuBo menuBo) { + 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; } @@ -119,7 +113,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl i order by m.parent_id, m.order_num*/ queryWrapper = queryWrapper - .select(QueryMethods.distinct(SYS_MENU.MENU_ID,SYS_MENU.PARENT_ID,SYS_MENU.MENU_NAME,SYS_MENU.PATH,SYS_MENU.COMPONENT,SYS_MENU.QUERY_PARAM,SYS_MENU.VISIBLE,SYS_MENU.STATUS,SYS_MENU.PERMS,SYS_MENU.IS_FRAME,SYS_MENU.IS_CACHE,SYS_MENU.MENU_TYPE,SYS_MENU.ICON,SYS_MENU.ORDER_NUM,SYS_MENU.CREATE_TIME)) + .select(QueryMethods.distinct(SYS_MENU.MENU_ID, SYS_MENU.PARENT_ID, SYS_MENU.MENU_NAME, SYS_MENU.PATH, SYS_MENU.COMPONENT, SYS_MENU.QUERY_PARAM, SYS_MENU.VISIBLE, SYS_MENU.STATUS, SYS_MENU.PERMS, SYS_MENU.IS_FRAME, SYS_MENU.IS_CACHE, SYS_MENU.MENU_TYPE, SYS_MENU.ICON, SYS_MENU.ORDER_NUM, SYS_MENU.CREATE_TIME)) .from(SYS_MENU) .leftJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID)) .leftJoin(SYS_USER_ROLE).on(SYS_ROLE_MENU.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID)) @@ -134,7 +128,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl i 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.orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc()); } List menuList = this.listAs(queryWrapper, SysMenuVo.class); return menuList; @@ -205,11 +199,11 @@ public class SysMenuServiceImpl extends BaseServiceImpl i return permsSet; } - 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()); + private QueryWrapper buildMenuTreeQueryWrapper() { + 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; } @@ -234,7 +228,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl i where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0 order by m.parent_id, m.order_num*/ queryWrapper = queryWrapper - .select(QueryMethods.distinct(SYS_MENU.MENU_ID,SYS_MENU.PARENT_ID,SYS_MENU.MENU_NAME,SYS_MENU.PATH,SYS_MENU.COMPONENT,SYS_MENU.QUERY_PARAM,SYS_MENU.VISIBLE,SYS_MENU.STATUS,SYS_MENU.PERMS,SYS_MENU.IS_FRAME,SYS_MENU.IS_CACHE,SYS_MENU.MENU_TYPE,SYS_MENU.ICON,SYS_MENU.ORDER_NUM,SYS_MENU.CREATE_TIME)) + .select(QueryMethods.distinct(SYS_MENU.MENU_ID, SYS_MENU.PARENT_ID, SYS_MENU.MENU_NAME, SYS_MENU.PATH, SYS_MENU.COMPONENT, SYS_MENU.QUERY_PARAM, SYS_MENU.VISIBLE, SYS_MENU.STATUS, SYS_MENU.PERMS, SYS_MENU.IS_FRAME, SYS_MENU.IS_CACHE, SYS_MENU.MENU_TYPE, SYS_MENU.ICON, SYS_MENU.ORDER_NUM, SYS_MENU.CREATE_TIME)) .from(SYS_MENU) .leftJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID)) .leftJoin(SYS_USER_ROLE).on(SYS_ROLE_MENU.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID)) @@ -244,9 +238,9 @@ public class SysMenuServiceImpl extends BaseServiceImpl i .and(SYS_MENU.MENU_TYPE.in("M", "C")) .and(SYS_MENU.STATUS.eq("0")) .and(SYS_ROLE.STATUS.eq("0")) - .orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc()); + .orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc()); } - List menus= this.list(queryWrapper); + List menus = this.list(queryWrapper); return getChildPerms(menus, 0); } @@ -273,10 +267,10 @@ public class SysMenuServiceImpl extends BaseServiceImpl i .from(SYS_MENU) .leftJoin(SYS_ROLE_MENU).on(SYS_ROLE_MENU.MENU_ID.eq(SYS_MENU.MENU_ID)) .where(SYS_ROLE_MENU.ROLE_ID.eq(roleId)); - if(role.getMenuCheckStrictly()){ + if (role.getMenuCheckStrictly()) { queryWrapper.and(SYS_MENU.MENU_ID.notIn(select(SYS_MENU.PARENT_ID).from(SYS_MENU).innerJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID)).and(SYS_ROLE_MENU.ROLE_ID.eq(roleId)))); } - queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc()); + queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc()); return this.listAs(queryWrapper, Long.class); } @@ -428,7 +422,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl i public boolean checkMenuNameUnique(SysMenuBo menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); QueryWrapper queryWrapper = query().where(SYS_MENU.MENU_NAME.eq(menu.getMenuName())) - .and(SYS_MENU.PARENT_ID.eq(menu.getParentId())); + .and(SYS_MENU.PARENT_ID.eq(menu.getParentId())); SysMenu info = this.getOne(queryWrapper); if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.NOT_UNIQUE; @@ -564,7 +558,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl i * @return 替换后的内链域名 */ public String innerLinkReplaceEach(String path) { - return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" }, - new String[] { "", "", "", "/", "/" }); + return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"}, + new String[]{"", "", "", "/", "/"}); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java index ebf93e9..d61b583 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -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 implements ISysOperLogService -{ +public class SysOperLogServiceImpl extends BaseServiceImpl implements ISysOperLogService { @Override public QueryWrapper query() { return super.query().from(SYS_OPER_LOG); @@ -61,8 +57,7 @@ public class SysOperLogServiceImpl extends BaseServiceImpl 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 selectOperLogList(SysOperLogBo operLogBo) - { + public List selectOperLogList(SysOperLogBo operLogBo) { QueryWrapper queryWrapper = buildQueryWrapper(operLogBo); return this.listAs(queryWrapper, SysOperLogVo.class); } @@ -137,12 +110,12 @@ public class SysOperLogServiceImpl extends BaseServiceImpl0 */ @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); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java index 7d9ee8c..5322edc 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssConfigServiceImpl.java @@ -41,7 +41,7 @@ import static com.ruoyi.system.domain.table.SysOssConfigTableDef.SYS_OSS_CONFIG; @Slf4j @RequiredArgsConstructor @Service -public class SysOssConfigServiceImpl extends BaseServiceImpl implements ISysOssConfigService { +public class SysOssConfigServiceImpl extends BaseServiceImpl implements ISysOssConfigService { private final SysOssConfigMapper baseMapper; @@ -78,18 +78,11 @@ public class SysOssConfigServiceImpl extends BaseServiceImpl 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 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,12 +113,11 @@ public class SysOssServiceImpl extends BaseServiceImpl imp } - @Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId") @Override public SysOssVo getById(Long ossId) { - QueryWrapper queryWrapper=query().where(SYS_OSS.OSS_ID.eq(ossId)); - return ossMapper.selectOneWithRelationsByQueryAs(queryWrapper,SysOssVo.class); + QueryWrapper queryWrapper = query().where(SYS_OSS.OSS_ID.eq(ossId)); + return ossMapper.selectOneWithRelationsByQueryAs(queryWrapper, SysOssVo.class); } @Override @@ -144,7 +129,7 @@ public class SysOssServiceImpl extends BaseServiceImpl imp FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName()); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8"); OssClient storage = OssFactory.instance(sysOss.getService()); - try(InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) { + try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) { int available = inputStream.available(); IoUtil.copy(inputStream, response.getOutputStream(), available); response.setContentLength(available); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 4bf92d7..fef4ebe 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -33,8 +33,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER; * @author dataprince数据小王子 */ @Service -public class SysPostServiceImpl extends BaseServiceImpl implements ISysPostService -{ +public class SysPostServiceImpl extends BaseServiceImpl implements ISysPostService { @Resource private ISysUserPostService userPostService; @@ -45,22 +44,15 @@ public class SysPostServiceImpl extends BaseServiceImpl /** * 根据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 * @return 岗位信息集合 */ @Override - public List selectPostList(SysPostBo postBo) - { + public List selectPostList(SysPostBo postBo) { QueryWrapper queryWrapper = buildQueryWrapper(postBo); return this.listAs(queryWrapper, SysPostVo.class); } @@ -96,8 +87,7 @@ public class SysPostServiceImpl extends BaseServiceImpl * @return 岗位列表 */ @Override - public List selectPostAll() - { + public List selectPostAll() { return this.listAs(query(), SysPostVo.class); } @@ -108,8 +98,7 @@ public class SysPostServiceImpl extends BaseServiceImpl * @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 * @return 选中岗位ID列表 */ @Override - public List selectPostListByUserId(Long userId) - { + public List selectPostListByUserId(Long userId) { /*select p.post_id from sys_post p left join sys_user_post up on up.post_id = p.post_id @@ -133,7 +121,7 @@ public class SysPostServiceImpl extends BaseServiceImpl .leftJoin(SYS_USER_POST).as("up").on(SYS_USER_POST.POST_ID.eq(SYS_POST.POST_ID)) .leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_POST.USER_ID)) .where(SYS_USER.USER_ID.eq(userId)); - return this.listAs(queryWrapper,Long.class); + return this.listAs(queryWrapper, Long.class); } /** @@ -149,12 +137,12 @@ public class SysPostServiceImpl extends BaseServiceImpl left join sys_user_post up on up.post_id = p.post_id left join sys_user u on u.user_id = up.user_id where u.user_name = #{userName}*/ - QueryWrapper queryWrapper = QueryWrapper.create().select(SYS_POST.POST_ID,SYS_POST.POST_NAME,SYS_POST.POST_CODE) - .from(SYS_POST).as("p") - .leftJoin(SYS_USER_POST).as("up").on(SYS_USER_POST.POST_ID.eq(SYS_POST.POST_ID)) - .leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_POST.USER_ID)) - .where(SYS_USER.USER_NAME.eq(userName)); - return this.listAs(queryWrapper,SysPostVo.class); + QueryWrapper queryWrapper = QueryWrapper.create().select(SYS_POST.POST_ID, SYS_POST.POST_NAME, SYS_POST.POST_CODE) + .from(SYS_POST).as("p") + .leftJoin(SYS_USER_POST).as("up").on(SYS_USER_POST.POST_ID.eq(SYS_POST.POST_ID)) + .leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_POST.USER_ID)) + .where(SYS_USER.USER_NAME.eq(userName)); + return this.listAs(queryWrapper, SysPostVo.class); } /** @@ -164,12 +152,10 @@ public class SysPostServiceImpl extends BaseServiceImpl * @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 * @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 * @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 */ @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 * @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 * @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); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 929bec4..203227f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -40,7 +40,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER; * 角色 业务层处理 * * @author ruoyi - * @author dataprince数据小王子 + * @author dataprince数据小王子 */ @Service public class SysRoleServiceImpl extends BaseServiceImpl implements ISysRoleService { @@ -74,28 +74,13 @@ public class SysRoleServiceImpl extends BaseServiceImpl .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 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 .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 userRoles = this.listAs(queryWrapper, SysRoleVo.class); List roles = selectRoleAll(); @@ -203,9 +187,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl .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 perms = this.listAs(queryWrapper, SysRoleVo.class); //List perms = roleMapper.selectRolePermissionByUserId(userId); Set permsSet = new HashSet<>(); @@ -270,8 +253,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl @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 @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;