更改了mybatis-plus分页插件的配置;稍微修改了Project相关的实体类和Service实现(未完成)
parent
534f2f7f24
commit
2b3a72d78b
|
@ -21,7 +21,7 @@ public class MybatisPlusConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.GAUSS));
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||||
return interceptor;
|
return interceptor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 佘语殊
|
||||||
|
* @since 2022/6/30 11:24
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/project")
|
||||||
|
public class ProjectController {
|
||||||
|
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
@ -35,4 +36,5 @@ public class Project {
|
||||||
private Boolean completed;
|
private Boolean completed;
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private Boolean deleted;
|
private Boolean deleted;
|
||||||
|
private Integer projectCreator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import lombok.Data;
|
||||||
* @since 2022/6/29 20:54
|
* @since 2022/6/29 20:54
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("project_type")
|
|
||||||
public class ProjectType {
|
public class ProjectType {
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
Integer projectClassId;
|
Integer projectClassId;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -12,7 +13,6 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
|
||||||
public class ResultProject {
|
public class ResultProject {
|
||||||
Integer projectId;
|
Integer projectId;
|
||||||
String projectName;
|
String projectName;
|
||||||
|
|
|
@ -2,8 +2,10 @@ package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -15,11 +17,17 @@ import java.util.List;
|
||||||
* @since 2022/6/29 17:07
|
* @since 2022/6/29 17:07
|
||||||
*/
|
*/
|
||||||
public interface ProjectMapper extends BaseMapper<Project> {
|
public interface ProjectMapper extends BaseMapper<Project> {
|
||||||
@Select("SELECT COUNT(*) FROM project WHERE project_id IN " +
|
@Select("""
|
||||||
"(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})")
|
SELECT COUNT(*) FROM project WHERE project_id IN
|
||||||
|
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id});
|
||||||
|
""")
|
||||||
Long getProjectTotalNum(@Param("id") Integer staffId);
|
Long getProjectTotalNum(@Param("id") Integer staffId);
|
||||||
@Select("SELECT * FROM project WHERE project_id IN " +
|
|
||||||
"(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})")
|
@Select("""
|
||||||
|
SELECT * FROM project WHERE project_id IN
|
||||||
|
(SELECT DISTINCT project_id FROM project_group)
|
||||||
|
${ew.customSqlSegment};
|
||||||
|
""")
|
||||||
@Results({
|
@Results({
|
||||||
@Result(column = "project_id", property = "projectId", id = true),
|
@Result(column = "project_id", property = "projectId", id = true),
|
||||||
@Result(column = "project_name", property = "projectName"),
|
@Result(column = "project_name", property = "projectName"),
|
||||||
|
@ -30,5 +38,5 @@ public interface ProjectMapper extends BaseMapper<Project> {
|
||||||
@Result(column = "{id = project_subclass_id}", property = "projectSubClassName", javaType = String.class,
|
@Result(column = "{id = project_subclass_id}", property = "projectSubClassName", javaType = String.class,
|
||||||
one = @One(select = "cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper.findClassNameById"))
|
one = @One(select = "cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper.findClassNameById"))
|
||||||
})
|
})
|
||||||
Page<ResultProject> findMyProject(Page<ResultProject> pg, @Param("id") Integer staffId);
|
IPage<ResultProject> findMyProject(IPage<ResultProject> pg, @Param("id") Integer staffId,@Param(Constants.WRAPPER) Wrapper<Project> wrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,22 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 阳勇权
|
* @author 阳勇权
|
||||||
* @since 2022/6/29 17:08
|
* @since 2022/6/29 17:08
|
||||||
*/
|
*/
|
||||||
public interface IProjectService extends IService<Project> {
|
public interface IProjectService extends IService<Project> {
|
||||||
Page<ResultProject> getOnePageProject(String toke) throws TokenException;
|
IPage<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
|
||||||
|
|
||||||
Long getProjectTotalNum(String token) throws TokenException;
|
Long getProjectTotalNum(String token) throws TokenException;
|
||||||
|
|
||||||
Boolean setProjectCompleted(String token, Project project) throws TokenException;
|
Boolean setProjectCompleted(String token, Project project) throws TokenException;
|
||||||
|
|
||||||
Boolean makeANewProject(Project project) throws TokenException;
|
Boolean makeANewProject(Project project) throws TokenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,36 +6,46 @@ import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.WrapperUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.sql.Wrapper;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 阳勇权
|
* @author 阳勇权
|
||||||
* @since 2022/6/29 19:36
|
* @since 2022/6/29 19:36
|
||||||
*/
|
*/
|
||||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||||
@Autowired
|
|
||||||
TokenUtils tokenUtils;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ResultProject> getOnePageProject(String token) throws TokenException {
|
public IPage<ResultProject> getOnePageProject(
|
||||||
Integer staffId = tokenUtils.getStaffId(token);
|
String token,
|
||||||
return null;
|
Integer pageCurrent,
|
||||||
|
Integer pageSize,
|
||||||
|
Map<String, Object> params
|
||||||
|
) throws TokenException {
|
||||||
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
|
|
||||||
|
return baseMapper.findMyProject(new Page<>(pageCurrent, pageSize), staffId,
|
||||||
|
Wrappers.<Project>query()
|
||||||
|
.allEq(WrapperUtils.getWrappedMapWithoutTime(params))
|
||||||
|
//.lambda()
|
||||||
|
//.between(params.get("projectStartTimeStart")!=null,Project::getProjectStartTime,)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getProjectTotalNum(String token) throws TokenException {
|
public Long getProjectTotalNum(String token) throws TokenException {
|
||||||
Integer staffId = tokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
return baseMapper.getProjectTotalNum(staffId);
|
return baseMapper.getProjectTotalNum(staffId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean setProjectCompleted(String token, Project project) throws TokenException {
|
public Boolean setProjectCompleted(String token, Project project) throws TokenException {
|
||||||
Integer staffId = tokenUtils.getStaffId(token);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue