mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
1、模板导入接口返回结果布尔值,检查优化;2、模版名重复判定优化;
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ public final class ErrorCodeConstants {
|
||||
public static final ErrorCode TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR = new ErrorCode(1_003_001_002, "内置模板操作权限不足");
|
||||
public static final ErrorCode TEMPLATE_NAME_UNIQE_ERROR = new ErrorCode(1_003_001_003, "模板名【{}】已存在,请编辑模板名后重试");
|
||||
public static final ErrorCode TEMPLATE_PREIVEW_QUERYPARAM_EMPTY = new ErrorCode(1_003_001_004, "查询参数不能为空:{}");
|
||||
|
||||
public static final ErrorCode TEMPLATE_IMPORT_CONTENT_EMPTY_ERROR = new ErrorCode(1_003_001_005, "导入模板内容不能为空,请检查");
|
||||
|
||||
// ========== UREPORT datasource模块 1-003-002-000 ==========
|
||||
public static final ErrorCode DATASOURCE_NOT_EXISTS = new ErrorCode(1_003_002_001, "报表数据源不存在");
|
||||
|
||||
+2
-1
@@ -197,7 +197,8 @@ public class ReportTemplateController {
|
||||
@PutMapping("/xml")
|
||||
@Operation(summary = "导入模版")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public void importTemplate(@RequestParam("name") @NotEmpty(message = "模版名称不能为空") String name, @RequestParam("file") MultipartFile file) {
|
||||
public CommonResult<Boolean> importTemplate(@RequestParam("name") @NotEmpty(message = "模版名称不能为空") String name, @RequestParam("file") MultipartFile file) {
|
||||
templateService.importTemplate(name, file);
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.template.ReportTemplateDO;
|
||||
import com.cf.imes.module.report.enums.template.ReportTemplateTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,6 +42,7 @@ public interface ReportTemplateMapper extends BaseMapperX<ReportTemplateDO> {
|
||||
/**
|
||||
* 查询模板列表
|
||||
* 普通用户用:organId+type:1 or type:0
|
||||
*
|
||||
* @param name
|
||||
* @param organId
|
||||
* @return
|
||||
@@ -58,4 +61,13 @@ public interface ReportTemplateMapper extends BaseMapperX<ReportTemplateDO> {
|
||||
return selectList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模版名是否重复
|
||||
*
|
||||
* @param reqVO
|
||||
* @param isSuperAdmin
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
int selectExistTemplateName(@Param("reqVO") ReportTemplateSaveReqVO reqVO, @Param("isSuperAdmin") boolean isSuperAdmin, @Param("type") Integer type);
|
||||
}
|
||||
|
||||
+8
-14
@@ -10,7 +10,6 @@ import cn.hutool.http.ContentType;
|
||||
import cn.hutool.http.Header;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.bstek.common.exception.ReportDesignException;
|
||||
import com.bstek.designer.bean.PreviewParameters;
|
||||
import com.bstek.designer.bean.ReportDefinitionWrapper;
|
||||
@@ -37,7 +36,6 @@ import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplatePreviewReqVO;
|
||||
@@ -77,6 +75,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_IMPORT_CONTENT_EMPTY_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_NAME_UNIQE_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_NOT_EXISTS;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_PREIVEW_QUERYPARAM_EMPTY;
|
||||
@@ -249,17 +248,8 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
* @param reqVO
|
||||
*/
|
||||
private void validateTemplateNameUnique(ReportTemplateSaveReqVO reqVO, boolean isSuperAdmin) {
|
||||
Long templateId = reqVO.getId();
|
||||
String name = reqVO.getName();
|
||||
LambdaQueryWrapper<ReportTemplateDO> wrapper = new LambdaQueryWrapperX<ReportTemplateDO>().eq(ReportTemplateDO::getName, name);
|
||||
if (ObjectUtil.isNotNull(templateId)) {
|
||||
wrapper.ne(ReportTemplateDO::getId, templateId);
|
||||
}
|
||||
if (isSuperAdmin) {
|
||||
wrapper.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.SYSTEM);
|
||||
}
|
||||
if (templateMapper.exists(wrapper)) {
|
||||
throw exception(TEMPLATE_NAME_UNIQE_ERROR, name);
|
||||
if (templateMapper.selectExistTemplateName(reqVO, isSuperAdmin, ReportTemplateTypeEnum.SYSTEM.getType()) > 0) {
|
||||
throw exception(TEMPLATE_NAME_UNIQE_ERROR, reqVO.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +498,11 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
// 校验模板名唯一性
|
||||
validateTemplateNameUnique(createReqVO, isSuperAdmin);
|
||||
// 复制信息
|
||||
createReqVO.setContent(jsonObject.getString("content"));
|
||||
String content = jsonObject.getString("content");
|
||||
if(StringUtils.isEmpty(content)) {
|
||||
throw new ServiceException(TEMPLATE_IMPORT_CONTENT_EMPTY_ERROR);
|
||||
}
|
||||
createReqVO.setContent(content);
|
||||
createReqVO.setDatasetIds(jsonObject.getJSONArray(DATASETIDS_FIELD_NAME).stream().map(s -> Long.parseLong(s.toString())).collect(Collectors.toSet()));
|
||||
createReqVO.setDatasourceIds(jsonObject.getJSONArray(DATASOURCEIDS_FIELD_NAME).stream().map(s -> Long.parseLong(s.toString())).collect(Collectors.toSet()));
|
||||
// 新增模板
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?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="com.cf.imes.module.report.dal.mysql.template.ReportTemplateMapper">
|
||||
|
||||
<select id="selectExistTemplateName" resultType="java.lang.Integer">
|
||||
SELECT COUNT(1)
|
||||
FROM report_template
|
||||
WHERE name = #{reqVO.name}
|
||||
<if test="reqVO.id != null">
|
||||
id != #{reqVO.id}
|
||||
</if>
|
||||
<if test="isSuperAdmin">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user