mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
添加链接失效反馈后端及数据库;登陆改为登录
This commit is contained in:
@@ -34,7 +34,7 @@ public class BaseController {
|
||||
public static final Integer COMMON_PAGE_SIZE = 10;
|
||||
|
||||
/**
|
||||
* 获取用户登陆状态
|
||||
* 获取用户登录状态
|
||||
*/
|
||||
public Boolean isLogin() {
|
||||
SessionManager sessionManager = RedisSessionManager.getInstance(redisTemplate);
|
||||
|
@@ -19,9 +19,11 @@ import plus.bookshelf.Common.Response.CommonReturnType;
|
||||
import plus.bookshelf.Config.QCloudCosConfig;
|
||||
import plus.bookshelf.Controller.VO.FileObjectVO;
|
||||
import plus.bookshelf.Controller.VO.FileVO;
|
||||
import plus.bookshelf.Service.Impl.FailureFeedbackServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.FileObjectServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.FileServiceImpl;
|
||||
import plus.bookshelf.Service.Impl.UserServiceImpl;
|
||||
import plus.bookshelf.Service.Model.FailureFeedbackModel;
|
||||
import plus.bookshelf.Service.Model.FileModel;
|
||||
import plus.bookshelf.Service.Model.FileObjectModel;
|
||||
import plus.bookshelf.Service.Model.UserModel;
|
||||
@@ -50,6 +52,9 @@ public class FileController extends BaseController {
|
||||
@Autowired
|
||||
FileObjectServiceImpl fileObjectService;
|
||||
|
||||
@Autowired
|
||||
FailureFeedbackServiceImpl failureFeedbackService;
|
||||
|
||||
@ApiOperation(value = "书籍下载页面获取文件提供的下载方式", notes = "")
|
||||
@RequestMapping(value = "getFile", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
@@ -95,6 +100,37 @@ public class FileController extends BaseController {
|
||||
return CommonReturnType.create(fileVOS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "链接失效反馈", notes = "查询文件列表")
|
||||
@RequestMapping(value = "object/FailureFeedback", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
public CommonReturnType failureFeedback(@RequestParam(value = "token", required = false) String token,
|
||||
@RequestParam(value = "bookId", required = false) Integer bookId,
|
||||
@RequestParam(value = "fileId", required = false) Integer fileId,
|
||||
@RequestParam(value = "fileObjectId", required = false) Integer fileObjectId) throws BusinessException {
|
||||
Integer userId = null;
|
||||
if (token != null) {
|
||||
try {
|
||||
UserModel userModel = userService.getUserByToken(redisTemplate, token);
|
||||
userId = userModel.getId();
|
||||
} catch (BusinessException e) {
|
||||
// 用户未登录,不返回错误信息
|
||||
}
|
||||
}
|
||||
|
||||
FailureFeedbackModel failureFeedbackModel = new FailureFeedbackModel();
|
||||
failureFeedbackModel.setBookId(bookId);
|
||||
failureFeedbackModel.setFileId(fileId);
|
||||
failureFeedbackModel.setFileObjectId(fileObjectId);
|
||||
failureFeedbackModel.setUserId(userId);
|
||||
failureFeedbackModel.setCreateTime(Calendar.getInstance().getTime());
|
||||
|
||||
Boolean isSuccess = failureFeedbackService.addFailureFeedback(failureFeedbackModel);
|
||||
if (!isSuccess) {
|
||||
throw new BusinessException(BusinessErrorCode.UNKNOWN_ERROR, "反馈失败");
|
||||
}
|
||||
return CommonReturnType.create(isSuccess);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "【管理员】查询文件对象列表", notes = "查询文件列表")
|
||||
@RequestMapping(value = "object/list", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package plus.bookshelf.Controller.VO;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class FailureFeedbackVO {
|
||||
|
||||
private Integer bookId;
|
||||
|
||||
private Integer fileId;
|
||||
|
||||
private Integer fileObjectId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Date createTime;
|
||||
}
|
@@ -0,0 +1,170 @@
|
||||
package plus.bookshelf.Dao.DO;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class FailureFeedbackDO {
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column failure_feedback.book_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Integer bookId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column failure_feedback.file_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Integer fileId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column failure_feedback.file_object_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Integer fileObjectId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column failure_feedback.user_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column failure_feedback.create_time
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column failure_feedback.book_id
|
||||
*
|
||||
* @return the value of failure_feedback.book_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column failure_feedback.book_id
|
||||
*
|
||||
* @param bookId the value for failure_feedback.book_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setBookId(Integer bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column failure_feedback.file_id
|
||||
*
|
||||
* @return the value of failure_feedback.file_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column failure_feedback.file_id
|
||||
*
|
||||
* @param fileId the value for failure_feedback.file_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setFileId(Integer fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column failure_feedback.file_object_id
|
||||
*
|
||||
* @return the value of failure_feedback.file_object_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getFileObjectId() {
|
||||
return fileObjectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column failure_feedback.file_object_id
|
||||
*
|
||||
* @param fileObjectId the value for failure_feedback.file_object_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setFileObjectId(Integer fileObjectId) {
|
||||
this.fileObjectId = fileObjectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column failure_feedback.user_id
|
||||
*
|
||||
* @return the value of failure_feedback.user_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column failure_feedback.user_id
|
||||
*
|
||||
* @param userId the value for failure_feedback.user_id
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column failure_feedback.create_time
|
||||
*
|
||||
* @return the value of failure_feedback.create_time
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column failure_feedback.create_time
|
||||
*
|
||||
* @param createTime the value for failure_feedback.create_time
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package plus.bookshelf.Dao.Mapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import plus.bookshelf.Dao.DO.FailureFeedbackDO;
|
||||
|
||||
@Repository // 添加这个注解,Autowired的时候idea就不会报错了
|
||||
public interface FailureFeedbackDOMapper {
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table failure_feedback
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insert(FailureFeedbackDO row);
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method corresponds to the database table failure_feedback
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insertSelective(FailureFeedbackDO row);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package plus.bookshelf.Service.Impl;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import plus.bookshelf.Dao.DO.FailureFeedbackDO;
|
||||
import plus.bookshelf.Dao.Mapper.FailureFeedbackDOMapper;
|
||||
import plus.bookshelf.Service.Model.FailureFeedbackModel;
|
||||
import plus.bookshelf.Service.Service.FailureFeedbackService;
|
||||
|
||||
@Service
|
||||
public class FailureFeedbackServiceImpl implements FailureFeedbackService {
|
||||
|
||||
@Autowired
|
||||
FailureFeedbackDOMapper failureFeedbackDOMapper;
|
||||
|
||||
/**
|
||||
* 添加反馈
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean addFailureFeedback(FailureFeedbackModel failureFeedbackModel) {
|
||||
FailureFeedbackDO failureFeedbackDO = convertToDataObject(failureFeedbackModel);
|
||||
int affectRows = failureFeedbackDOMapper.insertSelective(failureFeedbackDO);
|
||||
return affectRows > 0;
|
||||
}
|
||||
|
||||
private FailureFeedbackDO convertToDataObject(FailureFeedbackModel failureFeedbackModel) {
|
||||
if (failureFeedbackModel == null) {
|
||||
return null;
|
||||
}
|
||||
FailureFeedbackDO failureFeedbackDO = new FailureFeedbackDO();
|
||||
BeanUtils.copyProperties(failureFeedbackModel, failureFeedbackDO);
|
||||
return failureFeedbackDO;
|
||||
}
|
||||
}
|
@@ -56,7 +56,7 @@ public class UserServiceImpl implements UserService {
|
||||
// token 已过期
|
||||
Object userIdObject = RedisSessionManager.getInstance(redisTemplate).getValue(token);
|
||||
if (userIdObject == null) {
|
||||
throw new BusinessException(BusinessErrorCode.USER_TOKEN_EXPIRED, "登陆过期啦,请重新登录");
|
||||
throw new BusinessException(BusinessErrorCode.USER_TOKEN_EXPIRED, "登录过期啦,请重新登录");
|
||||
}
|
||||
|
||||
Integer userId = (Integer) userIdObject;
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package plus.bookshelf.Service.Model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class FailureFeedbackModel {
|
||||
|
||||
private Integer bookId;
|
||||
|
||||
private Integer fileId;
|
||||
|
||||
private Integer fileObjectId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Date createTime;
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package plus.bookshelf.Service.Service;
|
||||
|
||||
import plus.bookshelf.Service.Model.FailureFeedbackModel;
|
||||
|
||||
public interface FailureFeedbackService {
|
||||
|
||||
/**
|
||||
* 添加反馈
|
||||
*
|
||||
* @param failureFeedbackModel
|
||||
* @return
|
||||
*/
|
||||
Boolean addFailureFeedback(FailureFeedbackModel failureFeedbackModel);
|
||||
}
|
Reference in New Issue
Block a user