WfForm =》BpmForm

This commit is contained in:
YunaiV 2021-12-30 20:23:50 +08:00
parent 4b2af44ee3
commit 7ef86c14c0
23 changed files with 275 additions and 404 deletions

View File

@ -1,36 +0,0 @@
package cn.iocoder.yudao.adminserver.modules.activiti.convert.form;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormExcelVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormRespVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.WfForm;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 动态表单 Convert
*
* @author 芋艿
*/
@Mapper
public interface WfFormConvert {
WfFormConvert INSTANCE = Mappers.getMapper(WfFormConvert.class);
WfForm convert(WfFormCreateReqVO bean);
WfForm convert(WfFormUpdateReqVO bean);
WfFormRespVO convert(WfForm bean);
List<WfFormRespVO> convertList(List<WfForm> list);
PageResult<WfFormRespVO> convertPage(PageResult<WfForm> page);
List<WfFormExcelVO> convertList02(List<WfForm> list);
}

View File

@ -1,57 +0,0 @@
package cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.util.List;
/**
* 工作流的表单定义
* 用于工作流的申请表单需要动态配置的场景
*
* @author 芋道源码
*/
@TableName(value = "wf_form", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WfForm extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 表单名
*/
private String name;
/**
* 状态
*/
private Integer status;
/**
* 表单JSON
*/
private String formJson;
/**
* 表单配置
*
* 目前直接将 https://github.com/JakHuang/form-generator 生成的 JSON 直接保存
* 定义https://github.com/JakHuang/form-generator/issues/46
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> fields;
/**
* 备注
*/
private String remark;
}

View File

