增加消息查询服务
This commit is contained in:
@ -0,0 +1,68 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.service.IBizMessageQueryService;
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.vo.DescribeSiteMsgDetailVO;
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.vo.DescribeSiteMsgVO;
|
||||
|
||||
/**
|
||||
* 消息查询服务
|
||||
*
|
||||
* @author ajaxfan
|
||||
*/
|
||||
@RestController()
|
||||
@RequestMapping("/v1/message/")
|
||||
public class BizMessageQueryController {
|
||||
|
||||
private @Autowired IBizMessageQueryService service;
|
||||
|
||||
/**
|
||||
* 消息概要清单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("describeSiteMsg")
|
||||
@ResponseStatus(code = HttpStatus.OK)
|
||||
public List<DescribeSiteMsgVO> describeSiteMsg() {
|
||||
// Dao -> Vo
|
||||
return service.listOutline().stream().map(source -> {
|
||||
DescribeSiteMsgVO vo = new DescribeSiteMsgVO();
|
||||
vo.setMsgId(source.getId());
|
||||
BeanUtils.copyProperties(source, vo);
|
||||
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息明细
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("describeSiteMsgDetail/{id}")
|
||||
@ResponseStatus(code = HttpStatus.OK)
|
||||
public DescribeSiteMsgDetailVO describeSiteMsgDetail(@PathVariable("id") String id) {
|
||||
return Optional.ofNullable(service.getDetailById(id)).map(source -> {
|
||||
DescribeSiteMsgDetailVO vo = new DescribeSiteMsgDetailVO();
|
||||
vo.setMsgId(source.getId());
|
||||
BeanUtils.copyProperties(source, vo);
|
||||
|
||||
return vo;
|
||||
}).orElseGet(DescribeSiteMsgDetailVO::new);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage;
|
||||
|
||||
public interface BizMessageMapper extends BaseMapper<BizMessage> {
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.entity;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BizMessage {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private String title;
|
||||
private String category;
|
||||
private String content;
|
||||
private String url;
|
||||
private String params;
|
||||
private Timestamp createtime;
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage;
|
||||
|
||||
public interface IBizMessageQueryService {
|
||||
|
||||
List<BizMessage> listOutline();
|
||||
|
||||
BizMessage getDetailById(String id);
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.dao.BizMessageMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.entity.BizMessage;
|
||||
import com.chinaunicom.mall.ebtp.extend.bizmessage.service.IBizMessageQueryService;
|
||||
|
||||
/**
|
||||
* 消息查询服务
|
||||
*
|
||||
* @author ajaxfan
|
||||
*/
|
||||
@Service
|
||||
public class BizMessageQueryService implements IBizMessageQueryService {
|
||||
|
||||
private @Autowired BizMessageMapper mapper;
|
||||
|
||||
/**
|
||||
* 消息概要列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BizMessage> listOutline() {
|
||||
return mapper.selectList(new QueryWrapper<BizMessage>().select("id", "title", "category", "createtime"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public BizMessage getDetailById(String id) {
|
||||
return mapper.selectById(id);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.vo;
|
||||
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 消息详情
|
||||
*
|
||||
* @author ajaxfan
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(value = Include.NON_NULL)
|
||||
public class DescribeSiteMsgDetailVO {
|
||||
|
||||
private Integer msgId;
|
||||
private String title;
|
||||
private String category;
|
||||
private String content;
|
||||
private String url;
|
||||
private String params;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp createtime;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.bizmessage.vo;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 消息概要
|
||||
*
|
||||
* @author ajaxfan
|
||||
*/
|
||||
@Data
|
||||
public class DescribeSiteMsgVO {
|
||||
|
||||
private Integer msgId;
|
||||
private String title;
|
||||
private String category;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp createtime;
|
||||
|
||||
}
|
Reference in New Issue
Block a user