创建仓库
This commit is contained in:
14
src/main/java/vvpkassistant/SystemMessage/SystemMessage.java
Normal file
14
src/main/java/vvpkassistant/SystemMessage/SystemMessage.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package vvpkassistant.SystemMessage;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SystemMessage {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id; // 主键
|
||||
private String content; // 内容
|
||||
private String title; // 标题
|
||||
private String time; // 创建时间
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package vvpkassistant.SystemMessage;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import vvpkassistant.Data.ResponseData;
|
||||
import vvpkassistant.Tools.VVTools;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("systemMessage")
|
||||
public class SystemMessageController {
|
||||
|
||||
@Autowired
|
||||
private SystemMessageDao messageDao;
|
||||
|
||||
// 获取列表
|
||||
@PostMapping("list")
|
||||
public ResponseData<Object> messageList(@RequestBody Map<String,Integer> map) {
|
||||
Integer page = map.get("page");
|
||||
Integer size = map.get("size");
|
||||
List<SystemMessage> systemMessages = messageDao.messageList(page * size, size);
|
||||
return ResponseData.success(systemMessages);
|
||||
}
|
||||
|
||||
// 增加
|
||||
@PostMapping("add")
|
||||
public ResponseData<Object> createNewMessage(@RequestBody SystemMessage message) {
|
||||
message.setTime(VVTools.getCurrentTime("yyyy-MM-dd HH:mm"));
|
||||
return ResponseData.success(messageDao.insert(message));
|
||||
}
|
||||
|
||||
// 修改
|
||||
@PostMapping("update")
|
||||
public ResponseData<Object> updateMessage(@RequestBody SystemMessage message) {
|
||||
return ResponseData.success(messageDao.updateById(message));
|
||||
}
|
||||
|
||||
// 删除
|
||||
@PostMapping("delete")
|
||||
public ResponseData<Object> delete(@RequestBody SystemMessage message) {
|
||||
return ResponseData.success(messageDao.deleteById(message));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package vvpkassistant.SystemMessage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SystemMessageDao extends BaseMapper<SystemMessage> {
|
||||
|
||||
// 查询消息列表
|
||||
@Select("select * from system_message order by id desc limit #{page} , #{size}")
|
||||
List<SystemMessage> messageList(@Param("page")Integer page, @Param("size") Integer size);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user