项目查询优化标签查询
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
0062854702
commit
c0e2df344e
|
@ -17,6 +17,8 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -45,7 +47,7 @@ public class ProjectController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/project/get")
|
@GetMapping("/project/get")
|
||||||
public BaseResponse projectGet(@RequestParam(required = false) Integer listAll,
|
public BaseResponse projectGet(@RequestParam(required = false) Integer listAll,
|
||||||
@RequestParam(required = false) String tags,
|
@RequestParam(required = false) List<String> tags,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
log.info("请求接口[GET]: /project/get");
|
log.info("请求接口[GET]: /project/get");
|
||||||
return projectService.get(listAll,request,tags);
|
return projectService.get(listAll,request,tags);
|
||||||
|
|
|
@ -105,10 +105,10 @@ public class ProjectDAO {
|
||||||
return projectMapper.setProjectShow(setProjectShow);
|
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> 执行 DAO 层 ProjectDAO.get 方法");
|
||||||
log.info("\t\t> 从 MySQL 获取数据");
|
log.info("\t\t> 从 MySQL 获取数据");
|
||||||
if(tags != null){
|
if(tags != null && !tags.isEmpty()){
|
||||||
return projectMapper.getByTags(tags);
|
return projectMapper.getByTags(tags);
|
||||||
}
|
}
|
||||||
if(listAll == 0) {
|
if(listAll == 0) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.jsl.oa.model.doData.ProjectDO;
|
||||||
import com.jsl.oa.model.doData.ProjectUserDO;
|
import com.jsl.oa.model.doData.ProjectUserDO;
|
||||||
import com.jsl.oa.model.voData.ProjectInfoVO;
|
import com.jsl.oa.model.voData.ProjectInfoVO;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
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'")
|
@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_project where json_extract(tags,'$.tags')" +
|
//@Select("select * from organize_oa.oa_project where json_extract(tags,'$.tags')" +
|
||||||
"like concat('%',#{tags},'%')")
|
//"like concat('%',#{tags},'%')")
|
||||||
List<ProjectDO>getByTags(String tags);
|
List<ProjectDO>getByTags(List<String> tags);
|
||||||
|
|
||||||
@Select("select * from organize_oa.oa_project where is_delete=false and status =1")
|
@Select("select * from organize_oa.oa_project where is_delete=false and status =1")
|
||||||
List<ProjectDO> get(Long userId);
|
List<ProjectDO> get(Long userId);
|
||||||
|
|
|
@ -5,8 +5,10 @@ import com.jsl.oa.model.voData.ProjectCuttingEditVO;
|
||||||
import com.jsl.oa.model.voData.ProjectInfoVO;
|
import com.jsl.oa.model.voData.ProjectInfoVO;
|
||||||
import com.jsl.oa.model.voData.business.info.ProjectShowVO;
|
import com.jsl.oa.model.voData.business.info.ProjectShowVO;
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
|
import org.apache.catalina.LifecycleState;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ProjectService {
|
public interface ProjectService {
|
||||||
BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd);
|
BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd);
|
||||||
|
@ -25,7 +27,7 @@ public interface ProjectService {
|
||||||
|
|
||||||
BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id);
|
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);
|
BaseResponse getByName(String name);
|
||||||
|
|
||||||
|
|
|
@ -184,12 +184,12 @@ public class ProjectServiceImpl implements ProjectService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 方法");
|
log.info("\t> 执行 Service 层 ProjectService.get 方法");
|
||||||
//获取用户
|
//获取用户
|
||||||
Long userId= Processing.getAuthHeaderToUserId(request);
|
Long userId= Processing.getAuthHeaderToUserId(request);
|
||||||
//根据标签查询
|
//根据标签查询
|
||||||
if(tags != null){
|
if(tags != null && !tags.isEmpty()){
|
||||||
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll,tags);
|
List<ProjectDO> projectDOList = projectDAO.get(userId,listAll,tags);
|
||||||
return ResultUtil.success(projectDOList);
|
return ResultUtil.success(projectDOList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,11 @@
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</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>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user