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

时间格式化

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