12 changed files with 236 additions and 1 deletions
@ -0,0 +1,8 @@
|
||||
CREATE TABLE `book` ( |
||||
`id` int NOT NULL AUTO_INCREMENT, |
||||
`file_name` varchar(1000) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件名', |
||||
`file_path` varchar(1000) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '文件路径', |
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间', |
||||
`crt_user` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; |
||||
@ -0,0 +1,8 @@
|
||||
CREATE TABLE `feedback` ( |
||||
`id` int NOT NULL AUTO_INCREMENT, |
||||
`content` text COLLATE utf8mb4_general_ci COMMENT '内容', |
||||
`create_time` datetime DEFAULT NULL, |
||||
`crt_user` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人', |
||||
`crt_depart_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人所在单位', |
||||
PRIMARY KEY (`id`) |
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='意见反馈'; |
||||
@ -0,0 +1,54 @@
|
||||
package com.biutag.supervision.controller.mobileSupervision; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.supervision.common.UserContextHolder; |
||||
import com.biutag.supervision.pojo.Result; |
||||
import com.biutag.supervision.pojo.entity.Book; |
||||
import com.biutag.supervision.pojo.model.UserAuth; |
||||
import com.biutag.supervision.pojo.param.BookQueryParam; |
||||
import com.biutag.supervision.service.BookService; |
||||
import com.biutag.supervision.service.FileService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.IOException; |
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2025/5/23 |
||||
*/ |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("book") |
||||
@RestController |
||||
public class BookController { |
||||
|
||||
private final BookService bookService; |
||||
|
||||
private final FileService fileService; |
||||
|
||||
|
||||
@GetMapping |
||||
public Result<Page<Book>> list(BookQueryParam queryParam) { |
||||
LambdaQueryWrapper<Book> queryWrapper = new LambdaQueryWrapper<>(); |
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getFileName()), Book::getFileName, queryParam.getFileName()) |
||||
.orderByDesc(Book::getCreateTime); |
||||
return Result.success(bookService.page(Page.of(queryParam.getCurrent(), queryParam.getSize()), queryWrapper)); |
||||
} |
||||
|
||||
@PostMapping |
||||
public Result<Boolean> add(@RequestPart("file") MultipartFile file) throws IOException { |
||||
String filePath = fileService.upload(file); |
||||
Book book = new Book(); |
||||
book.setFileName(file.getOriginalFilename()); |
||||
book.setFilePath(filePath); |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
book.setCrtUser(user.getNickName()); |
||||
book.setCreateTime(LocalDateTime.now()); |
||||
return Result.success(bookService.save(book)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,36 @@
|
||||
package com.biutag.supervision.controller.mobileSupervision; |
||||
|
||||
import com.biutag.supervision.common.UserContextHolder; |
||||
import com.biutag.supervision.pojo.Result; |
||||
import com.biutag.supervision.pojo.entity.Feedback; |
||||
import com.biutag.supervision.pojo.model.UserAuth; |
||||
import com.biutag.supervision.service.FeedbackService; |
||||
import lombok.RequiredArgsConstructor; |
||||
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 java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2025/5/26 |
||||
*/ |
||||
@RequiredArgsConstructor |
||||
@RestController |
||||
@RequestMapping("feedback") |
||||
public class FeedbackController { |
||||
|
||||
private final FeedbackService feedbackService; |
||||
|
||||
@PostMapping |
||||
public Result<Boolean> add(@RequestBody Feedback feedback) { |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
feedback.setCreateTime(LocalDateTime.now()); |
||||
feedback.setCrtUser(user.getNickName()); |
||||
feedback.setCrtDepartName(user.getDepartName()); |
||||
return Result.success(feedbackService.save(feedback)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,8 @@
|
||||
package com.biutag.supervision.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.biutag.supervision.pojo.entity.Book; |
||||
|
||||
public interface BookMapper extends BaseMapper<Book> { |
||||
|
||||
} |
||||
@ -0,0 +1,8 @@
|
||||
package com.biutag.supervision.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.biutag.supervision.pojo.entity.Feedback; |
||||
|
||||
public interface FeedbackMapper extends BaseMapper<Feedback> { |
||||
|
||||
} |
||||
@ -0,0 +1,37 @@
|
||||
package com.biutag.supervision.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
@Setter |
||||
@Getter |
||||
public class Book { |
||||
|
||||
//
|
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
// 文件名
|
||||
@TableField("file_name") |
||||
private String fileName; |
||||
|
||||
// 文件路径
|
||||
@TableField("file_path") |
||||
private String filePath; |
||||
|
||||
// 创建时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
||||
@TableField("create_time") |
||||
private LocalDateTime createTime; |
||||
|
||||
//
|
||||
@TableField("crt_user") |
||||
private String crtUser; |
||||
|
||||
} |
||||
@ -0,0 +1,35 @@
|
||||
package com.biutag.supervision.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
@Setter |
||||
@Getter |
||||
public class Feedback { |
||||
|
||||
//
|
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
// 内容
|
||||
@TableField("content") |
||||
private String content; |
||||
|
||||
//
|
||||
@TableField("create_time") |
||||
private LocalDateTime createTime; |
||||
|
||||
// 创建人
|
||||
@TableField("crt_user") |
||||
private String crtUser; |
||||
|
||||
// 创建人所在单位
|
||||
@TableField("crt_depart_name") |
||||
private String crtDepartName; |
||||
|
||||
} |
||||
@ -0,0 +1,16 @@
|
||||
package com.biutag.supervision.pojo.param; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2025/5/23 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class BookQueryParam extends BasePage { |
||||
|
||||
private String fileName; |
||||
|
||||
} |
||||
@ -0,0 +1,11 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.biutag.supervision.pojo.entity.Book; |
||||
import com.biutag.supervision.mapper.BookMapper; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class BookService extends ServiceImpl<BookMapper, Book> { |
||||
|
||||
} |
||||
@ -0,0 +1,11 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.biutag.supervision.pojo.entity.Feedback; |
||||
import com.biutag.supervision.mapper.FeedbackMapper; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class FeedbackService extends ServiceImpl<FeedbackMapper, Feedback> { |
||||
|
||||
} |
||||
Loading…
Reference in new issue