Commit 9d8cdb2670c64be4ffe1c324edb8be10138760e3
1 parent
a4948d27
动态表单 后端代码
Showing
14 changed files
with
572 additions
and
0 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/OsFormController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.*; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.activiti.convert.form.OsFormConvert; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.activiti.service.form.OsFormService; | ||
| 8 | +import org.springframework.web.bind.annotation.*; | ||
| 9 | +import javax.annotation.Resource; | ||
| 10 | +import org.springframework.validation.annotation.Validated; | ||
| 11 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 12 | +import io.swagger.annotations.*; | ||
| 13 | +import javax.validation.*; | ||
| 14 | +import javax.servlet.http.*; | ||
| 15 | +import java.util.*; | ||
| 16 | +import java.io.IOException; | ||
| 17 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 18 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 19 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 20 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 21 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +@Api(tags = "动态表单") | ||
| 26 | +@RestController | ||
| 27 | +@RequestMapping("/os/form") | ||
| 28 | +@Validated | ||
| 29 | +public class OsFormController { | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + private OsFormService formService; | ||
| 33 | + | ||
| 34 | + @PostMapping("/create") | ||
| 35 | + @ApiOperation("创建动态表单") | ||
| 36 | + @PreAuthorize("@ss.hasPermission('os:form:create')") | ||
| 37 | + public CommonResult<Long> createForm(@Valid @RequestBody OsFormCreateReqVO createReqVO) { | ||
| 38 | + return success(formService.createForm(createReqVO)); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @PutMapping("/update") | ||
| 42 | + @ApiOperation("更新动态表单") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('os:form:update')") | ||
| 44 | + public CommonResult<Boolean> updateForm(@Valid @RequestBody OsFormUpdateReqVO updateReqVO) { | ||
| 45 | + formService.updateForm(updateReqVO); | ||
| 46 | + return success(true); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @DeleteMapping("/delete") | ||
| 50 | + @ApiOperation("删除动态表单") | ||
| 51 | + @ApiImplicitParam(name = "id", value = "编号", required = true) | ||
| 52 | + @PreAuthorize("@ss.hasPermission('os:form:delete')") | ||
| 53 | + public CommonResult<Boolean> deleteForm(@RequestParam("id") Long id) { | ||
| 54 | + formService.deleteForm(id); | ||
| 55 | + return success(true); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @GetMapping("/get") | ||
| 59 | + @ApiOperation("获得动态表单") | ||
| 60 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 61 | + @PreAuthorize("@ss.hasPermission('os:form:query')") | ||
| 62 | + public CommonResult<OsFormRespVO> getForm(@RequestParam("id") Long id) { | ||
| 63 | + OsFormDO form = formService.getForm(id); | ||
| 64 | + return success(OsFormConvert.INSTANCE.convert(form)); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @GetMapping("/list") | ||
| 68 | + @ApiOperation("获得动态表单列表") | ||
| 69 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | ||
| 70 | + @PreAuthorize("@ss.hasPermission('os:form:query')") | ||
| 71 | + public CommonResult<List<OsFormRespVO>> getFormList(@RequestParam("ids") Collection<Long> ids) { | ||
| 72 | + List<OsFormDO> list = formService.getFormList(ids); | ||
| 73 | + return success(OsFormConvert.INSTANCE.convertList(list)); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @GetMapping("/page") | ||
| 77 | + @ApiOperation("获得动态表单分页") | ||
| 78 | + @PreAuthorize("@ss.hasPermission('os:form:query')") | ||
| 79 | + public CommonResult<PageResult<OsFormRespVO>> getFormPage(@Valid OsFormPageReqVO pageVO) { | ||
| 80 | + PageResult<OsFormDO> pageResult = formService.getFormPage(pageVO); | ||
| 81 | + return success(OsFormConvert.INSTANCE.convertPage(pageResult)); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @GetMapping("/export-excel") | ||
| 85 | + @ApiOperation("导出动态表单 Excel") | ||
| 86 | + @PreAuthorize("@ss.hasPermission('os:form:export')") | ||
| 87 | + @OperateLog(type = EXPORT) | ||
| 88 | + public void exportFormExcel(@Valid OsFormExportReqVO exportReqVO, | ||
| 89 | + HttpServletResponse response) throws IOException { | ||
| 90 | + List<OsFormDO> list = formService.getFormList(exportReqVO); | ||
| 91 | + // 导出 Excel | ||
| 92 | + List<OsFormExcelVO> datas = OsFormConvert.INSTANCE.convertList02(list); | ||
| 93 | + ExcelUtils.write(response, "动态表单.xls", "数据", OsFormExcelVO.class, datas); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import io.swagger.annotations.*; | ||
| 5 | +import javax.validation.constraints.*; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | +* 动态表单 Base VO,提供给添加、修改、详细的子 VO 使用 | ||
| 9 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||
| 10 | +*/ | ||
| 11 | +@Data | ||
| 12 | +public class OsFormBaseVO { | ||
| 13 | + | ||
| 14 | + @ApiModelProperty(value = "表单名称", required = true) | ||
| 15 | + @NotNull(message = "表单名称不能为空") | ||
| 16 | + private String name; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "商户状态", required = true) | ||
| 19 | + @NotNull(message = "商户状态不能为空") | ||
| 20 | + private Integer status; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "表单JSON") | ||
| 23 | + private String formJson; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "备注") | ||
| 26 | + private String remark; | ||
| 27 | + | ||
| 28 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import io.swagger.annotations.*; | ||
| 5 | + | ||
| 6 | +@ApiModel("动态表单创建 Request VO") | ||
| 7 | +@Data | ||
| 8 | +@EqualsAndHashCode(callSuper = true) | ||
| 9 | +@ToString(callSuper = true) | ||
| 10 | +public class OsFormCreateReqVO extends OsFormBaseVO { | ||
| 11 | + | ||
| 12 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | + | ||
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 动态表单 Excel VO | ||
| 10 | + * | ||
| 11 | + * @author 芋艿 | ||
| 12 | + */ | ||
| 13 | +@Data | ||
| 14 | +public class OsFormExcelVO { | ||
| 15 | + | ||
| 16 | + @ExcelProperty("表单编号") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @ExcelProperty("表单名称") | ||
| 20 | + private String name; | ||
| 21 | + | ||
| 22 | + @ExcelProperty("商户状态") | ||
| 23 | + private Integer status; | ||
| 24 | + | ||
| 25 | + @ExcelProperty("表单JSON") | ||
| 26 | + private String formJson; | ||
| 27 | + | ||
| 28 | + @ExcelProperty("备注") | ||
| 29 | + private String remark; | ||
| 30 | + | ||
| 31 | + @ExcelProperty("创建时间") | ||
| 32 | + private Date createTime; | ||
| 33 | + | ||
| 34 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.annotations.*; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 8 | + | ||
| 9 | +@ApiModel(value = "动态表单 Excel 导出 Request VO", description = "参数和 OsFormPageReqVO 是一致的") | ||
| 10 | +@Data | ||
| 11 | +public class OsFormExportReqVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "表单名称") | ||
| 14 | + private String name; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "商户状态") | ||
| 17 | + private Integer status; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "表单JSON") | ||
| 20 | + private String formJson; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "备注") | ||
| 23 | + private String remark; | ||
| 24 | + | ||
| 25 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 26 | + @ApiModelProperty(value = "开始创建时间") | ||
| 27 | + private Date beginCreateTime; | ||
| 28 | + | ||
| 29 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 30 | + @ApiModelProperty(value = "结束创建时间") | ||
| 31 | + private Date endCreateTime; | ||
| 32 | + | ||
| 33 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.annotations.*; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 9 | + | ||
| 10 | +@ApiModel("动态表单分页 Request VO") | ||
| 11 | +@Data | ||
| 12 | +@EqualsAndHashCode(callSuper = true) | ||
| 13 | +@ToString(callSuper = true) | ||
| 14 | +public class OsFormPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "表单名称") | ||
| 17 | + private String name; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "商户状态") | ||
| 20 | + private Integer status; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "表单JSON") | ||
| 23 | + private String formJson; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "备注") | ||
| 26 | + private String remark; | ||
| 27 | + | ||
| 28 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 29 | + @ApiModelProperty(value = "开始创建时间") | ||
| 30 | + private Date beginCreateTime; | ||
| 31 | + | ||
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 33 | + @ApiModelProperty(value = "结束创建时间") | ||
| 34 | + private Date endCreateTime; | ||
| 35 | + | ||
| 36 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.annotations.*; | ||
| 6 | + | ||
| 7 | +@ApiModel("动态表单 Response VO") | ||
| 8 | +@Data | ||
| 9 | +@EqualsAndHashCode(callSuper = true) | ||
| 10 | +@ToString(callSuper = true) | ||
| 11 | +public class OsFormRespVO extends OsFormBaseVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "表单编号", required = true) | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "创建时间", required = true) | ||
| 17 | + private Date createTime; | ||
| 18 | + | ||
| 19 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/form/vo/OsFormUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import io.swagger.annotations.*; | ||
| 5 | +import javax.validation.constraints.*; | ||
| 6 | + | ||
| 7 | +@ApiModel("动态表单更新 Request VO") | ||
| 8 | +@Data | ||
| 9 | +@EqualsAndHashCode(callSuper = true) | ||
| 10 | +@ToString(callSuper = true) | ||
| 11 | +public class OsFormUpdateReqVO extends OsFormBaseVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "表单编号", required = true) | ||
| 14 | + @NotNull(message = "表单编号不能为空") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/form/OsFormConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.convert.form; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormCreateReqVO; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExcelVO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormRespVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; | ||
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | +import org.mapstruct.Mapper; | ||
| 10 | +import org.mapstruct.factory.Mappers; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 动态表单 Convert | ||
| 16 | + * | ||
| 17 | + * @author 芋艿 | ||
| 18 | + */ | ||
| 19 | +@Mapper | ||
| 20 | +public interface OsFormConvert { | ||
| 21 | + | ||
| 22 | + OsFormConvert INSTANCE = Mappers.getMapper(OsFormConvert.class); | ||
| 23 | + | ||
| 24 | + OsFormDO convert(OsFormCreateReqVO bean); | ||
| 25 | + | ||
| 26 | + OsFormDO convert(OsFormUpdateReqVO bean); | ||
| 27 | + | ||
| 28 | + OsFormRespVO convert(OsFormDO bean); | ||
| 29 | + | ||
| 30 | + List<OsFormRespVO> convertList(List<OsFormDO> list); | ||
| 31 | + | ||
| 32 | + PageResult<OsFormRespVO> convertPage(PageResult<OsFormDO> page); | ||
| 33 | + | ||
| 34 | + List<OsFormExcelVO> convertList02(List<OsFormDO> list); | ||
| 35 | + | ||
| 36 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/form/OsFormDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 动态表单 DO | ||
| 10 | + * | ||
| 11 | + * @author 芋艿 | ||
| 12 | + */ | ||
| 13 | +@TableName("os_form") | ||
| 14 | +@Data | ||
| 15 | +@EqualsAndHashCode(callSuper = true) | ||
| 16 | +@ToString(callSuper = true) | ||
| 17 | +@Builder | ||
| 18 | +@NoArgsConstructor | ||
| 19 | +@AllArgsConstructor | ||
| 20 | +public class OsFormDO extends BaseDO { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 表单编号 | ||
| 24 | + */ | ||
| 25 | + @TableId | ||
| 26 | + private Long id; | ||
| 27 | + /** | ||
| 28 | + * 表单名称 | ||
| 29 | + */ | ||
| 30 | + private String name; | ||
| 31 | + /** | ||
| 32 | + * 商户状态 | ||
| 33 | + */ | ||
| 34 | + private Integer status; | ||
| 35 | + /** | ||
| 36 | + * 表单JSON | ||
| 37 | + */ | ||
| 38 | + private String formJson; | ||
| 39 | + /** | ||
| 40 | + * 备注 | ||
| 41 | + */ | ||
| 42 | + private String remark; | ||
| 43 | + | ||
| 44 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/mysql/form/OsFormMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.form; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExportReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; | ||
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 10 | +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | ||
| 11 | +import org.apache.ibatis.annotations.Mapper; | ||
| 12 | + | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 动态表单 Mapper | ||
| 17 | + * | ||
| 18 | + * @author 芋艿 | ||
| 19 | + */ | ||
| 20 | +@Mapper | ||
| 21 | +public interface OsFormMapper extends BaseMapperX<OsFormDO> { | ||
| 22 | + | ||
| 23 | + default PageResult<OsFormDO> selectPage(OsFormPageReqVO reqVO) { | ||
| 24 | + return selectPage(reqVO, new QueryWrapperX<OsFormDO>() | ||
| 25 | + .likeIfPresent("name", reqVO.getName()) | ||
| 26 | + .eqIfPresent("status", reqVO.getStatus()) | ||
| 27 | + .eqIfPresent("form_json", reqVO.getFormJson()) | ||
| 28 | + .eqIfPresent("remark", reqVO.getRemark()) | ||
| 29 | + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||
| 30 | + .orderByDesc("id") ); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default List<OsFormDO> selectList(OsFormExportReqVO reqVO) { | ||
| 34 | + return selectList(new QueryWrapperX<OsFormDO>() | ||
| 35 | + .likeIfPresent("name", reqVO.getName()) | ||
| 36 | + .eqIfPresent("status", reqVO.getStatus()) | ||
| 37 | + .eqIfPresent("form_json", reqVO.getFormJson()) | ||
| 38 | + .eqIfPresent("remark", reqVO.getRemark()) | ||
| 39 | + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||
| 40 | + .orderByDesc("id") ); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/enums/form/FormErrorCodeConstants.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.enums.form; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * activiti 系统 错误码枚举类 | ||
| 7 | + * | ||
| 8 | + * 003 activiti | ||
| 9 | + * 001 oa | ||
| 10 | + * activiti 系统,使用 1-003-000-000 段 | ||
| 11 | + */ | ||
| 12 | +public interface FormErrorCodeConstants { | ||
| 13 | + ErrorCode FORM_NOT_EXISTS = new ErrorCode(1003001002, "动态表单不存在"); | ||
| 14 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/OsFormService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.service.form; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormCreateReqVO; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExportReqVO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; | ||
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 9 | + | ||
| 10 | +import java.util.*; | ||
| 11 | +import javax.validation.*; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 动态表单 Service 接口 | ||
| 16 | + * | ||
| 17 | + * @author 芋艿 | ||
| 18 | + */ | ||
| 19 | +public interface OsFormService { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 创建动态表单 | ||
| 23 | + * | ||
| 24 | + * @param createReqVO 创建信息 | ||
| 25 | + * @return 编号 | ||
| 26 | + */ | ||
| 27 | + Long createForm(@Valid OsFormCreateReqVO createReqVO); | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 更新动态表单 | ||
| 31 | + * | ||
| 32 | + * @param updateReqVO 更新信息 | ||
| 33 | + */ | ||
| 34 | + void updateForm(@Valid OsFormUpdateReqVO updateReqVO); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 删除动态表单 | ||
| 38 | + * | ||
| 39 | + * @param id 编号 | ||
| 40 | + */ | ||
| 41 | + void deleteForm(Long id); | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 获得动态表单 | ||
| 45 | + * | ||
| 46 | + * @param id 编号 | ||
| 47 | + * @return 动态表单 | ||
| 48 | + */ | ||
| 49 | + OsFormDO getForm(Long id); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 获得动态表单列表 | ||
| 53 | + * | ||
| 54 | + * @param ids 编号 | ||
| 55 | + * @return 动态表单列表 | ||
| 56 | + */ | ||
| 57 | + List<OsFormDO> getFormList(Collection<Long> ids); | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 获得动态表单分页 | ||
| 61 | + * | ||
| 62 | + * @param pageReqVO 分页查询 | ||
| 63 | + * @return 动态表单分页 | ||
| 64 | + */ | ||
| 65 | + PageResult<OsFormDO> getFormPage(OsFormPageReqVO pageReqVO); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 获得动态表单列表, 用于 Excel 导出 | ||
| 69 | + * | ||
| 70 | + * @param exportReqVO 查询条件 | ||
| 71 | + * @return 动态表单列表 | ||
| 72 | + */ | ||
| 73 | + List<OsFormDO> getFormList(OsFormExportReqVO exportReqVO); | ||
| 74 | + | ||
| 75 | +} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/form/impl/OsFormServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.adminserver.modules.activiti.service.form.impl; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormCreateReqVO; | ||
| 4 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormExportReqVO; | ||
| 5 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.adminserver.modules.activiti.controller.form.vo.OsFormUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.adminserver.modules.activiti.convert.form.OsFormConvert; | ||
| 8 | +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.form.OsFormDO; | ||
| 9 | +import cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.form.OsFormMapper; | ||
| 10 | +import cn.iocoder.yudao.adminserver.modules.activiti.service.form.OsFormService; | ||
| 11 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 12 | + | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | +import javax.annotation.Resource; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import java.util.*; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | +import static cn.iocoder.yudao.adminserver.modules.activiti.enums.form.FormErrorCodeConstants.FORM_NOT_EXISTS; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 动态表单 Service 实现类 | ||
| 23 | + * | ||
| 24 | + * @author 芋艿 | ||
| 25 | + */ | ||
| 26 | +@Service | ||
| 27 | +@Validated | ||
| 28 | +public class OsFormServiceImpl implements OsFormService { | ||
| 29 | + | ||
| 30 | + @Resource | ||
| 31 | + private OsFormMapper formMapper; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public Long createForm(OsFormCreateReqVO createReqVO) { | ||
| 35 | + // 插入 | ||
| 36 | + OsFormDO form = OsFormConvert.INSTANCE.convert(createReqVO); | ||
| 37 | + formMapper.insert(form); | ||
| 38 | + // 返回 | ||
| 39 | + return form.getId(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public void updateForm(OsFormUpdateReqVO updateReqVO) { | ||
| 44 | + // 校验存在 | ||
| 45 | + this.validateFormExists(updateReqVO.getId()); | ||
| 46 | + // 更新 | ||
| 47 | + OsFormDO updateObj = OsFormConvert.INSTANCE.convert(updateReqVO); | ||
| 48 | + formMapper.updateById(updateObj); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void deleteForm(Long id) { | ||
| 53 | + // 校验存在 | ||
| 54 | + this.validateFormExists(id); | ||
| 55 | + // 删除 | ||
| 56 | + formMapper.deleteById(id); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + private void validateFormExists(Long id) { | ||
| 60 | + if (formMapper.selectById(id) == null) { | ||
| 61 | + throw exception(FORM_NOT_EXISTS); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public OsFormDO getForm(Long id) { | ||
| 67 | + return formMapper.selectById(id); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public List<OsFormDO> getFormList(Collection<Long> ids) { | ||
| 72 | + return formMapper.selectBatchIds(ids); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public PageResult<OsFormDO> getFormPage(OsFormPageReqVO pageReqVO) { | ||
| 77 | + return formMapper.selectPage(pageReqVO); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public List<OsFormDO> getFormList(OsFormExportReqVO exportReqVO) { | ||
| 82 | + return formMapper.selectList(exportReqVO); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | +} |