update
This commit is contained in:
parent
6c53e4c9ae
commit
045d857ae2
@ -73,18 +73,10 @@ public class ToolController extends BaseController
|
||||
for (Tool vo : list) {
|
||||
//创建人、下载权限、系统管理员
|
||||
//1.已经审核通过、并且有下载权限
|
||||
vo.setDownloadStatus(
|
||||
userId.equals(vo.getCreateBy())||
|
||||
SysUser.isAdmin(SecurityUtils.getUserId()) ||
|
||||
SecurityUtils.hasPermi(Constants.DOWNLOAD_TOOL_PERMISSION) ||
|
||||
( RecordStatusEnum.DONE.getCode().equals(vo.getRecordStatus())&&
|
||||
iToolApplyService.checkToolApply(vo.getToolId(),userId)));
|
||||
vo.setDownloadStatus(toolService.isDownloadStatus(userId, vo));
|
||||
|
||||
ToolApply toolApply = new ToolApply();
|
||||
toolApply.setToolId(vo.getToolId());
|
||||
toolApply.setUserId(userId);
|
||||
List<ToolApply> hasApplyUsToolApplyList = iToolApplyService.selectToolApplyList(toolApply);
|
||||
vo.setIsHasApplyUse(hasApplyUsToolApplyList.size() > 0);
|
||||
// 是否已发起使用申请
|
||||
vo.setIsHasApplyUse(iToolApplyService.hasToolUseApply(vo.getToolId(), userId));
|
||||
}
|
||||
}
|
||||
return getDataTable(list);
|
||||
@ -123,7 +115,10 @@ public class ToolController extends BaseController
|
||||
@GetMapping(value = "/{toolId}")
|
||||
public AjaxResult getInfo(@PathVariable("toolId") String toolId)
|
||||
{
|
||||
return success(toolService.selectToolByToolId(toolId));
|
||||
Tool tool = toolService.selectToolByToolId(toolId);
|
||||
String userId = SecurityUtils.getUserId().toString();
|
||||
tool.setDownloadStatus(toolService.isDownloadStatus(userId, tool));
|
||||
return success(tool);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,4 +232,5 @@ public class ToolController extends BaseController
|
||||
{
|
||||
return AjaxResult.success(toolService.statistics());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,5 +63,7 @@ public interface ToolApplyMapper
|
||||
*/
|
||||
public int deleteToolApplyByIds(String[] ids);
|
||||
|
||||
int checkToolApply(@Param("toolId") String toolId, @Param("userId") String userId);
|
||||
int hasToolUseApply(@Param("toolId") String toolId, @Param("userId") String userId);
|
||||
|
||||
int checkToolUseApply(@Param("toolId") String toolId, @Param("userId") String userId);
|
||||
}
|
||||
|
@ -61,7 +61,9 @@ public interface IToolApplyService
|
||||
*/
|
||||
public int deleteToolApplyById(String id);
|
||||
|
||||
boolean checkToolApply(String toolId, String userId);
|
||||
boolean hasToolUseApply(String toolId, String userId);
|
||||
|
||||
boolean checkToolUseApply(String toolId, String userId);
|
||||
|
||||
void sendTzMessage(ToolApply toolApply);
|
||||
}
|
||||
|
@ -98,4 +98,6 @@ public interface IToolService
|
||||
Map<String, Object> statistics();
|
||||
|
||||
List<Tool> selectAllList(Tool tool);
|
||||
|
||||
boolean isDownloadStatus(String userId, Tool tool);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.rzdata.common.annotation.DataScope;
|
||||
import com.rzdata.common.constant.Constants;
|
||||
@ -93,6 +92,8 @@ public class DocumentServiceImpl implements IDocumentService
|
||||
if(CollUtil.isNotEmpty(attachments)){
|
||||
document.setAttachment(attachments.get(0));
|
||||
}
|
||||
String userId = SecurityUtils.getUserId().toString();
|
||||
document.setDownloadStatus(isDownloadStatus(userId, document));
|
||||
return document;
|
||||
}
|
||||
|
||||
@ -136,17 +137,21 @@ public class DocumentServiceImpl implements IDocumentService
|
||||
if (BooleanUtil.isTrue(document.getDownloadCheck())) {
|
||||
String userId = SecurityUtils.getUserId().toString();
|
||||
for (Document dc: documents) {
|
||||
dc.setDownloadStatus(isDownloadStatus(userId, dc));
|
||||
}
|
||||
}
|
||||
return documents;
|
||||
}
|
||||
|
||||
private boolean isDownloadStatus(String userId, Document dc){
|
||||
//文档中 是创建人 或者 配置了下载权限
|
||||
boolean downStatus = false;
|
||||
if(SecurityUtils.hasPermi(Constants.DOC_DOWNLOAD_PERMISSION) || userId.equals(dc.getCreateById()) || SysUser.isAdmin(SecurityUtils.getUserId())){
|
||||
downStatus = true;
|
||||
}else if(StrUtil.isNotBlank(dc.getToolId()) && iUseApplyService.checkToolApply(dc.getToolId(),userId)){
|
||||
}else if(StrUtil.isNotBlank(dc.getToolId()) && iUseApplyService.checkToolUseApply(dc.getToolId(), userId)){
|
||||
downStatus = true;
|
||||
}
|
||||
dc.setDownloadStatus(downStatus);
|
||||
}
|
||||
}
|
||||
return documents;
|
||||
return downStatus;
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,8 +129,14 @@ public class ToolApplyServiceImpl implements IToolApplyService
|
||||
return toolApplyMapper.deleteToolApplyById(id);
|
||||
}
|
||||
|
||||
public boolean checkToolApply(String toolId, String userId){
|
||||
return toolApplyMapper.checkToolApply(toolId, userId)>0;
|
||||
@Override
|
||||
public boolean checkToolUseApply(String toolId, String userId){
|
||||
return toolApplyMapper.checkToolUseApply(toolId, userId)>0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasToolUseApply(String toolId, String userId){
|
||||
return toolApplyMapper.hasToolUseApply(toolId, userId) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import com.rzdata.common.constant.Constants;
|
||||
import com.rzdata.common.core.domain.entity.SysDept;
|
||||
import com.rzdata.common.core.domain.entity.SysDictData;
|
||||
import com.rzdata.common.core.domain.entity.SysUser;
|
||||
import com.rzdata.common.enums.RecordStatusEnum;
|
||||
import com.rzdata.common.utils.DateUtils;
|
||||
import com.rzdata.common.utils.SecurityUtils;
|
||||
import com.rzdata.system.service.ISysDeptService;
|
||||
@ -72,6 +73,9 @@ public class ToolServiceImpl implements IToolService
|
||||
@Autowired
|
||||
private IToolRelationService iToolRelationService;
|
||||
|
||||
@Autowired
|
||||
private IToolApplyService iToolApplyService;
|
||||
|
||||
/**
|
||||
* 查询工具信息
|
||||
*
|
||||
@ -454,4 +458,15 @@ public class ToolServiceImpl implements IToolService
|
||||
}
|
||||
return tools;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDownloadStatus(String userId, Tool tool){
|
||||
//创建人、下载权限、系统管理员
|
||||
//1.已经审核通过、并且有下载权限
|
||||
return userId.equals(tool.getCreateBy()) ||
|
||||
SysUser.isAdmin(SecurityUtils.getUserId()) ||
|
||||
SecurityUtils.hasPermi(Constants.DOWNLOAD_TOOL_PERMISSION) ||
|
||||
( RecordStatusEnum.DONE.getCode().equals(tool.getRecordStatus())&&
|
||||
iToolApplyService.checkToolUseApply(tool.getToolId(), userId));
|
||||
}
|
||||
}
|
||||
|
@ -129,11 +129,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="checkToolApply" resultType="int">
|
||||
SELECT count(*) FROM `t_use_apply_item` uai
|
||||
left join `t_tool_apply` ua on uai.apply_id = ua.id
|
||||
WHERE ua.record_status = 'done'
|
||||
and uai.tool_id = #{toolId}
|
||||
and ua.user_id = #{userId}
|
||||
<select id="hasToolUseApply" resultType="int">
|
||||
SELECT count(*) FROM t_tool_apply ta
|
||||
WHERE ta.apply_type='use' and ta.tool_id = #{toolId} and ta.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="checkToolUseApply" resultType="int">
|
||||
SELECT count(*) FROM t_tool_apply ta
|
||||
WHERE ta.apply_type='use' and ta.record_status = 'done'
|
||||
and ta.tool_id = #{toolId}
|
||||
and ta.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user