简化代码,对于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) public static void main(String[] args)
{ {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ RuoYi-Flex启动成功 ლ(´ڡ`ლ)゙ \n" + System.out.println("(♥◠‿◠)ノ゙ RuoYi-Flex启动成功 ლ(´ڡ`ლ)゙ \n" +
" ███████ ██ ██ ██ ████████ ██ \n" + " ███████ ██ ██ ██ ████████ ██ \n" +

View File

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

View File

@ -1,6 +1,7 @@
oms.env=dev oms.env=dev
####### Database properties(Configure according to the the environment) ####### ####### 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.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.jdbc-url=jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.core.username=postgres spring.datasource.core.username=postgres

View File

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

View File

@ -3,15 +3,10 @@ package com.ruoyi.mf.service.impl;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils; 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.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -30,8 +25,7 @@ import static com.ruoyi.mf.domain.table.MfProductTableDef.MF_PRODUCT;
* 2023-11-23 * 2023-11-23
*/ */
@Service @Service
public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfProduct> implements IMfProductService public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfProduct> implements IMfProductService {
{
@Resource @Resource
private MfProductMapper mfProductMapper; private MfProductMapper mfProductMapper;
@ -42,17 +36,9 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
private QueryWrapper buildQueryWrapper(MfProductBo mfProductBo) { private QueryWrapper buildQueryWrapper(MfProductBo mfProductBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
queryWrapper.and(MF_PRODUCT.PRODUCT_NAME.like(mfProductBo.getProductName()));
if (StringUtils.isNotBlank(mfProductBo.getProductName())) { queryWrapper.and(MF_PRODUCT.ORDER_NUM.eq(mfProductBo.getOrderNum()));
queryWrapper.and(MF_PRODUCT.PRODUCT_NAME.like(mfProductBo.getProductName())); queryWrapper.and(MF_PRODUCT.STATUS.eq(mfProductBo.getStatus()));
}
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; return queryWrapper;
} }
@ -63,8 +49,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 产品树 * @return 产品树
*/ */
@Override @Override
public MfProductVo selectById(Long productId) public MfProductVo selectById(Long productId) {
{
return this.getOneAs(query().where(MF_PRODUCT.PRODUCT_ID.eq(productId)), MfProductVo.class); 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 产品树集合 * @return 产品树集合
*/ */
@Override @Override
public List<MfProductVo> selectList(MfProductBo mfProductBo) public List<MfProductVo> selectList(MfProductBo mfProductBo) {
{
QueryWrapper queryWrapper = buildQueryWrapper(mfProductBo); QueryWrapper queryWrapper = buildQueryWrapper(mfProductBo);
return this.listAs(queryWrapper, MfProductVo.class); return this.listAs(queryWrapper, MfProductVo.class);
} }
@ -89,8 +73,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 结果:true 操作成功false 操作失败 * @return 结果:true 操作成功false 操作失败
*/ */
@Override @Override
public boolean insert(MfProductBo mfProductBo) public boolean insert(MfProductBo mfProductBo) {
{
MfProduct mfProduct = MapstructUtils.convert(mfProductBo, MfProduct.class); MfProduct mfProduct = MapstructUtils.convert(mfProductBo, MfProduct.class);
return this.save(mfProduct);//使用全局配置的雪花算法主键生成器生成ID值 return this.save(mfProduct);//使用全局配置的雪花算法主键生成器生成ID值
@ -103,8 +86,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
* @return 结果:true 更新成功false 更新失败 * @return 结果:true 更新成功false 更新失败
*/ */
@Override @Override
public boolean update(MfProductBo mfProductBo) public boolean update(MfProductBo mfProductBo) {
{
MfProduct mfProduct = MapstructUtils.convert(mfProductBo, MfProduct.class); MfProduct mfProduct = MapstructUtils.convert(mfProductBo, MfProduct.class);
boolean updated = this.updateById(mfProduct); boolean updated = this.updateById(mfProduct);
@ -119,8 +101,7 @@ public class MfProductServiceImpl extends BaseServiceImpl<MfProductMapper, MfPro
*/ */
@Transactional @Transactional
@Override @Override
public boolean deleteByIds(Long[] productIds) public boolean deleteByIds(Long[] productIds) {
{
return this.removeByIds(Arrays.asList(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.Arrays;
import java.util.List; import java.util.List;
import com.mybatisflex.annotation.UseDataSource; import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils; 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.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo; import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl; 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 * 2023-11-22
*/ */
@Service @Service
public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStudent> implements IMfStudentService public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStudent> implements IMfStudentService {
{
@Resource @Resource
private MfStudentMapper mfStudentMapper; private MfStudentMapper mfStudentMapper;
@ -40,14 +39,8 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
private QueryWrapper buildQueryWrapper(MfStudentBo mfStudentBo) { private QueryWrapper buildQueryWrapper(MfStudentBo mfStudentBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
queryWrapper.and(MF_STUDENT.STUDENT_NAME.like(mfStudentBo.getStudentName()));
if (StringUtils.isNotBlank(mfStudentBo.getStudentName())) { queryWrapper.and(MF_STUDENT.STUDENT_STATUS.eq(mfStudentBo.getStudentStatus()));
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; return queryWrapper;
} }
@ -58,8 +51,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 学生信息表 * @return 学生信息表
*/ */
@Override @Override
public MfStudentVo selectById(Long studentId) public MfStudentVo selectById(Long studentId) {
{
return this.getOneAs(query().where(MF_STUDENT.STUDENT_ID.eq(studentId)), MfStudentVo.class); 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 学生信息表集合 * @return 学生信息表集合
*/ */
@Override @Override
public List<MfStudentVo> selectList(MfStudentBo mfStudentBo) public List<MfStudentVo> selectList(MfStudentBo mfStudentBo) {
{
QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo);
return this.listAs(queryWrapper, MfStudentVo.class); return this.listAs(queryWrapper, MfStudentVo.class);
} }
@ -84,8 +75,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
*/ */
@Override @Override
//@UseDataSource("ds2") //@UseDataSource("ds2")
public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo) public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo) {
{
QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo); QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo);
Page<MfStudentVo> page = this.pageAs(PageQuery.build(), queryWrapper, MfStudentVo.class); Page<MfStudentVo> page = this.pageAs(PageQuery.build(), queryWrapper, MfStudentVo.class);
return TableDataInfo.build(page); return TableDataInfo.build(page);
@ -98,8 +88,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 结果:true 操作成功false 操作失败 * @return 结果:true 操作成功false 操作失败
*/ */
@Override @Override
public boolean insert(MfStudentBo mfStudentBo) public boolean insert(MfStudentBo mfStudentBo) {
{
MfStudent mfStudent = MapstructUtils.convert(mfStudentBo, MfStudent.class); MfStudent mfStudent = MapstructUtils.convert(mfStudentBo, MfStudent.class);
return this.save(mfStudent);//使用全局配置的雪花算法主键生成器生成ID值 return this.save(mfStudent);//使用全局配置的雪花算法主键生成器生成ID值
@ -112,8 +101,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 结果:true 更新成功false 更新失败 * @return 结果:true 更新成功false 更新失败
*/ */
@Override @Override
public boolean update(MfStudentBo mfStudentBo) public boolean update(MfStudentBo mfStudentBo) {
{
MfStudent mfStudent = MapstructUtils.convert(mfStudentBo, MfStudent.class); MfStudent mfStudent = MapstructUtils.convert(mfStudentBo, MfStudent.class);
boolean updated = this.updateById(mfStudent); boolean updated = this.updateById(mfStudent);
@ -128,8 +116,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
*/ */
@Transactional @Transactional
@Override @Override
public boolean deleteByIds(Long[] studentIds) public boolean deleteByIds(Long[] studentIds) {
{
return this.removeByIds(Arrays.asList(studentIds)); return this.removeByIds(Arrays.asList(studentIds));
} }

View File

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

View File

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

View File

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

View File

@ -57,32 +57,21 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper,
private QueryWrapper buildQueryWrapper(${ClassName}Bo ${className}Bo) { private QueryWrapper buildQueryWrapper(${ClassName}Bo ${className}Bo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
#foreach($column in $columns) #foreach($column in $columns)
#if($column.query) #if($column.query)
#set($queryType=$column.queryType) #set($queryType=$column.queryType)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#set($javaType=$column.javaType) #set($javaType=$column.javaType)
#set($columnName=$column.columnName) #set($columnName=$column.columnName)
#set($capitalColumnName=$column.columnName.toUpperCase()) #set($capitalColumnName=$column.columnName.toUpperCase())
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($mpMethod=$column.queryType.toLowerCase()) #set($mpMethod=$column.queryType.toLowerCase())
#if($queryType != 'BETWEEN') #if($queryType != 'BETWEEN')
#if($javaType == 'String') queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.get$AttrName()));
#set($condition='StringUtils.isNotBlank('+${className}+'Bo.get'+$AttrName+'())') #else
#else queryWrapper.and(${CapitalUnderScoreClassName}.${capitalColumnName}.$mpMethod(${className}Bo.getParams().get("begin$AttrName"), ${className}Bo.getParams().get("end$AttrName")));
#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
#end #end
#end
#end #end
return queryWrapper; 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.common.redis.utils.CacheUtils;
import com.ruoyi.system.domain.bo.SysConfigBo; import com.ruoyi.system.domain.bo.SysConfigBo;
import com.ruoyi.system.domain.vo.SysConfigVo; import com.ruoyi.system.domain.vo.SysConfigVo;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
@ -52,7 +51,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
*/ */
@Override @Override
public SysConfigVo selectConfigById(Long configId) { 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 * @param config
* @return 查询条件 * @return 查询条件
*/ */
private QueryWrapper buildQueryWrapper(SysConfigBo config) { private QueryWrapper buildQueryWrapper(SysConfigBo config) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_CONFIG.CONFIG_NAME.like(config.getConfigName()))
if (StringUtils.isNotEmpty(config.getConfigName())) { .and(SYS_CONFIG.CONFIG_TYPE.eq(config.getConfigType()))
queryWrapper.and(SYS_CONFIG.CONFIG_NAME.like(config.getConfigName())); .and(SYS_CONFIG.CONFIG_KEY.like(config.getConfigKey()))
} .and(SYS_CONFIG.CREATE_TIME.between(config.getParams().get("beginTime"), config.getParams().get("endTime")));
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")));
}
return queryWrapper; return queryWrapper;
} }
@ -124,7 +110,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
public List<SysConfigVo> selectConfigList(SysConfigBo config) { public List<SysConfigVo> selectConfigList(SysConfigBo config) {
QueryWrapper queryWrapper = buildQueryWrapper(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 @Override
public TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config) { public TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config) {
QueryWrapper queryWrapper = buildQueryWrapper(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); return TableDataInfo.build(page);
} }
@ -176,7 +162,7 @@ public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysCo
@Override @Override
public boolean updateConfigByKey(SysConfigBo configBo) { public boolean updateConfigByKey(SysConfigBo configBo) {
SysConfig config = MapstructUtils.convert(configBo, SysConfig.class); 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 sysConfig = this.getOne(queryWrapper);
SysConfig configUpdate = new SysConfig(); SysConfig configUpdate = new SysConfig();

View File

@ -67,23 +67,13 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
* @return 查询条件 * @return 查询条件
*/ */
private QueryWrapper buildQueryWrapper(SysDeptBo deptBo) { private QueryWrapper buildQueryWrapper(SysDeptBo deptBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
queryWrapper.where(SYS_DEPT.DEL_FLAG.eq(0)); //where(SYS_DEPT.DEL_FLAG.eq(0));//逻辑删除字段mybatis-flex会自动添加该条件
.and(SYS_DEPT.DEPT_ID.eq(deptBo.getDeptId()))
if (ObjectUtil.isNotNull(deptBo.getDeptId())) { .and(SYS_DEPT.PARENT_ID.eq(deptBo.getParentId()))
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptBo.getDeptId())); .and(SYS_DEPT.DEPT_NAME.like(deptBo.getDeptName()))
} .and(SYS_DEPT.STATUS.eq(deptBo.getStatus()))
if (ObjectUtil.isNotNull(deptBo.getParentId())) { .orderBy(SYS_DEPT.PARENT_ID.asc(), SYS_DEPT.ORDER_NUM.asc());
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());
return queryWrapper; 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)) .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)); .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.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); return this.listAs(queryWrapper, Long.class);
@ -173,31 +163,32 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId") @Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override @Override
public SysDeptVo selectDeptById(Long deptId) { public SysDeptVo selectDeptById(Long deptId) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)); QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_ID.eq(deptId));
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptId)); return this.getOneAs(queryWrapper, SysDeptVo.class);
return this.getOneAs(queryWrapper, SysDeptVo.class);//TODO:缺少parent_name
} }
/** /**
* 根据 部门名称 查询记录数量 * 根据 部门名称 查询记录数量
*
* @param deptName 部门名称 * @param deptName 部门名称
* @return 记录数量 * @return 记录数量
*/ */
@Override @Override
public long selectDeptCountByName(String deptName) { 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); return this.count(queryWrapper);
} }
/** /**
* 根据 部门名称 查询部门信息 * 根据 部门名称 查询部门信息
*
* @param deptName 部门名称 * @param deptName 部门名称
* @return 部门信息 * @return 部门信息
*/ */
@Override @Override
public SysDeptVo selectDeptByName(String deptName) { public SysDeptVo selectDeptByName(String deptName) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0")); QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
return this.getOneAs(queryWrapper,SysDeptVo.class); return this.getOneAs(queryWrapper, SysDeptVo.class);
} }
/** /**
@ -212,10 +203,9 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
.select(QueryMethods.count(SYS_DEPT.DEPT_ID)) .select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT) .from(SYS_DEPT)
.where(SYS_DEPT.STATUS.eq("0")) .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() QueryWrapper queryWrapper = QueryWrapper.create()
.select(QueryMethods.count(SYS_DEPT.DEPT_ID)) .select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT) .from(SYS_DEPT)
.where(SYS_DEPT.DEL_FLAG.eq(0))
.and(SYS_DEPT.PARENT_ID.eq(deptId)); .and(SYS_DEPT.PARENT_ID.eq(deptId));
int result = deptMapper.selectObjectByQueryAs(queryWrapper,Integer.class); int result = deptMapper.selectObjectByQueryAs(queryWrapper, Integer.class);
return result > 0; return result > 0;
} }
@ -247,8 +236,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
public boolean checkDeptNameUnique(SysDeptBo dept) { public boolean checkDeptNameUnique(SysDeptBo dept) {
Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)); QueryWrapper queryWrapper = query().where(SYS_DEPT.DEPT_NAME.eq(dept.getDeptName()));
queryWrapper.and(SYS_DEPT.DEPT_NAME.eq(dept.getDeptName()));
queryWrapper.and(SYS_DEPT.PARENT_ID.eq(dept.getParentId())); queryWrapper.and(SYS_DEPT.PARENT_ID.eq(dept.getParentId()));
SysDeptVo info = this.getOneAs(queryWrapper, SysDeptVo.class); 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) //select * from sys_dept where find_in_set(#{deptId}, ancestors)
QueryWrapper queryWrapper = QueryWrapper.create() QueryWrapper queryWrapper = QueryWrapper.create()
.from(SYS_DEPT) .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); 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.mybatisflex.core.update.UpdateChain;
import com.ruoyi.common.core.constant.CacheNames; import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.utils.MapstructUtils; 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.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo; import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl; 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 @RequiredArgsConstructor
@Service @Service
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService {
{
@Resource @Resource
private SysDictDataMapper dictDataMapper; private SysDictDataMapper dictDataMapper;
@ -48,19 +46,15 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
/** /**
* 构造查询条件 * 构造查询条件
*
* @param dictDataBo * @param dictDataBo
* @return QueryWrapper * @return QueryWrapper
*/ */
private QueryWrapper buildQueryWrapper(SysDictDataBo dictDataBo) { private QueryWrapper buildQueryWrapper(SysDictDataBo dictDataBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
if (StringUtils.isNotEmpty(dictDataBo.getDictType())) { .and(SYS_DICT_DATA.DICT_TYPE.eq(dictDataBo.getDictType()))
queryWrapper.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());
if (StringUtils.isNotEmpty(dictDataBo.getDictLabel())) {
queryWrapper.and(SYS_DICT_DATA.DICT_LABEL.eq(dictDataBo.getDictLabel()));
}
queryWrapper.orderBy(SYS_DICT_DATA.DICT_SORT.asc());
return queryWrapper; return queryWrapper;
} }
@ -71,8 +65,7 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
* @return 字典数据集合信息 * @return 字典数据集合信息
*/ */
@Override @Override
public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictDataBo) public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictDataBo) {
{
QueryWrapper queryWrapper = buildQueryWrapper(dictDataBo); QueryWrapper queryWrapper = buildQueryWrapper(dictDataBo);
return this.listAs(queryWrapper, SysDictDataVo.class); return this.listAs(queryWrapper, SysDictDataVo.class);
} }
@ -93,20 +86,19 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
/** /**
* 根据字典类型和字典键值查询字典数据信息 * 根据字典类型和字典键值查询字典数据信息
* *
* @param dictType 字典类型 * @param dictType 字典类型
* @param dictValue 字典键值 * @param dictValue 字典键值
* @return 字典标签 * @return 字典标签
*/ */
@Override @Override
public String selectDictLabel(String dictType, String dictValue) public String selectDictLabel(String dictType, String dictValue) {
{
QueryWrapper queryWrapper = QueryWrapper.create() QueryWrapper queryWrapper = QueryWrapper.create()
.select(SYS_DICT_DATA.DICT_LABEL) .select(SYS_DICT_DATA.DICT_LABEL)
.from(SYS_DICT_DATA) .from(SYS_DICT_DATA)
.where(SYS_DICT_DATA.DICT_TYPE.eq(dictType)) .where(SYS_DICT_DATA.DICT_TYPE.eq(dictType))
.and(SYS_DICT_DATA.DICT_VALUE.eq(dictValue)); .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 字典数据 * @return 字典数据
*/ */
@Override @Override
public SysDictDataVo selectDictDataById(Long dictCode) public SysDictDataVo selectDictDataById(Long dictCode) {
{ return this.getOneAs(query().where(SYS_DICT_DATA.DICT_CODE.eq(dictCode)), SysDictDataVo.class);
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) .from(SYS_DICT_DATA)
.where(SYS_DICT_DATA.DICT_TYPE.eq(dictType)); .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") @Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
@Override @Override
public List<SysDictDataVo> selectDictDataByType(String dictType){ public List<SysDictDataVo> selectDictDataByType(String dictType) {
QueryWrapper queryWrapper=query().and(SYS_DICT_DATA.DICT_TYPE.eq(dictType)).orderBy(SYS_DICT_DATA.DICT_SORT.asc()); QueryWrapper queryWrapper = query().and(SYS_DICT_DATA.DICT_TYPE.eq(dictType)).orderBy(SYS_DICT_DATA.DICT_SORT.asc());
return this.listAs(queryWrapper, SysDictDataVo.class); return this.listAs(queryWrapper, SysDictDataVo.class);
} }
@ -159,10 +150,8 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
*/ */
@Override @Override
@Transactional @Transactional
public boolean deleteDictDataByIds(Long[] dictCodes) public boolean deleteDictDataByIds(Long[] dictCodes) {
{ for (Long dictCode : dictCodes) {
for (Long dictCode : dictCodes)
{
SysDictDataVo data = selectDictDataById(dictCode); SysDictDataVo data = selectDictDataById(dictCode);
CacheUtils.evict(CacheNames.SYS_DICT, data.getDictType()); 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") @CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType")
@Override @Override
public boolean insertDictData(SysDictDataBo dataBo) public boolean insertDictData(SysDictDataBo dataBo) {
{
SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class); SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class);
return this.save(data); return this.save(data);
} }
@ -191,15 +179,14 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, S
*/ */
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType") @CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType")
@Override @Override
public boolean updateDictData(SysDictDataBo dataBo) public boolean updateDictData(SysDictDataBo dataBo) {
{
SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class); SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class);
return this.updateById(data); return this.updateById(data);
} }
@Override @Override
public boolean updateDictDataType(String oldDictType, String newDictType){ public boolean updateDictDataType(String oldDictType, String newDictType) {
return UpdateChain.of(SysDictData.class) return UpdateChain.of(SysDictData.class)
.set(SysDictData::getDictType, newDictType) .set(SysDictData::getDictType, newDictType)
.where(SysDictData::getDictType).eq(oldDictType) .where(SysDictData::getDictType).eq(oldDictType)
.update(); .update();

View File

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

View File

@ -5,7 +5,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.useragent.UserAgent; import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil; import cn.hutool.http.useragent.UserAgentUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
@ -44,8 +43,7 @@ import static com.ruoyi.system.domain.table.SysLogininforTableDef.SYS_LOGININFOR
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@Service @Service
public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMapper, SysLogininfor> implements ISysLogininforService public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMapper, SysLogininfor> implements ISysLogininforService {
{
@Override @Override
public QueryWrapper query() { public QueryWrapper query() {
@ -109,8 +107,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
* @param logininforBo 访问日志对象 * @param logininforBo 访问日志对象
*/ */
@Override @Override
public void insertLogininfor(SysLogininforBo logininforBo) public void insertLogininfor(SysLogininforBo logininforBo) {
{
SysLogininfor logininfor = MapstructUtils.convert(logininforBo, SysLogininfor.class); SysLogininfor logininfor = MapstructUtils.convert(logininforBo, SysLogininfor.class);
logininfor.setLoginTime(new Date()); logininfor.setLoginTime(new Date());
this.save(logininfor); this.save(logininfor);
@ -124,24 +121,13 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
*/ */
private QueryWrapper buildQueryWrapper(SysLogininforBo logininforBo) { private QueryWrapper buildQueryWrapper(SysLogininforBo logininforBo) {
QueryWrapper queryWrapper = QueryWrapper.create() 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) .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); .from(SYS_LOGININFOR)
.and(SYS_LOGININFOR.IPADDR.like(logininforBo.getIpaddr()))
if (StringUtils.isNotEmpty(logininforBo.getIpaddr())) { .and(SYS_LOGININFOR.STATUS.eq(logininforBo.getStatus()))
queryWrapper.and(SYS_LOGININFOR.IPADDR.like(logininforBo.getIpaddr())); .and(SYS_LOGININFOR.USER_NAME.like(logininforBo.getUserName()))
} .and(SYS_LOGININFOR.LOGIN_TIME.between(logininforBo.getParams().get("beginTime"), logininforBo.getParams().get("endTime")))
if (StringUtils.isNotEmpty(logininforBo.getStatus())) { .orderBy(SYS_LOGININFOR.INFO_ID.desc());
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());
return queryWrapper; return queryWrapper;
} }
@ -152,8 +138,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
* @return 登录记录集合 * @return 登录记录集合
*/ */
@Override @Override
public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininforBo) public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininforBo) {
{
QueryWrapper queryWrapper = buildQueryWrapper(logininforBo); QueryWrapper queryWrapper = buildQueryWrapper(logininforBo);
return this.listAs(queryWrapper, SysLogininforVo.class); return this.listAs(queryWrapper, SysLogininforVo.class);
} }
@ -174,24 +159,23 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
/** /**
* 批量删除系统登录日志 * 批量删除系统登录日志
* delete from sys_logininfor where info_id in * delete from sys_logininfor where info_id in
*
* @param infoIds 需要删除的登录日志ID * @param infoIds 需要删除的登录日志ID
* @return 结果:true 删除成功false 删除失败 * @return 结果:true 删除成功false 删除失败
*/ */
@Override @Override
@Transactional @Transactional
public boolean deleteLogininforByIds(Long[] infoIds) public boolean deleteLogininforByIds(Long[] infoIds) {
{
return this.removeByIds(Arrays.asList(infoIds)); return this.removeByIds(Arrays.asList(infoIds));
} }
/** /**
* 清空系统登录日志 * 清空系统登录日志
* delete from sys_logininfor where info_id>0 * delete from sys_logininfor where info_id>0
* 返回结果true 删除成功false 删除失败 * 返回结果true 删除成功false 删除失败
*/ */
@Override @Override
public boolean cleanLogininfor() public boolean cleanLogininfor() {
{
QueryWrapper queryWrapper = query().from(SYS_LOGININFOR).where(SYS_LOGININFOR.INFO_ID.gt(0)); QueryWrapper queryWrapper = query().from(SYS_LOGININFOR).where(SYS_LOGININFOR.INFO_ID.gt(0));
return this.remove(queryWrapper); 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.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree; import cn.hutool.core.lang.tree.Tree;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@ -47,7 +48,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* @author dataprince数据小王子 * @author dataprince数据小王子
*/ */
@Service @Service
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> implements ISysMenuService { public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
@Resource @Resource
private SysMenuMapper menuMapper; private SysMenuMapper menuMapper;
@ -73,19 +74,12 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
return selectMenuList(new SysMenuBo(), userId); return selectMenuList(new SysMenuBo(), userId);
} }
private QueryWrapper buildQueryWrapper(SysMenuBo menuBo){ private QueryWrapper buildQueryWrapper(SysMenuBo menuBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
if (StringUtils.isNotEmpty(menuBo.getMenuName())) { .and(SYS_MENU.MENU_NAME.like(menuBo.getMenuName()))
queryWrapper.and(SYS_MENU.MENU_NAME.like(menuBo.getMenuName())); .and(SYS_MENU.VISIBLE.eq(menuBo.getVisible()))
} .and(SYS_MENU.STATUS.eq(menuBo.getStatus()))
if (StringUtils.isNotEmpty(menuBo.getVisible())) { .orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc());
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());
return queryWrapper; return queryWrapper;
} }
@ -119,7 +113,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
</if> </if>
order by m.parent_id, m.order_num*/ order by m.parent_id, m.order_num*/
queryWrapper = queryWrapper 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) .from(SYS_MENU)
.leftJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID)) .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)) .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())) { if (StringUtils.isNotEmpty(menuBo.getStatus())) {
queryWrapper.and(SYS_MENU.STATUS.eq(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); List<SysMenuVo> menuList = this.listAs(queryWrapper, SysMenuVo.class);
return menuList; return menuList;
@ -205,11 +199,11 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
return permsSet; return permsSet;
} }
private QueryWrapper buildMenuTreeQueryWrapper(){ private QueryWrapper buildMenuTreeQueryWrapper() {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
queryWrapper.and(SYS_MENU.MENU_TYPE.in(UserConstants.TYPE_DIR, UserConstants.TYPE_MENU)); .and(SYS_MENU.MENU_TYPE.in(UserConstants.TYPE_DIR, UserConstants.TYPE_MENU))
queryWrapper.and(SYS_MENU.STATUS.eq(UserConstants.MENU_NORMAL)); .and(SYS_MENU.STATUS.eq(UserConstants.MENU_NORMAL))
queryWrapper.orderBy(SYS_MENU.PARENT_ID.asc(),SYS_MENU.ORDER_NUM.asc()); .orderBy(SYS_MENU.PARENT_ID.asc(), SYS_MENU.ORDER_NUM.asc());
return queryWrapper; 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 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*/ order by m.parent_id, m.order_num*/
queryWrapper = queryWrapper 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) .from(SYS_MENU)
.leftJoin(SYS_ROLE_MENU).on(SYS_MENU.MENU_ID.eq(SYS_ROLE_MENU.MENU_ID)) .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)) .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.MENU_TYPE.in("M", "C"))
.and(SYS_MENU.STATUS.eq("0")) .and(SYS_MENU.STATUS.eq("0"))
.and(SYS_ROLE.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); return getChildPerms(menus, 0);
} }
@ -273,10 +267,10 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
.from(SYS_MENU) .from(SYS_MENU)
.leftJoin(SYS_ROLE_MENU).on(SYS_ROLE_MENU.MENU_ID.eq(SYS_MENU.MENU_ID)) .leftJoin(SYS_ROLE_MENU).on(SYS_ROLE_MENU.MENU_ID.eq(SYS_MENU.MENU_ID))
.where(SYS_ROLE_MENU.ROLE_ID.eq(roleId)); .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.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); return this.listAs(queryWrapper, Long.class);
} }
@ -428,7 +422,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
public boolean checkMenuNameUnique(SysMenuBo menu) { public boolean checkMenuNameUnique(SysMenuBo menu) {
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
QueryWrapper queryWrapper = query().where(SYS_MENU.MENU_NAME.eq(menu.getMenuName())) 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); SysMenu info = this.getOne(queryWrapper);
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
return UserConstants.NOT_UNIQUE; return UserConstants.NOT_UNIQUE;
@ -564,7 +558,7 @@ public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> i
* @return 替换后的内链域名 * @return 替换后的内链域名
*/ */
public String innerLinkReplaceEach(String path) { public String innerLinkReplaceEach(String path) {
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" }, return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"},
new String[] { "", "", "", "/", "/" }); new String[]{"", "", "", "/", "/"});
} }
} }

