feat: 项目列表支持模糊查询
- 项目名称支持模糊查询 - 分组类别支持模糊查询 - 赛事ID和参赛类型精确匹配 - 添加排序(按sort_order升序,create_time降序) Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.springblade.modules.martial.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -9,6 +10,7 @@ import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.martial.pojo.entity.MartialProject;
|
||||
import org.springblade.modules.martial.service.IMartialProjectService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -42,7 +44,27 @@ public class MartialProjectController extends BladeController {
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页列表", description = "分页查询")
|
||||
public R<IPage<MartialProject>> list(MartialProject project, Query query) {
|
||||
IPage<MartialProject> pages = projectService.page(Condition.getPage(query), Condition.getQueryWrapper(project));
|
||||
QueryWrapper<MartialProject> queryWrapper = new QueryWrapper<>();
|
||||
// 赛事ID精确匹配
|
||||
if (project.getCompetitionId() != null) {
|
||||
queryWrapper.eq("competition_id", project.getCompetitionId());
|
||||
}
|
||||
// 项目名称模糊查询
|
||||
if (StringUtil.isNotBlank(project.getProjectName())) {
|
||||
queryWrapper.like("project_name", project.getProjectName());
|
||||
}
|
||||
// 分组类别模糊查询
|
||||
if (StringUtil.isNotBlank(project.getCategory())) {
|
||||
queryWrapper.like("category", project.getCategory());
|
||||
}
|
||||
// 参赛类型精确匹配
|
||||
if (project.getType() != null) {
|
||||
queryWrapper.eq("type", project.getType());
|
||||
}
|
||||
// 按排序字段和创建时间排序
|
||||
queryWrapper.orderByAsc("sort_order").orderByDesc("create_time");
|
||||
|
||||
IPage<MartialProject> pages = projectService.page(Condition.getPage(query), queryWrapper);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user