| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- package jnpf.permission.service.impl;
- import cn.hutool.core.collection.CollectionUtil;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.github.yulichang.toolkit.JoinWrappers;
- import com.github.yulichang.wrapper.MPJLambdaWrapper;
- import jnpf.base.service.SuperServiceImpl;
- import jnpf.constant.CodeConst;
- import jnpf.constant.PermissionConst;
- import jnpf.permission.entity.*;
- import jnpf.permission.mapper.StandingMapper;
- import jnpf.permission.model.standing.StandingPagination;
- import jnpf.permission.service.CodeNumService;
- import jnpf.permission.service.PositionService;
- import jnpf.permission.service.RoleService;
- import jnpf.permission.service.StandingService;
- import jnpf.util.DateUtil;
- import jnpf.util.RandomUtil;
- import jnpf.util.StringUtil;
- import jnpf.util.UserProvider;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Collections;
- import java.util.List;
- /**
- * 身份管理impl
- *
- * @author JNPF开发平台组
- * @version v6.0.0
- * @copyright 引迈信息技术有限公司
- * @date 2025/3/4 18:24:09
- */
- @Service
- public class StandingServiceImpl extends SuperServiceImpl<StandingMapper, StandingEntity> implements StandingService {
- @Autowired
- private CodeNumService codeNumService;
- @Autowired
- private RoleService roleService;
- @Autowired
- private PositionService positionService;
- @Override
- public List<StandingEntity> getList(StandingPagination pagination) {
- boolean flag = false;
- QueryWrapper<StandingEntity> queryWrapper = new QueryWrapper<>();
- if (StringUtil.isNotEmpty(pagination.getKeyword())) {
- flag = true;
- queryWrapper.lambda().and(
- t -> t.like(StandingEntity::getFullName, pagination.getKeyword())
- .or().like(StandingEntity::getEnCode, pagination.getKeyword())
- );
- }
- //排序
- queryWrapper.lambda().orderByAsc(StandingEntity::getSortCode).orderByAsc(StandingEntity::getCreatorTime);
- if (flag) {
- queryWrapper.lambda().orderByDesc(StandingEntity::getLastModifyTime);
- }
- return this.list(queryWrapper);
- }
- @Override
- public void crete(StandingEntity entity) {
- entity.setId(RandomUtil.uuId());
- if (StringUtil.isEmpty(entity.getEnCode())) {
- entity.setEnCode(codeNumService.getCodeFunction(() -> codeNumService.getCodeOnce(CodeConst.SF), code -> this.isExistByEnCode(code, null)));
- }
- entity.setCreatorUserId(UserProvider.getUser().getUserId());
- entity.setCreatorTime(DateUtil.getNowDate());
- entity.setIsSystem(2);
- entity.setEnabledMark(1);
- this.save(entity);
- }
- @Override
- public Boolean update(String id, StandingEntity entity) {
- entity.setId(id);
- if (StringUtil.isEmpty(entity.getEnCode())) {
- entity.setEnCode(codeNumService.getCodeFunction(() -> codeNumService.getCodeOnce(CodeConst.SF), code -> this.isExistByEnCode(code, id)));
- }
- entity.setLastModifyUserId(UserProvider.getUser().getUserId());
- entity.setLastModifyTime(DateUtil.getNowDate());
- entity.setEnabledMark(1);
- return this.updateById(entity);
- }
- @Override
- public StandingEntity getInfo(String id) {
- return this.getById(id);
- }
- @Override
- public void delete(StandingEntity entity) {
- this.removeById(entity.getId());
- //todo 绑定关系删除
- }
- @Override
- public Boolean isExistByFullName(String fullName, String id) {
- QueryWrapper<StandingEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(StandingEntity::getFullName, fullName);
- if (!StringUtil.isEmpty(id)) {
- queryWrapper.lambda().ne(StandingEntity::getId, id);
- }
- return this.count(queryWrapper) > 0 ? true : false;
- }
- @Override
- public Boolean isExistByEnCode(String enCode, String id) {
- if (StringUtil.isEmpty(enCode)) return false;
- QueryWrapper<StandingEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(StandingEntity::getEnCode, enCode);
- if (!StringUtil.isEmpty(id)) {
- queryWrapper.lambda().ne(StandingEntity::getId, id);
- }
- return this.count(queryWrapper) > 0 ? true : false;
- }
- @Override
- public List<StandingEntity> getListByIds(List<String> idList) {
- if (CollectionUtil.isEmpty(idList)) return Collections.EMPTY_LIST;
- QueryWrapper<StandingEntity> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().in(StandingEntity::getId, idList);
- queryWrapper.lambda().eq(StandingEntity::getEnabledMark, 1);
- queryWrapper.lambda().orderByAsc(StandingEntity::getSortCode).orderByAsc(StandingEntity::getCreatorTime);
- return this.list(queryWrapper);
- }
- @Override
- public List<RoleEntity> getRolePage(StandingPagination pagination) {
- MPJLambdaWrapper<RoleEntity> queryWrapper = JoinWrappers.lambda(RoleEntity.class);
- queryWrapper.leftJoin(AuthorizeEntity.class, AuthorizeEntity::getObjectId, RoleEntity::getId);
- queryWrapper.selectAll(RoleEntity.class);
- if (!StringUtil.isEmpty(pagination.getKeyword())) {
- queryWrapper.and(
- t -> t.like(RoleEntity::getEnCode, pagination.getKeyword())
- .or().like(RoleEntity::getFullName, pagination.getKeyword())
- );
- }
- queryWrapper.eq(AuthorizeEntity::getItemId, pagination.getId());
- queryWrapper.eq(AuthorizeEntity::getObjectType, PermissionConst.ROLE);
- queryWrapper.isNotNull(RoleEntity::getId);
- queryWrapper.orderByAsc(RoleEntity::getGlobalMark).orderByDesc(AuthorizeEntity::getId);
- Page<RoleEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<RoleEntity> data = roleService.selectJoinListPage(page, RoleEntity.class, queryWrapper);
- return pagination.setData(data.getRecords(), page.getTotal());
- }
- @Override
- public List<PositionEntity> getPosPage(StandingPagination pagination) {
- MPJLambdaWrapper<PositionEntity> queryWrapper = JoinWrappers.lambda(PositionEntity.class);
- queryWrapper.leftJoin(AuthorizeEntity.class, AuthorizeEntity::getObjectId, PositionEntity::getId);
- queryWrapper.selectAll(PositionEntity.class);
- if (!StringUtil.isEmpty(pagination.getKeyword())) {
- queryWrapper.and(
- t -> t.like(PositionEntity::getEnCode, pagination.getKeyword())
- .or().like(PositionEntity::getFullName, pagination.getKeyword())
- );
- }
- queryWrapper.eq(AuthorizeEntity::getItemId, pagination.getId());
- queryWrapper.eq(AuthorizeEntity::getObjectType, PermissionConst.POSITION);
- queryWrapper.isNotNull(PositionEntity::getId);
- queryWrapper.orderByDesc(AuthorizeEntity::getId);
- Page<PositionEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
- IPage<PositionEntity> data = positionService.selectJoinListPage(page, PositionEntity.class, queryWrapper);
- return pagination.setData(data.getRecords(), page.getTotal());
- }
- }
|