项目查询和新增
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
This commit is contained in:
parent
b2a268ff29
commit
2494fb38b6
@ -27,6 +27,7 @@ public class ProjectController {
|
||||
|
||||
/**
|
||||
* 项目展示获取
|
||||
* 项目轮播图
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
@ -43,13 +44,14 @@ public class ProjectController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/project/get")
|
||||
public BaseResponse projectGet() {
|
||||
public BaseResponse projectGet(@RequestParam(required = false) Integer listAll,HttpServletRequest request) {
|
||||
log.info("请求接口[GET]: /project/get");
|
||||
return projectService.get();
|
||||
return projectService.get(listAll,request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个项目的详细
|
||||
* 项目轮播图
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
@ -62,6 +64,7 @@ public class ProjectController {
|
||||
|
||||
/**
|
||||
* 增加项目展示
|
||||
* 项目轮播图
|
||||
*
|
||||
* @param projectShowVO
|
||||
* @param request
|
||||
@ -81,6 +84,7 @@ public class ProjectController {
|
||||
|
||||
/**
|
||||
* 编辑展示的项目
|
||||
* 项目轮播图
|
||||
*
|
||||
* @param projectShowVO
|
||||
* @param id
|
||||
@ -106,6 +110,7 @@ public class ProjectController {
|
||||
|
||||
/**
|
||||
* 删除项目展示
|
||||
* 项目轮播图
|
||||
*
|
||||
* @param id
|
||||
* @param request
|
||||
|
@ -105,10 +105,14 @@ public class ProjectDAO {
|
||||
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\t> 从 MySQL 获取数据");
|
||||
return projectMapper.get();
|
||||
if(listAll == 0) {
|
||||
return projectMapper.get(userId);
|
||||
}else {
|
||||
return projectMapper.get1(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectDO getByName(String name) {
|
||||
|
@ -12,8 +12,10 @@ import java.util.List;
|
||||
public interface ProjectMapper {
|
||||
|
||||
@Insert("insert into organize_oa.oa_project " +
|
||||
"(name, description, introduction, core_code, git,type, reward) " +
|
||||
"value (#{name},#{description},#{introduction},#{coreCode},#{git},#{type},#{reward})")
|
||||
"(name, description, principal_id, cycle,file,complete_time," +
|
||||
"deadline,status,is_finish) " +
|
||||
"value (#{name},#{description},#{principalId},#{cycle},#{file}" +
|
||||
",#{completeTime},#{deadline},#{status},#{isFinish})")
|
||||
void projectAdd(ProjectInfoVO projectAdd);
|
||||
|
||||
|
||||
@ -22,11 +24,11 @@ public interface ProjectMapper {
|
||||
@Select("select * from organize_oa.oa_project where id=#{id}")
|
||||
ProjectDO getProjectById(Long id);
|
||||
|
||||
@Select("select * from organize_oa.oa_project_cutting where id in" +
|
||||
"(select pid from organize_oa.oa_project_user where uid=#{uid})")
|
||||
@Select("select * from organize_oa.oa_project_work where principal_id=#{uid}")
|
||||
//"(select id from organize_oa.oa_project_work where id in)")
|
||||
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);
|
||||
|
||||
@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'")
|
||||
boolean setProjectShow(String setProjectShow);
|
||||
|
||||
@Select("select * from organize_oa.oa_permissions")
|
||||
List<ProjectDO> get();
|
||||
@Select("select * from organize_oa.oa_project where is_delete=false and status =1")
|
||||
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}")
|
||||
ProjectDO getByName(String name);
|
||||
|
@ -20,12 +20,17 @@ import java.sql.Timestamp;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ProjectCuttingDO {
|
||||
private Long id;
|
||||
private Long principalId;
|
||||
private Long projectId;
|
||||
private Long pid;
|
||||
private Long workLoad;
|
||||
private Long cycle;
|
||||
private String name;
|
||||
private String tag;
|
||||
private Short engineering;
|
||||
private Integer estimatedTime;
|
||||
private Integer realTime;
|
||||
private Timestamp createdAt;
|
||||
private Timestamp updatedAt;
|
||||
private String description;
|
||||
private Integer is_delete;
|
||||
private Integer is_finish;
|
||||
private Integer status;
|
||||
private boolean type;
|
||||
private Timestamp beginTime;
|
||||
private Timestamp completeTime;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* <h1>project 数据表</h1>
|
||||
* <hr/>
|
||||
@ -18,14 +20,16 @@ import lombok.experimental.Accessors;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ProjectDO {
|
||||
private Long id;
|
||||
private Long principalId;
|
||||
private String tags;
|
||||
private Long cycle;
|
||||
private String name;
|
||||
private String file;
|
||||
private String description;
|
||||
private String introduction;
|
||||
private Short codeOpen;
|
||||
private String coreCode;
|
||||
private String git;
|
||||
private Short difficultyLevel;
|
||||
private Integer type;
|
||||
private Long reward;
|
||||
private Short status;
|
||||
private Integer is_delete;
|
||||
private Integer is_finish;
|
||||
private boolean status;
|
||||
private Timestamp beginTime;
|
||||
private Timestamp completeTime;
|
||||
private Timestamp deadline;
|
||||
}
|
||||
|
@ -4,36 +4,28 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
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;
|
||||
|
||||
@NotBlank(message = "简介不能为空")
|
||||
private String description;
|
||||
|
||||
@NotBlank(message = "描述不能为空")
|
||||
private String introduction;
|
||||
@NotNull(message = "周期不能为空")
|
||||
private Long cycle;
|
||||
|
||||
//@NotNull(message = "填写是否开放")
|
||||
private Short codeOpen;
|
||||
private String file;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public interface ProjectService {
|
||||
|
||||
BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id);
|
||||
|
||||
BaseResponse get();
|
||||
BaseResponse get(Integer listAll,HttpServletRequest request);
|
||||
|
||||
BaseResponse getByName(String name);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.jsl.oa.services.impl;
|
||||
|
||||
import com.jsl.oa.annotations.CheckUserHasPermission;
|
||||
import com.jsl.oa.dao.ProjectDAO;
|
||||
import com.jsl.oa.dao.RoleDAO;
|
||||
import com.jsl.oa.dao.UserDAO;
|
||||
import com.jsl.oa.model.doData.ProjectCuttingDO;
|
||||
import com.jsl.oa.model.doData.ProjectDO;
|
||||
@ -41,6 +42,7 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
private final RoleDAO roleDAO;
|
||||
private final ProjectDAO projectDAO;
|
||||
private final UserDAO userDAO;
|
||||
|
||||
@ -181,10 +183,19 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse get() {
|
||||
public BaseResponse get(Integer listAll,HttpServletRequest request) {
|
||||
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);
|
||||
}else {
|
||||
List<ProjectDO> projectDOList = projectDAO.get(userId,0);
|
||||
return ResultUtil.success(projectDOList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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) {
|
||||
// 生成字符集合,可以根据需要自定义
|
||||
String charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
@ -13,30 +13,36 @@
|
||||
<if test="description != null and description != ''">
|
||||
description = #{description},
|
||||
</if>
|
||||
<if test="introduction != null and introduction != ''">
|
||||
introduction = #{introduction},
|
||||
<if test="principal_id != null and principal_id != ''">
|
||||
principal_id = #{principal_id},
|
||||
</if>
|
||||
<if test="codeOpen != null and codeOpen != ''">
|
||||
code_open = #{codeOpen},
|
||||
<if test="tags != null and tags != ''">
|
||||
tags = #{tags},
|
||||
</if>
|
||||
<if test="coreCode != null and coreCode != ''">
|
||||
core_code = #{coreCode},
|
||||
<if test="cycle != null and cycle != ''">
|
||||
cycle = #{cycle},
|
||||
</if>
|
||||
<if test="git != null and git != ''">
|
||||
git = #{git},
|
||||
<if test="file != null and file != ''">
|
||||
file = #{file},
|
||||
</if>
|
||||
<if test="difficultyLevel != null and difficultyLevel != ''">
|
||||
difficulty_level = #{difficultyLevel},
|
||||
<if test="begin_time != null and begin_time != ''">
|
||||
begin_time = #{begin_time},
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
type = #{type},
|
||||
<if test="complete_time != null and complete_time != ''">
|
||||
complete_time = #{complete_time},
|
||||
</if>
|
||||
<if test="reward != null and reward != ''">
|
||||
reward = #{reward},
|
||||
<if test="deadline != null and deadline != ''">
|
||||
deadline = #{deadline},
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
status = #{status},
|
||||
</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>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
Loading…
x
Reference in New Issue
Block a user