From 9d8cdb2670c64be4ffe1c324edb8be10138760e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E5=AE=87?= <970895810@qq.com> Date: Wed, 3 Nov 2021 10:26:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=A1=A8=E5=8D=95=20?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/form/OsFormController.java | 96 +++++++++++++++++++ .../controller/form/vo/OsFormBaseVO.java | 28 ++++++ .../controller/form/vo/OsFormCreateReqVO.java | 12 +++ .../controller/form/vo/OsFormExcelVO.java | 34 +++++++ .../controller/form/vo/OsFormExportReqVO.java | 33 +++++++ .../controller/form/vo/OsFormPageReqVO.java | 36 +++++++ .../controller/form/vo/OsFormRespVO.java | 19 ++++ .../controller/form/vo/OsFormUpdateReqVO.java | 17 ++++ .../activiti/convert/form/OsFormConvert.java | 36 +++++++ .../dal/dataobject/form/OsFormDO.java | 44 +++++++++ .../activiti/dal/mysql/form/OsFormMapper.java | 43 +++++++++ .../enums/form/FormErrorCodeConstants.java | 14 +++ .../activiti/service/form/OsFormService.java | 75 +++++++++++++++ .../service/form/impl/OsFormServiceImpl.java | 85 ++++++++++++++++ 14 files changed, 572 insertions(+) create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/OsFormController.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormBaseVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormCreateReqVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExcelVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExportReqVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormPageReqVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormRespVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormUpdateReqVO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/form/OsFormConvert.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/form/OsFormDO.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/mysql/form/OsFormMapper.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/enums/form/FormErrorCodeConstants.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/OsFormService.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/impl/OsFormServiceImpl.java diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/OsFormController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/OsFormController.java new file mode 100644 index 000000000..847ef9f20 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/OsFormController.java @@ -0,0 +1,96 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form; + +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.*; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.adminserver.modules.activiti.convert.form.OsFormConvert; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; +import cn.iocoder.yudao.adminserver.modules.activiti.service.form.OsFormService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.annotations.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + + + +@Api(tags = "动态表单") +@RestController +@RequestMapping("/os/form") +@Validated +public class OsFormController { + + @Resource + private OsFormService formService; + + @PostMapping("/create") + @ApiOperation("创建动态表单") + @PreAuthorize("@ss.hasPermission('os:form:create')") + public CommonResult createForm(@Valid @RequestBody OsFormCreateReqVO createReqVO) { + return success(formService.createForm(createReqVO)); + } + + @PutMapping("/update") + @ApiOperation("更新动态表单") + @PreAuthorize("@ss.hasPermission('os:form:update')") + public CommonResult updateForm(@Valid @RequestBody OsFormUpdateReqVO updateReqVO) { + formService.updateForm(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @ApiOperation("删除动态表单") + @ApiImplicitParam(name = "id", value = "编号", required = true) + @PreAuthorize("@ss.hasPermission('os:form:delete')") + public CommonResult deleteForm(@RequestParam("id") Long id) { + formService.deleteForm(id); + return success(true); + } + + @GetMapping("/get") + @ApiOperation("获得动态表单") + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) + @PreAuthorize("@ss.hasPermission('os:form:query')") + public CommonResult getForm(@RequestParam("id") Long id) { + OsFormDO form = formService.getForm(id); + return success(OsFormConvert.INSTANCE.convert(form)); + } + + @GetMapping("/list") + @ApiOperation("获得动态表单列表") + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) + @PreAuthorize("@ss.hasPermission('os:form:query')") + public CommonResult> getFormList(@RequestParam("ids") Collection ids) { + List list = formService.getFormList(ids); + return success(OsFormConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @ApiOperation("获得动态表单分页") + @PreAuthorize("@ss.hasPermission('os:form:query')") + public CommonResult> getFormPage(@Valid OsFormPageReqVO pageVO) { + PageResult pageResult = formService.getFormPage(pageVO); + return success(OsFormConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @ApiOperation("导出动态表单 Excel") + @PreAuthorize("@ss.hasPermission('os:form:export')") + @OperateLog(type = EXPORT) + public void exportFormExcel(@Valid OsFormExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = formService.getFormList(exportReqVO); + // 导出 Excel + List datas = OsFormConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "动态表单.xls", "数据", OsFormExcelVO.class, datas); + } + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormBaseVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormBaseVO.java new file mode 100644 index 000000000..7868be836 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormBaseVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import io.swagger.annotations.*; +import javax.validation.constraints.*; + +/** +* 动态表单 Base VO,提供给添加、修改、详细的子 VO 使用 +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 +*/ +@Data +public class OsFormBaseVO { + + @ApiModelProperty(value = "表单名称", required = true) + @NotNull(message = "表单名称不能为空") + private String name; + + @ApiModelProperty(value = "商户状态", required = true) + @NotNull(message = "商户状态不能为空") + private Integer status; + + @ApiModelProperty(value = "表单JSON") + private String formJson; + + @ApiModelProperty(value = "备注") + private String remark; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormCreateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormCreateReqVO.java new file mode 100644 index 000000000..bd58aacf1 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormCreateReqVO.java @@ -0,0 +1,12 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import io.swagger.annotations.*; + +@ApiModel("动态表单创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OsFormCreateReqVO extends OsFormBaseVO { + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExcelVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExcelVO.java new file mode 100644 index 000000000..0d2147c96 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExcelVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import java.util.*; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 动态表单 Excel VO + * + * @author 芋艿 + */ +@Data +public class OsFormExcelVO { + + @ExcelProperty("表单编号") + private Long id; + + @ExcelProperty("表单名称") + private String name; + + @ExcelProperty("商户状态") + private Integer status; + + @ExcelProperty("表单JSON") + private String formJson; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private Date createTime; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExportReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExportReqVO.java new file mode 100644 index 000000000..bd68cd884 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExportReqVO.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import org.springframework.format.annotation.DateTimeFormat; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@ApiModel(value = "动态表单 Excel 导出 Request VO", description = "参数和 OsFormPageReqVO 是一致的") +@Data +public class OsFormExportReqVO { + + @ApiModelProperty(value = "表单名称") + private String name; + + @ApiModelProperty(value = "商户状态") + private Integer status; + + @ApiModelProperty(value = "表单JSON") + private String formJson; + + @ApiModelProperty(value = "备注") + private String remark; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "开始创建时间") + private Date beginCreateTime; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "结束创建时间") + private Date endCreateTime; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormPageReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormPageReqVO.java new file mode 100644 index 000000000..0c9167bc0 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormPageReqVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@ApiModel("动态表单分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OsFormPageReqVO extends PageParam { + + @ApiModelProperty(value = "表单名称") + private String name; + + @ApiModelProperty(value = "商户状态") + private Integer status; + + @ApiModelProperty(value = "表单JSON") + private String formJson; + + @ApiModelProperty(value = "备注") + private String remark; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "开始创建时间") + private Date beginCreateTime; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @ApiModelProperty(value = "结束创建时间") + private Date endCreateTime; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormRespVO.java new file mode 100644 index 000000000..adc63d31b --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import java.util.*; +import io.swagger.annotations.*; + +@ApiModel("动态表单 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OsFormRespVO extends OsFormBaseVO { + + @ApiModelProperty(value = "表单编号", required = true) + private Long id; + + @ApiModelProperty(value = "创建时间", required = true) + private Date createTime; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormUpdateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormUpdateReqVO.java new file mode 100644 index 000000000..daba1d922 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormUpdateReqVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; + +import lombok.*; +import io.swagger.annotations.*; +import javax.validation.constraints.*; + +@ApiModel("动态表单更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class OsFormUpdateReqVO extends OsFormBaseVO { + + @ApiModelProperty(value = "表单编号", required = true) + @NotNull(message = "表单编号不能为空") + private Long id; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/form/OsFormConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/form/OsFormConvert.java new file mode 100644 index 000000000..96bff877c --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/form/OsFormConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.convert.form; + +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExcelVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormRespVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormUpdateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; +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 OsFormConvert { + + OsFormConvert INSTANCE = Mappers.getMapper(OsFormConvert.class); + + OsFormDO convert(OsFormCreateReqVO bean); + + OsFormDO convert(OsFormUpdateReqVO bean); + + OsFormRespVO convert(OsFormDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/form/OsFormDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/form/OsFormDO.java new file mode 100644 index 000000000..8b6296da7 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/form/OsFormDO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form; + +import lombok.*; +import java.util.*; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 动态表单 DO + * + * @author 芋艿 + */ +@TableName("os_form") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OsFormDO extends BaseDO { + + /** + * 表单编号 + */ + @TableId + private Long id; + /** + * 表单名称 + */ + private String name; + /** + * 商户状态 + */ + private Integer status; + /** + * 表单JSON + */ + private String formJson; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/mysql/form/OsFormMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/mysql/form/OsFormMapper.java new file mode 100644 index 000000000..19acff215 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/mysql/form/OsFormMapper.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.form; + + + +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExportReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormPageReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 动态表单 Mapper + * + * @author 芋艿 + */ +@Mapper +public interface OsFormMapper extends BaseMapperX { + + default PageResult selectPage(OsFormPageReqVO reqVO) { + return selectPage(reqVO, new QueryWrapperX() + .likeIfPresent("name", reqVO.getName()) + .eqIfPresent("status", reqVO.getStatus()) + .eqIfPresent("form_json", reqVO.getFormJson()) + .eqIfPresent("remark", reqVO.getRemark()) + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc("id") ); + } + + default List selectList(OsFormExportReqVO reqVO) { + return selectList(new QueryWrapperX() + .likeIfPresent("name", reqVO.getName()) + .eqIfPresent("status", reqVO.getStatus()) + .eqIfPresent("form_json", reqVO.getFormJson()) + .eqIfPresent("remark", reqVO.getRemark()) + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc("id") ); + } + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/enums/form/FormErrorCodeConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/enums/form/FormErrorCodeConstants.java new file mode 100644 index 000000000..e0b961c00 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/enums/form/FormErrorCodeConstants.java @@ -0,0 +1,14 @@ +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 FormErrorCodeConstants { + ErrorCode FORM_NOT_EXISTS = new ErrorCode(1003001002, "动态表单不存在"); +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/OsFormService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/OsFormService.java new file mode 100644 index 000000000..1691d412d --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/OsFormService.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.service.form; + +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExportReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormPageReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormUpdateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import java.util.*; +import javax.validation.*; + + +/** + * 动态表单 Service 接口 + * + * @author 芋艿 + */ +public interface OsFormService { + + /** + * 创建动态表单 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createForm(@Valid OsFormCreateReqVO createReqVO); + + /** + * 更新动态表单 + * + * @param updateReqVO 更新信息 + */ + void updateForm(@Valid OsFormUpdateReqVO updateReqVO); + + /** + * 删除动态表单 + * + * @param id 编号 + */ + void deleteForm(Long id); + + /** + * 获得动态表单 + * + * @param id 编号 + * @return 动态表单 + */ + OsFormDO getForm(Long id); + + /** + * 获得动态表单列表 + * + * @param ids 编号 + * @return 动态表单列表 + */ + List getFormList(Collection ids); + + /** + * 获得动态表单分页 + * + * @param pageReqVO 分页查询 + * @return 动态表单分页 + */ + PageResult getFormPage(OsFormPageReqVO pageReqVO); + + /** + * 获得动态表单列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 动态表单列表 + */ + List getFormList(OsFormExportReqVO exportReqVO); + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/impl/OsFormServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/impl/OsFormServiceImpl.java new file mode 100644 index 000000000..ed2f03046 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/impl/OsFormServiceImpl.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.adminserver.modules.activiti.service.form.impl; + +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExportReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormPageReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormUpdateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.convert.form.OsFormConvert; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.form.OsFormMapper; +import cn.iocoder.yudao.adminserver.modules.activiti.service.form.OsFormService; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import java.util.*; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.adminserver.modules.activiti.enums.form.FormErrorCodeConstants.FORM_NOT_EXISTS; + +/** + * 动态表单 Service 实现类 + * + * @author 芋艿 + */ +@Service +@Validated +public class OsFormServiceImpl implements OsFormService { + + @Resource + private OsFormMapper formMapper; + + @Override + public Long createForm(OsFormCreateReqVO createReqVO) { + // 插入 + OsFormDO form = OsFormConvert.INSTANCE.convert(createReqVO); + formMapper.insert(form); + // 返回 + return form.getId(); + } + + @Override + public void updateForm(OsFormUpdateReqVO updateReqVO) { + // 校验存在 + this.validateFormExists(updateReqVO.getId()); + // 更新 + OsFormDO updateObj = OsFormConvert.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 OsFormDO getForm(Long id) { + return formMapper.selectById(id); + } + + @Override + public List getFormList(Collection ids) { + return formMapper.selectBatchIds(ids); + } + + @Override + public PageResult getFormPage(OsFormPageReqVO pageReqVO) { + return formMapper.selectPage(pageReqVO); + } + + @Override + public List getFormList(OsFormExportReqVO exportReqVO) { + return formMapper.selectList(exportReqVO); + } + +}