feat:用户查看记录表代码生成
This commit is contained in:
1 parent
e717f2c9dd
commit
7e391852df
9 files changed
+470
No files matched your search
+1
@@ -58,4 +58,5 @@ public interface MemberErrorCode {
|
||||
ErrorCode RECENT_NOT_EXISTS = new ErrorCode(2_001_000_001, "朋友圈操作不存在");
|
||||
ErrorCode REPORT_TYPE_NOT_NULL = new ErrorCode(2_001_000_002, "举报类型不能为空");
|
||||
ErrorCode RATING_SCORE_NOT_NULL = new ErrorCode(2_001_000_003, "评价分数不能为空");
|
||||
ErrorCode VIEW_RECORD_NOT_EXISTS = new ErrorCode(2_001_000_004, "用户查看记录不存在");
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.viewrecord;
|
||||
|
||||
import cn.iocoder.yudao.module.member.service.recent.ViewRecordService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.viewrecord.ViewRecordDO;
|
||||
|
||||
@Tag(name = "管理后台 - 用户查看记录")
|
||||
@RestController
|
||||
@RequestMapping("/member/view-record")
|
||||
@Validated
|
||||
public class ViewRecordController {
|
||||
|
||||
@Resource
|
||||
private ViewRecordService viewRecordService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户查看记录")
|
||||
@PreAuthorize("@ss.hasPermission('member:view-record:create')")
|
||||
public CommonResult<Long> createViewRecord(@Valid @RequestBody ViewRecordSaveReqVO createReqVO) {
|
||||
return success(viewRecordService.createViewRecord(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户查看记录")
|
||||
@PreAuthorize("@ss.hasPermission('member:view-record:update')")
|
||||
public CommonResult<Boolean> updateViewRecord(@Valid @RequestBody ViewRecordSaveReqVO updateReqVO) {
|
||||
viewRecordService.updateViewRecord(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户查看记录")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:view-record:delete')")
|
||||
public CommonResult<Boolean> deleteViewRecord(@RequestParam("id") Long id) {
|
||||
viewRecordService.deleteViewRecord(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户查看记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('member:view-record:query')")
|
||||
public CommonResult<ViewRecordRespVO> getViewRecord(@RequestParam("id") Long id) {
|
||||
ViewRecordDO viewRecord = viewRecordService.getViewRecord(id);
|
||||
return success(BeanUtils.toBean(viewRecord, ViewRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户查看记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('member:view-record:query')")
|
||||
public CommonResult<PageResult<ViewRecordRespVO>> getViewRecordPage(@Valid ViewRecordPageReqVO pageReqVO) {
|
||||
PageResult<ViewRecordDO> pageResult = viewRecordService.getViewRecordPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ViewRecordRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出用户查看记录 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('member:view-record:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportViewRecordExcel(@Valid ViewRecordPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ViewRecordDO> list = viewRecordService.getViewRecordPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "用户查看记录.xls", "数据", ViewRecordRespVO.class, BeanUtils.toBean(list, ViewRecordRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 用户查看记录分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ViewRecordPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户编号", example = "11805")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "查询分类、查看朋友圈", example = "1")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "查询分类、查看朋友圈", example = "9753")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "查看的标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "开始查看时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] viewStartTime;
|
||||
|
||||
@Schema(description = "结束查看时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] viewEndTime;
|
||||
|
||||
@Schema(description = "查看时间(秒)")
|
||||
private Integer viewSecond;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户查看记录 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ViewRecordRespVO {
|
||||
|
||||
@Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7112")
|
||||
@ExcelProperty("收件地址编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11805")
|
||||
@ExcelProperty("用户编号")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "查询分类、查看朋友圈", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("查询分类、查看朋友圈")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "查询分类、查看朋友圈", example = "9753")
|
||||
@ExcelProperty("查询分类、查看朋友圈")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "查看的标题")
|
||||
@ExcelProperty("查看的标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "开始查看时间")
|
||||
@ExcelProperty("开始查看时间")
|
||||
private LocalDateTime viewStartTime;
|
||||
|
||||
@Schema(description = "结束查看时间")
|
||||
@ExcelProperty("结束查看时间")
|
||||
private LocalDateTime viewEndTime;
|
||||
|
||||
@Schema(description = "查看时间(秒)")
|
||||
@ExcelProperty("查看时间(秒)")
|
||||
private Integer viewSecond;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户查看记录新增/修改 Request VO")
|
||||
@Data
|
||||
public class ViewRecordSaveReqVO {
|
||||
|
||||
@Schema(description = "收件地址编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7112")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11805")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "查询分类、查看朋友圈", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "查询分类、查看朋友圈不能为空")
|
||||
private String bizType;
|
||||
|
||||
@Schema(description = "查询分类、查看朋友圈", example = "9753")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "查看的标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "开始查看时间")
|
||||
private LocalDateTime viewStartTime;
|
||||
|
||||
@Schema(description = "结束查看时间")
|
||||
private LocalDateTime viewEndTime;
|
||||
|
||||
@Schema(description = "查看时间(秒)")
|
||||
private Integer viewSecond;
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.viewrecord;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 用户查看记录 DO
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@TableName("member_view_record")
|
||||
@KeySequence("member_view_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ViewRecordDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 收件地址编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Long memberId;
|
||||
|
||||
/**
|
||||
* 查询分类、查看朋友圈
|
||||
*/
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 查询分类、查看朋友圈
|
||||
*/
|
||||
private Long bizId;
|
||||
|
||||
/**
|
||||
* 查看的标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 开始查看时间
|
||||
*/
|
||||
private LocalDateTime viewStartTime;
|
||||
|
||||
/**
|
||||
* 结束查看时间
|
||||
*/
|
||||
private LocalDateTime viewEndTime;
|
||||
|
||||
/**
|
||||
* 查看时间(秒)
|
||||
*/
|
||||
private Integer viewSecond;
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.viewrecord;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.viewrecord.ViewRecordDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo.*;
|
||||
|
||||
/**
|
||||
* 用户查看记录 Mapper
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Mapper
|
||||
public interface ViewRecordMapper extends BaseMapperX<ViewRecordDO> {
|
||||
|
||||
default PageResult<ViewRecordDO> selectPage(ViewRecordPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ViewRecordDO>()
|
||||
.eqIfPresent(ViewRecordDO::getMemberId, reqVO.getMemberId())
|
||||
.eqIfPresent(ViewRecordDO::getBizType, reqVO.getBizType())
|
||||
.eqIfPresent(ViewRecordDO::getBizId, reqVO.getBizId())
|
||||
.eqIfPresent(ViewRecordDO::getTitle, reqVO.getTitle())
|
||||
.betweenIfPresent(ViewRecordDO::getViewStartTime, reqVO.getViewStartTime())
|
||||
.betweenIfPresent(ViewRecordDO::getViewEndTime, reqVO.getViewEndTime())
|
||||
.eqIfPresent(ViewRecordDO::getViewSecond, reqVO.getViewSecond())
|
||||
.betweenIfPresent(ViewRecordDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ViewRecordDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.member.service.recent;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.viewrecord.ViewRecordDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 用户查看记录 Service 接口
|
||||
*/
|
||||
public interface ViewRecordService {
|
||||
|
||||
/**
|
||||
* 创建用户查看记录
|
||||
*/
|
||||
Long createViewRecord(@Valid ViewRecordSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户查看记录
|
||||
*/
|
||||
void updateViewRecord(@Valid ViewRecordSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户查看记录
|
||||
*/
|
||||
void deleteViewRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户查看记录
|
||||
*/
|
||||
ViewRecordDO getViewRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户查看记录分页
|
||||
*/
|
||||
PageResult<ViewRecordDO> getViewRecordPage(ViewRecordPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package cn.iocoder.yudao.module.member.service.recent;
|
||||
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.viewrecord.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.viewrecord.ViewRecordDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.viewrecord.ViewRecordMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 用户查看记录 Service 实现类
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ViewRecordServiceImpl implements ViewRecordService {
|
||||
|
||||
@Resource
|
||||
private ViewRecordMapper viewRecordMapper;
|
||||
|
||||
/**
|
||||
* 创建用户查看记录
|
||||
*/
|
||||
@Override
|
||||
public Long createViewRecord(ViewRecordSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ViewRecordDO viewRecord = BeanUtils.toBean(createReqVO, ViewRecordDO.class);
|
||||
viewRecordMapper.insert(viewRecord);
|
||||
// 返回
|
||||
return viewRecord.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户查看记录
|
||||
*/
|
||||
@Override
|
||||
public void updateViewRecord(ViewRecordSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateViewRecordExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ViewRecordDO updateObj = BeanUtils.toBean(updateReqVO, ViewRecordDO.class);
|
||||
viewRecordMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户查看记录
|
||||
*/
|
||||
@Override
|
||||
public void deleteViewRecord(Long id) {
|
||||
// 校验存在
|
||||
validateViewRecordExists(id);
|
||||
// 删除
|
||||
viewRecordMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户查看记录
|
||||
*/
|
||||
@Override
|
||||
public ViewRecordDO getViewRecord(Long id) {
|
||||
return viewRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户查看记录分页
|
||||
*/
|
||||
@Override
|
||||
public PageResult<ViewRecordDO> getViewRecordPage(ViewRecordPageReqVO pageReqVO) {
|
||||
return viewRecordMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateViewRecordExists(Long id) {
|
||||
if (viewRecordMapper.selectById(id) == null) {
|
||||
throw exception(MemberErrorCode.VIEW_RECORD_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user