更改了mybatis-plus分页插件的配置;稍微修改了Project相关的实体类和Service实现(未完成)
parent
534f2f7f24
commit
2b3a72d78b
|
@ -21,7 +21,7 @@ public class MybatisPlusConfig {
|
|||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.GAUSS));
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +37,7 @@ public class StaffController {
|
|||
}
|
||||
|
||||
@GetMapping("/timetest")
|
||||
public LocalDateTime timeTest(){
|
||||
public LocalDateTime timeTest() {
|
||||
return LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
@ -35,4 +36,5 @@ public class Project {
|
|||
private Boolean completed;
|
||||
@TableLogic
|
||||
private Boolean deleted;
|
||||
private Integer projectCreator;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import lombok.Data;
|
|||
* @since 2022/6/29 20:54
|
||||
*/
|
||||
@Data
|
||||
@TableName("project_type")
|
||||
public class ProjectType {
|
||||
@TableId(type = IdType.AUTO)
|
||||
Integer projectClassId;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -12,7 +13,6 @@ import lombok.NoArgsConstructor;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class ResultProject {
|
||||
Integer projectId;
|
||||
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.ResultProject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -15,11 +17,17 @@ import java.util.List;
|
|||
* @since 2022/6/29 17:07
|
||||
*/
|
||||
public interface ProjectMapper extends BaseMapper<Project> {
|
||||
@Select("SELECT COUNT(*) FROM project WHERE project_id IN " +
|
||||
"(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})")
|
||||
@Select("""
|
||||
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);
|
||||
@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({
|
||||
@Result(column = "project_id", property = "projectId", id = true),
|
||||
@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,
|
||||
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.ResultProject;
|
||||
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.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 阳勇权
|
||||
* @since 2022/6/29 17:08
|
||||
*/
|
||||
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;
|
||||
|
||||
Boolean setProjectCompleted(String token, Project project) throws TokenException;
|
||||
|
||||
Boolean makeANewProject(Project project) throws TokenException;
|
||||
}
|
||||
|
|
|
@ -6,43 +6,53 @@ import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
|||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||
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.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.sql.Wrapper;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 阳勇权
|
||||
* @since 2022/6/29 19:36
|
||||
*/
|
||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
||||
@Autowired
|
||||
TokenUtils tokenUtils;
|
||||
|
||||
@Override
|
||||
public Page<ResultProject> getOnePageProject(String token) throws TokenException {
|
||||
Integer staffId = tokenUtils.getStaffId(token);
|
||||
return null;
|
||||
public IPage<ResultProject> getOnePageProject(
|
||||
String token,
|
||||
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
|
||||
public Long getProjectTotalNum(String token) throws TokenException{
|
||||
Integer staffId = tokenUtils.getStaffId(token);
|
||||
public Long getProjectTotalNum(String token) throws TokenException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
return baseMapper.getProjectTotalNum(staffId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setProjectCompleted(String token, Project project) throws TokenException{
|
||||
Integer staffId = tokenUtils.getStaffId(token);
|
||||
public Boolean setProjectCompleted(String token, Project project) throws TokenException {
|
||||
Integer staffId = TokenUtils.getStaffId(token);
|
||||
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean makeANewProject(Project project) throws TokenException{
|
||||
public Boolean makeANewProject(Project project) throws TokenException {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue