first commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package com.sqx.modules.message.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.message.entity.ActivityMessageInfo;
|
||||
import com.sqx.modules.message.service.ActivityMessageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/13
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "消息管理", tags = {"消息管理"})
|
||||
@RequestMapping(value = "/ActivityMessage")
|
||||
public class ActivityMessageController {
|
||||
|
||||
@Autowired
|
||||
private ActivityMessageService activityMessageService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台公告详情")
|
||||
@ResponseBody
|
||||
public Result getMessage(@PathVariable Integer id) {
|
||||
return Result.success().put("data",activityMessageService.findOne(Long.valueOf(id)));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台和用户端通用接口添加公告")
|
||||
@ResponseBody
|
||||
public Result addMessage(@RequestBody ActivityMessageInfo messageInfo) {
|
||||
activityMessageService.saveBody(messageInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台修改公告接口")
|
||||
@ResponseBody
|
||||
public Result uUpdate(@RequestBody ActivityMessageInfo messageInfo) {
|
||||
activityMessageService.updateBody(messageInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台删除公告接口")
|
||||
public Result deleteMessage(@PathVariable int id) {
|
||||
activityMessageService.delete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台获取全部公告接口")
|
||||
@ResponseBody
|
||||
public Result getMessageList() {
|
||||
List<ActivityMessageInfo> all = activityMessageService.findAll();
|
||||
return Result.success().put("data",all);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{state}/{page}/{limit}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台分页查询公告接口")
|
||||
@ResponseBody
|
||||
public Result getBodyPage(@PathVariable String state, @PathVariable Integer page, @PathVariable int limit) {
|
||||
return Result.success().put("data",activityMessageService.find(state, page,limit));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/type/{type}/{page}/{limit}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台通过类型获取接口 type1为公告2位用户反馈 3为系统消息 4为订单信息 5为用户消息 6客服消息")
|
||||
@ResponseBody
|
||||
public Result findType(@PathVariable Integer type, @PathVariable Integer page, @PathVariable int limit) {
|
||||
return Result.success().put("data",activityMessageService.findType(type, page,limit));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/findType/{userId}/{type}/{page}/{limit}", method = RequestMethod.GET)
|
||||
@ApiOperation("用户端获取消息列表 type 4为订单信息 5为用户消息")
|
||||
@ResponseBody
|
||||
public Result findType(@PathVariable String userId, @PathVariable String type, @PathVariable Integer page, @PathVariable int limit) {
|
||||
return Result.success().put("data",activityMessageService.findTypeByUserId(type, userId,page,limit));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.sqx.modules.message.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import com.sqx.modules.message.service.MessageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/13
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "消息管理", tags = {"消息管理"})
|
||||
@RequestMapping(value = "/message")
|
||||
public class MessageController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectMessageByUserId", method = RequestMethod.GET)
|
||||
@ApiOperation("查询用户消息")
|
||||
@ResponseBody
|
||||
public Result selectUserRecharge(int page, int limit, Long userId,Integer state){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("page",page);
|
||||
map.put("limit",limit);
|
||||
map.put("userId",userId);
|
||||
map.put("state",state);
|
||||
return Result.success().put("data",messageService.selectMessageList(map));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectMessageByType", method = RequestMethod.GET)
|
||||
@ApiOperation("获取消息 type1为公告2位用户反馈 3为系统消息 4为订单信息 5为用户消息 6客服消息 ")
|
||||
@ResponseBody
|
||||
public Result selectMessageByType(int page, int limit,Integer state){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("page",page);
|
||||
map.put("limit",limit);
|
||||
map.put("userId",null);
|
||||
map.put("state",state);
|
||||
return Result.success().put("data",messageService.selectMessageList(map));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectMessageDetails", method = RequestMethod.GET)
|
||||
@ApiOperation("获取消息详细信息")
|
||||
@ResponseBody
|
||||
public Result selectMessageDetails(Long id){
|
||||
return Result.success().put("data",messageService.selectMessageById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateMessage", method = RequestMethod.POST)
|
||||
@ApiOperation("修改消息")
|
||||
@ResponseBody
|
||||
public Result updateMessage(@RequestBody MessageInfo messageInfo){
|
||||
return Result.success().put("data",messageService.update(messageInfo));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/deleteMessageById", method = RequestMethod.POST)
|
||||
@ApiOperation("删除消息")
|
||||
@ResponseBody
|
||||
public Result deleteMessageById(Long id){
|
||||
return Result.success().put("data",messageService.delete(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/insertMessage", method = RequestMethod.POST)
|
||||
@ApiOperation("添加消息")
|
||||
@ResponseBody
|
||||
public Result insertMessage(MessageInfo messageInfo){
|
||||
return Result.success().put("data",messageService.saveBody(messageInfo));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台公告详情")
|
||||
@ResponseBody
|
||||
public Result getMessage(@PathVariable Long id) {
|
||||
return Result.success().put("data",messageService.selectMessageById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台和用户端通用接口添加公告")
|
||||
@ResponseBody
|
||||
public Result addMessage(@RequestBody MessageInfo messageInfo) {
|
||||
messageService.saveBody(messageInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台修改公告接口")
|
||||
@ResponseBody
|
||||
public Result uUpdate(@RequestBody MessageInfo messageInfo) {
|
||||
messageService.update(messageInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台删除公告接口")
|
||||
public Result deleteMessage(@PathVariable Long id) {
|
||||
messageService.delete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台获取全部公告接口")
|
||||
@ResponseBody
|
||||
public Result getMessageList(int page,int limit) {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("page",page);
|
||||
map.put("limit",limit);
|
||||
map.put("userId",null);
|
||||
map.put("state",null);
|
||||
map.put("type",null);
|
||||
return Result.success().put("data",messageService.selectMessageList(map));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/page/{state}/{page}/{limit}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台分页查询公告接口")
|
||||
@ResponseBody
|
||||
public Result getBodyPage(@PathVariable Integer state, @PathVariable Integer page, @PathVariable int limit) {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("page",page);
|
||||
map.put("limit",limit);
|
||||
map.put("state",state);
|
||||
map.put("type",null);
|
||||
map.put("userId",null);
|
||||
return Result.success().put("data",messageService.selectMessageList(map));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.sqx.modules.message.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import com.sqx.modules.message.service.MessageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/13
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "消息管理", tags = {"消息管理"})
|
||||
@RequestMapping(value = "/app/message")
|
||||
public class AppMessageController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/selectMessageByUserId", method = RequestMethod.GET)
|
||||
@ApiOperation("查询用户消息")
|
||||
@ResponseBody
|
||||
public Result selectMessageByUserId(int page, int limit,@RequestAttribute("userId") Long userId,Integer state){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("page",page);
|
||||
map.put("limit",limit);
|
||||
map.put("userId",userId);
|
||||
map.put("state",state);
|
||||
PageUtils pageUtils = messageService.selectMessageList(map);
|
||||
messageService.updateSendState(userId,state);
|
||||
return Result.success().put("data",pageUtils);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/selectMessageCount", method = RequestMethod.GET)
|
||||
@ApiOperation("查询未读消息总数")
|
||||
@ResponseBody
|
||||
public Result selectMessageCount(@RequestAttribute("userId") Long userId){
|
||||
int count = messageService.count(new QueryWrapper<MessageInfo>().eq("user_id", userId).in("state", 4, 5).eq("is_see", 0));
|
||||
return Result.success().put("data",count);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/selectMessage", method = RequestMethod.GET)
|
||||
@ApiOperation("查询用户消息")
|
||||
@ResponseBody
|
||||
public Result selectMessage(int page, int limit,Integer state){
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("page",page);
|
||||
map.put("limit",limit);
|
||||
map.put("state",state);
|
||||
return Result.success().put("data",messageService.selectMessageList(map));
|
||||
}
|
||||
|
||||
@Login
|
||||
@PostMapping("/insertMessage")
|
||||
@ApiOperation("添加投诉")
|
||||
public Result insertMessage(@RequestBody MessageInfo messageInfo){
|
||||
messageService.saveBody(messageInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.sqx.modules.message.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.message.entity.ActivityMessageInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivityMessageInfoDao extends BaseMapper<ActivityMessageInfo> {
|
||||
|
||||
IPage<ActivityMessageInfo> find(Page<ActivityMessageInfo> page,@Param("state") String state);
|
||||
|
||||
IPage<ActivityMessageInfo> findType(Page<ActivityMessageInfo> page,@Param("type") Integer type);
|
||||
|
||||
IPage<ActivityMessageInfo> findTypeByUserId(Page<ActivityMessageInfo> page,@Param("type")String type,@Param("userId") String userId);
|
||||
|
||||
Integer updateState(@Param("state") String state, @Param("id") Long id);
|
||||
|
||||
Integer updateSendState(@Param("sendState") String sendState, @Param("id") Long id);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sqx.modules.message.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
*/
|
||||
@Mapper
|
||||
public interface MessageInfoDao extends BaseMapper<MessageInfo> {
|
||||
|
||||
int updateSendState(@Param("userId") Long userId, @Param("state") Integer state);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.sqx.modules.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/13
|
||||
*/
|
||||
@Data
|
||||
@TableName("activity_message_info")
|
||||
public class ActivityMessageInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
private long id;
|
||||
|
||||
private String createAt;
|
||||
|
||||
private String content;
|
||||
|
||||
private String title;
|
||||
|
||||
private String image;
|
||||
|
||||
private String url;
|
||||
|
||||
private String sendState;
|
||||
|
||||
private String sendTime;
|
||||
|
||||
private String isSee;
|
||||
|
||||
private String state;
|
||||
|
||||
private String type;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String platform;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.sqx.modules.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/13
|
||||
*/
|
||||
@Data
|
||||
@TableName("message_info")
|
||||
public class MessageInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
private long id;
|
||||
|
||||
private String createAt;
|
||||
|
||||
private String content;
|
||||
|
||||
private String title;
|
||||
|
||||
private String image;
|
||||
|
||||
private String url;
|
||||
|
||||
private String sendState;
|
||||
|
||||
private String sendTime;
|
||||
|
||||
private String isSee;
|
||||
|
||||
private String state;
|
||||
|
||||
private String type;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String platform;
|
||||
|
||||
@TableField(exist = false)
|
||||
private UserEntity userEntity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.sqx.modules.message.service;
|
||||
|
||||
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.message.entity.ActivityMessageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ActivityMessageService {
|
||||
|
||||
int saveBody(ActivityMessageInfo messageInfo);
|
||||
|
||||
List<ActivityMessageInfo> findAll();
|
||||
|
||||
ActivityMessageInfo findOne(long id);
|
||||
|
||||
ActivityMessageInfo selectById(long id);
|
||||
|
||||
int delete(long id);
|
||||
|
||||
PageUtils find(String state, int page,int limit);
|
||||
|
||||
int updateBody(ActivityMessageInfo userInfo);
|
||||
|
||||
PageUtils findType(Integer type, int page,int limit);
|
||||
|
||||
int updateState(String state, Long id);
|
||||
|
||||
int updateSendState(String state, Long id);
|
||||
|
||||
PageUtils findTypeByUserId( String type,String userId, int page,int limit);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.sqx.modules.message.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface MessageService extends IService<MessageInfo> {
|
||||
|
||||
int updateSendState(Long userId, Integer state);
|
||||
|
||||
PageUtils selectMessageList(Map<String,Object> params);
|
||||
|
||||
int saveBody(MessageInfo messageInfo);
|
||||
|
||||
int update(MessageInfo messageInfo);
|
||||
|
||||
int delete(Long id);
|
||||
|
||||
MessageInfo selectMessageById(Long id);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.sqx.modules.message.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.message.dao.ActivityMessageInfoDao;
|
||||
import com.sqx.modules.message.entity.ActivityMessageInfo;
|
||||
import com.sqx.modules.message.service.ActivityMessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
@Service
|
||||
public class ActivityMessageServiceImpl extends ServiceImpl<ActivityMessageInfoDao, ActivityMessageInfo> implements ActivityMessageService {
|
||||
|
||||
@Autowired
|
||||
private ActivityMessageInfoDao activityMessageInfoDao;
|
||||
|
||||
@Override
|
||||
public List<ActivityMessageInfo> findAll() {
|
||||
return activityMessageInfoDao.selectList(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBody(ActivityMessageInfo messageInfo) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
messageInfo.setCreateAt(sdf.format(now));
|
||||
return activityMessageInfoDao.insert(messageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityMessageInfo findOne(long id) {
|
||||
return activityMessageInfoDao.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityMessageInfo selectById(long id) {
|
||||
return activityMessageInfoDao.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(long id) {
|
||||
activityMessageInfoDao.deleteById(id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils find(String state, int page,int limit) {
|
||||
Page<ActivityMessageInfo> pages = new Page<>(page, limit);
|
||||
return new PageUtils(activityMessageInfoDao.find(pages,state));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateBody(ActivityMessageInfo userInfo) {
|
||||
activityMessageInfoDao.updateById(userInfo);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils findType(Integer type, int page,int limit) {
|
||||
Page<ActivityMessageInfo> pages = new Page<>(page, limit);
|
||||
return new PageUtils(activityMessageInfoDao.findType(pages,type));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateState(String state, Long id) {
|
||||
return activityMessageInfoDao.updateState(state,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateSendState(String state, Long id) {
|
||||
return activityMessageInfoDao.updateSendState(state,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils findTypeByUserId( String type,String userId, int page,int limit) {
|
||||
Page<ActivityMessageInfo> pages = new Page<>(page, limit);
|
||||
return new PageUtils(activityMessageInfoDao.findTypeByUserId(pages,type,userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.sqx.modules.message.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Query;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.message.dao.MessageInfoDao;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import com.sqx.modules.message.service.MessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
@Service
|
||||
public class MessageServiceImpl extends ServiceImpl<MessageInfoDao, MessageInfo> implements MessageService {
|
||||
|
||||
@Autowired
|
||||
private MessageInfoDao messageInfoDao;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public int updateSendState(Long userId, Integer state) {
|
||||
return messageInfoDao.updateSendState(userId, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils selectMessageList(Map<String,Object> params){
|
||||
Long userId = (Long)params.get("userId");
|
||||
Integer state = (Integer)params.get("state");
|
||||
Integer type = (Integer)params.get("type");
|
||||
IPage<MessageInfo> page = this.page(
|
||||
new Query<MessageInfo>().getPage(params),
|
||||
new QueryWrapper<MessageInfo>()
|
||||
.eq(userId!=null,"user_id", userId)
|
||||
.eq(state!=null,"state", state)
|
||||
.eq(type!=null,"type", type).orderByDesc("create_at")
|
||||
);
|
||||
List<MessageInfo> records = page.getRecords();
|
||||
for (MessageInfo messageInfo:records){
|
||||
if(messageInfo.getUserId()!=null){
|
||||
messageInfo.setUserEntity(userService.selectUserById(Long.parseLong(messageInfo.getUserId())));
|
||||
}
|
||||
}
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBody(MessageInfo messageInfo){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
messageInfo.setCreateAt(sdf.format(now));
|
||||
return messageInfoDao.insert(messageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(MessageInfo messageInfo){
|
||||
return messageInfoDao.updateById(messageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id){
|
||||
return messageInfoDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageInfo selectMessageById(Long id){
|
||||
return messageInfoDao.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user