简化代码,对于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,10 +120,9 @@ 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())) {
if (ObjectUtil.isNotNull(customer) && ObjectUtil.isNotNull(customer.getCustomerId())) {
boolean updated = this.updateById(customer);
if (updated) {
QueryWrapper queryWrapper = QueryWrapper.create().from(GOODS).where(GOODS.CUSTOMER_ID.eq(customer.getCustomerId()));
@ -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,21 +152,17 @@ 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)
{
return goodsMapper.insertBatch(list)>0;
if (list.size() > 0) {
return goodsMapper.insertBatch(list) > 0;
}
}
return true;

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,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;

View File

@ -57,9 +57,8 @@ 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)
#if($column.query)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
@ -68,21 +67,11 @@ 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")));
}
#end
queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.getParams().get("begin$AttrName"), ${className}Bo.getParams().get("end$AttrName")));
#end
#end
#end
return queryWrapper;

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;
@ -52,7 +51,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
*/
@Override
public SysConfigVo selectConfigById(Long configId) {
return this.getOneAs(query().where(SYS_CONFIG.CONFIG_ID.eq(configId)),SysConfigVo.class);
return this.getOneAs(query().where(SYS_CONFIG.CONFIG_ID.eq(configId)), SysConfigVo.class);
}
/**
@ -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;
}
@ -124,7 +110,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
public List<SysConfigVo> 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<SysConfigMapper, SysCo
@Override
public TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config) {
QueryWrapper queryWrapper = buildQueryWrapper(config);
Page<SysConfigVo> page = this.pageAs(PageQuery.build(), queryWrapper,SysConfigVo.class);
Page<SysConfigVo> page = this.pageAs(PageQuery.build(), queryWrapper, SysConfigVo.class);
return TableDataInfo.build(page);
}
@ -176,7 +162,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
@Override
public boolean updateConfigByKey(SysConfigBo configBo) {
SysConfig config = MapstructUtils.convert(configBo, SysConfig.class);
QueryWrapper queryWrapper=query().where(SYS_CONFIG.CONFIG_KEY.eq(config.getConfigKey()));
QueryWrapper queryWrapper = query().where(SYS_CONFIG.CONFIG_KEY.eq(config.getConfigKey()));
SysConfig sysConfig = this.getOne(queryWrapper);
SysConfig configUpdate = new SysConfig();

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;
}
@ -155,10 +145,10 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
.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<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"));
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<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));
.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<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);
int result = deptMapper.selectObjectByQueryAs(queryWrapper, Integer.class);
return result > 0;
}
@ -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);
@ -354,7 +342,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
//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<SysDeptVo> children = this.listAs(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,15 +91,14 @@ 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)
.where(SYS_DICT_DATA.DICT_TYPE.eq(dictType))
.and(SYS_DICT_DATA.DICT_VALUE.eq(dictValue));
return dictDataMapper.selectObjectByQueryAs(queryWrapper,String.class);
return dictDataMapper.selectObjectByQueryAs(queryWrapper, String.class);
}
/**
@ -116,9 +108,8 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
* @return 字典数据
*/
@Override
public SysDictDataVo selectDictDataById(Long dictCode)
{
return this.getOneAs(query().where(SYS_DICT_DATA.DICT_CODE.eq(dictCode)),SysDictDataVo.class);
public SysDictDataVo selectDictDataById(Long dictCode) {
return this.getOneAs(query().where(SYS_DICT_DATA.DICT_CODE.eq(dictCode)), SysDictDataVo.class);
}
@ -135,7 +126,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
.from(SYS_DICT_DATA)
.where(SYS_DICT_DATA.DICT_TYPE.eq(dictType));
return dictDataMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
return dictDataMapper.selectObjectByQueryAs(queryWrapper, Integer.class);
}
/**
@ -146,8 +137,8 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
*/
@Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
@Override
public List<SysDictDataVo> selectDictDataByType(String dictType){
QueryWrapper queryWrapper=query().and(SYS_DICT_DATA.DICT_TYPE.eq(dictType)).orderBy(SYS_DICT_DATA.DICT_SORT.asc());
public List<SysDictDataVo> 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<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,14 +179,13 @@ 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);
}
@Override
public boolean updateDictDataType(String oldDictType, String newDictType){
public boolean updateDictDataType(String oldDictType, String newDictType) {
return UpdateChain.of(SysDictData.class)
.set(SysDictData::getDictType, newDictType)
.where(SysDictData::getDictType).eq(oldDictType)

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")));
}
private QueryWrapper buildQueryWrapper(SysDictTypeBo dictTypeBo) {
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,9 +128,8 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 字典类型
*/
@Override
public SysDictTypeVo selectDictTypeById(Long dictId)
{
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_ID.eq(dictId)),SysDictTypeVo.class);
public SysDictTypeVo selectDictTypeById(Long dictId) {
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_ID.eq(dictId)), SysDictTypeVo.class);
}
/**
@ -154,9 +139,8 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, S
* @return 字典类型
*/
@Override
public SysDictTypeVo selectDictTypeByType(String dictType)
{
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_TYPE.eq(dictType)),SysDictTypeVo.class);
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);
@ -124,24 +121,13 @@ 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());
.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<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;
@ -47,7 +48,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* @author dataprince数据小王子
*/
@Service
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> implements ISysMenuService {
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
@Resource
private SysMenuMapper menuMapper;
@ -73,19 +74,12 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> 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<SysMenuMapper,SysMenu> i
</if>
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<SysMenuMapper,SysMenu> 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<SysMenuVo> menuList = this.listAs(queryWrapper, SysMenuVo.class);
return menuList;
@ -205,11 +199,11 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> 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<SysMenuMapper,SysMenu> 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<SysMenuMapper,SysMenu> 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<SysMenu> menus= this.list(queryWrapper);
List<SysMenu> menus = this.list(queryWrapper);
return getChildPerms(menus, 0);
}
@ -273,10 +267,10 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> 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);
}
@ -564,7 +558,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> 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[]{"", "", "", "/", "/"});
}
}

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

@ -41,7 +41,7 @@ import static com.ruoyi.system.domain.table.SysOssConfigTableDef.SYS_OSS_CONFIG;
@Slf4j
@RequiredArgsConstructor
@Service
public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper,SysOssConfig> implements ISysOssConfigService {
public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper, SysOssConfig> implements ISysOssConfigService {
private final SysOssConfigMapper baseMapper;
@ -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,12 +113,11 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> 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<SysOssMapper, SysOss> 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);

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
@ -133,7 +121,7 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
.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<SysPostMapper, SysPost>
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)
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);
return this.listAs(queryWrapper, SysPostVo.class);
}
/**
@ -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;