Commit 20365d17 authored by 刘基明's avatar 刘基明

时间格式化

parent 5fbe7a74
package com.tanpu.community.api.beans.vo.feign.product;
import com.tanpu.community.api.beans.vo.feign.product.Net;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -16,6 +15,9 @@ public class FundCompanyVO {
@ApiModelProperty("icon")
private String img;
@ApiModelProperty("公司类型,0 公募,1 私募,2 白名单,3 私有 ")
private String type;
@ApiModelProperty("公司简介")
private String companyProfile;
......
......@@ -23,7 +23,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -41,10 +40,10 @@ import java.util.List;
@RequestMapping(value = "/api/homepage")
public class HomePageController {
@Autowired
@Resource
private HomePageManager homePageManager;
@Autowired
@Resource
private ThemeManager themeManager;
@Resource
......
......@@ -126,7 +126,7 @@ public class TopicManager {
return CommonResp.error(ErrorCodeConstant.TOPIC_NOT_FOUND.getCode(), "抱歉!该话题已下线。");
}
//
// 检验权限
if (TopicSpecialPermissionEnum.TRUE.getCode().equals(topicEntity.getSpecialPermission()) &&
!topicService.checkPermission(topicId, userHolder.getUserId())) {
return CommonResp.error(ErrorCodeConstant.TOPIC_PERMISSION_ABORT.getCode(), topicService.getPermissionToast(topicId));
......
......@@ -204,8 +204,10 @@ public class TopicService {
} else if (RelTypeEnum.FUND_COMPANY.type.equals(entity.getSubjectType().toString())) {
// 资管人
List<FundCompanyVO> fundCompany = feignService.getFundCompany(Collections.singletonList(entity.getSubjectId()));
FundCompanyVO company = fundCompany.get(0);
company.setType(String.valueOf(entity.getSubjectSubType())); // 公司类型
TopicAttachment attach = TopicAttachment.builder().type(RelTypeEnum.FUND_COMPANY.type)
.detail(TopicAttachmentDetail.builder().fundCompany(fundCompany.get(0)).build()).build();
.detail(TopicAttachmentDetail.builder().fundCompany(company).build()).build();
attachements.add(attach);
} else if (RelTypeEnum.NEW_COURSE_WARE.type.equals(entity.getSubjectType().toString())) {
......
......@@ -2,7 +2,9 @@ package com.tanpu.community.util;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
......@@ -41,16 +43,20 @@ public class TimeUtils {
/**
* 格式化话题列表时间
* 发布时间 = Today,显示时间格式:00:00 ,24小时制
* 发布时间 = Today-1,显示时间格式:昨日 00:00 ,24小时制
* 发布时间 <Today-1,显示时间格式:yyyy年mm月dd日
*/
public static String formatTopicListTime(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
long duration = between.toMinutes();
if (duration < 60 * 24) {
return start.format(DateTimeFormatter.ofPattern(" HH:mm"));
} else if (duration < 60 * 48) {
return start.format(DateTimeFormatter.ofPattern("昨天 HH:mm"));
public static String formatTopicListTime(LocalDateTime target) {
LocalDateTime dayBegin = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
LocalDateTime lastDayBegin = dayBegin.minusDays(1);
if (target.isAfter(dayBegin)) {
return target.format(DateTimeFormatter.ofPattern(" HH:mm"));
} else if (target.isAfter(lastDayBegin)) {
return target.format(DateTimeFormatter.ofPattern("昨天 HH:mm"));
}
return start.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
return target.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
}
public static String format(LocalDateTime start) {
......
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