View File

@ -3,11 +3,9 @@ package com.ruoyi.system.service.impl;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils; 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.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo; import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl; import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
@ -33,6 +31,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
@Resource @Resource
private SysNoticeMapper noticeMapper; private SysNoticeMapper noticeMapper;
@Override @Override
public QueryWrapper query() { public QueryWrapper query() {
return super.query().from(SYS_NOTICE); return super.query().from(SYS_NOTICE);
@ -56,18 +55,10 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
* @return 查询条件 * @return 查询条件
*/ */
private QueryWrapper buildQueryWrapper(SysNoticeBo noticeBo) { private QueryWrapper buildQueryWrapper(SysNoticeBo noticeBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_NOTICE.NOTICE_TITLE.like(noticeBo.getNoticeTitle()))
if (StringUtils.isNotEmpty(noticeBo.getNoticeTitle())) { .and(SYS_NOTICE.NOTICE_TYPE.eq(noticeBo.getNoticeType()))
queryWrapper.and(SYS_NOTICE.NOTICE_TITLE.like(noticeBo.getNoticeTitle())); .and(SYS_NOTICE.CREATE_BY.like(noticeBo.getCreateBy()));
}
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()));
}
return queryWrapper; return queryWrapper;
} }
@ -113,7 +104,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
* 修改公告 * 修改公告
* *
* @param noticeBo 公告信息 * @param noticeBo 公告信息
* @return true 更新成功false 更新失败 * @return true 更新成功false 更新失败
*/ */
@Override @Override
public Boolean updateNotice(SysNoticeBo noticeBo) { public Boolean updateNotice(SysNoticeBo noticeBo) {

View File

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

View File

@ -41,7 +41,7 @@ import static com.ruoyi.system.domain.table.SysOssConfigTableDef.SYS_OSS_CONFIG;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper,SysOssConfig> implements ISysOssConfigService { public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper, SysOssConfig> implements ISysOssConfigService {
private final SysOssConfigMapper baseMapper; private final SysOssConfigMapper baseMapper;
@ -78,18 +78,11 @@ public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper,
* @return 查询条件 * @return 查询条件
*/ */
private QueryWrapper buildQueryWrapper(SysOssConfigBo bo) { private QueryWrapper buildQueryWrapper(SysOssConfigBo bo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.and(SYS_OSS_CONFIG.CONFIG_KEY.eq(bo.getConfigKey()))
if (StringUtils.isNotEmpty(bo.getConfigKey())) { .and(SYS_OSS_CONFIG.BUCKET_NAME.like(bo.getBucketName()))
queryWrapper.and(SYS_OSS_CONFIG.CONFIG_KEY.eq(bo.getConfigKey())); .and(SYS_OSS_CONFIG.STATUS.eq(bo.getStatus()))
} .orderBy(SYS_OSS_CONFIG.OSS_CONFIG_ID.asc());
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());
return queryWrapper; return queryWrapper;
} }
@ -182,7 +175,7 @@ public class SysOssConfigServiceImpl extends BaseServiceImpl<SysOssConfigMapper,
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean updateOssConfigStatus(SysOssConfigBo bo) { public boolean updateOssConfigStatus(SysOssConfigBo bo) {
SysOssConfig sysOssConfig = MapstructUtils.convert(bo, SysOssConfig.class); SysOssConfig sysOssConfig = MapstructUtils.convert(bo, SysOssConfig.class);
boolean updated = this.updateById(sysOssConfig); boolean updated = this.updateById(sysOssConfig);
if (updated) { if (updated) {
RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, sysOssConfig.getConfigKey()); RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, sysOssConfig.getConfigKey());
} }

View File

@ -58,28 +58,14 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
} }
private QueryWrapper buildQueryWrapper(SysOssBo bo) { private QueryWrapper buildQueryWrapper(SysOssBo bo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); QueryWrapper queryWrapper = super.buildBaseQueryWrapper()
.where(SYS_OSS.FILE_NAME.like(bo.getFileName()))
if (StringUtils.isNotEmpty(bo.getFileName())) { .and(SYS_OSS.ORIGINAL_NAME.like(bo.getOriginalName()))
queryWrapper.where(SYS_OSS.FILE_NAME.like(bo.getFileName())); .and(SYS_OSS.FILE_SUFFIX.eq(bo.getFileSuffix()))
} .and(SYS_OSS.URL.eq(bo.getUrl()))
if (StringUtils.isNotEmpty(bo.getOriginalName())) { .and(SYS_OSS.CREATE_TIME.between(bo.getParams().get("beginCreateTime"), bo.getParams().get("endCreateTime")))
queryWrapper.and(SYS_OSS.ORIGINAL_NAME.like(bo.getOriginalName())); .and(SYS_OSS.SERVICE.eq(bo.getService()))
} .orderBy(SYS_OSS.OSS_ID.asc());
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());
return queryWrapper; return queryWrapper;
} }
@ -127,12 +113,11 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
} }
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId") @Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
@Override @Override
public SysOssVo getById(Long ossId) { public SysOssVo getById(Long ossId) {
QueryWrapper queryWrapper=query().where(SYS_OSS.OSS_ID.eq(ossId)); QueryWrapper queryWrapper = query().where(SYS_OSS.OSS_ID.eq(ossId));
return ossMapper.selectOneWithRelationsByQueryAs(queryWrapper,SysOssVo.class); return ossMapper.selectOneWithRelationsByQueryAs(queryWrapper, SysOssVo.class);
} }
@Override @Override
@ -144,7 +129,7 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName()); FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8"); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
OssClient storage = OssFactory.instance(sysOss.getService()); OssClient storage = OssFactory.instance(sysOss.getService());
try(InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) { try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
int available = inputStream.available(); int available = inputStream.available();
IoUtil.copy(inputStream, response.getOutputStream(), available); IoUtil.copy(inputStream, response.getOutputStream(), available);
response.setContentLength(available); response.setContentLength(available);

View File

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

View File

@ -40,7 +40,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* 角色 业务层处理 * 角色 业务层处理
* *
* @author ruoyi * @author ruoyi
* @author dataprince数据小王子 * @author dataprince数据小王子
*/ */
@Service @Service
public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService { public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
@ -74,28 +74,13 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.from(SYS_ROLE.as("r")) .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_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_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)); .leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.and(SYS_ROLE.ROLE_ID.eq(roleBo.getRoleId()))
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0)); .and(SYS_ROLE.ROLE_NAME.like(roleBo.getRoleName()))
if (ObjectUtil.isNotNull(roleBo.getRoleId())) { .and(SYS_ROLE.STATUS.eq(roleBo.getStatus()))
queryWrapper.and(SYS_ROLE.ROLE_ID.eq(roleBo.getRoleId())); .and(SYS_ROLE.ROLE_KEY.like(roleBo.getRoleKey()))
} .and(SYS_ROLE.CREATE_TIME.between(roleBo.getParams().get("beginTime"), roleBo.getParams().get("endTime")))
if (StringUtils.isNotEmpty(roleBo.getRoleName())) { .orderBy(SYS_ROLE.ROLE_SORT.asc());
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());
return queryWrapper; return queryWrapper;
} }
@ -143,9 +128,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.from(SYS_ROLE.as("r")) .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_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_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)); .leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0)) .where(SYS_USER_ROLE.USER_ID.eq(userId));
.and(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> userRoles = this.listAs(queryWrapper, SysRoleVo.class); List<SysRoleVo> userRoles = this.listAs(queryWrapper, SysRoleVo.class);
List<SysRoleVo> roles = selectRoleAll(); List<SysRoleVo> roles = selectRoleAll();
@ -203,9 +187,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.from(SYS_ROLE.as("r")) .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_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_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)); .leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0)) .where(SYS_USER_ROLE.USER_ID.eq(userId));
.and(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> perms = this.listAs(queryWrapper, SysRoleVo.class); List<SysRoleVo> perms = this.listAs(queryWrapper, SysRoleVo.class);
//List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId); //List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
@ -270,8 +253,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
@Override @Override
public boolean checkRoleNameUnique(SysRoleBo roleBo) { public boolean checkRoleNameUnique(SysRoleBo roleBo) {
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId(); Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_NAME.eq(roleBo.getRoleName())) QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_NAME.eq(roleBo.getRoleName()));
.and(SYS_ROLE.DEL_FLAG.eq(0));
SysRole info = this.getOne(queryWrapper); SysRole info = this.getOne(queryWrapper);
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE; return UserConstants.NOT_UNIQUE;
@ -288,8 +270,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
@Override @Override
public boolean checkRoleKeyUnique(SysRoleBo roleBo) { public boolean checkRoleKeyUnique(SysRoleBo roleBo) {
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId(); Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_KEY.eq(roleBo.getRoleKey())) QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_KEY.eq(roleBo.getRoleKey()));
.and(SYS_ROLE.DEL_FLAG.eq(0));
SysRole info = this.getOne(queryWrapper); SysRole info = this.getOne(queryWrapper);
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE; return UserConstants.NOT_UNIQUE;