u
This commit is contained in:
1 parent
9aa4a72321
commit
9bf7c40b70
40 files changed
+918
-189
No files matched your search
+1
@@ -17,6 +17,7 @@ public class AutoMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
if (ObjectUtils.isNotEmpty(userId) && userId > 0){
|
||||
this.strictInsertFill(metaObject, "createBy", Long.class, userId);
|
||||
this.strictUpdateFill(metaObject, "updateBy", Long.class, userId);
|
||||
}
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package cn.link56.forum.service;
|
||||
|
||||
import cn.link56.forum.mapper.PostMapper;
|
||||
import cn.link56.forum.model.po.PostPO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class PostService extends ServiceImpl<PostMapper, PostPO> {
|
||||
@Resource
|
||||
private PostMapper postMapper;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package cn.link56.forum.service;
|
||||
|
||||
import cn.link56.forum.mapper.PostTagMapper;
|
||||
import cn.link56.forum.model.po.PostTagPO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class PostTagService extends ServiceImpl<PostTagMapper, PostTagPO> {
|
||||
@Resource
|
||||
private PostTagMapper postTagMapper;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package cn.link56.post.controller;
|
||||
|
||||
import cn.link56.common.Result;
|
||||
import cn.link56.post.model.dto.PostAddDTO;
|
||||
import cn.link56.post.model.vo.PostEditVO;
|
||||
import cn.link56.post.model.vo.PostTagVO;
|
||||
import cn.link56.post.service.PostService;
|
||||
import cn.link56.post.service.PostTagService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/post")
|
||||
public class PostController {
|
||||
|
||||
@Resource
|
||||
private PostService postService;
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result<PostEditVO> addPost(@RequestBody @Validated PostAddDTO postAddDTO) {
|
||||
PostEditVO postEditVO = postService.addPost(postAddDTO);
|
||||
return Result.success(postEditVO);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package cn.link56.post.controller;
|
||||
|
||||
import cn.link56.common.Result;
|
||||
import cn.link56.post.mapper.PostTagMapper;
|
||||
import cn.link56.post.model.vo.PostTagVO;
|
||||
import cn.link56.post.service.PostTagService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/post/tag")
|
||||
public class PostTagController {
|
||||
@Resource
|
||||
private PostTagService postTagService;
|
||||
|
||||
@GetMapping
|
||||
public Result<List<PostTagVO>> listTags(){
|
||||
List<PostTagVO> list = postTagService.listTags();
|
||||
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.link56.forum.mapper;
|
||||
package cn.link56.post.mapper;
|
||||
|
||||
import cn.link56.forum.model.po.PostCommentPO;
|
||||
import cn.link56.post.model.po.PostCommentPO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.link56.forum.mapper;
|
||||
package cn.link56.post.mapper;
|
||||
|
||||
import cn.link56.forum.model.po.PostFavoritePO;
|
||||
import cn.link56.post.model.po.PostFavoritePO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.link56.forum.mapper;
|
||||
package cn.link56.post.mapper;
|
||||
|
||||
import cn.link56.forum.model.po.PostLikePO;
|
||||
import cn.link56.post.model.po.PostLikePO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.link56.forum.mapper;
|
||||
package cn.link56.post.mapper;
|
||||
|
||||
import cn.link56.forum.model.po.PostPO;
|
||||
import cn.link56.post.model.po.PostPO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
+5
-2
@@ -1,9 +1,12 @@
|
||||
package cn.link56.forum.mapper;
|
||||
package cn.link56.post.mapper;
|
||||
|
||||
import cn.link56.forum.model.po.PostTagPO;
|
||||
import cn.link56.post.model.po.PostTagPO;
|
||||
import cn.link56.post.model.vo.PostTagVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PostTagMapper extends BaseMapper<PostTagPO> {
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cn.link56.forum.mapper;
|
||||
package cn.link56.post.mapper;
|
||||
|
||||
import cn.link56.forum.model.po.PostViewPO;
|
||||
import cn.link56.post.model.po.PostViewPO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.link56.post.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PostAddDTO {
|
||||
@NotBlank(message = "帖子标题不能为空")
|
||||
private String title;
|
||||
@NotBlank(message = "帖子内容不能为空")
|
||||
private String content;
|
||||
@NotBlank(message = "帖子摘要不能为空")
|
||||
private String summary;
|
||||
private String cover;
|
||||
private List<String> tags;
|
||||
|
||||
private Integer status;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.link56.forum.model.po;
|
||||
package cn.link56.post.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.link56.forum.model.po;
|
||||
package cn.link56.post.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.link56.forum.model.po;
|
||||
package cn.link56.post.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
+19
-9
@@ -1,12 +1,16 @@
|
||||
package cn.link56.forum.model.po;
|
||||
package cn.link56.post.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -28,33 +32,39 @@ public class PostPO {
|
||||
@TableField("b_summary")
|
||||
private String summary;
|
||||
|
||||
@TableField("b_tags")
|
||||
private String tags;
|
||||
@TableField("b_tag")
|
||||
private String tag;
|
||||
|
||||
@TableField("b_cover")
|
||||
private String cover;
|
||||
|
||||
@TableField("b_publish_time")
|
||||
private String publishTime;
|
||||
|
||||
@TableField("b_status")
|
||||
private Integer status;
|
||||
|
||||
@TableField(
|
||||
value = "b_create_user_id",
|
||||
value = "b_create_by",
|
||||
fill = FieldFill.INSERT
|
||||
)
|
||||
private Long createUserId;
|
||||
private Long createBy;
|
||||
|
||||
@TableField(
|
||||
value = "b_create_time",
|
||||
fill = FieldFill.INSERT
|
||||
)
|
||||
private Long createTime;
|
||||
private Date createTime;
|
||||
|
||||
@TableField(
|
||||
value = "b_update_user_id",
|
||||
value = "b_update_by",
|
||||
fill = FieldFill.INSERT_UPDATE
|
||||
)
|
||||
private Long updateUserId;
|
||||
private Long updateBy;
|
||||
|
||||
@TableField(
|
||||
value = "b_update_time",
|
||||
fill = FieldFill.INSERT_UPDATE
|
||||
)
|
||||
private Long updateTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.link56.forum.model.po;
|
||||
package cn.link56.post.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package cn.link56.forum.model.po;
|
||||
package cn.link56.post.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.link56.post.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PostEditVO {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private String summary;
|
||||
private String cover;
|
||||
private List<String> tags;
|
||||
private Integer status;
|
||||
private Date publishTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.link56.post.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PostTagVO {
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cn.link56.forum.service;
|
||||
package cn.link56.post.service;
|
||||
|
||||
import cn.link56.forum.mapper.PostCommentMapper;
|
||||
import cn.link56.forum.model.po.PostCommentPO;
|
||||
import cn.link56.post.mapper.PostCommentMapper;
|
||||
import cn.link56.post.model.po.PostCommentPO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cn.link56.forum.service;
|
||||
package cn.link56.post.service;
|
||||
|
||||
import cn.link56.forum.mapper.PostFavoriteMapper;
|
||||
import cn.link56.forum.model.po.PostFavoritePO;
|
||||
import cn.link56.post.mapper.PostFavoriteMapper;
|
||||
import cn.link56.post.model.po.PostFavoritePO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cn.link56.forum.service;
|
||||
package cn.link56.post.service;
|
||||
|
||||
import cn.link56.forum.mapper.PostLikeMapper;
|
||||
import cn.link56.forum.model.po.PostLikePO;
|
||||
import cn.link56.post.mapper.PostLikeMapper;
|
||||
import cn.link56.post.model.po.PostLikePO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.link56.post.service;
|
||||
|
||||
import cn.link56.common.context.UserContext;
|
||||
import cn.link56.post.mapper.PostMapper;
|
||||
import cn.link56.post.model.dto.PostAddDTO;
|
||||
import cn.link56.post.model.po.PostPO;
|
||||
import cn.link56.post.model.vo.PostEditVO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class PostService extends ServiceImpl<PostMapper, PostPO> {
|
||||
@Resource
|
||||
private PostMapper postMapper;
|
||||
|
||||
@Transactional
|
||||
public PostEditVO addPost(PostAddDTO postAddDTO) {
|
||||
PostPO postPO = new PostPO();
|
||||
|
||||
BeanUtils.copyProperties(postAddDTO, postPO);
|
||||
|
||||
postPO.setTag(StringUtils.join(postAddDTO.getTags(), ","));
|
||||
postPO.setCompanyId(UserContext.getCompanyId());
|
||||
|
||||
postMapper.insert(postPO);
|
||||
|
||||
PostEditVO postEditVO = new PostEditVO();
|
||||
|
||||
BeanUtils.copyProperties(postPO, postEditVO);
|
||||
postEditVO.setTags(postAddDTO.getTags());
|
||||
|
||||
return postEditVO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.link56.post.service;
|
||||
|
||||
import cn.link56.post.mapper.PostTagMapper;
|
||||
import cn.link56.post.model.po.PostTagPO;
|
||||
import cn.link56.post.model.vo.PostTagVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PostTagService extends ServiceImpl<PostTagMapper, PostTagPO> {
|
||||
@Resource
|
||||
private PostTagMapper postTagMapper;
|
||||
|
||||
public List<PostTagVO> listTags() {
|
||||
LambdaQueryWrapper<PostTagPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PostTagPO::getCanuse,"1");
|
||||
|
||||
List<PostTagPO> postTagPOS = postTagMapper.selectList(wrapper);
|
||||
|
||||
return postTagPOS.stream().map(postTagPO -> {
|
||||
PostTagVO postTagVO = new PostTagVO();
|
||||
BeanUtils.copyProperties(postTagPO, postTagVO);
|
||||
|
||||
return postTagVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cn.link56.forum.service;
|
||||
package cn.link56.post.service;
|
||||
|
||||
import cn.link56.forum.mapper.PostViewMapper;
|
||||
import cn.link56.forum.model.po.PostViewPO;
|
||||
import cn.link56.post.mapper.PostViewMapper;
|
||||
import cn.link56.post.model.po.PostViewPO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -16,6 +16,9 @@ logging:
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
mail:
|
||||
host: smtp.163.com #邮箱服务器地址
|
||||
username: hi_itao@163.com #邮箱账号
|
||||
|
||||
Reference in new issue
Block a user