Commit 51f16d19 by yangfangfang

Merge branch 'master' of git.minrow.com:reyun/saasio

parents 97381058 5d412e5f
...@@ -40,7 +40,7 @@ public class IONotice { ...@@ -40,7 +40,7 @@ public class IONotice {
private Boolean release; private Boolean release;
private boolean isRead; private Boolean isRead = false;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
...@@ -224,11 +224,11 @@ public class IONotice { ...@@ -224,11 +224,11 @@ public class IONotice {
} }
@Transient @Transient
public boolean getIsRead() { public Boolean getIsRead() {
return isRead; return isRead;
} }
public void setIsRead(boolean isRead) { public void setIsRead(Boolean isRead) {
this.isRead = isRead; this.isRead = isRead;
} }
} }
...@@ -16,7 +16,7 @@ public interface NoticeRepository extends JpaRepository<IONotice, Long> { ...@@ -16,7 +16,7 @@ public interface NoticeRepository extends JpaRepository<IONotice, Long> {
// @Query(value = "select * from ionotice n where n.isdeploy is true and (io_account like %?1% or io_account = '-1') order by deploy_date desc", nativeQuery = true) // @Query(value = "select * from ionotice n where n.isdeploy is true and (io_account like %?1% or io_account = '-1') order by deploy_date desc", nativeQuery = true)
// List<IONotice> listRecentDeployNotice(String email); // List<IONotice> listRecentDeployNotice(String email);
@Query(value = "select * from ionotice n where n.isdeploy is true and n.modify_date>= ?1 and (io_account='-1' or io_account like CONCAT('%<',?2,'>%')) union select * from ionotice where is_top=1 and isdeploy is true and modify_date< ?1 and (io_account='-1' or io_account like CONCAT('%<',?2,'>%')) order by modify_date desc" @Query(value = "select * from ionotice n where n.isdeploy is true and n.deploy_date>= ?1 and (io_account='-1' or io_account like CONCAT('%<',?2,'>%')) union select * from ionotice where is_top=1 and isdeploy is true and deploy_date< ?1 and (io_account='-1' or io_account like CONCAT('%<',?2,'>%')) order by deploy_date desc"
, nativeQuery = true) , nativeQuery = true)
List<IONotice> listRecentDeployNotice(String currentDate, Long rootParent); List<IONotice> listRecentDeployNotice(String currentDate, Long rootParent);
......
...@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -38,6 +39,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -38,6 +39,7 @@ public class NoticeServiceImpl implements NoticeService {
Account account = accountRepository.findOne(accountId); Account account = accountRepository.findOne(accountId);
List<IONotice> recentDeployNoticeList = noticeRepository.listRecentDeployNotice(DateUtil.getBeforeDays(7), account.getRootParent()); List<IONotice> recentDeployNoticeList = noticeRepository.listRecentDeployNotice(DateUtil.getBeforeDays(7), account.getRootParent());
List<IONotice> result = new ArrayList<>();
if (!CollectionUtils.isEmpty(recentDeployNoticeList)) { if (!CollectionUtils.isEmpty(recentDeployNoticeList)) {
...@@ -58,9 +60,29 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -58,9 +60,29 @@ public class NoticeServiceImpl implements NoticeService {
} }
} }
} }
List<IONotice> unreadTopList = new ArrayList<>();
List<IONotice> unreadNotTopList = new ArrayList<>();
List<IONotice> readTopList = new ArrayList<>();
List<IONotice> readNotTopList = new ArrayList<>();
for (IONotice notice : recentDeployNoticeList) {
boolean isread = notice.getIsRead()==null?false:notice.getIsRead();
if (!isread && notice.getIs_top()) {
unreadTopList.add(notice);
} else if (!isread && !notice.getIs_top()) {
unreadNotTopList.add(notice);
} else if (isread && notice.getIs_top()) {
readTopList.add(notice);
} else {
readNotTopList.add(notice);
}
}
result.addAll(unreadTopList);
result.addAll(unreadNotTopList);
result.addAll(readTopList);
result.addAll(readNotTopList);
} }
return recentDeployNoticeList; return result;
} }
@Override @Override
......
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