【新增】反馈日志记录接口
This commit is contained in:
62
src/main/java/com/corewing/app/entity/FeedbackLog.java
Normal file
62
src/main/java/com/corewing/app/entity/FeedbackLog.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 反馈日志
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_feedback_log")
|
||||
public class FeedbackLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 反馈用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* oss地址
|
||||
*/
|
||||
private String ossPath;
|
||||
|
||||
/**
|
||||
* 日志文件大小
|
||||
*/
|
||||
private Long logSize;
|
||||
|
||||
/**
|
||||
* 反馈日志内容
|
||||
*/
|
||||
private String logContent;
|
||||
|
||||
/**
|
||||
* 日志文件名称
|
||||
*/
|
||||
private String logName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
10
src/main/java/com/corewing/app/mapper/FeedbackLogMapper.java
Normal file
10
src/main/java/com/corewing/app/mapper/FeedbackLogMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.corewing.app.entity.FeedbackLog;
|
||||
import lombok.Data;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FeedbackLogMapper extends BaseMapper<FeedbackLog> {
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.corewing.app.modules.app;
|
||||
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.entity.FeedbackLog;
|
||||
import com.corewing.app.service.FeedbackLogService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 上传日志接口控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/feedback_log")
|
||||
public class AppFeedbackLogController {
|
||||
|
||||
@Resource
|
||||
private FeedbackLogService feedbackLogService;
|
||||
|
||||
/**
|
||||
* 上传日志
|
||||
* @param feedbackLog
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/uploadFeedbackLog")
|
||||
public Result<String> uploadFeedbackLog(MultipartFile file, FeedbackLog feedbackLog) {
|
||||
return Result.isBool(feedbackLogService.uploadFeedbackLog(file, feedbackLog));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.entity.FeedbackLog;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface FeedbackLogService extends IService<FeedbackLog> {
|
||||
|
||||
boolean uploadFeedbackLog(MultipartFile file, FeedbackLog feedbackLog);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.entity.FeedbackLog;
|
||||
import com.corewing.app.mapper.FeedbackLogMapper;
|
||||
import com.corewing.app.service.FeedbackLogService;
|
||||
import com.corewing.app.util.OSSUploadUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Service
|
||||
public class FeedbackLogServiceImpl extends ServiceImpl<FeedbackLogMapper, FeedbackLog> implements FeedbackLogService {
|
||||
|
||||
@Override
|
||||
public boolean uploadFeedbackLog(MultipartFile file, FeedbackLog feedbackLog) {
|
||||
|
||||
feedbackLog.setLogSize(file.getSize());
|
||||
feedbackLog.setLogName(feedbackLog.getUserId() + "_" + file.getOriginalFilename());
|
||||
|
||||
try {
|
||||
String ossPath = OSSUploadUtil.uploadFile(file.getInputStream(), "feedback_log/" + feedbackLog.getLogName());
|
||||
feedbackLog.setOssPath(ossPath);
|
||||
return save(feedbackLog);
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user