|
|
@ -13,7 +13,6 @@ package com.yami.shop.admin.controller;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import com.yami.shop.common.response.ServerResponseEntity;
|
|
|
|
import com.yami.shop.common.response.ServerResponseEntity;
|
|
|
@ -27,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.yami.shop.bean.enums.MessageStatus;
|
|
|
|
import com.yami.shop.bean.enums.MessageStatus;
|
|
|
@ -36,19 +34,28 @@ import com.yami.shop.service.MessageService;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* MessageController类,作为Spring RESTful风格的控制器,用于处理后台管理系统中与消息(Message)相关的各种操作接口。
|
|
|
|
|
|
|
|
* 包含消息的分页查询、获取单个消息详情、保存消息、修改消息、公开留言、取消公开留言以及批量删除消息等功能。
|
|
|
|
* @author lgh on 2018/10/15.
|
|
|
|
* @author lgh on 2018/10/15.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/admin/message")
|
|
|
|
@RequestMapping("/admin/message")
|
|
|
|
public class MessageController {
|
|
|
|
public class MessageController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 通过Spring的依赖注入机制,自动注入MessageService的实例,以便调用其提供的业务方法来处理消息相关逻辑。
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MessageService messageService;
|
|
|
|
private MessageService messageService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 分页获取
|
|
|
|
* 分页获取消息的接口方法。
|
|
|
|
|
|
|
|
* 根据传入的Message对象(可能包含用户名等查询条件)以及PageParam对象(用于分页参数设置),
|
|
|
|
|
|
|
|
* 使用MessageService的page方法结合LambdaQueryWrapper进行分页查询。
|
|
|
|
|
|
|
|
* 如果消息的用户名不为空,则按照用户名进行模糊查询;如果消息状态不为空,则精确匹配消息状态进行查询。
|
|
|
|
|
|
|
|
* 最后将查询到的分页消息结果封装在ServerResponseEntity中返回,用于统一的接口响应格式处理。
|
|
|
|
|
|
|
|
* @param message 可能包含查询条件的消息对象,比如按用户名模糊查询、按消息状态精确查询等。
|
|
|
|
|
|
|
|
* @param page 分页参数对象,包含页码、每页数量等信息。
|
|
|
|
|
|
|
|
* @return 返回包含分页消息信息的ServerResponseEntity,成功时其数据部分为IPage<Message>类型。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("/page")
|
|
|
|
@GetMapping("/page")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:page')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:page')")
|
|
|
@ -60,7 +67,11 @@ public class MessageController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取信息
|
|
|
|
* 获取指定ID消息详细信息的接口方法。
|
|
|
|
|
|
|
|
* 通过路径变量获取消息的ID,调用MessageService的getById方法获取对应的消息对象,
|
|
|
|
|
|
|
|
* 然后将获取到的消息对象封装在ServerResponseEntity中返回,用于统一的接口响应格式处理。
|
|
|
|
|
|
|
|
* @param id 要获取信息的消息的ID。
|
|
|
|
|
|
|
|
* @return 返回包含指定消息详细信息的ServerResponseEntity,成功时其数据部分为Message类型。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("/info/{id}")
|
|
|
|
@GetMapping("/info/{id}")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:info')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:info')")
|
|
|
@ -70,7 +81,11 @@ public class MessageController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 保存
|
|
|
|
* 保存消息的接口方法。
|
|
|
|
|
|
|
|
* 接收通过请求体传入的Message对象(包含要保存的消息相关信息),调用MessageService的save方法将消息保存到数据库中,
|
|
|
|
|
|
|
|
* 最后返回表示保存成功的ServerResponseEntity对象,用于统一的接口响应格式处理,其无具体数据内容(Void类型)。
|
|
|
|
|
|
|
|
* @param message 要保存的消息对象,通过请求体传入,包含消息的各项属性信息。
|
|
|
|
|
|
|
|
* @return 返回表示保存成功的ServerResponseEntity,无数据内容(Void类型)。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping
|
|
|
|
@PostMapping
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:save')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:save')")
|
|
|
@ -80,7 +95,11 @@ public class MessageController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 修改
|
|
|
|
* 修改消息的接口方法。
|
|
|
|
|
|
|
|
* 接收通过请求体传入的Message对象(包含要修改的消息相关信息),调用MessageService的updateById方法根据消息的ID更新数据库中的对应消息记录,
|
|
|
|
|
|
|
|
* 最后返回表示修改成功的ServerResponseEntity对象,用于统一的接口响应格式处理,其无具体数据内容(Void类型)。
|
|
|
|
|
|
|
|
* @param message 要修改的消息对象,通过请求体传入,包含消息的各项属性信息。
|
|
|
|
|
|
|
|
* @return 返回表示修改成功的ServerResponseEntity,无数据内容(Void类型)。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PutMapping
|
|
|
|
@PutMapping
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:update')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:update')")
|
|
|
@ -90,7 +109,11 @@ public class MessageController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 公开留言
|
|
|
|
* 公开留言的接口方法。
|
|
|
|
|
|
|
|
* 根据路径变量获取要操作的消息的ID,创建一个新的Message对象,设置其ID为传入的消息ID,并将消息状态设置为公开状态(通过MessageStatus.RELEASE.value()获取对应值),
|
|
|
|
|
|
|
|
* 然后调用MessageService的updateById方法更新数据库中对应消息的状态为公开,最后返回表示操作成功的ServerResponseEntity对象,用于统一的接口响应格式处理,其无具体数据内容(Void类型)。
|
|
|
|
|
|
|
|
* @param id 要设置为公开状态的消息的ID。
|
|
|
|
|
|
|
|
* @return 返回表示操作成功的ServerResponseEntity,无数据内容(Void类型)。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PutMapping("/release/{id}")
|
|
|
|
@PutMapping("/release/{id}")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:release')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:release')")
|
|
|
@ -103,7 +126,11 @@ public class MessageController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 取消公开留言
|
|
|
|
* 取消公开留言的接口方法。
|
|
|
|
|
|
|
|
* 根据路径变量获取要操作的消息的ID,创建一个新的Message对象,设置其ID为传入的消息ID,并将消息状态设置为取消公开状态(通过MessageStatus.CANCEL.value()获取对应值),
|
|
|
|
|
|
|
|
* 然后调用MessageService的updateById方法更新数据库中对应消息的状态为取消公开,最后返回表示操作成功的ServerResponseEntity对象,用于统一的接口响应格式处理,其无具体数据内容(Void类型)。
|
|
|
|
|
|
|
|
* @param id 要设置为取消公开状态的消息的ID。
|
|
|
|
|
|
|
|
* @return 返回表示操作成功的ServerResponseEntity,无数据内容(Void类型)。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PutMapping("/cancel/{id}")
|
|
|
|
@PutMapping("/cancel/{id}")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:cancel')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:cancel')")
|
|
|
@ -116,7 +143,11 @@ public class MessageController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 删除
|
|
|
|
* 删除消息的接口方法(支持批量删除)。
|
|
|
|
|
|
|
|
* 通过路径变量获取要删除的消息的ID数组,将其转换为List集合后,调用MessageService的removeByIds方法,
|
|
|
|
|
|
|
|
* 根据传入的消息ID集合批量删除数据库中的对应消息记录,最后返回表示删除成功的ServerResponseEntity对象,用于统一的接口响应格式处理,其无具体数据内容(Void类型)。
|
|
|
|
|
|
|
|
* @param ids 要删除的消息的ID数组,通过路径变量传入。
|
|
|
|
|
|
|
|
* @return 返回表示删除成功的ServerResponseEntity,无数据内容(Void类型)。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:delete')")
|
|
|
|
@PreAuthorize("@pms.hasPermission('admin:message:delete')")
|
|
|
|