fix - 自测表单模型新/删/改/查接口完成
This commit is contained in:
parent
949c68fbf5
commit
92f820bcdb
@ -9,10 +9,10 @@ import cn.axzo.workflow.core.service.dto.request.model.BpmModelSearchDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.form.model.BpmModelBaseVO;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.flowable.engine.ManagementService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.NativeModelQuery;
|
||||
import org.flowable.form.api.FormManagementService;
|
||||
import org.flowable.form.api.FormRepositoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -41,7 +41,7 @@ public class BpmFormModelServiceImpl implements BpmFormModelService {
|
||||
@Resource
|
||||
private RepositoryService repositoryService;
|
||||
@Resource
|
||||
private FormManagementService managementService;
|
||||
private ManagementService managementService;
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
@Resource
|
||||
@ -61,15 +61,8 @@ public class BpmFormModelServiceImpl implements BpmFormModelService {
|
||||
model.setCategory(dto.getCategory());
|
||||
model.setName(dto.getName());
|
||||
model.setTenantId(dto.getTenantId());
|
||||
model.setMetaInfo(MODEL_META_INFO_FORM);
|
||||
repositoryService.saveModel(model);
|
||||
// try {
|
||||
// repositoryService.addModelEditorSource(model.getId(),
|
||||
// objectMapper.writeValueAsString(new SimpleFormModel()).getBytes());
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// throw new WorkflowEngineException(e.getMessage());
|
||||
// }
|
||||
|
||||
return model.getId();
|
||||
}
|
||||
|
||||
@ -78,30 +71,19 @@ public class BpmFormModelServiceImpl implements BpmFormModelService {
|
||||
public void updateFormModel(FormModelUpdateDTO dto) {
|
||||
Model model = repositoryService.createModelQuery()
|
||||
.modelId(dto.getFormModelId())
|
||||
.modelKey(dto.getKey())
|
||||
.modelTenantId(dto.getTenantId())
|
||||
.singleResult();
|
||||
if (Objects.isNull(model)) {
|
||||
throw new WorkflowEngineException("表单模型不存在");
|
||||
}
|
||||
|
||||
// FormDefinitionDTO formDefinition = dto.getFormDefinition();
|
||||
// formDefinition.setKey(model.getKey());
|
||||
// formDefinition.setName(dto.getName());
|
||||
//
|
||||
// model.setName(dto.getName());
|
||||
// model.setCategory(dto.getCategory());
|
||||
//
|
||||
// try {
|
||||
// repositoryService.addModelEditorSource(model.getId(),
|
||||
// objectMapper.writeValueAsString(formDefinition).getBytes());
|
||||
// } catch (Exception e) {
|
||||
// throw new WorkflowEngineException(e.getMessage());
|
||||
// }
|
||||
model.setName(dto.getName());
|
||||
model.setCategory(dto.getCategory());
|
||||
repositoryService.saveModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFormModel(String formModelId, String tenantId) {
|
||||
public void deleteFormModel(String formModelId, @Nullable String tenantId) {
|
||||
Model model = repositoryService.getModel(formModelId);
|
||||
if (Objects.isNull(model)) {
|
||||
throw new WorkflowEngineException("模型不存在");
|
||||
@ -142,14 +124,16 @@ public class BpmFormModelServiceImpl implements BpmFormModelService {
|
||||
baseQuerySql.append(sqlConnectors(baseQuerySql))
|
||||
.append(" META_INFO_ = #{metaInfo}");
|
||||
query.parameter("metaInfo", MODEL_META_INFO_FORM);
|
||||
List<Model> models = query //.orderByLastUpdateTime()
|
||||
.sql(baseQuerySql.append(" order by LAST_UPDATE_TIME_ desc").toString())
|
||||
NativeModelQuery dateSqlQuery = query //.orderByLastUpdateTime()
|
||||
.sql(baseQuerySql.append(" order by LAST_UPDATE_TIME_ desc").toString());
|
||||
List<Model> models = dateSqlQuery
|
||||
.listPage((dto.getPageNo() - 1) * dto.getPageSize(), dto.getPageSize());
|
||||
if (CollectionUtils.isEmpty(models)) {
|
||||
return new BpmPageResult<>(Collections.emptyList(), query.count());
|
||||
return new BpmPageResult<>(Collections.emptyList(), 0L);
|
||||
}
|
||||
|
||||
return new BpmPageResult<>(formModelConverter.toVos(models), query.count());
|
||||
NativeModelQuery countSqlQuery = query.sql(countSql(baseQuerySql));
|
||||
return new BpmPageResult<>(formModelConverter.toVos(models), countSqlQuery.count());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -170,4 +154,12 @@ public class BpmFormModelServiceImpl implements BpmFormModelService {
|
||||
}
|
||||
return " and";
|
||||
}
|
||||
|
||||
public static String countSql(StringBuilder stringBuilder) {
|
||||
int start = 0;
|
||||
if ((start = stringBuilder.indexOf("SELECT")) < 0) {
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
return stringBuilder.replace(start + 7, 8, "count(1)").toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import cn.axzo.workflow.core.service.dto.request.model.BpmModelSearchDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
|
||||
import cn.axzo.workflow.core.service.dto.response.form.model.BpmModelBaseVO;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -30,8 +31,7 @@ public class BpmFormModelController {
|
||||
|
||||
@GetMapping("/page")
|
||||
public CommonResponse<BpmPageResult<BpmModelBaseVO>> modelPage(@Valid @RequestBody BpmModelSearchDTO dto) {
|
||||
bpmFormModelService.getModelPage(dto);
|
||||
return CommonResponse.success();
|
||||
return CommonResponse.success(bpmFormModelService.getModelPage(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@ -46,9 +46,9 @@ public class BpmFormModelController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
public CommonResponse<Boolean> deleteFormModel(@RequestParam String formModelId,
|
||||
public CommonResponse<Boolean> deleteFormModel(@ApiParam(name = "表单模型 ID") @RequestParam String id,
|
||||
@RequestParam(required = false) String tenantId) {
|
||||
bpmFormModelService.deleteFormModel(formModelId, tenantId);
|
||||
bpmFormModelService.deleteFormModel(id, tenantId);
|
||||
return CommonResponse.success(true);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user