com.didiglobal.logi.security.dao.impl.ProjectDaoImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logi-security-spring-boot-starter Show documentation
Show all versions of logi-security-spring-boot-starter Show documentation
logi-security 提供项目大多都需要的一些基础功能(用户、角色、权限、登录、注册、操作记录)
package com.didiglobal.logi.security.dao.impl;
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.didiglobal.logi.security.common.constant.FieldConstant;
import com.didiglobal.logi.security.common.dto.project.ProjectBriefQueryDTO;
import com.didiglobal.logi.security.common.dto.project.ProjectQueryDTO;
import com.didiglobal.logi.security.common.entity.project.Project;
import com.didiglobal.logi.security.common.entity.project.ProjectBrief;
import com.didiglobal.logi.security.common.po.ProjectPO;
import com.didiglobal.logi.security.dao.ProjectDao;
import com.didiglobal.logi.security.dao.mapper.ProjectMapper;
import com.didiglobal.logi.security.util.CopyBeanUtil;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
/**
* @author cjm
*/
@Component
public class ProjectDaoImpl extends BaseDaoImpl implements ProjectDao {
@Autowired
private ProjectMapper projectMapper;
@Override
public Project selectByProjectId(Integer projectId) {
QueryWrapper queryWrapper = getQueryWrapperWithAppName();
queryWrapper.eq( FieldConstant.ID, projectId);
return CopyBeanUtil.copy(projectMapper.selectOne(queryWrapper), Project.class);
}
@Override
public void insert(Project project) {
ProjectPO projectPO = CopyBeanUtil.copy(project, ProjectPO.class);
projectPO.setAppName(logiSecurityProper.getAppName());
projectMapper.insert(projectPO);
project.setId(projectPO.getId());
}
@Override
public void deleteByProjectId(Integer projectId) {
projectMapper.deleteById(projectId);
}
@Override
public void update(Project project) {
projectMapper.updateById(CopyBeanUtil.copy(project, ProjectPO.class));
}
@Override
public int selectCountByProjectNameAndNotProjectId(String projectName, Integer projectId) {
QueryWrapper queryWrapper = getQueryWrapperWithAppName();
queryWrapper
.eq(FieldConstant.PROJECT_NAME, projectName)
.ne(projectId != null, FieldConstant.ID, projectId);
return projectMapper.selectCount(queryWrapper);
}
private QueryWrapper wrapBriefQuery() {
QueryWrapper queryWrapper = getQueryWrapperWithAppName();
queryWrapper.select(FieldConstant.ID, FieldConstant.PROJECT_CODE, FieldConstant.PROJECT_NAME);
return queryWrapper;
}
@Override
public IPage selectBriefPage(ProjectBriefQueryDTO queryDTO) {
IPage page = new Page<>(queryDTO.getPage(), queryDTO.getSize());
QueryWrapper projectWrapper = wrapBriefQuery();
String projectName = queryDTO.getProjectName();
if(!StringUtils.isEmpty(projectName)) {
projectWrapper.like(FieldConstant.PROJECT_NAME, projectName);
}
projectMapper.selectPage(page, projectWrapper);
return CopyBeanUtil.copyPage(page, ProjectBrief.class);
}
@Override
public List selectAllBriefList() {
return CopyBeanUtil.copyList(projectMapper.selectList(wrapBriefQuery()), ProjectBrief.class);
}
@Override
public IPage selectPageByDeptIdListAndProjectIdList(ProjectQueryDTO queryDTO, List deptIdList,
List projectIdList) {
IPage page = new Page<>(queryDTO.getPage(), queryDTO.getSize());
QueryWrapper projectWrapper = getQueryWrapperWithAppName();
String projectCode = queryDTO.getProjectCode();
String projectName = queryDTO.getProjectName();
projectWrapper
.eq(queryDTO.getRunning() != null, FieldConstant.RUNNING, queryDTO.getRunning())
.eq(!StringUtils.isEmpty(projectCode), FieldConstant.PROJECT_CODE, projectCode)
.like(!StringUtils.isEmpty(projectName), FieldConstant.PROJECT_NAME, projectName)
.in(deptIdList != null && !deptIdList.isEmpty(), FieldConstant.DEPT_ID, deptIdList)
.in(projectIdList != null && !projectIdList.isEmpty(), FieldConstant.ID, projectIdList);
return CopyBeanUtil.copyPage(projectMapper.selectPage(page, projectWrapper), Project.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy