新增点赞、收藏、浏览记录功能
This commit is contained in:
parent
e3e4e9baaf
commit
a286f91ef5
|
@ -0,0 +1,19 @@
|
|||
package org.dromara.system.constant;
|
||||
|
||||
/**
|
||||
* 点赞,收藏,浏览记录
|
||||
*/
|
||||
public interface RecordTypeConstants {
|
||||
/**
|
||||
* 点赞
|
||||
*/
|
||||
Integer LIKE = 1;
|
||||
/**
|
||||
* 收藏
|
||||
*/
|
||||
Integer COLLECT = 2;
|
||||
/**
|
||||
* 记录
|
||||
*/
|
||||
Integer RECORD = 3;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.dromara.system.constant;
|
||||
|
||||
public interface StatusConstants {
|
||||
|
||||
Integer DISABLED = 0;
|
||||
|
||||
Integer IN_USE = 1;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.dromara.system.controller.portal;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.domain.bo.SysOssTextbookBo;
|
||||
import org.dromara.system.domain.vo.SysOssTextbookVo;
|
||||
import org.dromara.system.service.ISysOssTextbookService;
|
||||
import org.dromara.system.service.ISysTextbookRecordService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>TODO<p>
|
||||
*
|
||||
* @author cjw
|
||||
* @version V1.0.0
|
||||
* @date 2024/7/15 16:59
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/person")
|
||||
public class PersonSpaceController {
|
||||
|
||||
private final ISysTextbookRecordService recordService;
|
||||
|
||||
private final ISysOssTextbookService textbookService;
|
||||
|
||||
/**
|
||||
* 查询我的上传
|
||||
*/
|
||||
@GetMapping("/textbook/pageList")
|
||||
public TableDataInfo<SysOssTextbookVo> textbookList(SysOssTextbookBo bo, PageQuery pageQuery) {
|
||||
bo.setCreateBy(LoginHelper.getUserId());
|
||||
return textbookService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
}
|
|
@ -46,7 +46,7 @@ public class PortalController extends BaseController {
|
|||
* 查询门户Banner列表
|
||||
*/
|
||||
@GetMapping("/banner/list")
|
||||
public TableDataInfo<SysHomeBannerVo> bannerList(HttpServletRequest request,SysHomeBannerBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<SysHomeBannerVo> bannerList(HttpServletRequest request, SysHomeBannerBo bo, PageQuery pageQuery) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
return bannerService.queryPageList(bo, pageQuery);
|
||||
|
@ -56,7 +56,7 @@ public class PortalController extends BaseController {
|
|||
* 查询学校名师列表
|
||||
*/
|
||||
@GetMapping("/show/list")
|
||||
public TableDataInfo<SysHomeShowVo> showList(HttpServletRequest request,SysHomeShowBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<SysHomeShowVo> showList(HttpServletRequest request, SysHomeShowBo bo, PageQuery pageQuery) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
return showService.queryPageList(bo, pageQuery);
|
||||
|
@ -77,7 +77,7 @@ public class PortalController extends BaseController {
|
|||
* 查询学校动态列表
|
||||
*/
|
||||
@GetMapping("/trend/list")
|
||||
public TableDataInfo<SysHomeTrendVo> trendList(HttpServletRequest request,SysHomeTrendBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<SysHomeTrendVo> trendList(HttpServletRequest request, SysHomeTrendBo bo, PageQuery pageQuery) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
return trendService.queryPageList(bo, pageQuery);
|
||||
|
@ -98,7 +98,7 @@ public class PortalController extends BaseController {
|
|||
* 分页查询目录-专题资源
|
||||
*/
|
||||
@GetMapping("/resource/catalog/pageList")
|
||||
public TableDataInfo<SysCatalogResourceVo> pageList(HttpServletRequest request,SysCatalogResourceBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<SysCatalogResourceVo> pageList(HttpServletRequest request, SysCatalogResourceBo bo, PageQuery pageQuery) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
//TenantHelper.setDynamic(tenantId);
|
||||
bo.setAncestors(tenantId);
|
||||
|
@ -109,7 +109,7 @@ public class PortalController extends BaseController {
|
|||
* 查询目录-专题资源
|
||||
*/
|
||||
@GetMapping("/resource/catalog/tree")
|
||||
public R<List<Tree<Long>>> treeList(HttpServletRequest request,SysCatalogResourceBo bo) {
|
||||
public R<List<Tree<Long>>> treeList(HttpServletRequest request, SysCatalogResourceBo bo) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
List<Tree<Long>> trees = resourceService.buildTreeSelect(bo);
|
||||
|
@ -121,7 +121,7 @@ public class PortalController extends BaseController {
|
|||
* 查询目录-专题资源
|
||||
*/
|
||||
@GetMapping("/resource/catalog/list")
|
||||
public R<List<SysCatalogResourceVo>> resourceCatalogList(HttpServletRequest request,SysCatalogResourceBo bo) {
|
||||
public R<List<SysCatalogResourceVo>> resourceCatalogList(HttpServletRequest request, SysCatalogResourceBo bo) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
List<SysCatalogResourceVo> list = resourceService.queryList(bo);
|
||||
|
@ -132,7 +132,7 @@ public class PortalController extends BaseController {
|
|||
* 查询专题资源列表
|
||||
*/
|
||||
@GetMapping("/resource/list")
|
||||
public TableDataInfo<SysOssResourceVo> resourceList(HttpServletRequest request,SysOssResourceBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<SysOssResourceVo> resourceList(HttpServletRequest request, SysOssResourceBo bo, PageQuery pageQuery) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
return ossResourceService.queryPageList(bo, pageQuery);
|
||||
|
@ -147,14 +147,14 @@ public class PortalController extends BaseController {
|
|||
|
||||
@PostMapping("/resource/preview/{id}")
|
||||
public R<String> resourcePreview(@PathVariable Long id) {
|
||||
return R.ok("操作成功",ossResourceService.preview(id));
|
||||
return R.ok("操作成功", ossResourceService.preview(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询目录-同步教材
|
||||
*/
|
||||
@GetMapping("/textbook/catalog/tree")
|
||||
public R<List<Tree<Long>>> treeList(HttpServletRequest request,SysCatalogTextbookBo bo) {
|
||||
public R<List<Tree<Long>>> treeList(HttpServletRequest request, SysCatalogTextbookBo bo) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
List<Tree<Long>> trees = textbookService.buildTreeSelect(bo);
|
||||
|
@ -165,7 +165,7 @@ public class PortalController extends BaseController {
|
|||
* 查询目录-同步教材
|
||||
*/
|
||||
@GetMapping("/textbook/catalog/list")
|
||||
public R<List<SysCatalogTextbookVo>> textbookCatalogList(HttpServletRequest request,SysCatalogTextbookBo bo) {
|
||||
public R<List<SysCatalogTextbookVo>> textbookCatalogList(HttpServletRequest request, SysCatalogTextbookBo bo) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
List<SysCatalogTextbookVo> list = textbookService.queryList(bo);
|
||||
|
@ -176,7 +176,7 @@ public class PortalController extends BaseController {
|
|||
* 查询同步教材列表
|
||||
*/
|
||||
@GetMapping("/textbook/list")
|
||||
public TableDataInfo<SysOssTextbookVo> textbookList(HttpServletRequest request,SysOssTextbookBo bo, PageQuery pageQuery) {
|
||||
public TableDataInfo<SysOssTextbookVo> textbookList(HttpServletRequest request, SysOssTextbookBo bo, PageQuery pageQuery) {
|
||||
String tenantId = ServletUtils.getHeader(request, "Tenantid");
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
return ossTextbookService.queryPageList(bo, pageQuery);
|
||||
|
@ -185,11 +185,33 @@ public class PortalController extends BaseController {
|
|||
@GetMapping("/textbook/{id}")
|
||||
public R<SysOssTextbookVo> getTextbookInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(ossTextbookService.queryById(id));
|
||||
return R.ok(ossTextbookService.browseById(id));
|
||||
}
|
||||
|
||||
@PostMapping("/textbook/preview/{id}")
|
||||
public R<String> textbookPreview(@PathVariable Long id) {
|
||||
return R.ok("操作成功",ossTextbookService.preview(id));
|
||||
return R.ok("操作成功", ossTextbookService.preview(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞
|
||||
*
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/textbook/like")
|
||||
public R<Void> like(@RequestBody OperateOssTextbookBo bo) {
|
||||
return toAjax(ossTextbookService.like(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 收藏
|
||||
*
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/textbook/collect")
|
||||
public R<Void> collect(@RequestBody OperateOssTextbookBo bo) {
|
||||
return toAjax(ossTextbookService.collect(bo));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,9 @@ public class SysOssTextbook extends TenantEntity {
|
|||
private Integer status;
|
||||
|
||||
private Long downloadNum;
|
||||
|
||||
private Long previewNum;
|
||||
private Long likeNum;
|
||||
private Long collectNum;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package org.dromara.system.domain;
|
||||
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 同步教材记录对象 sys_textbook_record
|
||||
*
|
||||
* @author cjw
|
||||
* @date 2024-07-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_textbook_record")
|
||||
public class SysTextbookRecord extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long ossTextbookId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer recordType;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.dromara.system.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>点赞,收藏等操作<p>
|
||||
*
|
||||
* @author cjw
|
||||
* @version V1.0.0
|
||||
* @date 2024/7/15 14:51
|
||||
*/
|
||||
@Data
|
||||
public class OperateOssTextbookBo {
|
||||
/**
|
||||
* 同步教材id
|
||||
*/
|
||||
private Long ossTextbookId;
|
||||
|
||||
/**
|
||||
* 具体操作 1.确定 0.取消
|
||||
*/
|
||||
private Integer operate;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.dromara.system.domain.bo;
|
||||
|
||||
import org.dromara.system.domain.SysTextbookRecord;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 同步教材记录业务对象 sys_textbook_record
|
||||
*
|
||||
* @author cjw
|
||||
* @date 2024-07-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = SysTextbookRecord.class, reverseConvertGenerate = false)
|
||||
public class SysTextbookRecordBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
||||
private Long ossTextbookId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
||||
private Integer recordType;
|
||||
|
||||
|
||||
}
|
|
@ -64,7 +64,8 @@ public class SysOssTextbookVo implements Serializable {
|
|||
|
||||
private Long downloadNum;
|
||||
private Long previewNum;
|
||||
|
||||
private Long likeNum;
|
||||
private Long collectNum;
|
||||
/**
|
||||
* 容量
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.dromara.system.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.system.domain.SysTextbookRecord;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 同步教材记录视图对象 sys_textbook_record
|
||||
*
|
||||
* @author cjw
|
||||
* @date 2024-07-15
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = SysTextbookRecord.class)
|
||||
public class SysTextbookRecordVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long ossTextbookId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer recordType;
|
||||
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import org.dromara.system.domain.vo.SysOssTextbookVo;
|
|||
public interface SysOssTextbookMapper extends BaseMapperPlus<SysOssTextbook, SysOssTextbookVo> {
|
||||
Page<SysOssTextbookVo> selectPageList(@Param("page") Page<SysOssTextbook> page,
|
||||
@Param(Constants.WRAPPER) Wrapper<SysOssTextbook> queryWrapper);
|
||||
|
||||
@DataPermission({
|
||||
@DataColumn(key = "userName", value = "ot.create_by")
|
||||
})
|
||||
|
@ -29,5 +30,12 @@ public interface SysOssTextbookMapper extends BaseMapperPlus<SysOssTextbook, Sys
|
|||
@Param(Constants.WRAPPER) Wrapper<SysOssTextbook> queryWrapper);
|
||||
|
||||
int addDownloadNum(Long id);
|
||||
|
||||
int addPreviewNum(Long id);
|
||||
|
||||
int addLikeNum(Long id);
|
||||
int subLikeNum(Long id);
|
||||
|
||||
int addCollectNum(Long id);
|
||||
int subCollectNum(Long id);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.dromara.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.system.domain.SysTextbookRecord;
|
||||
import org.dromara.system.domain.vo.SysTextbookRecordVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 同步教材记录Mapper接口
|
||||
*
|
||||
* @author cjw
|
||||
* @date 2024-07-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysTextbookRecordMapper extends BaseMapperPlus<SysTextbookRecord, SysTextbookRecordVo> {
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ package org.dromara.system.service;
|
|||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.bo.OperateOssTextbookBo;
|
||||
import org.dromara.system.domain.bo.SysOssTextbookBo;
|
||||
import org.dromara.system.domain.vo.SysOssTextbookVo;
|
||||
|
||||
|
@ -21,10 +22,10 @@ public interface ISysOssTextbookService {
|
|||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param ossId 主键
|
||||
* @param id 主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
SysOssTextbookVo queryById(Long ossId);
|
||||
SysOssTextbookVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询【请填写功能名称】列表
|
||||
|
@ -94,4 +95,10 @@ public interface ISysOssTextbookService {
|
|||
|
||||
String preview(Long id);
|
||||
|
||||
Boolean like(OperateOssTextbookBo bo);
|
||||
|
||||
Boolean collect(OperateOssTextbookBo bo);
|
||||
|
||||
SysOssTextbookVo browseById(Long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.dromara.system.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.bo.SysTextbookRecordBo;
|
||||
import org.dromara.system.domain.vo.SysTextbookRecordVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 同步教材记录Service接口
|
||||
*
|
||||
* @author cjw
|
||||
* @date 2024-07-15
|
||||
*/
|
||||
public interface ISysTextbookRecordService {
|
||||
|
||||
/**
|
||||
* 查询同步教材记录
|
||||
*
|
||||
* @param ossTextbookId 主键
|
||||
* @return 同步教材记录
|
||||
*/
|
||||
SysTextbookRecordVo queryById(Long ossTextbookId);
|
||||
|
||||
/**
|
||||
* 分页查询同步教材记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 同步教材记录分页列表
|
||||
*/
|
||||
TableDataInfo<SysTextbookRecordVo> queryPageList(SysTextbookRecordBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的同步教材记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 同步教材记录列表
|
||||
*/
|
||||
List<SysTextbookRecordVo> queryList(SysTextbookRecordBo bo);
|
||||
|
||||
}
|
|
@ -16,14 +16,20 @@ import org.dromara.common.core.utils.StringUtils;
|
|||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.constant.FileTypeConstants;
|
||||
import org.dromara.system.constant.RecordTypeConstants;
|
||||
import org.dromara.system.constant.StatusConstants;
|
||||
import org.dromara.system.domain.SysCatalogTextbook;
|
||||
import org.dromara.system.domain.SysOssTextbook;
|
||||
import org.dromara.system.domain.SysTextbookRecord;
|
||||
import org.dromara.system.domain.bo.OperateOssTextbookBo;
|
||||
import org.dromara.system.domain.bo.SysOssTextbookBo;
|
||||
import org.dromara.system.domain.vo.SysCatalogTextbookVo;
|
||||
import org.dromara.system.domain.vo.SysOssTextbookVo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.mapper.SysOssTextbookMapper;
|
||||
import org.dromara.system.mapper.SysTextbookRecordMapper;
|
||||
import org.dromara.system.service.ISysCatalogTextbookService;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.dromara.system.service.ISysOssTextbookService;
|
||||
|
@ -49,15 +55,17 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
|
||||
private final ISysOssService ossService;
|
||||
|
||||
private final SysTextbookRecordMapper textbookRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param ossId 主键
|
||||
* @param id 主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public SysOssTextbookVo queryById(Long ossId) {
|
||||
return baseMapper.selectVoById(ossId);
|
||||
public SysOssTextbookVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,6 +130,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
.eq(ObjectUtil.isNotNull(bo.getType()), "ot.type", bo.getType())
|
||||
.eq(ObjectUtil.isNotNull(bo.getStatus()), "ot.status", bo.getStatus())
|
||||
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), "ot.file_suffix", bo.getFileSuffix())
|
||||
.eq(ObjectUtil.isNotNull(bo.getCreateBy()), "ot.create_by", bo.getCreateBy())
|
||||
.like(StringUtils.isNotEmpty(bo.getFileName()), "ot.file_name", bo.getFileName())
|
||||
.and(ObjectUtil.isNotNull(bo.getCatalogId()), w -> {
|
||||
List<SysCatalogTextbook> list = catalogService.selectList(new LambdaQueryWrapper<SysCatalogTextbook>()
|
||||
|
@ -295,6 +304,64 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
return ossService.getUrlById(ossTextbook.getOssId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean like(OperateOssTextbookBo bo) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Integer operate = bo.getOperate();
|
||||
Long ossTextbookId = bo.getOssTextbookId();
|
||||
SysTextbookRecord data = new SysTextbookRecord();
|
||||
data.setOssTextbookId(bo.getOssTextbookId());
|
||||
data.setRecordType(RecordTypeConstants.LIKE);
|
||||
if (StatusConstants.IN_USE.equals(operate)) {
|
||||
baseMapper.addLikeNum(ossTextbookId);
|
||||
textbookRecordMapper.insert(data);
|
||||
} else {
|
||||
textbookRecordMapper.delete(new LambdaQueryWrapper<SysTextbookRecord>()
|
||||
.eq(SysTextbookRecord::getOssTextbookId, data.getOssTextbookId())
|
||||
.eq(SysTextbookRecord::getRecordType, data.getRecordType())
|
||||
.eq(SysTextbookRecord::getCreateBy, userId));
|
||||
baseMapper.subLikeNum(ossTextbookId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean collect(OperateOssTextbookBo bo) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Integer operate = bo.getOperate();
|
||||
Long ossTextbookId = bo.getOssTextbookId();
|
||||
SysTextbookRecord data = new SysTextbookRecord();
|
||||
data.setOssTextbookId(bo.getOssTextbookId());
|
||||
data.setRecordType(RecordTypeConstants.COLLECT);
|
||||
if (StatusConstants.IN_USE.equals(operate)) {
|
||||
baseMapper.addCollectNum(ossTextbookId);
|
||||
textbookRecordMapper.insert(data);
|
||||
} else {
|
||||
textbookRecordMapper.delete(new LambdaQueryWrapper<SysTextbookRecord>()
|
||||
.eq(SysTextbookRecord::getOssTextbookId, data.getOssTextbookId())
|
||||
.eq(SysTextbookRecord::getRecordType, data.getRecordType())
|
||||
.eq(SysTextbookRecord::getCreateBy, userId));
|
||||
baseMapper.subCollectNum(ossTextbookId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysOssTextbookVo browseById(Long id) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
SysOssTextbookVo ossTextbookVo = baseMapper.selectVoById(id);
|
||||
SysTextbookRecord data = new SysTextbookRecord();
|
||||
data.setOssTextbookId(id);
|
||||
data.setRecordType(RecordTypeConstants.RECORD);
|
||||
//不管如何先删再添加
|
||||
textbookRecordMapper.delete(new LambdaQueryWrapper<SysTextbookRecord>()
|
||||
.eq(SysTextbookRecord::getOssTextbookId, data.getOssTextbookId())
|
||||
.eq(SysTextbookRecord::getRecordType, data.getRecordType())
|
||||
.eq(SysTextbookRecord::getCreateBy, userId));
|
||||
textbookRecordMapper.insert(data);
|
||||
return ossTextbookVo;
|
||||
}
|
||||
|
||||
private List<String> processFormatSuffixQuery(int format) {
|
||||
switch (format) {
|
||||
case 1 -> {
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package org.dromara.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.SysTextbookRecord;
|
||||
import org.dromara.system.domain.bo.SysTextbookRecordBo;
|
||||
import org.dromara.system.domain.vo.SysTextbookRecordVo;
|
||||
import org.dromara.system.mapper.SysTextbookRecordMapper;
|
||||
import org.dromara.system.service.ISysTextbookRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 同步教材记录Service业务层处理
|
||||
*
|
||||
* @author cjw
|
||||
* @date 2024-07-15
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysTextbookRecordServiceImpl implements ISysTextbookRecordService {
|
||||
|
||||
private final SysTextbookRecordMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询同步教材记录
|
||||
*
|
||||
* @param ossTextbookId 主键
|
||||
* @return 同步教材记录
|
||||
*/
|
||||
@Override
|
||||
public SysTextbookRecordVo queryById(Long ossTextbookId){
|
||||
return baseMapper.selectVoById(ossTextbookId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询同步教材记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 同步教材记录分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysTextbookRecordVo> queryPageList(SysTextbookRecordBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysTextbookRecord> lqw = buildQueryWrapper(bo);
|
||||
Page<SysTextbookRecordVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的同步教材记录列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 同步教材记录列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysTextbookRecordVo> queryList(SysTextbookRecordBo bo) {
|
||||
LambdaQueryWrapper<SysTextbookRecord> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysTextbookRecord> buildQueryWrapper(SysTextbookRecordBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysTextbookRecord> lqw = Wrappers.lambdaQuery();
|
||||
return lqw;
|
||||
}
|
||||
|
||||
}
|
|
@ -28,4 +28,28 @@
|
|||
set preview_num = preview_num + 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="addLikeNum">
|
||||
update sys_oss_textbook
|
||||
set like_num = like_num + 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="subLikeNum">
|
||||
update sys_oss_textbook
|
||||
set like_num = like_num - 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="addCollectNum">
|
||||
update sys_oss_textbook
|
||||
set collect_num = collect_num + 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="subCollectNum">
|
||||
update sys_oss_textbook
|
||||
set collect_num = collect_num - 1
|
||||
where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.SysTextbookRecordMapper">
|
||||
|
||||
<insert id="replaceInto">
|
||||
replace into
|
||||
</insert>
|
||||
</mapper>
|
Loading…
Reference in New Issue