8 changed files with 430 additions and 1 deletions
@ -0,0 +1,118 @@ |
|||||
|
package com.qs.serve.modules.biz.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.biz.entity.so.BizCommentSo; |
||||
|
import com.qs.serve.modules.biz.entity.bo.BizCommentBo; |
||||
|
import com.qs.serve.modules.biz.entity.BizComment; |
||||
|
import com.qs.serve.modules.biz.service.BizCommentService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 业务 通用的评论 |
||||
|
* @author YenHex |
||||
|
* @since 2023-02-17 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("biz/comment") |
||||
|
public class BizCommentController { |
||||
|
|
||||
|
private BizCommentService bizCommentService; |
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<BizComment>> getList(BizCommentSo param){ |
||||
|
BizComment entity = CopierUtil.copy(param,new BizComment()); |
||||
|
LambdaQueryWrapper<BizComment> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
PageUtil.startPage(); |
||||
|
List<BizComment> list = bizCommentService.list(lqw); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
public R<PageVo<BizComment>> getPage(BizCommentSo param){ |
||||
|
BizComment entity = CopierUtil.copy(param,new BizComment()); |
||||
|
LambdaQueryWrapper<BizComment> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
PageUtil.startPage(); |
||||
|
List<BizComment> list = bizCommentService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
public R<BizComment> getById(@PathVariable("id") String id){ |
||||
|
BizComment bizComment = bizCommentService.getById(id); |
||||
|
return R.ok(bizComment); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/updateById") |
||||
|
@SysLog(module = SystemModule.BIZ, title = "评论", biz = BizType.UPDATE) |
||||
|
@PreAuthorize("hasRole('biz:comment:update')") |
||||
|
public R<?> updateById(@RequestBody @Valid BizCommentBo param){ |
||||
|
BizComment entity = CopierUtil.copy(param,new BizComment()); |
||||
|
boolean result = bizCommentService.updateById(entity); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/save") |
||||
|
@SysLog(module = SystemModule.BIZ, title = "评论", biz = BizType.INSERT) |
||||
|
public R<?> save(@RequestBody @Valid BizCommentBo param){ |
||||
|
BizComment entity = CopierUtil.copy(param,new BizComment()); |
||||
|
boolean result = bizCommentService.save(entity); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{ids}") |
||||
|
@SysLog(module = SystemModule.BIZ, title = "评论", biz = BizType.DELETE) |
||||
|
public R<?> deleteById(@PathVariable("ids") String ids){ |
||||
|
List<Long> idsLong = StringUtils.splitIdLong(ids); |
||||
|
boolean result = bizCommentService.removeByIds(idsLong); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,96 @@ |
|||||
|
package com.qs.serve.modules.biz.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 通用的评论 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-02-17 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("biz_comment") |
||||
|
public class BizComment implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 目标类型 */ |
||||
|
@NotBlank(message = "目标类型不能为空") |
||||
|
@Length(max = 20,message = "目标类型长度不能超过20字") |
||||
|
private String targetType; |
||||
|
|
||||
|
/** 目标id */ |
||||
|
@NotBlank(message = "目标id不能为空") |
||||
|
@Length(max = 64,message = "目标id长度不能超过64字") |
||||
|
private String targetId; |
||||
|
|
||||
|
/** 用户id */ |
||||
|
@NotBlank(message = "用户id不能为空") |
||||
|
@Length(max = 40,message = "用户id长度不能超过40字") |
||||
|
private String userId; |
||||
|
|
||||
|
/** 用户名称 */ |
||||
|
@Length(max = 50,message = "用户名称长度不能超过50字") |
||||
|
private String userName; |
||||
|
|
||||
|
/** 头像 */ |
||||
|
@Length(max = 255,message = "头像长度不能超过255字") |
||||
|
private String userAvatar; |
||||
|
|
||||
|
/** 附件ID */ |
||||
|
@Length(max = 1024,message = "附件ID长度不能超过1024字") |
||||
|
private String docId; |
||||
|
|
||||
|
/** 内容 */ |
||||
|
@Length(max = 1024,message = "内容长度不能超过1024字") |
||||
|
private String context; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 租户id */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 删除标识 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private Boolean delFlag; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,87 @@ |
|||||
|
package com.qs.serve.modules.biz.entity.bo; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 通用的评论 Bo |
||||
|
* @author YenHex |
||||
|
* @since 2023-02-17 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BizCommentBo implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
private Long id; |
||||
|
|
||||
|
/** 目标类型 */ |
||||
|
@NotBlank(message = "目标类型不能为空") |
||||
|
@Length(max = 20,message = "目标类型长度不能超过20字") |
||||
|
private String targetType; |
||||
|
|
||||
|
/** 目标id */ |
||||
|
@NotBlank(message = "目标id不能为空") |
||||
|
@Length(max = 64,message = "目标id长度不能超过64字") |
||||
|
private String targetId; |
||||
|
|
||||
|
/** 用户id */ |
||||
|
@NotBlank(message = "用户id不能为空") |
||||
|
@Length(max = 40,message = "用户id长度不能超过40字") |
||||
|
private String userId; |
||||
|
|
||||
|
/** 用户名称 */ |
||||
|
@Length(max = 50,message = "用户名称长度不能超过50字") |
||||
|
private String userName; |
||||
|
|
||||
|
/** 头像 */ |
||||
|
@Length(max = 255,message = "头像长度不能超过255字") |
||||
|
private String userAvatar; |
||||
|
|
||||
|
/** 附件ID */ |
||||
|
@Length(max = 1024,message = "附件ID长度不能超过1024字") |
||||
|
private String docId; |
||||
|
|
||||
|
/** 内容 */ |
||||
|
@Length(max = 1024,message = "内容长度不能超过1024字") |
||||
|
private String context; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 租户id */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 删除标识 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private Boolean delFlag; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,77 @@ |
|||||
|
package com.qs.serve.modules.biz.entity.so; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 通用的评论 查询参数 |
||||
|
* @author YenHex |
||||
|
* @since 2023-02-17 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BizCommentSo implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
private Long id; |
||||
|
|
||||
|
/** 目标类型 */ |
||||
|
private String targetType; |
||||
|
|
||||
|
/** 目标id */ |
||||
|
private String targetId; |
||||
|
|
||||
|
/** 用户id */ |
||||
|
private String userId; |
||||
|
|
||||
|
/** 用户名称 */ |
||||
|
private String userName; |
||||
|
|
||||
|
/** 头像 */ |
||||
|
private String userAvatar; |
||||
|
|
||||
|
/** 附件ID */ |
||||
|
private String docId; |
||||
|
|
||||
|
/** 内容 */ |
||||
|
private String context; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 租户id */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 删除标识 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private Boolean delFlag; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.biz.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.biz.entity.BizComment; |
||||
|
|
||||
|
/** |
||||
|
* 通用的评论 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2023-02-17 |
||||
|
*/ |
||||
|
public interface BizCommentMapper extends BaseMapper<BizComment> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.biz.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.biz.entity.BizComment; |
||||
|
|
||||
|
/** |
||||
|
* 通用的评论 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2023-02-17 |
||||
|
*/ |
||||
|
public interface BizCommentService extends IService<BizComment> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
package com.qs.serve.modules.biz.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.biz.entity.BizComment; |
||||
|
import com.qs.serve.modules.biz.service.BizCommentService; |
||||
|
import com.qs.serve.modules.biz.mapper.BizCommentMapper; |
||||
|
|
||||
|
/** |
||||
|
* 通用的评论 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-02-17 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BizCommentServiceImpl extends ServiceImpl<BizCommentMapper,BizComment> implements BizCommentService { |
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue