Commit 9f9f3f35 authored by Administrator's avatar Administrator

赛事列表接口增加赛事类型条件

parent b023b13e
......@@ -198,6 +198,9 @@
<if test="@org.apache.commons.lang3.StringUtils@isNotBlank(param.keyword)">
and a.cmpt_name like concat('%',#{param.keyword},'%')
</if>
<if test="@org.apache.commons.lang3.StringUtils@isNotBlank(param.cmptType)">
and c.`type`= #{param.cmptType}
</if>
<if test="param.type == 1">
and now() >= c.openTime and c.deadLine >= now()
</if>
......
......@@ -198,7 +198,7 @@ public class CmptService {
public Page<List<Cmpt>> queryCmpt(Pageable page, Map<String, String> param) {
// 响应级缓存:同一筛选条件+分页 的所有用户看到相同结果,缓存1分钟
// 1000 req/s 下,60秒窗口内每个缓存key仅查DB一次,DB压力降至 < 0.02 req/s
String responseCacheKey = CacheTemplate.REDIS_KEY_PREFIX + CacheTemplate.NS_CMPT_LIST_RESP + ":" + param.get("userId") + ":" + param.get("type")
String responseCacheKey = CacheTemplate.REDIS_KEY_PREFIX + CacheTemplate.NS_CMPT_LIST_RESP + ":" + param.get("userId") + ":" + param.get("type") + ":" + param.get("cmptType")
+ ":" + param.get("keyword") + ":" + param.get("partnerId")
+ ":" + page.getPageNumber() + ":" + page.getPageSize();
Object cached = valueOperations.get(responseCacheKey);
......@@ -214,7 +214,7 @@ public class CmptService {
}
// count 短时缓存:同一筛选条件翻页时避免重复执行跨库COUNT查询
String countCacheKey = CacheTemplate.REDIS_KEY_PREFIX + CacheTemplate.NS_CMPT_LIST_COUNT + ":" + param.get("userId") + ":" + param.get("type") + ":" + param.get("keyword") + ":" + param.get("partnerId");
String countCacheKey = CacheTemplate.REDIS_KEY_PREFIX + CacheTemplate.NS_CMPT_LIST_COUNT + ":" + param.get("userId") + ":" + param.get("type") + ":" + param.get("cmptType") + ":" + param.get("keyword") + ":" + param.get("partnerId");
Long count = null;
Object cachedCount = valueOperations.get(countCacheKey);
if (cachedCount != null) {
......
......@@ -45,7 +45,7 @@ import java.util.concurrent.TimeUnit;
@Log4j2
@RestController
@RequestMapping("api")
@Api(value = "赛客助手小程序api", tags = "赛客助手小程序api")
@Api(value = "赛事助手小程序api", tags = "赛事助手小程序api")
@ApiSort(1)
public class MicroApiController {
private static final String SIGNING_CODE = "1";
......@@ -457,16 +457,19 @@ public class MicroApiController {
/**
* 小程序赛事列表接口
* 赛事助手小程序赛事列表接口
*
* @return 赛事列表
*/
@PostMapping(value = "/cmpt")
@ApiResponses({@ApiResponse(code = 200, message = "成功"), @ApiResponse(code = -1, message = "失败", response = ObjectUtils.Null.class), @ApiResponse(code = 200, message = "成功", response = Page.class, responseContainer = "List")})
@ApiImplicitParams({@ApiImplicitParam(value = "页码", name = "page", required = false, paramType = "query"), @ApiImplicitParam(value = "条数", name = "size", required = false, paramType = "query"), @ApiImplicitParam(value = "关键字", name = "keyword", required = false)})
@ApiImplicitParams({@ApiImplicitParam(value = "页码", name = "page", required = false, paramType = "query"),
@ApiImplicitParam(value = "条数", name = "size", required = false, paramType = "query"),
@ApiImplicitParam(value = "关键字", name = "keyword", required = false)})
@ApiOperation(value = "赛事列表", notes = "赛事列表,与查询接口一致", tags = "首页接口")
public Page<List<Cmpt>> cmpt(@ApiIgnore Pageable page, String keyword, HttpServletRequest request) {
int type = NumberUtils.toInt(request.getParameter("type"), 0);
String cmptType = request.getParameter("cmptType");
String partnerId = request.getParameter("partnerId");
String creator = request.getParameter("userId");
Partner partner = cmptService.getPartnerById(partnerId);
......@@ -481,6 +484,7 @@ public class MicroApiController {
param.put("userId", partner.getUserId() + "");
param.put("creator", creator);
param.put("type", type + "");
param.put("cmptType", cmptType);
param.put("keyword", keyword);
param.put("partnerId", partnerId);
Page<List<Cmpt>> result = cmptService.queryCmpt(page, param);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment