通用模块-公共消息
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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.Map;
|
||||
|
||||
/**
|
||||
* 公共消息
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonMessage")
|
||||
@RequestMapping("common/message")
|
||||
public class MessageController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@RequestMapping("/listByPage")
|
||||
public R listByPage(@RequestBody Map<String, Object> params) {
|
||||
LambdaQueryWrapper<Message> wrapper = new LambdaQueryWrapper();
|
||||
if (params.containsKey("title")&& StringUtils.isNotEmpty(params.get("title").toString())) {
|
||||
wrapper.like(Message::getTitle,params.get("title"));
|
||||
}
|
||||
if (params.containsKey("type")&& StringUtils.isNotEmpty(params.get("type").toString())) {
|
||||
wrapper.eq(Message::getType,params.get("type"));
|
||||
}
|
||||
if (params.containsKey("isBook")&& StringUtils.isNotEmpty(params.get("isBook").toString())) {
|
||||
wrapper.eq(Message::getIsBook,params.get("isBook"));
|
||||
}
|
||||
if (params.containsKey("isMedical")&& StringUtils.isNotEmpty(params.get("isMedical").toString())) {
|
||||
wrapper.eq(Message::getIsBook,params.get("isMedical"));
|
||||
}
|
||||
if (params.containsKey("isSociology")&& StringUtils.isNotEmpty(params.get("isSociology").toString())) {
|
||||
wrapper.eq(Message::getIsBook,params.get("isSociology"));
|
||||
}
|
||||
wrapper.orderByDesc(Message::getCreateTime);
|
||||
Page<Message> page = messageService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
@RequestMapping("/getMessageById")
|
||||
public R getMessageById(String id) {
|
||||
return R.ok().put("result", messageService.getById(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.Message;
|
||||
|
||||
public interface MessageService extends IService<Message> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.MessageDao;
|
||||
import com.peanut.modules.common.entity.Message;
|
||||
import com.peanut.modules.common.service.MessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonMessageService")
|
||||
public class MessageServiceImpl extends ServiceImpl<MessageDao, Message> implements MessageService {
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.Message;
|
||||
import com.peanut.modules.master.service.MessageService;
|
||||
@@ -12,9 +11,11 @@ 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.Map;
|
||||
|
||||
/**
|
||||
* 公共消息
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterMessage")
|
||||
@RequestMapping("master/message")
|
||||
@@ -47,6 +48,11 @@ public class MessageController {
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
@RequestMapping("/getMessageById")
|
||||
public R getMessageById(String id) {
|
||||
return R.ok().put("result", messageService.getById(id));
|
||||
}
|
||||
|
||||
@RequestMapping("/saveOrUpdateMessage")
|
||||
public R saveOrUpdateMessage(@RequestBody Message message) {
|
||||
messageService.saveOrUpdate(message);
|
||||
|
||||
Reference in New Issue
Block a user