feat: 代码开发中...
This commit is contained in:
@@ -4,6 +4,8 @@ plugins {
|
||||
id 'io.spring.dependency-management' version '1.1.0'
|
||||
}
|
||||
|
||||
evaluationDependsOn(":blog-frontend")
|
||||
|
||||
group = 'cn.hamster3.application.blog'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '17'
|
||||
@@ -60,8 +62,13 @@ tasks.named('test') {
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(":blog-frontend:npmBuild")
|
||||
from(tasks.findByPath(":blog-frontend:npmBuild").outputs) {
|
||||
dependsOn(":blog-frontend:npmBuildOnly")
|
||||
//noinspection ConfigurationAvoidance
|
||||
from(tasks.findByPath(":blog-frontend:npmBuildOnly").outputs) {
|
||||
into 'static'
|
||||
}
|
||||
}
|
||||
|
||||
clean {
|
||||
delete(files('bin'))
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
package cn.hamster3.application.blog.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 附件相关接口
|
||||
@@ -9,4 +10,28 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/attach")
|
||||
public class AttachController {
|
||||
@PostMapping("/")
|
||||
public ResponseVO<Void> createAttach(@RequestBody MultipartFile file) {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
|
||||
@PutMapping("/{attachID}/")
|
||||
public ResponseVO<Void> modifyAttach(@PathVariable String attachID, @RequestBody MultipartFile file) {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
|
||||
@GetMapping("/{attachID}/")
|
||||
public ResponseVO<Void> getAttach() {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{attachID}/")
|
||||
public ResponseVO<Void> deleteAttach(@PathVariable String attachID) {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseVO<Void> getAttachList() {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,42 @@
|
||||
package cn.hamster3.application.blog.controller;
|
||||
|
||||
import cn.hamster3.application.blog.entity.BlogEntity;
|
||||
import cn.hamster3.application.blog.service.IBlogService;
|
||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogCreateRequireVO;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogInfoResponseVO;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogUpdateRequireVO;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 博文相关接口
|
||||
*/
|
||||
@Tag(name = "博文接口", description = "博文相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/blog")
|
||||
@RequestMapping(value = "/api/v1/blog", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public class BlogController {
|
||||
@GetMapping("/")
|
||||
public ResponseVO<List<BlogEntity>> getBlogList() {
|
||||
@Resource
|
||||
private IBlogService blogService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseVO<Long> createBlog(@RequestBody @Valid BlogCreateRequireVO requireVO) {
|
||||
return blogService.createBlog(requireVO);
|
||||
}
|
||||
|
||||
@GetMapping("/{blogID}/")
|
||||
public ResponseVO<BlogInfoResponseVO> getBlogInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseVO<List<BlogInfoResponseVO>> getBlogInfoList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping("/{blogID}/")
|
||||
public ResponseVO<Void> updateBlog(@PathVariable String blogID, @RequestBody @Valid BlogUpdateRequireVO requireVO) {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
}
|
||||
|
@@ -2,38 +2,49 @@ package cn.hamster3.application.blog.controller;
|
||||
|
||||
import cn.hamster3.application.blog.service.IUserService;
|
||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserInfoResponseVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterRequireVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterResponseVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserUpdateRequireVO;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户相关接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/user")
|
||||
@RequestMapping(value = "/api/v1/user", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public class UserController {
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
@PostMapping("/")
|
||||
public ResponseVO<UserRegisterResponseVO> registerUser(@RequestBody @Valid UserRegisterRequireVO requireVO) {
|
||||
public ResponseVO<UserRegisterResponseVO> createUser(@RequestBody @Valid UserRegisterRequireVO requireVO) {
|
||||
return userService.registerUser(requireVO);
|
||||
}
|
||||
|
||||
@PutMapping("/")
|
||||
public Object modifyUserInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseVO<Void> getAllUserInfo() {
|
||||
public ResponseVO<Void> updateUser(@RequestBody @Valid UserUpdateRequireVO requireVO) {
|
||||
return ResponseVO.success();
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public ResponseVO<List<UserInfoResponseVO>> getAllUserInfo() {
|
||||
return ResponseVO.success(new ArrayList<>());
|
||||
}
|
||||
|
||||
@GetMapping("/{userID}/")
|
||||
public Object getUserInfo(@PathVariable String userID) {
|
||||
return null;
|
||||
public ResponseVO<UserInfoResponseVO> getUserInfo(@PathVariable String userID) {
|
||||
return ResponseVO.success(null);
|
||||
}
|
||||
|
||||
@GetMapping("/{userID}/attaches")
|
||||
public ResponseVO<Void> getUserAttaches(@PathVariable String userID) {
|
||||
return ResponseVO.success(null);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package cn.hamster3.application.blog.entity.mapper;
|
||||
|
||||
import cn.hamster3.application.blog.entity.BlogEntity;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogCreateRequireVO;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogInfoResponseVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING)
|
||||
public interface BlogMapper {
|
||||
BlogEntity voToEntity(BlogCreateRequireVO requireVO);
|
||||
|
||||
BlogInfoResponseVO entityToInfoVO(BlogEntity requireVO);
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package cn.hamster3.application.blog.entity.mapper;
|
||||
|
||||
import cn.hamster3.application.blog.entity.UserEntity;
|
||||
import cn.hamster3.application.blog.vo.user.UserInfoResponseVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterRequireVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterResponseVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, componentModel = MappingConstants.ComponentModel.SPRING)
|
||||
public interface UserMapper {
|
||||
UserEntity voToEntity(UserRegisterRequireVO requireVO);
|
||||
|
||||
UserInfoResponseVO entityToInfoVO(UserEntity requireVO);
|
||||
|
||||
UserRegisterResponseVO entityToRegisterVO(UserEntity requireVO);
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package cn.hamster3.application.blog.mapper;
|
||||
|
||||
import cn.hamster3.application.blog.entity.UserEntity;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterRequireVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterResponseVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface UserMapper {
|
||||
|
||||
@Mapping(target = "permissions", ignore = true)
|
||||
@Mapping(target = "attachEntities", ignore = true)
|
||||
@Mapping(target = "blogEntities", ignore = true)
|
||||
UserEntity voToEntity(UserRegisterRequireVO requireVO);
|
||||
|
||||
UserRegisterResponseVO entityToVO(UserEntity requireVO);
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package cn.hamster3.application.blog.service;
|
||||
|
||||
public interface IAttachService {
|
||||
}
|
@@ -1,4 +1,8 @@
|
||||
package cn.hamster3.application.blog.service;
|
||||
|
||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogCreateRequireVO;
|
||||
|
||||
public interface IBlogService {
|
||||
ResponseVO<Long> createBlog(BlogCreateRequireVO requireVO);
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package cn.hamster3.application.blog.service.impl;
|
||||
|
||||
import cn.hamster3.application.blog.service.IAttachService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AttachService implements IAttachService {
|
||||
}
|
@@ -1,12 +1,25 @@
|
||||
package cn.hamster3.application.blog.service.impl;
|
||||
|
||||
import cn.hamster3.application.blog.dao.BlogRepository;
|
||||
import cn.hamster3.application.blog.entity.BlogEntity;
|
||||
import cn.hamster3.application.blog.entity.mapper.BlogMapper;
|
||||
import cn.hamster3.application.blog.service.IBlogService;
|
||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||
import cn.hamster3.application.blog.vo.blog.BlogCreateRequireVO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BlogService implements IBlogService {
|
||||
@Resource
|
||||
BlogMapper blogMapper;
|
||||
@Resource
|
||||
private BlogRepository blogRepo;
|
||||
|
||||
@Override
|
||||
public ResponseVO<Long> createBlog(BlogCreateRequireVO requireVO) {
|
||||
BlogEntity entity = blogMapper.voToEntity(requireVO);
|
||||
BlogEntity save = blogRepo.save(entity);
|
||||
return ResponseVO.success(save.getId());
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package cn.hamster3.application.blog.service.impl;
|
||||
|
||||
import cn.hamster3.application.blog.dao.UserRepository;
|
||||
import cn.hamster3.application.blog.entity.UserEntity;
|
||||
import cn.hamster3.application.blog.mapper.UserMapper;
|
||||
import cn.hamster3.application.blog.entity.mapper.UserMapper;
|
||||
import cn.hamster3.application.blog.service.IUserService;
|
||||
import cn.hamster3.application.blog.vo.ResponseVO;
|
||||
import cn.hamster3.application.blog.vo.user.UserRegisterRequireVO;
|
||||
@@ -37,6 +37,6 @@ public class UserService implements IUserService {
|
||||
entity.setPassword(passwordEncoder.encode(entity.getPassword()));
|
||||
UserEntity save = userRepo.save(entity);
|
||||
|
||||
return ResponseVO.success("注册成功!", userMapper.entityToVO(save));
|
||||
return ResponseVO.success("注册成功!", userMapper.entityToRegisterVO(save));
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,6 @@ public class ResponseVO<T> {
|
||||
return new ResponseVO<>(200, "", null);
|
||||
}
|
||||
|
||||
public static ResponseVO<Void> success(String msg) {
|
||||
return new ResponseVO<>(200, msg, null);
|
||||
}
|
||||
|
||||
public static <T> ResponseVO<T> success(T data) {
|
||||
return new ResponseVO<>(200, "", data);
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package cn.hamster3.application.blog.vo.blog;
|
||||
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BlogCreateRequireVO {
|
||||
@Nullable
|
||||
@Max(value = 16, message = "密码最大长度不能超过 16 个字!")
|
||||
private String password;
|
||||
@NotNull(message = "博客文章内容不能为空!")
|
||||
private String content;
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package cn.hamster3.application.blog.vo.blog;
|
||||
|
||||
public class BlogInfoResponseVO {
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package cn.hamster3.application.blog.vo.blog;
|
||||
|
||||
public class BlogUpdateRequireVO {
|
||||
private String password;
|
||||
private String content;
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package cn.hamster3.application.blog.vo.user;
|
||||
|
||||
public class UserInfoResponseVO {
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package cn.hamster3.application.blog.vo.user;
|
||||
|
||||
public class UserUpdateRequireVO {
|
||||
}
|
@@ -1,3 +1,11 @@
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /
|
||||
multipart:
|
||||
enable: true
|
||||
max-file-size: 16M
|
||||
max-require-size: 32M
|
||||
spring:
|
||||
# 要使用的环境预设
|
||||
# prod: 生产环境
|
||||
|
Reference in New Issue
Block a user