diff --git a/form/src/main/java/com/ccsens/form/api/FileController.java b/form/src/main/java/com/ccsens/form/api/FileController.java new file mode 100644 index 00000000..f30e8302 --- /dev/null +++ b/form/src/main/java/com/ccsens/form/api/FileController.java @@ -0,0 +1,105 @@ +package com.ccsens.form.api; + +import cn.hutool.core.lang.Snowflake; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.cloudutil.feign.TallFeignClient; +import com.ccsens.form.bean.po.CommonFile; +import com.ccsens.form.bean.vo.FileVo; +import com.ccsens.form.service.IFileService; +import com.ccsens.form.util.Constant; +import com.ccsens.util.*; +import com.ccsens.util.exception.BaseException; +import io.swagger.annotations.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.Part; +import java.util.List; + +/** + * @description: + * @author: whj + * @time: 2020/7/17 11:36 + */ +@Slf4j +@Api(tags = "文件") +@RestController +@RequestMapping("/file") +public class FileController { + + @Resource + private IFileService fileService; + @Resource + private TallFeignClient tallFeignClient; + @Resource + private Snowflake snowflake; + + + @ApiOperation(value = "上传文件") + @ApiImplicitParams({ + }) + @RequestMapping(value = "upload", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse upload(HttpServletRequest request, @RequestParam() List files) throws Exception { + log.info("文件上传:{}", files); + + String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN); + JsonResponse tokenRes = tallFeignClient.getUserIdByToken(authHeader); + log.info("{}查询userId返回:{}", authHeader, tokenRes); + if (tokenRes.getCode().intValue() != CodeEnum.SUCCESS.getCode().intValue()) { + return tokenRes; + } + JSONObject json = JSON.parseObject(JSON.toJSONString(tokenRes.getData())); + Long userId = json.getLong("id"); + String dir = PropUtil.path + Constant.File.UPLOAD_URL; + List fileVos = fileService.saveFile(dir, files, userId); + List vos = FileVo.Upload.transFilePo(fileVos); + log.info("文件上传返回:{}", vos); + return JsonResponse.newInstance().ok(vos); + } + + @ApiOperation(value = "文件下载") + @GetMapping(value = "download/{id}") + public void download(HttpServletResponse response, @PathVariable("id")Long id) throws Exception { + log.info("文件下载:{}", id); + CommonFile file = fileService.getById(id); + log.info("文件信息;{}", file); + if (file == null) { + throw new BaseException(CodeEnum.FILE_NOT_FOUND); + } + UploadFileUtil_Servlet3.download(response, file.getLocation(), file.getFileName()); + log.info("文件下载结束"); + } + + @ApiOperation(value = "文件下载, 指定路径") + @GetMapping(value = "download/know") + public void downloadFile(HttpServletResponse response, String path ) throws Exception { + log.info("文件下载, 指定路径:{}", path); + UploadFileUtil_Servlet3.download(response, path, path.substring(path.lastIndexOf(java.io.File.separator) + 1)); + log.info("文件下载结束"); + } + + + @ApiOperation(value = "上传图片证明文件(不大于2M)") + @ApiImplicitParams({ + }) + @RequestMapping(value = "/upload/photo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse uploadPhone(HttpServletRequest request, @RequestParam() Part file) throws Exception { + log.info("文件上传:{}", file); + String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN); + JsonResponse tokenRes = tallFeignClient.getUserIdByToken(authHeader); + log.info("{}查询userId返回:{}", authHeader, tokenRes); + if (tokenRes.getCode().intValue() != CodeEnum.SUCCESS.getCode().intValue()) { + return tokenRes; + } + JSONObject json = JSON.parseObject(JSON.toJSONString(tokenRes.getData())); + Long userId = json.getLong("id"); + FileVo.Upload vo = fileService.uploadPhone(file,userId); + + return JsonResponse.newInstance().ok(vo); + } + +} diff --git a/form/src/main/java/com/ccsens/form/api/FormController.java b/form/src/main/java/com/ccsens/form/api/FormController.java index 36376f00..e1e44dc6 100644 --- a/form/src/main/java/com/ccsens/form/api/FormController.java +++ b/form/src/main/java/com/ccsens/form/api/FormController.java @@ -3,6 +3,7 @@ package com.ccsens.form.api; import com.ccsens.cloudutil.annotation.MustLogin; import com.ccsens.form.bean.dto.FormDto; import com.ccsens.form.bean.vo.FormVo; +import com.ccsens.form.bean.vo.ModuleVo; import com.ccsens.form.service.IFormService; import com.ccsens.util.JsonResponse; import com.ccsens.util.bean.dto.QueryDto; @@ -31,12 +32,22 @@ public class FormController { private IFormService formService; @MustLogin - @ApiOperation(value = "查找表单详细信息", notes = "zy:查询表单的基本信息,组件信息,及当前用户填写的信息") + @ApiOperation(value = "查找自己填写的表单信息", notes = "zy:查询表单的基本信息,组件信息,及当前用户填写的信息") + @RequestMapping(value = "/getOneself", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse getOneselfFormInfo(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找自己填写的表单信息:{}",params); + FormVo.GetFormInfo getFormInfo = formService.getOneselfFormInfo(params); + log.info("查找自己填写的表单信息完成:{}",getFormInfo); + return JsonResponse.newInstance().ok(getFormInfo); + } + + @MustLogin + @ApiOperation(value = "查找指定用户填写的表单信息", notes = "zy:查询表单的基本信息,组件信息,及对应的用户填写的信息") @RequestMapping(value = "/get", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) - public JsonResponse getFormInfo(@ApiParam @Validated @RequestBody QueryDto params) { - log.info("查找表单详细信息:{}",params); - FormVo.GetFormInfo getFormInfo = formService.getFormInfo(params); - log.info("查找表单详细信息"); + public JsonResponse getFormByFormUserId(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找指定用户填写的表单信息:{}",params); + FormVo.GetFormInfo getFormInfo = formService.getFormByFormUserId(params.getParam()); + log.info("查找指定用户填写的表单信息完成:{}",getFormInfo); return JsonResponse.newInstance().ok(getFormInfo); } @@ -62,12 +73,43 @@ public class FormController { } @MustLogin - @ApiOperation(value = "查找", notes = "zy:查询该表单填写的人数,和需要统计的组件内的统计信息") - @RequestMapping(value = "/statistics", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) - public JsonResponse statisticsForm(@ApiParam @Validated @RequestBody QueryDto params) { - log.info("统计提交的信息:{}",params); - FormVo.StatisticsForm formLists = formService.statisticsForm(params.getParam()); - log.info("统计提交的信息"); + @ApiOperation(value = "查找表单的基本信息,包括组件信息", notes = "zy:查询表单的基本信息包括访问路径二维码,和组件信息") + @RequestMapping(value = "/info", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse getFormInfo(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找表单的基本信息:{}",params); + ModuleVo.FormInfo formLists = formService.getFormInfo(params.getParam()); + log.info("查找表单的基本信息完成:{}",formLists); return JsonResponse.newInstance().ok(formLists); } + + @MustLogin + @ApiOperation(value = "添加表单", notes = "") + @RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse saveFormInfo(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("添加表单:{}",params); + formService.saveFormInfo(params.getParam(),params.getUserId()); + log.info("添加表单成功"); + return JsonResponse.newInstance().ok(); + } + + @MustLogin + @ApiOperation(value = "修改表单", notes = "") + @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse updateFormInfo(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("修改表单:{}",params); + formService.updateFormInfo(params.getParam(),params.getUserId()); + log.info("修改表单成功"); + return JsonResponse.newInstance().ok(); + } + + @MustLogin + @ApiOperation(value = "删除表单", notes = "") + @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse deleteFormInfo(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("删除表单:{}",params); + formService.deleteFormInfo(params.getParam(),params.getUserId()); + log.info("删除表单成功"); + return JsonResponse.newInstance().ok(); + } + } diff --git a/form/src/main/java/com/ccsens/form/api/ModuleController.java b/form/src/main/java/com/ccsens/form/api/ModuleController.java index 4d91cd53..f88bb9fa 100644 --- a/form/src/main/java/com/ccsens/form/api/ModuleController.java +++ b/form/src/main/java/com/ccsens/form/api/ModuleController.java @@ -1,6 +1,7 @@ package com.ccsens.form.api; import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.form.bean.dto.FormDto; import com.ccsens.form.bean.dto.ModuleDto; import com.ccsens.form.bean.vo.ModuleVo; import com.ccsens.form.service.IModuleService; @@ -46,7 +47,7 @@ public class ModuleController { @RequestMapping(value = "/get/formModule", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse getFormModule(@ApiParam @Validated @RequestBody QueryDto params) { log.info("查找表单内组件和配置信息:{}",params); - ModuleVo.ModuleInfo moduleInfoList = moduleService.getFormModule(params.getParam(),params.getUserId()); + ModuleVo.ModuleInfo moduleInfoList = moduleService.getFormModule(params.getParam()); log.info("查找表单内组件和配置信息结果:{}",moduleInfoList); return JsonResponse.newInstance().ok(moduleInfoList); } @@ -60,4 +61,34 @@ public class ModuleController { log.info("修改组件的配置信息和选项成功"); return JsonResponse.newInstance().ok(); } + + @MustLogin + @ApiOperation(value = "给表单添加组件", notes = "") + @RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse saveModule(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("给表单添加组件:{}",params); + moduleService.saveModule(params.getParam(),params.getUserId()); + log.info("给表单添加组件成功"); + return JsonResponse.newInstance().ok(); + } + + @MustLogin + @ApiOperation(value = "一次添加多个组件", notes = "") + @RequestMapping(value = "/save/more", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse saveMoreModule(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("一次添加多个组件:{}",params); + moduleService.saveMoreModule(params.getParam(),params.getUserId()); + log.info("一次添加多个组件成功"); + return JsonResponse.newInstance().ok(); + } + + @MustLogin + @ApiOperation(value = "删除表单内的组件", notes = "") + @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse deleteFormModule(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("删除表单内的组件:{}",params); + moduleService.deleteFormModule(params.getParam(),params.getUserId()); + log.info("删除表单内的组件成功"); + return JsonResponse.newInstance().ok(); + } } diff --git a/form/src/main/java/com/ccsens/form/bean/dto/FormDto.java b/form/src/main/java/com/ccsens/form/bean/dto/FormDto.java index 2a59024e..f2abe7f1 100644 --- a/form/src/main/java/com/ccsens/form/bean/dto/FormDto.java +++ b/form/src/main/java/com/ccsens/form/bean/dto/FormDto.java @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** @@ -12,11 +13,48 @@ import javax.validation.constraints.NotNull; @Data public class FormDto { @Data - @ApiModel("查找表单的详细信息") + @ApiModel("表单id") public static class GetFormInfo{ @NotNull @ApiModelProperty("表单id") private Long formId; } + + @Data + @ApiModel("用户填写表单信息的Id") + public static class FormUser{ + @NotNull + @ApiModelProperty("用户填写表单信息的id") + private Long formUserId; + } + + @Data + @ApiModel("添加表单") + public static class SaveForm{ + @NotBlank(message = "标题不能为空") + @ApiModelProperty("标题") + private String title; + @ApiModelProperty("详情") + private String description; + @ApiModelProperty("封面图片文件的id") + private Long coverImageId; + } + + + @Data + @ApiModel("修改表单") + public static class UpdateForm{ + @NotNull + @ApiModelProperty("表单id") + private Long formId; + @ApiModelProperty("标题") + private String title; + @ApiModelProperty("详情") + private String description; + @ApiModelProperty("封面图片文件的id") + private Long coverImageId; + } + + } diff --git a/form/src/main/java/com/ccsens/form/bean/dto/ModuleDto.java b/form/src/main/java/com/ccsens/form/bean/dto/ModuleDto.java index e4e7e1c4..18a68310 100644 --- a/form/src/main/java/com/ccsens/form/bean/dto/ModuleDto.java +++ b/form/src/main/java/com/ccsens/form/bean/dto/ModuleDto.java @@ -14,11 +14,18 @@ import java.util.List; @Data public class ModuleDto { @Data - @ApiModel("查找表单内的组件信息") + @ApiModel("表单内的组件id") public static class GetFormModule{ @NotNull @ApiModelProperty("表单组件关联id") private Long formModuleId; + + public GetFormModule() { + } + + public GetFormModule(@NotNull Long formModuleId) { + this.formModuleId = formModuleId; + } } @Data @@ -58,4 +65,26 @@ public class ModuleDto { @ApiModelProperty("子选项") private List subOptionList; } + + @Data + @ApiModel("给表单添加组件") + public static class SaveModule{ + @NotNull + @ApiModelProperty("表单id") + private Long formId; + @NotNull + @ApiModelProperty("组件id") + private Long moduleId; + } + + + @Data + @ApiModel("添加多个组件") + public static class SaveMoreModule{ + @NotNull + @ApiModelProperty("表单id") + private Long formId; + @ApiModelProperty("组件id") + private List moduleIdList; + } } diff --git a/form/src/main/java/com/ccsens/form/bean/dto/WriteDto.java b/form/src/main/java/com/ccsens/form/bean/dto/WriteDto.java index 1dbac907..e858b418 100644 --- a/form/src/main/java/com/ccsens/form/bean/dto/WriteDto.java +++ b/form/src/main/java/com/ccsens/form/bean/dto/WriteDto.java @@ -33,6 +33,8 @@ public class WriteDto { @Data @ApiModel("组件内的答案") public static class ModuleAnswer{ + @ApiModelProperty("选项的id") + private Long optionId; @ApiModelProperty("答案或选项的key") private String answer; } diff --git a/form/src/main/java/com/ccsens/form/bean/po/CommonFile.java b/form/src/main/java/com/ccsens/form/bean/po/CommonFile.java new file mode 100644 index 00000000..bb934bd6 --- /dev/null +++ b/form/src/main/java/com/ccsens/form/bean/po/CommonFile.java @@ -0,0 +1,106 @@ +package com.ccsens.form.bean.po; + +import java.io.Serializable; +import java.util.Date; + +public class CommonFile implements Serializable { + private Long id; + + private Long userId; + + private String fileName; + + private String location; + + private String visitLocation; + + private Date createdAt; + + private Date updatedAt; + + private Byte recStatus; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName == null ? null : fileName.trim(); + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location == null ? null : location.trim(); + } + + public String getVisitLocation() { + return visitLocation; + } + + public void setVisitLocation(String visitLocation) { + this.visitLocation = visitLocation == null ? null : visitLocation.trim(); + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Byte getRecStatus() { + return recStatus; + } + + public void setRecStatus(Byte recStatus) { + this.recStatus = recStatus; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", userId=").append(userId); + sb.append(", fileName=").append(fileName); + sb.append(", location=").append(location); + sb.append(", visitLocation=").append(visitLocation); + sb.append(", createdAt=").append(createdAt); + sb.append(", updatedAt=").append(updatedAt); + sb.append(", recStatus=").append(recStatus); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/form/src/main/java/com/ccsens/form/bean/po/CommonFileExample.java b/form/src/main/java/com/ccsens/form/bean/po/CommonFileExample.java new file mode 100644 index 00000000..01d6257e --- /dev/null +++ b/form/src/main/java/com/ccsens/form/bean/po/CommonFileExample.java @@ -0,0 +1,711 @@ +package com.ccsens.form.bean.po; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class CommonFileExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public CommonFileExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andFileNameIsNull() { + addCriterion("file_name is null"); + return (Criteria) this; + } + + public Criteria andFileNameIsNotNull() { + addCriterion("file_name is not null"); + return (Criteria) this; + } + + public Criteria andFileNameEqualTo(String value) { + addCriterion("file_name =", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotEqualTo(String value) { + addCriterion("file_name <>", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameGreaterThan(String value) { + addCriterion("file_name >", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameGreaterThanOrEqualTo(String value) { + addCriterion("file_name >=", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameLessThan(String value) { + addCriterion("file_name <", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameLessThanOrEqualTo(String value) { + addCriterion("file_name <=", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameLike(String value) { + addCriterion("file_name like", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotLike(String value) { + addCriterion("file_name not like", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameIn(List values) { + addCriterion("file_name in", values, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotIn(List values) { + addCriterion("file_name not in", values, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameBetween(String value1, String value2) { + addCriterion("file_name between", value1, value2, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotBetween(String value1, String value2) { + addCriterion("file_name not between", value1, value2, "fileName"); + return (Criteria) this; + } + + public Criteria andLocationIsNull() { + addCriterion("location is null"); + return (Criteria) this; + } + + public Criteria andLocationIsNotNull() { + addCriterion("location is not null"); + return (Criteria) this; + } + + public Criteria andLocationEqualTo(String value) { + addCriterion("location =", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationNotEqualTo(String value) { + addCriterion("location <>", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationGreaterThan(String value) { + addCriterion("location >", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationGreaterThanOrEqualTo(String value) { + addCriterion("location >=", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationLessThan(String value) { + addCriterion("location <", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationLessThanOrEqualTo(String value) { + addCriterion("location <=", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationLike(String value) { + addCriterion("location like", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationNotLike(String value) { + addCriterion("location not like", value, "location"); + return (Criteria) this; + } + + public Criteria andLocationIn(List values) { + addCriterion("location in", values, "location"); + return (Criteria) this; + } + + public Criteria andLocationNotIn(List values) { + addCriterion("location not in", values, "location"); + return (Criteria) this; + } + + public Criteria andLocationBetween(String value1, String value2) { + addCriterion("location between", value1, value2, "location"); + return (Criteria) this; + } + + public Criteria andLocationNotBetween(String value1, String value2) { + addCriterion("location not between", value1, value2, "location"); + return (Criteria) this; + } + + public Criteria andVisitLocationIsNull() { + addCriterion("visit_location is null"); + return (Criteria) this; + } + + public Criteria andVisitLocationIsNotNull() { + addCriterion("visit_location is not null"); + return (Criteria) this; + } + + public Criteria andVisitLocationEqualTo(String value) { + addCriterion("visit_location =", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationNotEqualTo(String value) { + addCriterion("visit_location <>", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationGreaterThan(String value) { + addCriterion("visit_location >", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationGreaterThanOrEqualTo(String value) { + addCriterion("visit_location >=", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationLessThan(String value) { + addCriterion("visit_location <", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationLessThanOrEqualTo(String value) { + addCriterion("visit_location <=", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationLike(String value) { + addCriterion("visit_location like", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationNotLike(String value) { + addCriterion("visit_location not like", value, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationIn(List values) { + addCriterion("visit_location in", values, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationNotIn(List values) { + addCriterion("visit_location not in", values, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationBetween(String value1, String value2) { + addCriterion("visit_location between", value1, value2, "visitLocation"); + return (Criteria) this; + } + + public Criteria andVisitLocationNotBetween(String value1, String value2) { + addCriterion("visit_location not between", value1, value2, "visitLocation"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNull() { + addCriterion("created_at is null"); + return (Criteria) this; + } + + public Criteria andCreatedAtIsNotNull() { + addCriterion("created_at is not null"); + return (Criteria) this; + } + + public Criteria andCreatedAtEqualTo(Date value) { + addCriterion("created_at =", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotEqualTo(Date value) { + addCriterion("created_at <>", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThan(Date value) { + addCriterion("created_at >", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("created_at >=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThan(Date value) { + addCriterion("created_at <", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtLessThanOrEqualTo(Date value) { + addCriterion("created_at <=", value, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtIn(List values) { + addCriterion("created_at in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotIn(List values) { + addCriterion("created_at not in", values, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtBetween(Date value1, Date value2) { + addCriterion("created_at between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andCreatedAtNotBetween(Date value1, Date value2) { + addCriterion("created_at not between", value1, value2, "createdAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNull() { + addCriterion("updated_at is null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIsNotNull() { + addCriterion("updated_at is not null"); + return (Criteria) this; + } + + public Criteria andUpdatedAtEqualTo(Date value) { + addCriterion("updated_at =", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotEqualTo(Date value) { + addCriterion("updated_at <>", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThan(Date value) { + addCriterion("updated_at >", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) { + addCriterion("updated_at >=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThan(Date value) { + addCriterion("updated_at <", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtLessThanOrEqualTo(Date value) { + addCriterion("updated_at <=", value, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtIn(List values) { + addCriterion("updated_at in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotIn(List values) { + addCriterion("updated_at not in", values, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtBetween(Date value1, Date value2) { + addCriterion("updated_at between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andUpdatedAtNotBetween(Date value1, Date value2) { + addCriterion("updated_at not between", value1, value2, "updatedAt"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNull() { + addCriterion("rec_status is null"); + return (Criteria) this; + } + + public Criteria andRecStatusIsNotNull() { + addCriterion("rec_status is not null"); + return (Criteria) this; + } + + public Criteria andRecStatusEqualTo(Byte value) { + addCriterion("rec_status =", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotEqualTo(Byte value) { + addCriterion("rec_status <>", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThan(Byte value) { + addCriterion("rec_status >", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) { + addCriterion("rec_status >=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThan(Byte value) { + addCriterion("rec_status <", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusLessThanOrEqualTo(Byte value) { + addCriterion("rec_status <=", value, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusIn(List values) { + addCriterion("rec_status in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotIn(List values) { + addCriterion("rec_status not in", values, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusBetween(Byte value1, Byte value2) { + addCriterion("rec_status between", value1, value2, "recStatus"); + return (Criteria) this; + } + + public Criteria andRecStatusNotBetween(Byte value1, Byte value2) { + addCriterion("rec_status not between", value1, value2, "recStatus"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/form/src/main/java/com/ccsens/form/bean/po/FormBasic.java b/form/src/main/java/com/ccsens/form/bean/po/FormBasic.java index 6f2735a9..daa24c24 100644 --- a/form/src/main/java/com/ccsens/form/bean/po/FormBasic.java +++ b/form/src/main/java/com/ccsens/form/bean/po/FormBasic.java @@ -10,7 +10,7 @@ public class FormBasic implements Serializable { private String description; - private String coverImage; + private Long coverImage; private String accessPath; @@ -54,12 +54,12 @@ public class FormBasic implements Serializable { this.description = description == null ? null : description.trim(); } - public String getCoverImage() { + public Long getCoverImage() { return coverImage; } - public void setCoverImage(String coverImage) { - this.coverImage = coverImage == null ? null : coverImage.trim(); + public void setCoverImage(Long coverImage) { + this.coverImage = coverImage; } public String getAccessPath() { diff --git a/form/src/main/java/com/ccsens/form/bean/po/FormBasicExample.java b/form/src/main/java/com/ccsens/form/bean/po/FormBasicExample.java index 16504789..5b0e1afb 100644 --- a/form/src/main/java/com/ccsens/form/bean/po/FormBasicExample.java +++ b/form/src/main/java/com/ccsens/form/bean/po/FormBasicExample.java @@ -315,62 +315,52 @@ public class FormBasicExample { return (Criteria) this; } - public Criteria andCoverImageEqualTo(String value) { + public Criteria andCoverImageEqualTo(Long value) { addCriterion("cover_image =", value, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageNotEqualTo(String value) { + public Criteria andCoverImageNotEqualTo(Long value) { addCriterion("cover_image <>", value, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageGreaterThan(String value) { + public Criteria andCoverImageGreaterThan(Long value) { addCriterion("cover_image >", value, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageGreaterThanOrEqualTo(String value) { + public Criteria andCoverImageGreaterThanOrEqualTo(Long value) { addCriterion("cover_image >=", value, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageLessThan(String value) { + public Criteria andCoverImageLessThan(Long value) { addCriterion("cover_image <", value, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageLessThanOrEqualTo(String value) { + public Criteria andCoverImageLessThanOrEqualTo(Long value) { addCriterion("cover_image <=", value, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageLike(String value) { - addCriterion("cover_image like", value, "coverImage"); - return (Criteria) this; - } - - public Criteria andCoverImageNotLike(String value) { - addCriterion("cover_image not like", value, "coverImage"); - return (Criteria) this; - } - - public Criteria andCoverImageIn(List values) { + public Criteria andCoverImageIn(List values) { addCriterion("cover_image in", values, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageNotIn(List values) { + public Criteria andCoverImageNotIn(List values) { addCriterion("cover_image not in", values, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageBetween(String value1, String value2) { + public Criteria andCoverImageBetween(Long value1, Long value2) { addCriterion("cover_image between", value1, value2, "coverImage"); return (Criteria) this; } - public Criteria andCoverImageNotBetween(String value1, String value2) { + public Criteria andCoverImageNotBetween(Long value1, Long value2) { addCriterion("cover_image not between", value1, value2, "coverImage"); return (Criteria) this; } diff --git a/form/src/main/java/com/ccsens/form/bean/po/FormWrite.java b/form/src/main/java/com/ccsens/form/bean/po/FormWrite.java index 65c07089..e08e6d30 100644 --- a/form/src/main/java/com/ccsens/form/bean/po/FormWrite.java +++ b/form/src/main/java/com/ccsens/form/bean/po/FormWrite.java @@ -10,6 +10,8 @@ public class FormWrite implements Serializable { private Long formModuleId; + private Long optionId; + private String answer; private Long operator; @@ -46,6 +48,14 @@ public class FormWrite implements Serializable { this.formModuleId = formModuleId; } + public Long getOptionId() { + return optionId; + } + + public void setOptionId(Long optionId) { + this.optionId = optionId; + } + public String getAnswer() { return answer; } @@ -95,6 +105,7 @@ public class FormWrite implements Serializable { sb.append(", id=").append(id); sb.append(", formUserId=").append(formUserId); sb.append(", formModuleId=").append(formModuleId); + sb.append(", optionId=").append(optionId); sb.append(", answer=").append(answer); sb.append(", operator=").append(operator); sb.append(", createdAt=").append(createdAt); diff --git a/form/src/main/java/com/ccsens/form/bean/po/FormWriteExample.java b/form/src/main/java/com/ccsens/form/bean/po/FormWriteExample.java index cb38a713..6dcdb23e 100644 --- a/form/src/main/java/com/ccsens/form/bean/po/FormWriteExample.java +++ b/form/src/main/java/com/ccsens/form/bean/po/FormWriteExample.java @@ -285,6 +285,66 @@ public class FormWriteExample { return (Criteria) this; } + public Criteria andOptionIdIsNull() { + addCriterion("option_id is null"); + return (Criteria) this; + } + + public Criteria andOptionIdIsNotNull() { + addCriterion("option_id is not null"); + return (Criteria) this; + } + + public Criteria andOptionIdEqualTo(Long value) { + addCriterion("option_id =", value, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdNotEqualTo(Long value) { + addCriterion("option_id <>", value, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdGreaterThan(Long value) { + addCriterion("option_id >", value, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdGreaterThanOrEqualTo(Long value) { + addCriterion("option_id >=", value, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdLessThan(Long value) { + addCriterion("option_id <", value, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdLessThanOrEqualTo(Long value) { + addCriterion("option_id <=", value, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdIn(List values) { + addCriterion("option_id in", values, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdNotIn(List values) { + addCriterion("option_id not in", values, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdBetween(Long value1, Long value2) { + addCriterion("option_id between", value1, value2, "optionId"); + return (Criteria) this; + } + + public Criteria andOptionIdNotBetween(Long value1, Long value2) { + addCriterion("option_id not between", value1, value2, "optionId"); + return (Criteria) this; + } + public Criteria andAnswerIsNull() { addCriterion("answer is null"); return (Criteria) this; diff --git a/form/src/main/java/com/ccsens/form/bean/vo/FileVo.java b/form/src/main/java/com/ccsens/form/bean/vo/FileVo.java new file mode 100644 index 00000000..9a4c9e86 --- /dev/null +++ b/form/src/main/java/com/ccsens/form/bean/vo/FileVo.java @@ -0,0 +1,44 @@ +package com.ccsens.form.bean.vo; + +import com.ccsens.form.bean.po.CommonFile; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @description: 文件 + * @author: whj + * @time: 2020/7/17 11:39 + */ +public class FileVo { + @ApiModel("文件上传") + @Data + public static class Upload{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("文件名") + private String name; + @ApiModelProperty("访问路径") + private String visitUrl; + + /** + * 参数转化 + * @param files 文件对象 + * @return 文件访问 + */ + public static List transFilePo(List files) { + List vos = new ArrayList<>(); + files.forEach(file->{ + Upload vo = new Upload(); + vo.setId(file.getId()); + vo.setName(file.getFileName()); + vo.setVisitUrl(file.getVisitLocation()); + vos.add(vo); + }); + return vos; + } + } +} diff --git a/form/src/main/java/com/ccsens/form/bean/vo/FormVo.java b/form/src/main/java/com/ccsens/form/bean/vo/FormVo.java index 7b0ec1b0..419708b0 100644 --- a/form/src/main/java/com/ccsens/form/bean/vo/FormVo.java +++ b/form/src/main/java/com/ccsens/form/bean/vo/FormVo.java @@ -23,7 +23,11 @@ public class FormVo { @ApiModelProperty("描述") private Long description; @ApiModelProperty("封面图片") - private Long coverImage; + private String coverImagePath; + @ApiModelProperty("访问路径") + private String accessPath; + @ApiModelProperty("二维码路径") + private String qrcodePath; @ApiModelProperty("组件信息") private List moduleList; } @@ -33,7 +37,9 @@ public class FormVo { public static class FormModuleVo{ @ApiModelProperty("组件id") private Long id; - @ApiModelProperty("组件类型 (单选:radio)(多选:CheckBox)(下拉菜单:pullDown)(文本:text)(多行文本:textarea)(富文本:richText)") + @ApiModelProperty("表单内的组件id") + private Long formModuleId; + @ApiModelProperty("组件类型 (单选:radio)(多选:CheckBox)(下拉菜单:pullDown)(文本:text)(多行文本:textarea)(富文本:richText)(日期:date)") private byte type; @ApiModelProperty("图标") private String logo; @@ -46,7 +52,7 @@ public class FormVo { @ApiModelProperty("当前用户已填写的答案") private String answer; @ApiModelProperty("组件配置") - private List moduleConfigList; + private List moduleConfigList; @ApiModelProperty("选项信息") private List optionList; } diff --git a/form/src/main/java/com/ccsens/form/bean/vo/ModuleVo.java b/form/src/main/java/com/ccsens/form/bean/vo/ModuleVo.java index 877b4264..5be5e673 100644 --- a/form/src/main/java/com/ccsens/form/bean/vo/ModuleVo.java +++ b/form/src/main/java/com/ccsens/form/bean/vo/ModuleVo.java @@ -12,12 +12,33 @@ import java.util.List; @Data public class ModuleVo { + @Data + @ApiModel("查看表单的基本信息") + public static class FormInfo{ + @ApiModelProperty("表单id") + private Long id; + @ApiModelProperty("标题") + private Long title; + @ApiModelProperty("描述") + private Long description; + @ApiModelProperty("封面图片") + private String coverImagePath; + @ApiModelProperty("访问路径") + private String accessPath; + @ApiModelProperty("二维码路径") + private String qrcodePath; + @ApiModelProperty("提交状态") + private Byte submitStatus; + @ApiModelProperty("组件信息") + private List moduleList; + } + @Data @ApiModel("组件基本信息") public static class ModuleInfo{ @ApiModelProperty("组件id") private Long id; - @ApiModelProperty("组件类型 (单选:radio)(多选:CheckBox)(下拉菜单:pullDown)(文本:text)(多行文本:textarea)(富文本:richText)") + @ApiModelProperty("组件类型 (单选:radio)(多选:CheckBox)(下拉菜单:pullDown)(文本:text)(多行文本:textarea)(富文本:richText)(日期:date)") private byte type; @ApiModelProperty("图标") private String logo; diff --git a/form/src/main/java/com/ccsens/form/persist/dao/FormBasicDao.java b/form/src/main/java/com/ccsens/form/persist/dao/FormBasicDao.java index 0f7cbc87..e652b846 100644 --- a/form/src/main/java/com/ccsens/form/persist/dao/FormBasicDao.java +++ b/form/src/main/java/com/ccsens/form/persist/dao/FormBasicDao.java @@ -1,6 +1,7 @@ package com.ccsens.form.persist.dao; import com.ccsens.form.bean.vo.FormVo; +import com.ccsens.form.bean.vo.ModuleVo; import com.ccsens.form.persist.mapper.FormBasicMapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -22,4 +23,26 @@ public interface FormBasicDao extends FormBasicMapper { * @return 返回统计信息 */ List getStatisticsForm(@Param("formId") Long formId); + + /** + * 查看组件级答案 + * @param formId 表单id + * @param userId userId + * @return 组件信息及答案 + */ + List getFormModuleByFormId(@Param("formId")Long formId, @Param("userId")Long userId); + + /** + * 删除表单和表单关联的所有信息(表单,表单内的组件,组件的配置,组件的选项,用户表单的信息,用户填写的信息) + * @param formId 表单id + * @param userId userId 操作人id + */ + void deleteForm(@Param("formId")Long formId, @Param("userId")Long userId); + + /** + * 删除组件和组件关联的所有信息(表单内的组件,组件的配置,组件的选项,用户填写的信息) + * @param formModuleId 表单id + * @param userId userId 操作人id + */ + void deleteModule(@Param("formModuleId")Long formModuleId, @Param("formId")Long userId); } diff --git a/form/src/main/java/com/ccsens/form/persist/dao/ModuleDao.java b/form/src/main/java/com/ccsens/form/persist/dao/ModuleDao.java index 5f40f27d..0a3974ee 100644 --- a/form/src/main/java/com/ccsens/form/persist/dao/ModuleDao.java +++ b/form/src/main/java/com/ccsens/form/persist/dao/ModuleDao.java @@ -1,5 +1,6 @@ package com.ccsens.form.persist.dao; +import com.ccsens.form.bean.vo.FormVo; import com.ccsens.form.bean.vo.ModuleVo; import com.ccsens.form.persist.mapper.ModuleMapper; import org.apache.ibatis.annotations.Param; @@ -45,4 +46,20 @@ public interface ModuleDao extends ModuleMapper { * @return 返回选项信息 */ List getOptionByFormModuleId(@Param("formModuleId")Long formModuleId,@Param("parentId")Long parentId); + + /** + * 查找选项,和用户是否选择 + * @param formModuleId 表单内组件id + * @param parentId 上级id + * @param userId userId + * @return 返回选项信息和是否被选择 + */ + List queryOption(@Param("formModuleId")Long formModuleId, @Param("parentId")Long parentId, @Param("userId")Long userId); + + /** + * 查找表单内组件当前最大的排序 + * @param formId + * @return + */ + int getMaxSequence(@Param("formId")Long formId); } diff --git a/form/src/main/java/com/ccsens/form/persist/mapper/CommonFileMapper.java b/form/src/main/java/com/ccsens/form/persist/mapper/CommonFileMapper.java new file mode 100644 index 00000000..b1519c9d --- /dev/null +++ b/form/src/main/java/com/ccsens/form/persist/mapper/CommonFileMapper.java @@ -0,0 +1,30 @@ +package com.ccsens.form.persist.mapper; + +import com.ccsens.form.bean.po.CommonFile; +import com.ccsens.form.bean.po.CommonFileExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface CommonFileMapper { + long countByExample(CommonFileExample example); + + int deleteByExample(CommonFileExample example); + + int deleteByPrimaryKey(Long id); + + int insert(CommonFile record); + + int insertSelective(CommonFile record); + + List selectByExample(CommonFileExample example); + + CommonFile selectByPrimaryKey(Long id); + + int updateByExampleSelective(@Param("record") CommonFile record, @Param("example") CommonFileExample example); + + int updateByExample(@Param("record") CommonFile record, @Param("example") CommonFileExample example); + + int updateByPrimaryKeySelective(CommonFile record); + + int updateByPrimaryKey(CommonFile record); +} \ No newline at end of file diff --git a/form/src/main/java/com/ccsens/form/service/FileService.java b/form/src/main/java/com/ccsens/form/service/FileService.java new file mode 100644 index 00000000..8c0aff42 --- /dev/null +++ b/form/src/main/java/com/ccsens/form/service/FileService.java @@ -0,0 +1,105 @@ +package com.ccsens.form.service; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.ObjectUtil; +import com.ccsens.form.bean.po.CommonFile; +import com.ccsens.form.bean.vo.FileVo; +import com.ccsens.form.persist.mapper.CommonFileMapper; +import com.ccsens.form.util.Constant; +import com.ccsens.util.*; +import com.ccsens.util.exception.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import javax.servlet.http.Part; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @description: 文件操作 + * @author: whj + * @time: 2020/7/17 14:25 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class FileService implements IFileService { + + @Resource + private CommonFileMapper commonFileMapper; + @Resource + private Snowflake snowflake; + + + @Override + public List saveFile(String dir, List files, Long userId) throws IOException, NotSupportedFileTypeException { + List fileList = new ArrayList<>(); + String allowedExt = WebConstant.IMG_TYPE + "," + WebConstant.Wps.FILE_TYPE_ALL; + for (Part file: files) { + + log.info("文件名:{}", file.getSubmittedFileName()); + String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExt, dir); + CommonFile fileDo = new CommonFile(); + String name = file.getSubmittedFileName(); + fileDo.setId(snowflake.nextId()); + fileDo.setFileName(name); + fileDo.setLocation(dir + File.separator + path); + fileDo.setUserId(userId); + if (WebConstant.IMG_TYPE.contains(name.substring(name.lastIndexOf(".") + 1))) { + fileDo.setVisitLocation(PropUtil.imgDomain + Constant.File.UPLOAD_URL + File.separator + path); + } else { + fileDo.setVisitLocation(PropUtil.domain + "file/download/"+fileDo.getId()); + } + commonFileMapper.insertSelective(fileDo); + log.info("保存文件:{}", fileDo); + fileList.add(fileDo); + } + return fileList; + } + + + @Override + public CommonFile getById(Long id) { + return commonFileMapper.selectByPrimaryKey(id); + } + + @Override + public FileVo.Upload uploadPhone(Part file, Long userId) throws IOException, NotSupportedFileTypeException { + FileVo.Upload vo = new FileVo.Upload(); + if(ObjectUtil.isNotNull(file)) { + //限制文件大小 2M + if (file.getSize() > 2097152) { + throw new BaseException(CodeEnum.PHOTO_FILE_EXCEED_2M); + } + + String dir = PropUtil.path + Constant.File.UPLOAD_URL; + String allowedExt = WebConstant.IMG_TYPE; + + log.info("文件名:{}", file.getSubmittedFileName()); + String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExt, dir); + + CommonFile fileDo = new CommonFile(); + String name = file.getSubmittedFileName(); + fileDo.setId(snowflake.nextId()); + fileDo.setFileName(name); + fileDo.setLocation(dir + File.separator + path); + fileDo.setUserId(userId); + + fileDo.setVisitLocation(PropUtil.imgDomain + Constant.File.UPLOAD_URL + File.separator + path); + + commonFileMapper.insertSelective(fileDo); + log.info("保存文件:{}", fileDo); + vo.setId(fileDo.getId()); + vo.setName(fileDo.getFileName()); + vo.setVisitUrl(fileDo.getVisitLocation()); + } + return vo; + } + +} diff --git a/form/src/main/java/com/ccsens/form/service/FormService.java b/form/src/main/java/com/ccsens/form/service/FormService.java index 9b421dd8..b38b1932 100644 --- a/form/src/main/java/com/ccsens/form/service/FormService.java +++ b/form/src/main/java/com/ccsens/form/service/FormService.java @@ -1,19 +1,33 @@ package com.ccsens.form.service; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.ccsens.form.bean.dto.FormDto; -import com.ccsens.form.bean.po.FormBasic; -import com.ccsens.form.bean.po.FormUser; -import com.ccsens.form.bean.po.FormUserExample; +import com.ccsens.form.bean.dto.ModuleDto; +import com.ccsens.form.bean.po.*; import com.ccsens.form.bean.vo.FormVo; +import com.ccsens.form.bean.vo.ModuleVo; import com.ccsens.form.persist.dao.FormBasicDao; +import com.ccsens.form.persist.dao.ModuleDao; +import com.ccsens.form.persist.mapper.CommonFileMapper; +import com.ccsens.form.persist.mapper.FormModuleMapper; import com.ccsens.form.persist.mapper.FormUserMapper; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.PropUtil; +import com.ccsens.util.QrCodeUtil; import com.ccsens.util.bean.dto.QueryDto; +import com.ccsens.util.exception.BaseException; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.sql.Struct; +import java.util.ArrayList; import java.util.List; /** @@ -27,13 +41,165 @@ public class FormService implements IFormService{ private FormBasicDao formBasicDao; @Resource private FormUserMapper formUserMapper; + @Resource + private FormModuleMapper formModuleMapper; + @Resource + private IModuleService moduleService; + @Resource + private ModuleDao moduleDao; + @Resource + private Snowflake snowflake; + @Resource + private CommonFileMapper commonFileMapper; + + /** + * 添加表单 + */ + @Override + public void saveFormInfo(FormDto.SaveForm param, Long userId) throws Exception { + FormBasic formBasic = new FormBasic(); + formBasic.setId(snowflake.nextId()); + formBasic.setTitle(param.getTitle()); + formBasic.setDescription(param.getDescription()); + formBasic.setCoverImage(param.getCoverImageId()); + formBasic.setSubmitStatus((byte) 1); + formBasic.setUserId(userId); + formBasic.setOperator(userId); + //获取访问路径 + String accessPath = PropUtil.accessPath + "?formId=" + formBasic.getId(); + formBasic.setAccessPath(accessPath); + //生成二维码,保存路径 + String fileName = QrCodeUtil.getQrCodeWithUtf8(accessPath, PropUtil.path); + formBasic.setQrcodePath(PropUtil.imgDomain + fileName); + //存入数据库 + formBasicDao.insertSelective(formBasic); + + } + + /** + * 修改表单 + */ + @Override + public void updateFormInfo(FormDto.UpdateForm param, Long userId) { + //查找表单信息 + FormBasic formBasic = formBasicDao.selectByPrimaryKey(param.getFormId()); + + if(ObjectUtil.isNotNull(formBasic)){ + //验证是否是创建表单的用户 + if(!formBasic.getUserId().equals(userId)){ + throw new BaseException(CodeEnum.NOT_POWER); + } + if(StrUtil.isNotEmpty(param.getTitle())){ + formBasic.setTitle(param.getTitle()); + } + if(StrUtil.isNotEmpty(param.getDescription())){ + formBasic.setDescription(param.getDescription()); + } + if(ObjectUtil.isNotNull(param.getCoverImageId())){ + formBasic.setCoverImage(param.getCoverImageId()); + } + formBasic.setOperator(userId); + formBasicDao.updateByPrimaryKeySelective(formBasic); + } + } + + /** + * 删除表单,同时删除表单内的组件,组件的配置,组件的选项,用户表单的信息,用户填写的信息 + */ + @Override + public void deleteFormInfo(FormDto.GetFormInfo param, Long userId) { + //查找表信息 + FormBasic formBasic = formBasicDao.selectByPrimaryKey(param.getFormId()); + if(ObjectUtil.isNotNull(formBasic)) { + //验证是否是创建表单的用户 + if (!formBasic.getUserId().equals(userId)) { + throw new BaseException(CodeEnum.NOT_POWER); + } + //删除表单和关联的信息 + formBasicDao.deleteForm(param.getFormId(),userId); + } + } /** * 查看表单详细信息 */ @Override - public FormVo.GetFormInfo getFormInfo(QueryDto params) { - return null; + public FormVo.GetFormInfo getOneselfFormInfo(QueryDto params) { + FormDto.GetFormInfo formInfo = params.getParam(); + //查询该用户是否有表单的记录信息 + FormUserExample formUserExample = new FormUserExample(); + formUserExample.createCriteria().andFormIdEqualTo(formInfo.getFormId()).andUserIdEqualTo(params.getUserId()); + if(formUserMapper.countByExample(formUserExample) > 0){ + //没有则添加一条 状态为0未提交 + FormUser formUser = new FormUser(); + formUser.setId(snowflake.nextId()); + formUser.setFormId(formInfo.getFormId()); + formUser.setUserId(params.getUserId()); + formUser.setUserName(params.getUserName()); + formUser.setAvatarUrl(params.getAvatarUrl()); + formUser.setSubmitStatus((byte) 0); + formUser.setOperator(params.getUserId()); + formUserMapper.insertSelective(formUser); + } + //查询表单信息和此用户填写的信息 + return getFormInfoByFormIdAndUserId(formInfo.getFormId(),params.getUserId()); + } + + @Override + public FormVo.GetFormInfo getFormByFormUserId(FormDto.FormUser param) { + FormUser formUser = formUserMapper.selectByPrimaryKey(param.getFormUserId()); + if(ObjectUtil.isNull(formUser)) { + return null; + } + return getFormInfoByFormIdAndUserId(formUser.getFormId(),formUser.getUserId()); + } + + private FormVo.GetFormInfo getFormInfoByFormIdAndUserId(Long formId,Long userId){ + //获取表单基本信息 + FormVo.GetFormInfo formInfo = new FormVo.GetFormInfo(); + FormBasic formBasic = formBasicDao.selectByPrimaryKey(formId); + if(ObjectUtil.isNotNull(formBasic)){ + return formInfo; + } + BeanUtil.copyProperties(formBasic,formInfo); + //查找封面图片路径 + CommonFile commonFile = commonFileMapper.selectByPrimaryKey(formBasic.getCoverImage()); + if(ObjectUtil.isNotNull(commonFile)){ + formInfo.setCoverImagePath(commonFile.getVisitLocation()); + } + //获取组件信息及除了选择题以外的答案 + List formModuleVo = formBasicDao.getFormModuleByFormId(formId, userId); + if(CollectionUtil.isNotEmpty(formModuleVo)){ + formModuleVo.forEach(formModule -> { + //获取组件配置信息 + List moduleConfigList = moduleDao.getConfigByFormModuleId(formModule.getFormModuleId()); + //没有配置信息则查询默认配置 + if(CollectionUtil.isEmpty(moduleConfigList)){ + moduleConfigList = moduleDao.getConfigByModuleId(formModule.getId()); + } + formModule.setModuleConfigList(moduleConfigList); + //获取组件内的选项信息 + List formOptionVos = queryOption(formModule.getFormModuleId(), 0L, userId); + formModule.setOptionList(formOptionVos); + }); + } + formInfo.setModuleList(formModuleVo); + return formInfo; + } + /** + * 通过表单内的组价id和上级id查看选项信息 + */ + private List queryOption(Long formModuleId, Long parentId, Long userId){ + List optionList = moduleDao.queryOption(formModuleId,parentId,userId); + if(CollectionUtil.isNotEmpty(optionList)){ + optionList.forEach(option -> { + List subOptionList = queryOption(formModuleId,option.getId(),userId); + if(CollectionUtil.isNotEmpty(subOptionList)) { + option.setSubOption(subOptionList); + } + }); + } + return optionList; } /** @@ -61,4 +227,39 @@ public class FormService implements IFormService{ form.setModuleList(statisticsModuleList); return form; } + + /** + * 查询表单基本信息 + */ + @Override + public ModuleVo.FormInfo getFormInfo(FormDto.GetFormInfo param) { + //表单的基本信息 + ModuleVo.FormInfo formInfo = new ModuleVo.FormInfo(); + FormBasic formBasic = formBasicDao.selectByPrimaryKey(param.getFormId()); + if(ObjectUtil.isNull(formBasic)){ + return formInfo; + } + BeanUtil.copyProperties(formBasic,formInfo); + //查找封面图片路径 + CommonFile commonFile = commonFileMapper.selectByPrimaryKey(formBasic.getCoverImage()); + if(ObjectUtil.isNotNull(commonFile)){ + formInfo.setCoverImagePath(commonFile.getVisitLocation()); + } + //查找关联的组件 + FormModuleExample formModuleExample = new FormModuleExample(); + formModuleExample.createCriteria().andFormIdEqualTo(param.getFormId()); + List formModuleList = formModuleMapper.selectByExample(formModuleExample); + if(CollectionUtil.isEmpty(formModuleList)){ + return formInfo; + } + List moduleInfoList = new ArrayList<>(); + formModuleList.forEach(formModule -> { + ModuleVo.ModuleInfo moduleInfo = moduleService.getFormModule(new ModuleDto.GetFormModule(formModule.getId())); + if(ObjectUtil.isNotNull(moduleInfo)) { + moduleInfoList.add(moduleInfo); + } + }); + formInfo.setModuleList(moduleInfoList); + return formInfo; + } } diff --git a/form/src/main/java/com/ccsens/form/service/IFileService.java b/form/src/main/java/com/ccsens/form/service/IFileService.java new file mode 100644 index 00000000..d2fb25b7 --- /dev/null +++ b/form/src/main/java/com/ccsens/form/service/IFileService.java @@ -0,0 +1,42 @@ +package com.ccsens.form.service; + +import com.ccsens.form.bean.po.CommonFile; +import com.ccsens.form.bean.vo.FileVo; +import com.ccsens.util.NotSupportedFileTypeException; + +import javax.servlet.http.Part; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; + +/** + * 文件操作 + * @author whj + */ +public interface IFileService { + /*** + * 批量上传文件 + * @param dir 上级目录 + * @param files 文件 + * @param userId 用户id + * @return 文件信息 + * @throws IOException 文件存储异常 + * @throws NotSupportedFileTypeException 文件存储异常 + */ + List saveFile(String dir, List files, Long userId) throws IOException, NotSupportedFileTypeException; + + /** + * 根据ID查询数据 + * @param id id + * @return 文件 + */ + CommonFile getById(Long id); + + /** + * 上传图片文件,不能超过2M + * @param file + * @return + */ + FileVo.Upload uploadPhone(Part file, Long userId) throws IOException, NotSupportedFileTypeException; + +} diff --git a/form/src/main/java/com/ccsens/form/service/IFormService.java b/form/src/main/java/com/ccsens/form/service/IFormService.java index ecd8a763..881b8df3 100644 --- a/form/src/main/java/com/ccsens/form/service/IFormService.java +++ b/form/src/main/java/com/ccsens/form/service/IFormService.java @@ -2,6 +2,7 @@ package com.ccsens.form.service; import com.ccsens.form.bean.dto.FormDto; import com.ccsens.form.bean.vo.FormVo; +import com.ccsens.form.bean.vo.ModuleVo; import com.ccsens.util.bean.dto.QueryDto; import java.util.List; @@ -11,11 +12,18 @@ import java.util.List; */ public interface IFormService { /** - * 查询表单的详细信息 + * 查询表单的信息和自己填写的信息 * @param params 表单id 和用户的id姓名头像等信息 * @return 返回表单基本信息,组价信息,选项信息,和当前用户填写的信息 */ - FormVo.GetFormInfo getFormInfo(QueryDto params); + FormVo.GetFormInfo getOneselfFormInfo(QueryDto params); + + /** + * 查询指定用户填写的表单信息 + * @param param 用户填写表单的信息 + * @return 返回表单基本信息,组价信息,选项信息,和指定用户填写的信息 + */ + FormVo.GetFormInfo getFormByFormUserId(FormDto.FormUser param); /** * 查询表单填写人列表 @@ -30,4 +38,33 @@ public interface IFormService { * @return 返回填写总人数,和需要被统计的组件的统计信息 */ FormVo.StatisticsForm statisticsForm(FormDto.GetFormInfo param); + + /** + * 查询表单基本信息 + * @param param 表单id + * @return 返回表单id + */ + ModuleVo.FormInfo getFormInfo(FormDto.GetFormInfo param); + + + /** + * 添加表单 + * @param param 表单信息 + * @param userId userId + */ + void saveFormInfo(FormDto.SaveForm param, Long userId) throws Exception; + + /** + * 修改表单内 + * @param param 表单信息 + * @param userId userId + */ + void updateFormInfo(FormDto.UpdateForm param, Long userId); + + /** + * 删除表单 + * @param param 表单id + * @param userId userId + */ + void deleteFormInfo(FormDto.GetFormInfo param, Long userId); } diff --git a/form/src/main/java/com/ccsens/form/service/IModuleService.java b/form/src/main/java/com/ccsens/form/service/IModuleService.java index 9c7faa8c..8c58e998 100644 --- a/form/src/main/java/com/ccsens/form/service/IModuleService.java +++ b/form/src/main/java/com/ccsens/form/service/IModuleService.java @@ -19,10 +19,9 @@ public interface IModuleService { /** * 根据id查询表单内添加的组件的信息 * @param param 表单内添加的组件的id - * @param userId userId * @return 返回组件的配置和选项信息 */ - ModuleVo.ModuleInfo getFormModule(ModuleDto.GetFormModule param, Long userId); + ModuleVo.ModuleInfo getFormModule(ModuleDto.GetFormModule param); /** * 修改组件的配置和选项 @@ -31,4 +30,25 @@ public interface IModuleService { */ void updateFormModule(ModuleDto.UpdateFormModule params,Long userId); + /** + * 给表单添加一个组件 + * @param param 表单id 和组件id + * @param userId 组件id + */ + void saveModule(ModuleDto.SaveModule param, Long userId); + + /** + * 同时添加多个组件 + * @param param 表单id和组件id + * @param userId userId + */ + void saveMoreModule(ModuleDto.SaveMoreModule param, Long userId); + + /** + * 删除表单内的组件 + * @param param 表单内的组件id + * @param userId userId + */ + void deleteFormModule(ModuleDto.GetFormModule param, Long userId); + } diff --git a/form/src/main/java/com/ccsens/form/service/ModuleService.java b/form/src/main/java/com/ccsens/form/service/ModuleService.java index 689030e6..89cdd0c0 100644 --- a/form/src/main/java/com/ccsens/form/service/ModuleService.java +++ b/form/src/main/java/com/ccsens/form/service/ModuleService.java @@ -2,15 +2,17 @@ package com.ccsens.form.service; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.ObjectUtil; import com.ccsens.form.bean.dto.ModuleDto; -import com.ccsens.form.bean.po.FormModuleConfig; -import com.ccsens.form.bean.po.FormModuleConfigExample; -import com.ccsens.form.bean.po.FormModuleOption; -import com.ccsens.form.bean.po.FormModuleOptionExample; +import com.ccsens.form.bean.po.*; import com.ccsens.form.bean.vo.ModuleVo; +import com.ccsens.form.persist.dao.FormBasicDao; import com.ccsens.form.persist.dao.ModuleDao; import com.ccsens.form.persist.mapper.FormModuleConfigMapper; +import com.ccsens.form.persist.mapper.FormModuleMapper; import com.ccsens.form.persist.mapper.FormModuleOptionMapper; +import com.ccsens.util.CodeEnum; +import com.ccsens.util.exception.BaseException; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -29,11 +31,15 @@ public class ModuleService implements IModuleService{ @Resource private ModuleDao moduleDao; @Resource + private FormModuleMapper formModuleMapper; + @Resource private FormModuleConfigMapper formModuleConfigMapper; @Resource private FormModuleOptionMapper formModuleOptionMapper; @Resource private Snowflake snowflake; + @Resource + private FormBasicDao formBasicDao; /** * 查找所有组件模板 @@ -47,19 +53,22 @@ public class ModuleService implements IModuleService{ * 根据id查询表单内添加的组件的信息 */ @Override - public ModuleVo.ModuleInfo getFormModule(ModuleDto.GetFormModule param, Long userId) { + public ModuleVo.ModuleInfo getFormModule(ModuleDto.GetFormModule param) { //查找组件基本信息 ModuleVo.ModuleInfo moduleInfo = moduleDao.getModuleByFormModuleId(param.getFormModuleId()); - //查找当前组件的配置 - List moduleConfigList = moduleDao.getConfigByFormModuleId(param.getFormModuleId()); - //没有配置信息则查询默认配置 - if(CollectionUtil.isEmpty(moduleConfigList)){ - moduleConfigList = moduleDao.getConfigByModuleId(moduleInfo.getId()); + if(ObjectUtil.isNotNull(moduleInfo)){ + //查找当前组件的配置 + List moduleConfigList = moduleDao.getConfigByFormModuleId(param.getFormModuleId()); + //没有配置信息则查询默认配置 + if(CollectionUtil.isEmpty(moduleConfigList)){ + moduleConfigList = moduleDao.getConfigByModuleId(moduleInfo.getId()); + } + moduleInfo.setModuleConfigList(moduleConfigList); + //查找选项信息 + List optionList = getOptionByFormModuleId(param.getFormModuleId(),0L); + moduleInfo.setOptionList(optionList); + } - moduleInfo.setModuleConfigList(moduleConfigList); - //查找选项信息 - List optionList = getOptionByFormModuleId(param.getFormModuleId(),0L); - moduleInfo.setOptionList(optionList); return moduleInfo; } @@ -144,4 +153,84 @@ public class ModuleService implements IModuleService{ } } } + + /** + * 添加组件 + * @param param 表单id 和组件id + * @param userId 组件id + */ + @Override + public void saveModule(ModuleDto.SaveModule param, Long userId) { + //查找表单信息 + FormBasic formBasic = formBasicDao.selectByPrimaryKey(param.getFormId()); + if(ObjectUtil.isNotNull(formBasic)) { + //验证是否是创建表单的用户 + if (!formBasic.getUserId().equals(userId)) { + throw new BaseException(CodeEnum.NOT_POWER); + } + //查找该表单内组件当前的最大排序 + int sequence = moduleDao.getMaxSequence(param.getFormId()); + //添加数据 + FormModule formModule = new FormModule(); + formModule.setId(snowflake.nextId()); + formModule.setFormId(param.getFormId()); + formModule.setModuleId(param.getModuleId()); + formModule.setSequence(sequence + 1); + formModule.setOperator(userId); + formModuleMapper.insertSelective(formModule); + } + } + + /** + * 同时添加多个组件 + * @param param 表单id和组件id + * @param userId userId + */ + @Override + public void saveMoreModule(ModuleDto.SaveMoreModule param, Long userId) { + //查找表单信息 + FormBasic formBasic = formBasicDao.selectByPrimaryKey(param.getFormId()); + if(ObjectUtil.isNotNull(formBasic)) { + //验证是否是创建表单的用户 + if (!formBasic.getUserId().equals(userId)) { + throw new BaseException(CodeEnum.NOT_POWER); + } + if(CollectionUtil.isNotEmpty(param.getModuleIdList())){ + //查找该表单内组件当前的最大排序 + int sequence = moduleDao.getMaxSequence(param.getFormId()); + for(Long moduleId : param.getModuleIdList()){ + sequence++; + //添加数据 + FormModule formModule = new FormModule(); + formModule.setId(snowflake.nextId()); + formModule.setFormId(param.getFormId()); + formModule.setModuleId(moduleId); + formModule.setSequence(sequence); + formModule.setOperator(userId); + formModuleMapper.insertSelective(formModule); + } + } + } + } + + /** + * 删除表单内的组件 + * @param param 表单内的组件id + * @param userId userId + */ + @Override + public void deleteFormModule(ModuleDto.GetFormModule param, Long userId) { + //查找表单内的组件的信息信息 + FormModule formModule = formModuleMapper.selectByPrimaryKey(param.getFormModuleId()); + if(ObjectUtil.isNotNull(formModule)) { + //查找表单信息 + FormBasic formBasic = formBasicDao.selectByPrimaryKey(formModule.getFormId()); + //验证是否是创建表单的用户 + if (!formBasic.getUserId().equals(userId)) { + throw new BaseException(CodeEnum.NOT_POWER); + } + //删除组件和关联的信息 + formBasicDao.deleteModule(param.getFormModuleId(),userId); + } + } } diff --git a/form/src/main/java/com/ccsens/form/service/WriteService.java b/form/src/main/java/com/ccsens/form/service/WriteService.java index 10c0a39f..0af2f52a 100644 --- a/form/src/main/java/com/ccsens/form/service/WriteService.java +++ b/form/src/main/java/com/ccsens/form/service/WriteService.java @@ -73,6 +73,7 @@ public class WriteService implements IWriteService{ formWrite.setId(snowflake.nextId()); formWrite.setFormUserId(formUser.getId()); formWrite.setFormModuleId(moduleWrite.getFormModuleId()); + formWrite.setOptionId(moduleAnswer.getOptionId()); formWrite.setAnswer(moduleAnswer.getAnswer()); formWrite.setOperator(params.getUserId()); formWriteMapper.insertSelective(formWrite); diff --git a/form/src/main/java/com/ccsens/form/util/Constant.java b/form/src/main/java/com/ccsens/form/util/Constant.java index 0f930ea9..ae4f4372 100644 --- a/form/src/main/java/com/ccsens/form/util/Constant.java +++ b/form/src/main/java/com/ccsens/form/util/Constant.java @@ -23,5 +23,7 @@ public class Constant { /**日期*/ public static final String DATE = "date"; } - + public static class File{ + public static final String UPLOAD_URL = "upload"; + } } diff --git a/form/src/main/resources/application-dev.yml b/form/src/main/resources/application-dev.yml index 4629e1b6..220f3285 100644 --- a/form/src/main/resources/application-dev.yml +++ b/form/src/main/resources/application-dev.yml @@ -33,6 +33,8 @@ file: signUpUrl: https://test.tall.wiki/compete/ domain: https://test.tall.wiki/gateway/form/ imgDomain: https://test.tall.wiki/gateway/form/uploads/ -#gameMqName: game_status_wisdom + +accessPath: https://www.baidu.com + logging: path: \ No newline at end of file diff --git a/form/src/main/resources/application-prod.yml b/form/src/main/resources/application-prod.yml index bc3181b6..58ab4196 100644 --- a/form/src/main/resources/application-prod.yml +++ b/form/src/main/resources/application-prod.yml @@ -36,4 +36,6 @@ notGatewayUrl: https://www.tall.wiki/ file: path: /home/cloud/form/uploads/ domain: https://www.tall.wiki/gateway/form/ - imgDomain: https://www.tall.wiki/gateway/form/uploads/ \ No newline at end of file + imgDomain: https://www.tall.wiki/gateway/form/uploads/ + +accessPath: https://www.baidu.com \ No newline at end of file diff --git a/form/src/main/resources/application-test.yml b/form/src/main/resources/application-test.yml index 121e121b..b0341dec 100644 --- a/form/src/main/resources/application-test.yml +++ b/form/src/main/resources/application-test.yml @@ -33,3 +33,5 @@ file: path: /home/cloud/form/uploads/ domain: https://test.tall.wiki/gateway/form/ imgDomain: https://test.tall.wiki/gateway/form/uploads/ + +accessPath: https://www.baidu.com \ No newline at end of file diff --git a/form/src/main/resources/mapper_dao/FormBasicDao.xml b/form/src/main/resources/mapper_dao/FormBasicDao.xml index f3f00a48..491d98b5 100644 --- a/form/src/main/resources/mapper_dao/FormBasicDao.xml +++ b/form/src/main/resources/mapper_dao/FormBasicDao.xml @@ -10,6 +10,50 @@ + + UPDATE + t_form_basic fb + LEFT JOIN t_form_module fm on fm.form_id = fb.id and fm.rec_status = 0 + LEFT JOIN t_form_module_config mc on mc.form_module_id = fm.id and mc.rec_status = 0 + LEFT JOIN t_form_module_option o on o.form_module_id = fm.id and o.rec_status = 0 + LEFT JOIN t_form_user u on u.form_id = fb.id and u.rec_status = 0 + LEFT JOIN t_form_write w on w.form_user_id = u.id and w.rec_status = 0 + SET + fb.rec_status = 2, + fb.operator = #{userId}, + fm.rec_status = 2, + fm.operator = #{userId}, + mc.rec_status = 2, + mc.operator = #{userId}, + o.rec_status = 2, + o.operator = #{userId}, + u.rec_status = 2, + u.operator = #{userId}, + w.rec_status = 2, + w.operator = #{userId} + WHERE + fb.id = #{formId} + and fb.rec_status = 0 + + + UPDATE + t_form_module fm + LEFT JOIN t_form_module_config mc on mc.form_module_id = fm.id and mc.rec_status = 0 + LEFT JOIN t_form_module_option o on o.form_module_id = fm.id and o.rec_status = 0 + LEFT JOIN t_form_write w on w.form_module_id = u.id and w.rec_status = 0 + SET + fm.rec_status = 2, + fm.operator = #{userId}, + mc.rec_status = 2, + mc.operator = #{userId}, + o.rec_status = 2, + o.operator = #{userId}, + w.rec_status = 2, + w.operator = #{userId} + WHERE + fm.id = #{formModuleId} + and fb.rec_status = 0 + + \ No newline at end of file diff --git a/form/src/main/resources/mapper_dao/ModuleDao.xml b/form/src/main/resources/mapper_dao/ModuleDao.xml index 716033ff..60cfc9d0 100644 --- a/form/src/main/resources/mapper_dao/ModuleDao.xml +++ b/form/src/main/resources/mapper_dao/ModuleDao.xml @@ -96,5 +96,49 @@ and parent_id = #{parentId} and rec_status = 0 + + \ No newline at end of file diff --git a/form/src/main/resources/mapper_raw/CommonFileMapper.xml b/form/src/main/resources/mapper_raw/CommonFileMapper.xml new file mode 100644 index 00000000..f23849fa --- /dev/null +++ b/form/src/main/resources/mapper_raw/CommonFileMapper.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, user_id, file_name, location, visit_location, created_at, updated_at, rec_status + + + + + delete from t_common_file + where id = #{id,jdbcType=BIGINT} + + + delete from t_common_file + + + + + + insert into t_common_file (id, user_id, file_name, + location, visit_location, created_at, + updated_at, rec_status) + values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{fileName,jdbcType=VARCHAR}, + #{location,jdbcType=VARCHAR}, #{visitLocation,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, + #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}) + + + insert into t_common_file + + + id, + + + user_id, + + + file_name, + + + location, + + + visit_location, + + + created_at, + + + updated_at, + + + rec_status, + + + + + #{id,jdbcType=BIGINT}, + + + #{userId,jdbcType=BIGINT}, + + + #{fileName,jdbcType=VARCHAR}, + + + #{location,jdbcType=VARCHAR}, + + + #{visitLocation,jdbcType=VARCHAR}, + + + #{createdAt,jdbcType=TIMESTAMP}, + + + #{updatedAt,jdbcType=TIMESTAMP}, + + + #{recStatus,jdbcType=TINYINT}, + + + + + + update t_common_file + + + id = #{record.id,jdbcType=BIGINT}, + + + user_id = #{record.userId,jdbcType=BIGINT}, + + + file_name = #{record.fileName,jdbcType=VARCHAR}, + + + location = #{record.location,jdbcType=VARCHAR}, + + + visit_location = #{record.visitLocation,jdbcType=VARCHAR}, + + + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{record.recStatus,jdbcType=TINYINT}, + + + + + + + + update t_common_file + set id = #{record.id,jdbcType=BIGINT}, + user_id = #{record.userId,jdbcType=BIGINT}, + file_name = #{record.fileName,jdbcType=VARCHAR}, + location = #{record.location,jdbcType=VARCHAR}, + visit_location = #{record.visitLocation,jdbcType=VARCHAR}, + created_at = #{record.createdAt,jdbcType=TIMESTAMP}, + updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{record.recStatus,jdbcType=TINYINT} + + + + + + update t_common_file + + + user_id = #{userId,jdbcType=BIGINT}, + + + file_name = #{fileName,jdbcType=VARCHAR}, + + + location = #{location,jdbcType=VARCHAR}, + + + visit_location = #{visitLocation,jdbcType=VARCHAR}, + + + created_at = #{createdAt,jdbcType=TIMESTAMP}, + + + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + + + rec_status = #{recStatus,jdbcType=TINYINT}, + + + where id = #{id,jdbcType=BIGINT} + + + update t_common_file + set user_id = #{userId,jdbcType=BIGINT}, + file_name = #{fileName,jdbcType=VARCHAR}, + location = #{location,jdbcType=VARCHAR}, + visit_location = #{visitLocation,jdbcType=VARCHAR}, + created_at = #{createdAt,jdbcType=TIMESTAMP}, + updated_at = #{updatedAt,jdbcType=TIMESTAMP}, + rec_status = #{recStatus,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/form/src/main/resources/mapper_raw/FormBasicMapper.xml b/form/src/main/resources/mapper_raw/FormBasicMapper.xml index 8367c631..7f9ed6b9 100644 --- a/form/src/main/resources/mapper_raw/FormBasicMapper.xml +++ b/form/src/main/resources/mapper_raw/FormBasicMapper.xml @@ -5,7 +5,7 @@ - + @@ -114,7 +114,7 @@ created_at, updated_at, rec_status ) values (#{id,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, - #{coverImage,jdbcType=VARCHAR}, #{accessPath,jdbcType=VARCHAR}, #{qrcodePath,jdbcType=VARCHAR}, + #{coverImage,jdbcType=BIGINT}, #{accessPath,jdbcType=VARCHAR}, #{qrcodePath,jdbcType=VARCHAR}, #{submitStatus,jdbcType=TINYINT}, #{userId,jdbcType=BIGINT}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} ) @@ -170,7 +170,7 @@ #{description,jdbcType=VARCHAR}, - #{coverImage,jdbcType=VARCHAR}, + #{coverImage,jdbcType=BIGINT}, #{accessPath,jdbcType=VARCHAR}, @@ -217,7 +217,7 @@ description = #{record.description,jdbcType=VARCHAR}, - cover_image = #{record.coverImage,jdbcType=VARCHAR}, + cover_image = #{record.coverImage,jdbcType=BIGINT}, access_path = #{record.accessPath,jdbcType=VARCHAR}, @@ -253,7 +253,7 @@ set id = #{record.id,jdbcType=BIGINT}, title = #{record.title,jdbcType=VARCHAR}, description = #{record.description,jdbcType=VARCHAR}, - cover_image = #{record.coverImage,jdbcType=VARCHAR}, + cover_image = #{record.coverImage,jdbcType=BIGINT}, access_path = #{record.accessPath,jdbcType=VARCHAR}, qrcode_path = #{record.qrcodePath,jdbcType=VARCHAR}, submit_status = #{record.submitStatus,jdbcType=TINYINT}, @@ -276,7 +276,7 @@ description = #{description,jdbcType=VARCHAR}, - cover_image = #{coverImage,jdbcType=VARCHAR}, + cover_image = #{coverImage,jdbcType=BIGINT}, access_path = #{accessPath,jdbcType=VARCHAR}, @@ -309,7 +309,7 @@ update t_form_basic set title = #{title,jdbcType=VARCHAR}, description = #{description,jdbcType=VARCHAR}, - cover_image = #{coverImage,jdbcType=VARCHAR}, + cover_image = #{coverImage,jdbcType=BIGINT}, access_path = #{accessPath,jdbcType=VARCHAR}, qrcode_path = #{qrcodePath,jdbcType=VARCHAR}, submit_status = #{submitStatus,jdbcType=TINYINT}, diff --git a/form/src/main/resources/mapper_raw/FormWriteMapper.xml b/form/src/main/resources/mapper_raw/FormWriteMapper.xml index 607dfd64..bd510523 100644 --- a/form/src/main/resources/mapper_raw/FormWriteMapper.xml +++ b/form/src/main/resources/mapper_raw/FormWriteMapper.xml @@ -5,6 +5,7 @@ + @@ -70,7 +71,8 @@ - id, form_user_id, form_module_id, answer, operator, created_at, updated_at, rec_status + id, form_user_id, form_module_id, option_id, answer, operator, created_at, updated_at, + rec_status