package com.dsh.other.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.dsh.other.entity.Notice; import com.dsh.other.entity.Phone; import com.dsh.other.feignclient.model.SysNotice; import com.dsh.other.service.NoticeService; import com.dsh.other.service.PhoneService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @RestController @RequestMapping("") public class SystemNoticeController { @Autowired private NoticeService noticeSers; @Autowired private PhoneService phoneService; private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @PostMapping("/base/notice/queryNoticeDetails") public List getSysNoticeDetails() { List notices = new ArrayList<>(); List list = noticeSers.list(new QueryWrapper() .eq("state", 1) .eq("upOrDown", 1) .orderByDesc("insertTime")); if (list.size() > 0) { list.forEach(noList -> { SysNotice notice = new SysNotice(); notice.setNoticeId(noList.getId()); notice.setNoticeTitle(noList.getName()); notice.setNoticeContents(noList.getContent()); notice.setNoticeTime(format.format(noList.getInsertTime())); notices.add(notice); }); } return notices; } @PostMapping("/base/notice/queryNotice") public SysNotice getSysNoticeBuId(@RequestParam("noticeId") Integer noticeId) { SysNotice sysNotice = new SysNotice(); Notice notice = noticeSers.getById(noticeId); if (null != notice) { sysNotice.setNoticeId(notice.getId()); sysNotice.setNoticeTitle(notice.getName()); sysNotice.setNoticeContents(notice.getContent()); sysNotice.setNoticeTime(format.format(notice.getInsertTime())); } return sysNotice; } @PostMapping("/base/notice/sysTell") public List queryCustomerTel() { List tellS = new ArrayList<>(); List list = phoneService.list(); if (list.size() > 0) { String phone = list.get(0).getPhone(); String[] split = phone.split(","); tellS = Arrays.asList(split); } return tellS; } }