门户同步教材详情添加是否点赞、收藏
This commit is contained in:
parent
d80480336b
commit
0a61a6e8cf
|
@ -128,7 +128,13 @@ public class SysOssPersonController extends BaseController {
|
|||
sysOssPersonService.download(id, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 预览
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SaCheckPermission("file:person:preview")
|
||||
@PostMapping("/preview/{id}")
|
||||
public R<String> preview(@NotNull(message = "主键不能为空") @PathVariable Long id) throws Exception {
|
||||
|
|
|
@ -79,6 +79,9 @@ public class SysOssTextbookVo implements Serializable {
|
|||
@Translation(type = TransConstant.DEPT_ID_TO_NAME)
|
||||
private Long createDept;
|
||||
|
||||
private Boolean isLike;
|
||||
private Boolean isCollect;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.dromara.system.service.ISysOssService;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -237,6 +238,9 @@ public class SysOssPersonServiceImpl implements ISysOssPersonService {
|
|||
date.setFileSuffix(ossPerson.getFileSuffix());
|
||||
date.setFilePath(path);
|
||||
date.setType(ossPerson.getType());
|
||||
date.setCreateDept(ossPerson.getCreateDept());
|
||||
date.setCreateBy(ossPerson.getCreateBy());
|
||||
date.setCreateTime(new Date());
|
||||
return textbookMapper.insert(date) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,7 +306,6 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
|
||||
@Override
|
||||
public Boolean like(OperateOssTextbookBo bo) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Integer operate = bo.getOperate();
|
||||
Long ossTextbookId = bo.getOssTextbookId();
|
||||
SysTextbookRecord data = new SysTextbookRecord();
|
||||
|
@ -316,10 +315,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
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));
|
||||
textbookRecordMapper.delete(buildRecordQueryWrapper(data));
|
||||
baseMapper.subLikeNum(ossTextbookId);
|
||||
}
|
||||
return true;
|
||||
|
@ -327,7 +323,6 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
|
||||
@Override
|
||||
public Boolean collect(OperateOssTextbookBo bo) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
Integer operate = bo.getOperate();
|
||||
Long ossTextbookId = bo.getOssTextbookId();
|
||||
SysTextbookRecord data = new SysTextbookRecord();
|
||||
|
@ -337,10 +332,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
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));
|
||||
textbookRecordMapper.delete(buildRecordQueryWrapper(data));
|
||||
baseMapper.subCollectNum(ossTextbookId);
|
||||
}
|
||||
return true;
|
||||
|
@ -348,18 +340,27 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
|||
|
||||
@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>()
|
||||
textbookRecordMapper.delete(buildRecordQueryWrapper(data));
|
||||
textbookRecordMapper.insert(data);
|
||||
//是否点赞
|
||||
data.setRecordType(RecordTypeConstants.LIKE);
|
||||
ossTextbookVo.setIsLike(textbookRecordMapper.exists(buildRecordQueryWrapper(data)));
|
||||
//是否收藏
|
||||
data.setRecordType(RecordTypeConstants.COLLECT);
|
||||
ossTextbookVo.setIsCollect(textbookRecordMapper.exists(buildRecordQueryWrapper(data)));
|
||||
return ossTextbookVo;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysTextbookRecord> buildRecordQueryWrapper(SysTextbookRecord data) {
|
||||
return new LambdaQueryWrapper<SysTextbookRecord>()
|
||||
.eq(SysTextbookRecord::getOssTextbookId, data.getOssTextbookId())
|
||||
.eq(SysTextbookRecord::getRecordType, data.getRecordType())
|
||||
.eq(SysTextbookRecord::getCreateBy, userId));
|
||||
textbookRecordMapper.insert(data);
|
||||
return ossTextbookVo;
|
||||
.eq(SysTextbookRecord::getCreateBy, LoginHelper.getUserId());
|
||||
}
|
||||
|
||||
private List<String> processFormatSuffixQuery(int format) {
|
||||
|
|
Loading…
Reference in New Issue