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