管理端模块-消息管理

This commit is contained in:
wuchunlei
2024-03-28 17:10:09 +08:00
parent 76fd1b11ef
commit 3e46ee92ba
5 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.Message;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MessageDao extends MPJBaseMapper<Message> {
}

View File

@@ -0,0 +1,59 @@
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("message")
public class Message {
private static final long serialVersionUID = 1L;
@TableId
private Integer id;
/**
* 标题
*/
private String title;
/**
* 0本地信息1外链
*/
private Integer type;
/**
* 本地信息内容
*/
private String content;
/**
* 外链地址
*/
private String url;
/**
* 是否在疯子读书显示0否1是
*/
private Integer isBook;
/**
* 是否在医学视频显示
*/
private Integer isMedical;
/**
* 是否在国学显示0否1是
*/
private Integer isSociology;
private Date createTime;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,64 @@
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;
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("masterMessage")
@RequestMapping("master/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("/saveOrUpdateMessage")
public R saveOrUpdateMessage(@RequestBody Message message) {
messageService.saveOrUpdate(message);
return R.ok();
}
@RequestMapping("/delMessage")
public R delMessage(String id) {
messageService.removeById(id);
return R.ok();
}
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.Message;
public interface MessageService extends IService<Message> {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.master.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.master.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("messageService")
public class MessageServiceImpl extends ServiceImpl<MessageDao, Message> implements MessageService {
}