Compare commits

...

7 Commits

Author SHA1 Message Date
96fdab94f7
Merge branch 'feature'
All checks were successful
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head This commit looks good
2024-03-11 16:20:32 +08:00
f5259a3526
Merge remote-tracking branch 'origin/feature' into feature
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
2024-03-11 16:20:09 +08:00
8e94e06267
Upload 2024-03-11 16:20:02 +08:00
176yunxuan
bf8ef7c748 优化项目标签和状态查询
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
2024-03-11 16:13:17 +08:00
176yunxuan
c0e2df344e 项目查询优化标签查询
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
2024-03-11 13:11:01 +08:00
176yunxuan
0062854702 项目查询优化标签查询
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
2024-03-11 09:26:50 +08:00
176yunxuan
2494fb38b6 项目查询和新增
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit
2024-03-10 17:36:13 +08:00
11 changed files with 154 additions and 68 deletions

2
.gitignore vendored
View File

@ -35,3 +35,5 @@ build/
### 自定义 ###
*.pdf
/src/main/resources/application-dev.yml
**/.DS_Store
/logs

View File

@ -17,6 +17,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
@Slf4j
@RestController
@ -27,6 +29,7 @@ public class ProjectController {
/**
* 项目展示获取
* 项目轮播图
*
* @param id
* @return
@ -43,13 +46,17 @@ public class ProjectController {
* @return
*/
@GetMapping("/project/get")
public BaseResponse projectGet() {
public BaseResponse projectGet(@RequestParam(required = false) Integer listAll,
@RequestParam(required = false) List<String> tags,
@RequestParam(required = false) Integer isFinish,
HttpServletRequest request) {
log.info("请求接口[GET]: /project/get");
return projectService.get();
return projectService.get(listAll,request,tags,isFinish);
}
/**
* 单个项目的详细
* 项目轮播图
*
* @param name
* @return
@ -62,6 +69,7 @@ public class ProjectController {
/**
* 增加项目展示
* 项目轮播图
*
* @param projectShowVO
* @param request
@ -81,6 +89,7 @@ public class ProjectController {
/**
* 编辑展示的项目
* 项目轮播图
*
* @param projectShowVO
* @param id
@ -106,6 +115,7 @@ public class ProjectController {
/**
* 删除项目展示
* 项目轮播图
*
* @param id
* @param request

View File

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

View File

@ -5,6 +5,7 @@ import com.jsl.oa.model.doData.ProjectDO;
import com.jsl.oa.model.doData.ProjectUserDO;
import com.jsl.oa.model.voData.ProjectInfoVO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -12,8 +13,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 +25,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 +41,18 @@ 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 json_extract(tags,'$.tags')" +
//"like concat('%',#{tags},'%')")
@Select("select * from organize_oa.oa_project where is_finish=#{isFinish} and is_delete=false")
List<ProjectDO>getByIsfinish(Integer isFinish);
List<ProjectDO>getByTags(List<String> tags);
@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 and status=1")
List<ProjectDO> get1(Long userId);
@Select("select * from organize_oa.oa_project where name=#{name}")
ProjectDO getByName(String name);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -4,36 +4,23 @@ 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 = "项目名不为空")
@NotNull(message = "负责人id不能为空")
private Long principalId;
@NotBlank(message = "项目名不能为空")
private String name;
@NotBlank(message = "简介不能为空")
private String description;
@NotNull(message = "周期不能为空")
private Long cycle;
private String file;
private Timestamp completeTime;
private Timestamp deadline;
private Integer status;
private Integer isFinish;
@NotBlank(message = "描述不能为空")
private String introduction;
//@NotNull(message = "填写是否开放")
private Short codeOpen;
private String coreCode;
private String git;
//@NotNull(message = "难度等级不能为空")
private Short difficultyLevel;
@NotNull(message = "项目类型不能为空")
private Integer type;
private Long reward;
//@NotNull(message = "项目状态不能为空")
private Short status;
}

View File

@ -7,6 +7,7 @@ import com.jsl.oa.model.voData.business.info.ProjectShowVO;
import com.jsl.oa.utils.BaseResponse;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
public interface ProjectService {
BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd);
@ -25,7 +26,7 @@ public interface ProjectService {
BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id);
BaseResponse get();
BaseResponse get(Integer listAll, HttpServletRequest request, List<String> tags, Integer isFinish);
BaseResponse getByName(String name);

View File

@ -3,6 +3,7 @@ package com.jsl.oa.services.impl;
import com.jsl.oa.annotations.CheckUserHasPermission;
import com.jsl.oa.dao.ProjectDAO;
import com.jsl.oa.dao.UserDAO;
import com.jsl.oa.mapper.RoleMapper;
import com.jsl.oa.model.doData.ProjectCuttingDO;
import com.jsl.oa.model.doData.ProjectDO;
import com.jsl.oa.model.doData.UserDO;
@ -20,6 +21,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
@ -41,6 +43,7 @@ import java.util.List;
@RequiredArgsConstructor
public class ProjectServiceImpl implements ProjectService {
private final RoleMapper roleMapper;
private final ProjectDAO projectDAO;
private final UserDAO userDAO;
@ -181,10 +184,30 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public BaseResponse get() {
public BaseResponse get(Integer listAll, HttpServletRequest request, List<String> tags, Integer isFinish) {
log.info("\t> 执行 Service 层 ProjectService.get 方法");
List<ProjectDO> projectDOList = projectDAO.get();
return ResultUtil.success(projectDOList);
//获取用户
Long userId= Processing.getAuthHeaderToUserId(request);
//根据状态查询
if(isFinish != null){
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll,tags,isFinish);
return ResultUtil.success(projectDOList);
}
//根据标签查询
if(tags != null && !tags.isEmpty()){
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll,tags,isFinish);
return ResultUtil.success(projectDOList);
}
//判断是否是老师(项目负责人)
if(listAll != null && Processing.checkUserIsTeacher(request,roleMapper)){
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll,tags,isFinish);
return ResultUtil.success(projectDOList);
}else {
List<ProjectDO> projectDOList = projectDAO.get(userId,0,tags,isFinish);
return ResultUtil.success(projectDOList);
}
}
@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) {
// 生成字符集合可以根据需要自定义
String charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

View File

@ -13,32 +13,47 @@
<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>
<select id="getByTags" resultType="com.jsl.oa.model.doData.ProjectDO">
select * from organize_oa.oa_project where
<foreach collection="tags" item="tag" separator=",'%') and json_extract(tags,'$.tags')like concat('%',"
open="json_extract(tags,'$.tags')like concat('%',"
close=",'%') and is_delete=false">
#{tag}
</foreach>
</select>
</mapper>