我的收藏-取消收藏 同时取消订阅。

收藏、订阅查询列表 状态字段中英文切换、根据状态查询修改。
This commit is contained in:
wangzhijiang
2022-03-03 16:22:25 +08:00
parent d88cf8722e
commit 038cdab4c7
5 changed files with 85 additions and 12 deletions
@@ -30,7 +30,10 @@
and bdl.title like concat(concat('%',#{params.title}),'%')
</if>
<if test="params.state != null and params.state != '' ">
and bdl.state = #{params.state}
and bdl.state in
<foreach collection="params.state.split(',')" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by occ.create_time desc
</select>
@@ -14,6 +14,8 @@ import com.jero.modules.collection.entity.OnlCgformCollection;
import com.jero.modules.collection.mapper.OnlCgformCollectionMapper;
import com.jero.modules.collection.service.IOnlCgformCollectionService;
import com.jero.modules.ocr.util.LineHumpUtil;
import com.jero.modules.subscribe.entity.OnlCgformSubscribe;
import com.jero.modules.subscribe.mapper.OnlCgformSubscribeMapper;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
@@ -21,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -40,6 +43,8 @@ public class OnlCgformCollectionServiceImpl extends ServiceImpl<OnlCgformCollect
OnlCgformCollectionMapper onlCgformCollectionMapper;
@Autowired
private SysDictItemServiceImpl sysDictItemServiceImpl;
@Autowired
private OnlCgformSubscribeMapper onlCgformSubscribeMapper;
/**
* 保存
@@ -62,12 +67,25 @@ public class OnlCgformCollectionServiceImpl extends ServiceImpl<OnlCgformCollect
* @return
*/
@Override
@Transactional
public void deleteById(String id) {
boolean checkData = checkData(id);
if(!checkData){
throw new JeroBootException("该用户没有权限!");
}
removeById(id);
try {
OnlCgformCollection onlCgformCollection = super.baseMapper.selectById(id);
List<String> documentIdList = new ArrayList<>();
documentIdList.add(onlCgformCollection.getDocumentId());
//删除订阅
deleteSubscribe(documentIdList);
removeById(id);
}catch (Exception ex){
log.error("取消收藏失败:" + ex.getMessage());
throw new JeroBootException("取消收藏失败!");
}
}
/**
@@ -77,6 +95,7 @@ public class OnlCgformCollectionServiceImpl extends ServiceImpl<OnlCgformCollect
* @return
*/
@Override
@Transactional
public void deleteByIds(List<String> ids) {
for (String id : ids) {
boolean checkData = checkData(id);
@@ -84,7 +103,20 @@ public class OnlCgformCollectionServiceImpl extends ServiceImpl<OnlCgformCollect
throw new JeroBootException("该用户没有权限!");
}
}
removeByIds(ids);
try {
QueryWrapper<OnlCgformCollection> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(OnlCgformCollection::getId,ids);
List<OnlCgformCollection> onlCgformCollections = super.baseMapper.selectList(queryWrapper);
List<String> documentIdList = onlCgformCollections.stream().map(OnlCgformCollection::getDocumentId).distinct().collect(Collectors.toList());
//删除订阅
deleteSubscribe(documentIdList);
removeByIds(ids);
}catch (Exception ex){
log.error("批量取消收藏失败:" + ex.getMessage());
throw new JeroBootException("批量取消收藏失败!");
}
}
/**
@@ -196,25 +228,31 @@ public class OnlCgformCollectionServiceImpl extends ServiceImpl<OnlCgformCollect
params.put("createBy",sysUser.getUsername());
IPage result = onlCgformCollectionMapper.queryPageList(page,params);
List<Map<String,Object>> records = result.getRecords();
dataDispose(records);
dataDispose(records,params);
return result;
}
public void dataDispose(List<Map<String,Object>> datas){
public void dataDispose(List<Map<String,Object>> datas, Map<String,Object> params){
if(CollectionUtils.isNotEmpty(datas)){
List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();
//获取所有文本状态数据字典
List<SysDictItem> stateList = sysDictItems.stream()
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals("file_type"))
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals("state"))
.collect(Collectors.toList());
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
String cut = (String) params.get("cut");
for (Map<String, Object> data : datas) {
Date createTime = (Date) data.get("createTime");
data.put("createTime",sdf.format(createTime));
String state = (String) data.get("state");
for (SysDictItem sysDictItem : stateList) {
if(StringUtils.equals(state,sysDictItem.getItemValue())){
data.put("state",sysDictItem.getItemText());
if(StringUtils.equals(cut,"cn")){
data.put("state",sysDictItem.getItemText());
}else {
data.put("state",sysDictItem.getEnName());
}
break;
}
}
@@ -246,4 +284,17 @@ public class OnlCgformCollectionServiceImpl extends ServiceImpl<OnlCgformCollect
}
return result;
}
public void deleteSubscribe(List<String> docIdList){
try {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
QueryWrapper<OnlCgformSubscribe> deleteWarpper = new QueryWrapper<>();
deleteWarpper.lambda().in(OnlCgformSubscribe::getDocumentId,docIdList);
deleteWarpper.lambda().eq(OnlCgformSubscribe::getCreateBy,sysUser.getUsername());
onlCgformSubscribeMapper.delete(deleteWarpper);
}catch (Exception ex){
log.error("删除订阅信息失败:" + ex.getMessage());
throw new JeroBootException("删除订阅信息失败!");
}
}
}
@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 领域与用户关系
@@ -41,4 +43,11 @@ public class DomainUserRelController {
public Result<?> queryList(){
return domainUserRelService.queryList();
}
@AutoLog(value = "查询领域、文档关联的用户Id")
@ApiOperation(value="查询领域、文档关联的用户Id", notes="查询领域、文档关联的用户Id")
@PostMapping("/queryDomainUserRelInfo")
public Result<?> queryDomainUserRelInfo(@RequestBody Map<String,Object> params){
return Result.ok(domainUserRelService.queryDomainUserRelInfo(params));
}
}
@@ -31,7 +31,10 @@
and bdl.title like concat(concat('%',#{params.title}),'%')
</if>
<if test="params.state != null and params.state != '' ">
and bdl.state = #{params.state}
and bdl.state in
<foreach collection="params.state.split(',')" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by ocs.create_time desc
</select>
@@ -210,7 +210,7 @@ public class OnlCgformSubscribeServiceImpl extends ServiceImpl<OnlCgformSubscrib
params.put("createBy",sysUser.getUsername());
IPage result = onlCgformSubscribeMapper.queryPageList(page,params);
List<Map<String,Object>> records = result.getRecords();
dataDispose(records);
dataDispose(records,params);
return result;
}
@@ -241,21 +241,28 @@ public class OnlCgformSubscribeServiceImpl extends ServiceImpl<OnlCgformSubscrib
* 数据处理
* @param datas
*/
public void dataDispose(List<Map<String,Object>> datas){
public void dataDispose(List<Map<String,Object>> datas,Map<String,Object> params){
if(CollectionUtils.isNotEmpty(datas)){
List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();
//获取所有文本状态数据字典
List<SysDictItem> stateList = sysDictItems.stream()
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals("file_type"))
.filter(e -> StringUtils.isNotBlank(e.getDictCode()) && e.getDictCode().equals("state"))
.collect(Collectors.toList());
SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
//cut: cn 中文 en 英文
String cut = (String) params.get("cut");
for (Map<String, Object> data : datas) {
Date createTime = (Date) data.get("createTime");
data.put("createTime",sdf.format(createTime));
String state = (String) data.get("state");
for (SysDictItem sysDictItem : stateList) {
if(StringUtils.equals(state,sysDictItem.getItemValue())){
data.put("state",sysDictItem.getItemText());
if(StringUtils.equals(cut,"cn")){
data.put("state",sysDictItem.getItemText());
}else {
data.put("state",sysDictItem.getEnName());
}
break;
}
}