项目查询和新增
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit

This commit is contained in:
176yunxuan 2024-03-10 17:36:13 +08:00
parent b2a268ff29
commit 2494fb38b6
10 changed files with 112 additions and 64 deletions

View File

@ -27,6 +27,7 @@ public class ProjectController {
/** /**
* 项目展示获取 * 项目展示获取
* 项目轮播图
* *
* @param id * @param id
* @return * @return
@ -43,13 +44,14 @@ public class ProjectController {
* @return * @return
*/ */
@GetMapping("/project/get") @GetMapping("/project/get")
public BaseResponse projectGet() { public BaseResponse projectGet(@RequestParam(required = false) Integer listAll,HttpServletRequest request) {
log.info("请求接口[GET]: /project/get"); log.info("请求接口[GET]: /project/get");
return projectService.get(); return projectService.get(listAll,request);
} }
/** /**
* 单个项目的详细 * 单个项目的详细
* 项目轮播图
* *
* @param name * @param name
* @return * @return
@ -62,6 +64,7 @@ public class ProjectController {
/** /**
* 增加项目展示 * 增加项目展示
* 项目轮播图
* *
* @param projectShowVO * @param projectShowVO
* @param request * @param request
@ -81,6 +84,7 @@ public class ProjectController {
/** /**
* 编辑展示的项目 * 编辑展示的项目
* 项目轮播图
* *
* @param projectShowVO * @param projectShowVO
* @param id * @param id
@ -106,6 +110,7 @@ public class ProjectController {
/** /**
* 删除项目展示 * 删除项目展示
* 项目轮播图
* *
* @param id * @param id
* @param request * @param request

View File

@ -105,10 +105,14 @@ public class ProjectDAO {
return projectMapper.setProjectShow(setProjectShow); return projectMapper.setProjectShow(setProjectShow);
} }
public List<ProjectDO> get() { public List<ProjectDO> get(Long userId,Integer listAll) {
log.info("\t> 执行 DAO 层 ProjectDAO.get 方法"); log.info("\t> 执行 DAO 层 ProjectDAO.get 方法");
log.info("\t\t> 从 MySQL 获取数据"); log.info("\t\t> 从 MySQL 获取数据");
return projectMapper.get(); if(listAll == 0) {
return projectMapper.get(userId);
}else {
return projectMapper.get1(userId);
}
} }
public ProjectDO getByName(String name) { public ProjectDO getByName(String name) {

View File

@ -12,8 +12,10 @@ import java.util.List;
public interface ProjectMapper { public interface ProjectMapper {
@Insert("insert into organize_oa.oa_project " + @Insert("insert into organize_oa.oa_project " +
"(name, description, introduction, core_code, git,type, reward) " + "(name, description, principal_id, cycle,file,complete_time," +
"value (#{name},#{description},#{introduction},#{coreCode},#{git},#{type},#{reward})") "deadline,status,is_finish) " +
"value (#{name},#{description},#{principalId},#{cycle},#{file}" +
",#{completeTime},#{deadline},#{status},#{isFinish})")
void projectAdd(ProjectInfoVO projectAdd); void projectAdd(ProjectInfoVO projectAdd);
@ -22,11 +24,11 @@ public interface ProjectMapper {
@Select("select * from organize_oa.oa_project where id=#{id}") @Select("select * from organize_oa.oa_project where id=#{id}")
ProjectDO getProjectById(Long id); ProjectDO getProjectById(Long id);
@Select("select * from organize_oa.oa_project_cutting where id in" + @Select("select * from organize_oa.oa_project_work where principal_id=#{uid}")
"(select pid from organize_oa.oa_project_user where uid=#{uid})") //"(select id from organize_oa.oa_project_work where id in)")
List<ProjectCuttingDO> projectGetUserInCutting(Long uid); List<ProjectCuttingDO> projectGetUserInCutting(Long uid);
@Insert("insert into organize_oa.oa_project_user(uid, pid)value (#{uid},#{pid})") @Insert("update organize_oa.oa_project_work set principal_id =#{uid} where id=#{pid}")
void projectAddUserInCutting(Long uid, Long pid); void projectAddUserInCutting(Long uid, Long pid);
@Select("select data from organize_oa.oa_config where value='project_show'") @Select("select data from organize_oa.oa_config where value='project_show'")
@ -38,8 +40,11 @@ public interface ProjectMapper {
@Update("UPDATE organize_oa.oa_config SET data = #{setProjectShow}, updated_at = CURRENT_TIMESTAMP WHERE value = 'project_show'") @Update("UPDATE organize_oa.oa_config SET data = #{setProjectShow}, updated_at = CURRENT_TIMESTAMP WHERE value = 'project_show'")
boolean setProjectShow(String setProjectShow); boolean setProjectShow(String setProjectShow);
@Select("select * from organize_oa.oa_permissions") @Select("select * from organize_oa.oa_project where is_delete=false and status =1")
List<ProjectDO> get(); List<ProjectDO> get(Long userId);
@Select("select * from organize_oa.oa_project where status =1")
List<ProjectDO> get1(Long userId);
@Select("select * from organize_oa.oa_project where name=#{name}") @Select("select * from organize_oa.oa_project where name=#{name}")
ProjectDO getByName(String name); ProjectDO getByName(String name);

View File

@ -20,12 +20,17 @@ import java.sql.Timestamp;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class ProjectCuttingDO { public class ProjectCuttingDO {
private Long id; private Long id;
private Long principalId;
private Long projectId;
private Long pid; private Long pid;
private Long workLoad;
private Long cycle;
private String name; private String name;
private String tag; private String description;
private Short engineering; private Integer is_delete;
private Integer estimatedTime; private Integer is_finish;
private Integer realTime; private Integer status;
private Timestamp createdAt; private boolean type;
private Timestamp updatedAt; private Timestamp beginTime;
private Timestamp completeTime;
} }

View File

@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.sql.Timestamp;
/** /**
* <h1>project 数据表</h1> * <h1>project 数据表</h1>
* <hr/> * <hr/>
@ -18,14 +20,16 @@ import lombok.experimental.Accessors;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class ProjectDO { public class ProjectDO {
private Long id; private Long id;
private Long principalId;
private String tags;
private Long cycle;
private String name; private String name;
private String file;
private String description; private String description;
private String introduction; private Integer is_delete;
private Short codeOpen; private Integer is_finish;
private String coreCode; private boolean status;
private String git; private Timestamp beginTime;
private Short difficultyLevel; private Timestamp completeTime;
private Integer type; private Timestamp deadline;
private Long reward;
private Short status;
} }

View File

@ -4,36 +4,28 @@ import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
@Data @Data
public class ProjectInfoVO { public class ProjectInfoVO {
@NotNull(message = "id不能为空")
private Long id;
@NotBlank(message = "项目名不为空") private Long id;
@NotNull(message = "负责人id不能为空")
private Long principalId;
@NotBlank(message = "项目名不能为空")
private String name; private String name;
@NotBlank(message = "简介不能为空")
private String description; private String description;
@NotBlank(message = "描述不能为空") @NotNull(message = "周期不能为空")
private String introduction; private Long cycle;
//@NotNull(message = "填写是否开放") private String file;
private Short codeOpen;
private String coreCode; private Timestamp completeTime;
private Timestamp deadline;
private Integer status;
private Integer isFinish;
private String git;
//@NotNull(message = "难度等级不能为空")
private Short difficultyLevel;
@NotNull(message = "项目类型不能为空")
private Integer type;
private Long reward;
//@NotNull(message = "项目状态不能为空")
private Short status;
} }

View File

@ -25,7 +25,7 @@ public interface ProjectService {
BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id); BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id);
BaseResponse get(); BaseResponse get(Integer listAll,HttpServletRequest request);
BaseResponse getByName(String name); BaseResponse getByName(String name);

View File

@ -2,6 +2,7 @@ package com.jsl.oa.services.impl;
import com.jsl.oa.annotations.CheckUserHasPermission; import com.jsl.oa.annotations.CheckUserHasPermission;
import com.jsl.oa.dao.ProjectDAO; import com.jsl.oa.dao.ProjectDAO;
import com.jsl.oa.dao.RoleDAO;
import com.jsl.oa.dao.UserDAO; import com.jsl.oa.dao.UserDAO;
import com.jsl.oa.model.doData.ProjectCuttingDO; import com.jsl.oa.model.doData.ProjectCuttingDO;
import com.jsl.oa.model.doData.ProjectDO; import com.jsl.oa.model.doData.ProjectDO;
@ -41,6 +42,7 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ProjectServiceImpl implements ProjectService { public class ProjectServiceImpl implements ProjectService {
private final RoleDAO roleDAO;
private final ProjectDAO projectDAO; private final ProjectDAO projectDAO;
private final UserDAO userDAO; private final UserDAO userDAO;
@ -181,10 +183,19 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public BaseResponse get() { public BaseResponse get(Integer listAll,HttpServletRequest request) {
log.info("\t> 执行 Service 层 ProjectService.get 方法"); log.info("\t> 执行 Service 层 ProjectService.get 方法");
List<ProjectDO> projectDOList = projectDAO.get(); //获取用户
Long userId= Processing.getAuthHeaderToUserId(request);
//判断是否是老师(项目负责人)
if(Processing.checkUserIsTeacher(request,roleDAO.roleMapper)){
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll);
return ResultUtil.success(projectDOList); return ResultUtil.success(projectDOList);
}else {
List<ProjectDO> projectDOList = projectDAO.get(userId,0);
return ResultUtil.success(projectDOList);
}
} }
@Override @Override

View File

@ -177,6 +177,22 @@ public class Processing {
} }
} }
/**
* 检查用户是否是老师
* @param request
* @param roleMapper
* @return
*/
public static @NotNull Boolean checkUserIsTeacher(HttpServletRequest request, @NotNull RoleMapper roleMapper) {
RoleUserDO roleUserDO = roleMapper.getRoleUserByUid(Processing.getAuthHeaderToUserId(request));
if (roleUserDO != null) {
RoleDO roleDO = roleMapper.getRoleByRoleName("teacher");
return roleUserDO.getRid().equals(roleDO.getId());
} else {
return false;
}
}
private static char getCharFromIndex(int index) { private static char getCharFromIndex(int index) {
// 生成字符集合可以根据需要自定义 // 生成字符集合可以根据需要自定义
String charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; String charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

View File

@ -13,30 +13,36 @@
<if test="description != null and description != ''"> <if test="description != null and description != ''">
description = #{description}, description = #{description},
</if> </if>
<if test="introduction != null and introduction != ''"> <if test="principal_id != null and principal_id != ''">
introduction = #{introduction}, principal_id = #{principal_id},
</if> </if>
<if test="codeOpen != null and codeOpen != ''"> <if test="tags != null and tags != ''">
code_open = #{codeOpen}, tags = #{tags},
</if> </if>
<if test="coreCode != null and coreCode != ''"> <if test="cycle != null and cycle != ''">
core_code = #{coreCode}, cycle = #{cycle},
</if> </if>
<if test="git != null and git != ''"> <if test="file != null and file != ''">
git = #{git}, file = #{file},
</if> </if>
<if test="difficultyLevel != null and difficultyLevel != ''"> <if test="begin_time != null and begin_time != ''">
difficulty_level = #{difficultyLevel}, begin_time = #{begin_time},
</if> </if>
<if test="type != null and type != ''"> <if test="complete_time != null and complete_time != ''">
type = #{type}, complete_time = #{complete_time},
</if> </if>
<if test="reward != null and reward != ''"> <if test="deadline != null and deadline != ''">
reward = #{reward}, deadline = #{deadline},
</if> </if>
<if test="status != null and status != ''"> <if test="status != null and status != ''">
status = #{status}, status = #{status},
</if> </if>
<if test="is_finish != null and is_finish != ''">
is_finish = #{is_finish},
</if>
<if test="is_delete != null and is_delete != ''">
is_delete = #{is_delete},
</if>
</set> </set>
where id = #{id} where id = #{id}
</update> </update>