项目查询优化标签查询
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit

This commit is contained in:
176yunxuan 2024-03-11 13:11:01 +08:00
parent 0062854702
commit c0e2df344e
6 changed files with 21 additions and 9 deletions

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
@ -45,7 +47,7 @@ public class ProjectController {
*/
@GetMapping("/project/get")
public BaseResponse projectGet(@RequestParam(required = false) Integer listAll,
@RequestParam(required = false) String tags,
@RequestParam(required = false) List<String> tags,
HttpServletRequest request) {
log.info("请求接口[GET]: /project/get");
return projectService.get(listAll,request,tags);

View File

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

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;
@ -40,9 +41,9 @@ 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_project where json_extract(tags,'$.tags')" +
"like concat('%',#{tags},'%')")
List<ProjectDO>getByTags(String tags);
//@Select("select * from organize_oa.oa_project where json_extract(tags,'$.tags')" +
//"like concat('%',#{tags},'%')")
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);

View File

@ -5,8 +5,10 @@ import com.jsl.oa.model.voData.ProjectCuttingEditVO;
import com.jsl.oa.model.voData.ProjectInfoVO;
import com.jsl.oa.model.voData.business.info.ProjectShowVO;
import com.jsl.oa.utils.BaseResponse;
import org.apache.catalina.LifecycleState;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
public interface ProjectService {
BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd);
@ -25,7 +27,7 @@ public interface ProjectService {
BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id);
BaseResponse get(Integer listAll,HttpServletRequest request,String tags);
BaseResponse get(Integer listAll, HttpServletRequest request, List<String> tags);
BaseResponse getByName(String name);

View File

@ -184,12 +184,12 @@ public class ProjectServiceImpl implements ProjectService {
}
@Override
public BaseResponse get(Integer listAll,HttpServletRequest request,String tags) {
public BaseResponse get(Integer listAll,HttpServletRequest request,List<String> tags) {
log.info("\t> 执行 Service 层 ProjectService.get 方法");
//获取用户
Long userId= Processing.getAuthHeaderToUserId(request);
//根据标签查询
if(tags != null){
if(tags != null && !tags.isEmpty()){
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll,tags);
return ResultUtil.success(projectDOList);
}

View File

@ -47,4 +47,11 @@
where id = #{id}
</update>
<select id="getByTags" resultType="com.jsl.oa.model.doData.ProjectDO">
select * from organize_oa.oa_project where json_extract(tags,'$.tags')like concat
<foreach collection="tags" item="tag" separator=",'%'" open="('%'," close=",'%')">
#{tag}
</foreach>
</select>
</mapper>