|
|
|
@ -27,6 +27,8 @@ import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
|
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
|
|
|
|
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
|
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
@ -64,7 +66,6 @@ import io.swagger.annotations.ApiParam;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
import util.DateUtil;
|
|
|
|
|
import util.IdWorker;
|
|
|
|
|
import util.ScaleFilter;
|
|
|
|
|
import util.StringTools;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@ -72,6 +73,7 @@ import util.StringTools;
|
|
|
|
|
@RequestMapping("/my")
|
|
|
|
|
@Api(tags = "MyController")
|
|
|
|
|
public class MyController extends BaseController {
|
|
|
|
|
private static final String REDIS_KEY_THANKS = "thanks";
|
|
|
|
|
@Autowired
|
|
|
|
|
private S3Service s3Service;
|
|
|
|
|
@Autowired
|
|
|
|
@ -96,6 +98,9 @@ public class MyController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SensitiveWordBs sensitiveWordBs;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
public static String USER_AVATAR_DIRECTORY = "user/avatar/";
|
|
|
|
|
public static String USER_FEEDBACK_IMAGE_DIRECTORY = "user/feedback/";
|
|
|
|
|
|
|
|
|
@ -400,8 +405,17 @@ public class MyController extends BaseController {
|
|
|
|
|
@ApiOperation(value = "11.感谢", notes = "贡献者列表")
|
|
|
|
|
@GetMapping("/thanks")
|
|
|
|
|
public Result<List<UserRespDTO>> getThanks() {
|
|
|
|
|
List<UserRespDTO> list=userInfoService.getThanks().stream().sorted(Comparator.comparing(u->getIndex(u))).map(user->getUserRespDTO(user, false, Collections.emptySet())).collect(Collectors.toList());
|
|
|
|
|
return Result.success(list);
|
|
|
|
|
return Result.success(getThankList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private List<UserRespDTO> getThankList() {
|
|
|
|
|
List<UserRespDTO> thanks = (List<UserRespDTO>) redisTemplate.opsForValue().get(REDIS_KEY_THANKS);
|
|
|
|
|
if (CollectionUtils.isEmpty(thanks)) {
|
|
|
|
|
thanks = userInfoService.getThanks().stream().sorted(Comparator.comparing(u->getIndex(u))).map(user->getUserRespDTO(user, false, Collections.emptySet())).collect(Collectors.toList());
|
|
|
|
|
redisTemplate.opsForValue().set(REDIS_KEY_THANKS, thanks);
|
|
|
|
|
}
|
|
|
|
|
return thanks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Integer getIndex(UserInfo u) {
|
|
|
|
|