55 lines
1.9 KiB
Java
55 lines
1.9 KiB
Java
package com.peanut.modules.common.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.peanut.common.utils.R;
|
|
import com.peanut.modules.common.entity.Message;
|
|
import com.peanut.modules.common.service.MessageService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 公共消息
|
|
*/
|
|
@Slf4j
|
|
@RestController("commonMessage")
|
|
@RequestMapping("common/message")
|
|
public class MessageController {
|
|
|
|
@Autowired
|
|
private MessageService messageService;
|
|
|
|
@RequestMapping("/listByPage")
|
|
public R listByPage(@RequestBody Message message) {
|
|
LambdaQueryWrapper<Message> wrapper = new LambdaQueryWrapper();
|
|
if (message.getIsBook()!=null&&message.getIsBook()==1){
|
|
wrapper.eq(Message::getIsBook,1);
|
|
}
|
|
if (message.getIsMedical()!=null&&message.getIsMedical()==1){
|
|
wrapper.eq(Message::getIsMedical,1);
|
|
}
|
|
if (message.getIsSociology()!=null&&message.getIsSociology()==1){
|
|
wrapper.eq(Message::getIsSociology,1);
|
|
}
|
|
if (message.getIsPsyche()!=null&&message.getIsPsyche()==1){
|
|
wrapper.eq(Message::getIsPsyche,1);
|
|
}
|
|
wrapper.orderByDesc(Message::getCreateTime);
|
|
List<Message> messages = messageService.getBaseMapper().selectList(wrapper);
|
|
return R.ok().put("messages", messages);
|
|
}
|
|
|
|
@RequestMapping("/getMessageById")
|
|
public R getMessageById(String id) {
|
|
return R.ok().put("result", messageService.getById(id));
|
|
}
|
|
|
|
}
|