linxk hace 1 semana
padre
commit
0d3eefbc36

+ 1 - 1
cif-service/src/main/java/com/txz/cif/core/cache/CacheType.java

@@ -11,7 +11,7 @@ public enum CacheType {
 	 */
 	AppSecretKey,
 
-	Top,
+	Top2,
 
 	sjtcRefundCallback,
 

+ 7 - 3
cif-service/src/main/java/com/txz/cif/web/RedEnvelopeApiController.java

@@ -11,6 +11,7 @@ import com.txz.cif.service.RedEnvelopeService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.txz.cif.service.UserService;
+import com.txz.cif.web.bo.TopBO;
 import com.txz.cif.web.bo.UserDetailBo;
 import com.txz.cif.web.bo.UserTopBo;
 import com.txz.cif.web.para.RedEnvelopeListParam;
@@ -99,14 +100,15 @@ public class RedEnvelopeApiController {
 
 	@GetMapping("/top")
 	@ApiOperation(value = "排行榜type 1 7天收益排行",httpMethod = "GET")
-	public Result<List<UserTopBo>> top(@RequestParam(defaultValue = "1") Integer type,@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer size) {
-		String key = CacheKey.generateKey(CacheType.Top,type+":"+page+":"+size).toString();
+	public Result<TopBO> top(@RequestParam(defaultValue = "1") Integer type, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
+		String key = CacheKey.generateKey(CacheType.Top2,type+":"+page+":"+size).toString();
 		Object o = redisUtil.get(key);
 		if (o != null){
-			return ResultGenerator.genSuccessResult(JSONUtil.toBean(o.toString(),PageInfo.class));
+			return ResultGenerator.genSuccessResult(JSONUtil.toBean(o.toString(),TopBO.class));
 		}
 		List<UserTopBo> tops= redEnvelopeService.top(type,page,size);
 		PageInfo pageInfo = new PageInfo(tops);
+		TopBO bo = new TopBO();
 		pageInfo.setList(tops.stream().map(e->{
 			User user = userService.findById(e.getUserId());
 			if (user != null){
@@ -130,6 +132,8 @@ public class RedEnvelopeApiController {
 			}
 			return e;
 		}).collect(Collectors.toList()));
+		bo.setUsers(pageInfo);
+		bo.setUpdateTime(DateUtil.date());
 		redisUtil.set(key,JSONUtil.toJsonStr(pageInfo),1, TimeUnit.DAYS);
 		return ResultGenerator.genSuccessResult(pageInfo);
 	}

+ 21 - 0
cif-service/src/main/java/com/txz/cif/web/bo/TopBO.java

@@ -0,0 +1,21 @@
+package com.txz.cif.web.bo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.github.pagehelper.PageInfo;
+import lombok.*;
+
+import java.util.Date;
+
+@Getter
+@Setter
+@ToString
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class TopBO {
+
+    private PageInfo<TopBO> users;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+}