@ -1,55 +0,0 @@
package cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.util.List;
import java.util.Map;
/**
* 工作流的表单结果
* 用户每次填写工作流的申请表单时会保存一条记录到该表
*
* @author 芋道源码
*/
@TableName(value = "wf_form", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WfFormData extends BaseDO {
/**
* 编号
*/
private Long id;
/**
* 表单编号
*
* 关联 {@link WfForm#getId()}
*/
private Long formId;
/**
* 状态
*/
private Integer status;
/**
* 表单配置
*
* 冗余 {@link WfForm#getFields()}
* 主要考虑表单是可以修改的
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> fields;
/**
* 表单值
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private Map<String, Object> values;
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.yudao.adminserver.modules.activiti.enums.form;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
/**
* activiti 系统 错误码枚举类
*
* 003 activiti
* 001 oa
* activiti 系统使用 1-003-000-000
*/
public interface WfFormErrorCodeConstants {
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1003001002, "动态表单不存在");
}

View File

@ -1,2 +0,0 @@
// TODO @芋艿思考下 activitioa 的定位边界模块的拆分
package cn.iocoder.yudao.adminserver.modules.activiti;

View File

@ -1,75 +0,0 @@
package cn.iocoder.yudao.adminserver.modules.activiti.service.form;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormExportReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormPageReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.WfForm;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import java.util.*;
import javax.validation.*;
/**
* 动态表单 Service 接口
*
* TODO @风里雾里
*/
public interface WfFormService {
/**
* 创建动态表单
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createForm(@Valid WfFormCreateReqVO createReqVO);
/**
* 更新动态表单
*
* @param updateReqVO 更新信息
*/
void updateForm(@Valid WfFormUpdateReqVO updateReqVO);
/**
* 删除动态表单
*
* @param id 编号
*/
void deleteForm(Long id);
/**
* 获得动态表单
*
* @param id 编号
* @return 动态表单
*/
WfForm getForm(Long id);
/**
* 获得动态表单列表
*
* @param ids 编号
* @return 动态表单列表
*/
List<WfForm> getFormList(Collection<Long> ids);
/**
* 获得动态表单分页
*
* @param pageReqVO 分页查询
* @return 动态表单分页
*/
PageResult<WfForm> getFormPage(WfFormPageReqVO pageReqVO);
/**
* 获得动态表单列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 动态表单列表
*/
List<WfForm> getFormList(WfFormExportReqVO exportReqVO);
}

View File

@ -1,86 +0,0 @@
package cn.iocoder.yudao.adminserver.modules.activiti.service.form.impl;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormExportReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormPageReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.convert.form.WfFormConvert;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.WfForm;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.form.WfFormMapper;
import cn.iocoder.yudao.adminserver.modules.activiti.service.form.WfFormService;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.adminserver.modules.activiti.enums.form.WfFormErrorCodeConstants.FORM_NOT_EXISTS;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 动态表单 Service 实现类
*
* TODO @风里雾里
*/
@Service
@Validated
public class WfFormServiceImpl implements WfFormService {
@Resource
private WfFormMapper formMapper;
@Override
public Long createForm(WfFormCreateReqVO createReqVO) {
// 插入
WfForm form = WfFormConvert.INSTANCE.convert(createReqVO);
formMapper.insert(form);
// 返回
return form.getId();
}
@Override
public void updateForm(WfFormUpdateReqVO updateReqVO) {
// 校验存在
this.validateFormExists(updateReqVO.getId());
// 更新
WfForm updateObj = WfFormConvert.INSTANCE.convert(updateReqVO);
formMapper.updateById(updateObj);
}
@Override
public void deleteForm(Long id) {
// 校验存在
this.validateFormExists(id);
// 删除
formMapper.deleteById(id);
}
private void validateFormExists(Long id) {
if (formMapper.selectById(id) == null) {
throw exception(FORM_NOT_EXISTS);
}
}
@Override
public WfForm getForm(Long id) {
return formMapper.selectById(id);
}
@Override
public List<WfForm> getFormList(Collection<Long> ids) {
return formMapper.selectBatchIds(ids);
}
@Override
public PageResult<WfForm> getFormPage(WfFormPageReqVO pageReqVO) {
return formMapper.selectPage(pageReqVO);
}
@Override
public List<WfForm> getFormList(WfFormExportReqVO exportReqVO) {
return formMapper.selectList(exportReqVO);
}
}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.*; import cn.iocoder.yudao.adminserver.modules.bpm.convert.form.BpmFormConvert;
import cn.iocoder.yudao.adminserver.modules.activiti.convert.form.WfFormConvert; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.WfForm; import cn.iocoder.yudao.adminserver.modules.bpm.service.form.BpmFormService;
import cn.iocoder.yudao.adminserver.modules.activiti.service.form.WfFormService; import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.*;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@ -25,27 +25,26 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
// TODO @风里雾里 Os=Wf/os 改成 /wl 开头目前这个模块咱先定位成给工作流用的
@Api(tags = "动态表单") @Api(tags = "动态表单")
@RestController @RestController
@RequestMapping("/wl/form") @RequestMapping("/bpm/form")
@Validated @Validated
public class WlFormController { public class BpmFormController {
@Resource @Resource
private WfFormService formService; private BpmFormService formService;
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建动态表单") @ApiOperation("创建动态表单")
@PreAuthorize("@ss.hasPermission('os:form:create')") @PreAuthorize("@ss.hasPermission('bpm:form:create')")
public CommonResult<Long> createForm(@Valid @RequestBody WfFormCreateReqVO createReqVO) { public CommonResult<Long> createForm(@Valid @RequestBody BpmFormCreateReqVO createReqVO) {
return success(formService.createForm(createReqVO)); return success(formService.createForm(createReqVO));
} }
@PutMapping("/update") @PutMapping("/update")
@ApiOperation("更新动态表单") @ApiOperation("更新动态表单")
@PreAuthorize("@ss.hasPermission('os:form:update')") @PreAuthorize("@ss.hasPermission('bpm:form:update')")
public CommonResult<Boolean> updateForm(@Valid @RequestBody WfFormUpdateReqVO updateReqVO) { public CommonResult<Boolean> updateForm(@Valid @RequestBody BpmFormUpdateReqVO updateReqVO) {
formService.updateForm(updateReqVO); formService.updateForm(updateReqVO);
return success(true); return success(true);
} }
@ -53,7 +52,7 @@ public class WlFormController {
@DeleteMapping("/delete") @DeleteMapping("/delete")
@ApiOperation("删除动态表单") @ApiOperation("删除动态表单")
@ApiImplicitParam(name = "id", value = "编号", required = true) @ApiImplicitParam(name = "id", value = "编号", required = true)
@PreAuthorize("@ss.hasPermission('os:form:delete')") @PreAuthorize("@ss.hasPermission('bpm:form:delete')")
public CommonResult<Boolean> deleteForm(@RequestParam("id") Long id) { public CommonResult<Boolean> deleteForm(@RequestParam("id") Long id) {
formService.deleteForm(id); formService.deleteForm(id);
return success(true); return success(true);
@ -62,39 +61,39 @@ public class WlFormController {
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得动态表单") @ApiOperation("获得动态表单")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('os:form:query')") @PreAuthorize("@ss.hasPermission('bpm:form:query')")
public CommonResult<WfFormRespVO> getForm(@RequestParam("id") Long id) { public CommonResult<BpmFormRespVO> getForm(@RequestParam("id") Long id) {
WfForm form = formService.getForm(id); BpmForm form = formService.getForm(id);
return success(WfFormConvert.INSTANCE.convert(form)); return success(BpmFormConvert.INSTANCE.convert(form));
} }
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获得动态表单列表") @ApiOperation("获得动态表单列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('os:form:query')") @PreAuthorize("@ss.hasPermission('bpm:form:query')")
public CommonResult<List<WfFormRespVO>> getFormList(@RequestParam("ids") Collection<Long> ids) { public CommonResult<List<BpmFormRespVO>> getFormList(@RequestParam("ids") Collection<Long> ids) {
List<WfForm> list = formService.getFormList(ids); List<BpmForm> list = formService.getFormList(ids);
return success(WfFormConvert.INSTANCE.convertList(list)); return success(BpmFormConvert.INSTANCE.convertList(list));
} }
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得动态表单分页") @ApiOperation("获得动态表单分页")
@PreAuthorize("@ss.hasPermission('os:form:query')") @PreAuthorize("@ss.hasPermission('bpm:form:query')")
public CommonResult<PageResult<WfFormRespVO>> getFormPage(@Valid WfFormPageReqVO pageVO) { public CommonResult<PageResult<BpmFormRespVO>> getFormPage(@Valid BpmFormPageReqVO pageVO) {
PageResult<WfForm> pageResult = formService.getFormPage(pageVO); PageResult<BpmForm> pageResult = formService.getFormPage(pageVO);
return success(WfFormConvert.INSTANCE.convertPage(pageResult)); return success(BpmFormConvert.INSTANCE.convertPage(pageResult));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ApiOperation("导出动态表单 Excel") @ApiOperation("导出动态表单 Excel")
@PreAuthorize("@ss.hasPermission('os:form:export')") @PreAuthorize("@ss.hasPermission('bpm:form:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportFormExcel(@Valid WfFormExportReqVO exportReqVO, public void exportFormExcel(@Valid BpmFormExportReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
List<WfForm> list = formService.getFormList(exportReqVO); List<BpmForm> list = formService.getFormList(exportReqVO);
// 导出 Excel // 导出 Excel
List<WfFormExcelVO> datas = WfFormConvert.INSTANCE.convertList02(list); List<BpmFormExcelVO> datas = BpmFormConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "动态表单.xls", "数据", WfFormExcelVO.class, datas); ExcelUtils.write(response, "动态表单.xls", "数据", BpmFormExcelVO.class, datas);
} }
} }

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*; import lombok.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -9,7 +9,7 @@ import javax.validation.constraints.*;
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成 * 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/ */
@Data @Data
public class WfFormBaseVO { public class BpmFormBaseVO {
@ApiModelProperty(value = "表单名称", required = true) @ApiModelProperty(value = "表单名称", required = true)
@NotNull(message = "表单名称不能为空") @NotNull(message = "表单名称不能为空")

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*; import lombok.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -7,6 +7,6 @@ import io.swagger.annotations.*;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WfFormCreateReqVO extends WfFormBaseVO { public class BpmFormCreateReqVO extends BpmFormBaseVO {
} }

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
/** /**
* 动态表单 Excel VO * 动态表单 Excel VO
@ -11,7 +11,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
* @author 芋艿 * @author 芋艿
*/ */
@Data @Data
public class WfFormExcelVO { public class BpmFormExcelVO {
@ExcelProperty("表单编号") @ExcelProperty("表单编号")
private Long id; private Long id;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
@ -8,7 +8,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ApiModel(value = "动态表单 Excel 导出 Request VO", description = "参数和 OsFormPageReqVO 是一致的") @ApiModel(value = "动态表单 Excel 导出 Request VO", description = "参数和 OsFormPageReqVO 是一致的")
@Data @Data
public class WfFormExportReqVO { public class BpmFormExportReqVO {
@ApiModelProperty(value = "表单名称") @ApiModelProperty(value = "表单名称")
private String name; private String name;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
@ -11,7 +11,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WfFormPageReqVO extends PageParam { public class BpmFormPageReqVO extends PageParam {
@ApiModelProperty(value = "表单名称") @ApiModelProperty(value = "表单名称")
private String name; private String name;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
@ -8,7 +8,7 @@ import io.swagger.annotations.*;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WfFormRespVO extends WfFormBaseVO { public class BpmFormRespVO extends BpmFormBaseVO {
@ApiModelProperty(value = "表单编号", required = true) @ApiModelProperty(value = "表单编号", required = true)
private Long id; private Long id;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; package cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo;
import lombok.*; import lombok.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -8,7 +8,7 @@ import javax.validation.constraints.*;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class WfFormUpdateReqVO extends WfFormBaseVO { public class BpmFormUpdateReqVO extends BpmFormBaseVO {
@ApiModelProperty(value = "表单编号", required = true) @ApiModelProperty(value = "表单编号", required = true)
@NotNull(message = "表单编号不能为空") @NotNull(message = "表单编号不能为空")

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.form;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExcelVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 动态表单 Convert
*
* @author 芋艿
*/
@Mapper
public interface BpmFormConvert {
BpmFormConvert INSTANCE = Mappers.getMapper(BpmFormConvert.class);
BpmForm convert(BpmFormCreateReqVO bean);
BpmForm convert(BpmFormUpdateReqVO bean);
BpmFormRespVO convert(BpmForm bean);
List<BpmFormRespVO> convertList(List<BpmForm> list);
PageResult<BpmFormRespVO> convertPage(PageResult<BpmForm> page);
List<BpmFormExcelVO> convertList02(List<BpmForm> list);
}

View File

@ -33,6 +33,14 @@ public class BpmForm extends BaseDO {
* 表单名 * 表单名
*/ */
private String name; private String name;
/**
* 状态
*/
private Integer status;
/**
* 表单JSON
*/
private String formJson;
/** /**
* 表单配置 * 表单配置
* *

View File

@ -15,7 +15,7 @@ import java.util.Map;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@TableName(value = "wf_form", autoResultMap = true) @TableName(value = "bpm_form_data", autoResultMap = true)
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@ -34,6 +34,10 @@ public class BpmFormData extends BaseDO {
* 关联 {@link BpmForm#getId()} * 关联 {@link BpmForm#getId()}
*/ */
private Long formId; private Long formId;
/**
* 状态
*/
private Integer status;
/** /**
* 表单配置 * 表单配置
* *

View File

@ -1,10 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.form; package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.form;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExportReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormExportReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.WfFormPageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.WfForm;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
@ -18,26 +17,26 @@ import java.util.List;
* @author 风里雾里 * @author 风里雾里
*/ */
@Mapper @Mapper
public interface WfFormMapper extends BaseMapperX<WfForm> { public interface BpmFormMapper extends BaseMapperX<BpmForm> {
default PageResult<WfForm> selectPage(WfFormPageReqVO reqVO) { default PageResult<BpmForm> selectPage(BpmFormPageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<WfForm>() return selectPage(reqVO, new QueryWrapperX<BpmForm>()
.likeIfPresent("name", reqVO.getName()) .likeIfPresent("name", reqVO.getName())
.eqIfPresent("status", reqVO.getStatus()) .eqIfPresent("status", reqVO.getStatus())
.eqIfPresent("form_json", reqVO.getFormJson()) .eqIfPresent("form_json", reqVO.getFormJson())
.eqIfPresent("remark", reqVO.getRemark()) .eqIfPresent("remark", reqVO.getRemark())
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc("id") ); .orderByDesc("id"));
} }
default List<WfForm> selectList(WfFormExportReqVO reqVO) { default List<BpmForm> selectList(BpmFormExportReqVO reqVO) {
return selectList(new QueryWrapperX<WfForm>() return selectList(new QueryWrapperX<BpmForm>()
.likeIfPresent("name", reqVO.getName()) .likeIfPresent("name", reqVO.getName())
.eqIfPresent("status", reqVO.getStatus()) .eqIfPresent("status", reqVO.getStatus())
.eqIfPresent("form_json", reqVO.getFormJson()) .eqIfPresent("form_json", reqVO.getFormJson())
.eqIfPresent("remark", reqVO.getRemark()) .eqIfPresent("remark", reqVO.getRemark())
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc("id") ); .orderByDesc("id"));
} }
} }

View File

@ -23,11 +23,13 @@ public interface BpmErrorCodeConstants {
ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1003001006, "HR岗位未设置"); ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1003001006, "HR岗位未设置");
ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1003001007, "请假天数必须>=1"); ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1003001007, "请假天数必须>=1");
// ========== OA 工作流模块 1-003-002-000 ==========
// ========== OA 工作流模块 1-004-001-000 ==========
ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存"); ErrorCode BPMN_MODEL_EDITOR_SOURCE_NOT_EXISTS = new ErrorCode(1004001001, "模型数据为空,请先成功设计流程并保存");
ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常"); ErrorCode BPMN_MODEL_ERROR = new ErrorCode(1004001002, "工作流模型异常");
ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001003, "流程数据为空"); ErrorCode BPMN_MODEL_PROCESS_NOT_EXISTS = new ErrorCode(1004001003, "流程数据为空");
ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在"); ErrorCode BPMN_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1004001004, "流程定义不存在");
// ========== 动态表单模块 1-003-003-000 ==========
ErrorCode BPM_FORM_NOT_EXISTS = new ErrorCode(1003001002, "动态表单不存在");
} }

View File

@ -0,0 +1,76 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.form;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExportReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* 动态表单 Service 接口
*
* @author @风里雾里
*/
public interface BpmFormService {
/**
* 创建动态表单
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createForm(@Valid BpmFormCreateReqVO createReqVO);
/**
* 更新动态表单
*
* @param updateReqVO 更新信息
*/
void updateForm(@Valid BpmFormUpdateReqVO updateReqVO);
/**
* 删除动态表单
*
* @param id 编号
*/
void deleteForm(Long id);
/**
* 获得动态表单
*
* @param id 编号
* @return 动态表单
*/
BpmForm getForm(Long id);
/**
* 获得动态表单列表
*
* @param ids 编号
* @return 动态表单列表
*/
List<BpmForm> getFormList(Collection<Long> ids);
/**
* 获得动态表单分页
*
* @param pageReqVO 分页查询
* @return 动态表单分页
*/
PageResult<BpmForm> getFormPage(BpmFormPageReqVO pageReqVO);
/**
* 获得动态表单列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 动态表单列表
*/
List<BpmForm> getFormList(BpmFormExportReqVO exportReqVO);
}

View File

@ -0,0 +1,85 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.form;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormExportReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormPageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.form.vo.BpmFormUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.form.BpmFormConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.form.BpmForm;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.form.BpmFormMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.BPM_FORM_NOT_EXISTS;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 动态表单 Service 实现类
*
* @author 风里雾里
*/
@Service
@Validated
public class BpmFormServiceImpl implements BpmFormService {
@Resource
private BpmFormMapper formMapper;
@Override
public Long createForm(BpmFormCreateReqVO createReqVO) {
// 插入
BpmForm form = BpmFormConvert.INSTANCE.convert(createReqVO);
formMapper.insert(form);
// 返回
return form.getId();
}
@Override
public void updateForm(BpmFormUpdateReqVO updateReqVO) {
// 校验存在
this.validateFormExists(updateReqVO.getId());
// 更新
BpmForm updateObj = BpmFormConvert.INSTANCE.convert(updateReqVO);
formMapper.updateById(updateObj);
}
@Override
public void deleteForm(Long id) {
// 校验存在
this.validateFormExists(id);
// 删除
formMapper.deleteById(id);
}
private void validateFormExists(Long id) {
if (formMapper.selectById(id) == null) {
throw exception(BPM_FORM_NOT_EXISTS);
}
}
@Override
public BpmForm getForm(Long id) {
return formMapper.selectById(id);
}
@Override
public List<BpmForm> getFormList(Collection<Long> ids) {
return formMapper.selectBatchIds(ids);
}
@Override
public PageResult<BpmForm> getFormPage(BpmFormPageReqVO pageReqVO) {
return formMapper.selectPage(pageReqVO);
}
@Override
public List<BpmForm> getFormList(BpmFormExportReqVO exportReqVO) {
return formMapper.selectList(exportReqVO);
}
}

View File

@ -1,14 +1,11 @@
package cn.iocoder.yudao.framework.activiti.config; package cn.iocoder.yudao.framework.activiti.config;
import lombok.AllArgsConstructor;
import org.activiti.image.ProcessDiagramGenerator; import org.activiti.image.ProcessDiagramGenerator;
import org.activiti.image.impl.DefaultProcessDiagramGenerator; import org.activiti.image.impl.DefaultProcessDiagramGenerator;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Configuration @Configuration
public class YudaoActivitiConfiguration { public class YudaoActivitiConfiguration {
@ -24,19 +21,9 @@ public class YudaoActivitiConfiguration {
/** /**
* ProcessEngineConfigurationConfigurer 实现类设置使用 MyBatis SqlSessionFactory * ProcessEngineConfigurationConfigurer 实现类设置使用 MyBatis SqlSessionFactory
*/ */
@Component @Bean
@AllArgsConstructor public ProcessEngineConfigurationConfigurer processEngineConfigurationConfigurer(SqlSessionFactory sqlSessionFactory) {
public static class SqlSessionFactoryProcessEngineConfigurationConfigurer return springProcessEngineConfiguration -> springProcessEngineConfiguration.setSqlSessionFactory(sqlSessionFactory);
implements ProcessEngineConfigurationConfigurer {
private final SqlSessionFactory sqlSessionFactory;
@Override
public void configure(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
springProcessEngineConfiguration.setSqlSessionFactory(sqlSessionFactory);
} }
}
} }