Browse Source

20210108表单接口完成,未测试

recovery
zy_Java 5 years ago
parent
commit
a488e4ca62
  1. 105
      form/src/main/java/com/ccsens/form/api/FileController.java
  2. 64
      form/src/main/java/com/ccsens/form/api/FormController.java
  3. 33
      form/src/main/java/com/ccsens/form/api/ModuleController.java
  4. 40
      form/src/main/java/com/ccsens/form/bean/dto/FormDto.java
  5. 31
      form/src/main/java/com/ccsens/form/bean/dto/ModuleDto.java
  6. 2
      form/src/main/java/com/ccsens/form/bean/dto/WriteDto.java
  7. 106
      form/src/main/java/com/ccsens/form/bean/po/CommonFile.java
  8. 711
      form/src/main/java/com/ccsens/form/bean/po/CommonFileExample.java
  9. 8
      form/src/main/java/com/ccsens/form/bean/po/FormBasic.java
  10. 30
      form/src/main/java/com/ccsens/form/bean/po/FormBasicExample.java
  11. 11
      form/src/main/java/com/ccsens/form/bean/po/FormWrite.java
  12. 60
      form/src/main/java/com/ccsens/form/bean/po/FormWriteExample.java
  13. 44
      form/src/main/java/com/ccsens/form/bean/vo/FileVo.java
  14. 12
      form/src/main/java/com/ccsens/form/bean/vo/FormVo.java
  15. 23
      form/src/main/java/com/ccsens/form/bean/vo/ModuleVo.java
  16. 23
      form/src/main/java/com/ccsens/form/persist/dao/FormBasicDao.java
  17. 17
      form/src/main/java/com/ccsens/form/persist/dao/ModuleDao.java
  18. 30
      form/src/main/java/com/ccsens/form/persist/mapper/CommonFileMapper.java
  19. 105
      form/src/main/java/com/ccsens/form/service/FileService.java
  20. 211
      form/src/main/java/com/ccsens/form/service/FormService.java
  21. 42
      form/src/main/java/com/ccsens/form/service/IFileService.java
  22. 41
      form/src/main/java/com/ccsens/form/service/IFormService.java
  23. 24
      form/src/main/java/com/ccsens/form/service/IModuleService.java
  24. 117
      form/src/main/java/com/ccsens/form/service/ModuleService.java
  25. 1
      form/src/main/java/com/ccsens/form/service/WriteService.java
  26. 4
      form/src/main/java/com/ccsens/form/util/Constant.java
  27. 4
      form/src/main/resources/application-dev.yml
  28. 4
      form/src/main/resources/application-prod.yml
  29. 2
      form/src/main/resources/application-test.yml
  30. 76
      form/src/main/resources/mapper_dao/FormBasicDao.xml
  31. 44
      form/src/main/resources/mapper_dao/ModuleDao.xml
  32. 258
      form/src/main/resources/mapper_raw/CommonFileMapper.xml
  33. 14
      form/src/main/resources/mapper_raw/FormBasicMapper.xml
  34. 28
      form/src/main/resources/mapper_raw/FormWriteMapper.xml
  35. 6
      util/src/main/java/com/ccsens/util/PropUtil.java
  36. 3
      util/src/main/java/com/ccsens/util/QrCodeUtil.java

105
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<FileVo.Upload> upload(HttpServletRequest request, @RequestParam() List<Part> 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<CommonFile> fileVos = fileService.saveFile(dir, files, userId);
List<FileVo.Upload> 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<FileVo.Upload> 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);
}
}

64
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<FormVo.GetFormInfo> getOneselfFormInfo(@ApiParam @Validated @RequestBody QueryDto<FormDto.GetFormInfo> 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<FormVo.GetFormInfo> getFormInfo(@ApiParam @Validated @RequestBody QueryDto<FormDto.GetFormInfo> params) {
log.info("查找表单详细信息:{}",params);
FormVo.GetFormInfo getFormInfo = formService.getFormInfo(params);
log.info("查找表单详细信息");
public JsonResponse<FormVo.GetFormInfo> getFormByFormUserId(@ApiParam @Validated @RequestBody QueryDto<FormDto.FormUser> 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<FormVo.StatisticsForm> statisticsForm(@ApiParam @Validated @RequestBody QueryDto<FormDto.GetFormInfo> 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<ModuleVo.FormInfo> getFormInfo(@ApiParam @Validated @RequestBody QueryDto<FormDto.GetFormInfo> 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<FormDto.SaveForm> 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<FormDto.UpdateForm> 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<FormDto.GetFormInfo> params) {
log.info("删除表单:{}",params);
formService.deleteFormInfo(params.getParam(),params.getUserId());
log.info("删除表单成功");
return JsonResponse.newInstance().ok();
}
}

33
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<ModuleVo.ModuleInfo> getFormModule(@ApiParam @Validated @RequestBody QueryDto<ModuleDto.GetFormModule> 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<ModuleDto.SaveModule> 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<ModuleDto.SaveMoreModule> 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<ModuleDto.GetFormModule> params) {
log.info("删除表单内的组件:{}",params);
moduleService.deleteFormModule(params.getParam(),params.getUserId());
log.info("删除表单内的组件成功");
return JsonResponse.newInstance().ok();
}
}

40
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;
}
}

31
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<ModuleOption> 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<Long> moduleIdList;
}
}

2
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;
}

106
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();
}
}

711
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<Criteria> oredCriteria;
public CommonFileExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> 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<Long> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<Long> 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<String> values) {
addCriterion("file_name in", values, "fileName");
return (Criteria) this;
}
public Criteria andFileNameNotIn(List<String> 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<String> values) {
addCriterion("location in", values, "location");
return (Criteria) this;
}
public Criteria andLocationNotIn(List<String> 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<String> values) {
addCriterion("visit_location in", values, "visitLocation");
return (Criteria) this;
}
public Criteria andVisitLocationNotIn(List<String> 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<Date> values) {
addCriterion("created_at in", values, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotIn(List<Date> 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<Date> values) {
addCriterion("updated_at in", values, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotIn(List<Date> 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<Byte> values) {
addCriterion("rec_status in", values, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotIn(List<Byte> 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);
}
}
}

8
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() {

30
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<String> values) {
public Criteria andCoverImageIn(List<Long> values) {
addCriterion("cover_image in", values, "coverImage");
return (Criteria) this;
}
public Criteria andCoverImageNotIn(List<String> values) {
public Criteria andCoverImageNotIn(List<Long> 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;
}

11
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);

60
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<Long> values) {
addCriterion("option_id in", values, "optionId");
return (Criteria) this;
}
public Criteria andOptionIdNotIn(List<Long> 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;

44
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<Upload> transFilePo(List<CommonFile> files) {
List<Upload> 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;
}
}
}

12
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<FormModuleVo> 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<FormModuleConfigVo> moduleConfigList;
private List<ModuleVo.ModuleConfig> moduleConfigList;
@ApiModelProperty("选项信息")
private List<FormOptionVo> optionList;
}

23
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<ModuleInfo> 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;

23
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<FormVo.StatisticsModule> getStatisticsForm(@Param("formId") Long formId);
/**
* 查看组件级答案
* @param formId 表单id
* @param userId userId
* @return 组件信息及答案
*/
List<FormVo.FormModuleVo> 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);
}

17
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<ModuleVo.Option> getOptionByFormModuleId(@Param("formModuleId")Long formModuleId,@Param("parentId")Long parentId);
/**
* 查找选项和用户是否选择
* @param formModuleId 表单内组件id
* @param parentId 上级id
* @param userId userId
* @return 返回选项信息和是否被选择
*/
List<FormVo.FormOptionVo> queryOption(@Param("formModuleId")Long formModuleId, @Param("parentId")Long parentId, @Param("userId")Long userId);
/**
* 查找表单内组件当前最大的排序
* @param formId
* @return
*/
int getMaxSequence(@Param("formId")Long formId);
}

30
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<CommonFile> 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);
}

105
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<CommonFile> saveFile(String dir, List<Part> files, Long userId) throws IOException, NotSupportedFileTypeException {
List<CommonFile> 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;
}
}

211
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<FormDto.GetFormInfo> params) {
return null;
public FormVo.GetFormInfo getOneselfFormInfo(QueryDto<FormDto.GetFormInfo> 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<FormVo.FormModuleVo> formModuleVo = formBasicDao.getFormModuleByFormId(formId, userId);
if(CollectionUtil.isNotEmpty(formModuleVo)){
formModuleVo.forEach(formModule -> {
//获取组件配置信息
List<ModuleVo.ModuleConfig> moduleConfigList = moduleDao.getConfigByFormModuleId(formModule.getFormModuleId());
//没有配置信息则查询默认配置
if(CollectionUtil.isEmpty(moduleConfigList)){
moduleConfigList = moduleDao.getConfigByModuleId(formModule.getId());
}
formModule.setModuleConfigList(moduleConfigList);
//获取组件内的选项信息
List<FormVo.FormOptionVo> formOptionVos = queryOption(formModule.getFormModuleId(), 0L, userId);
formModule.setOptionList(formOptionVos);
});
}
formInfo.setModuleList(formModuleVo);
return formInfo;
}
/**
* 通过表单内的组价id和上级id查看选项信息
*/
private List<FormVo.FormOptionVo> queryOption(Long formModuleId, Long parentId, Long userId){
List<FormVo.FormOptionVo> optionList = moduleDao.queryOption(formModuleId,parentId,userId);
if(CollectionUtil.isNotEmpty(optionList)){
optionList.forEach(option -> {
List<FormVo.FormOptionVo> 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<FormModule> formModuleList = formModuleMapper.selectByExample(formModuleExample);
if(CollectionUtil.isEmpty(formModuleList)){
return formInfo;
}
List<ModuleVo.ModuleInfo> 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;
}
}

42
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<CommonFile> saveFile(String dir, List<Part> 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;
}

41
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<FormDto.GetFormInfo> params);
FormVo.GetFormInfo getOneselfFormInfo(QueryDto<FormDto.GetFormInfo> 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);
}

24
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);
}

117
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<ModuleVo.ModuleConfig> moduleConfigList = moduleDao.getConfigByFormModuleId(param.getFormModuleId());
//没有配置信息则查询默认配置
if(CollectionUtil.isEmpty(moduleConfigList)){
moduleConfigList = moduleDao.getConfigByModuleId(moduleInfo.getId());
if(ObjectUtil.isNotNull(moduleInfo)){
//查找当前组件的配置
List<ModuleVo.ModuleConfig> moduleConfigList = moduleDao.getConfigByFormModuleId(param.getFormModuleId());
//没有配置信息则查询默认配置
if(CollectionUtil.isEmpty(moduleConfigList)){
moduleConfigList = moduleDao.getConfigByModuleId(moduleInfo.getId());
}
moduleInfo.setModuleConfigList(moduleConfigList);
//查找选项信息
List<ModuleVo.Option> optionList = getOptionByFormModuleId(param.getFormModuleId(),0L);
moduleInfo.setOptionList(optionList);
}
moduleInfo.setModuleConfigList(moduleConfigList);
//查找选项信息
List<ModuleVo.Option> 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);
}
}
}

1
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);

4
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";
}
}

4
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:

4
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/
imgDomain: https://www.tall.wiki/gateway/form/uploads/
accessPath: https://www.baidu.com

2
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

76
form/src/main/resources/mapper_dao/FormBasicDao.xml

@ -10,6 +10,50 @@
<result column="nums" property="nums"/>
</collection>
</resultMap>
<update id="deleteForm">
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>
<update id="deleteModule">
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
</update>
<select id="getFormList" resultType="com.ccsens.form.bean.vo.FormVo$FormList">
SELECT
@ -60,4 +104,36 @@
) w on t.fmId = w.form_module_id
GROUP BY t.fmId,w.answer
</select>
<select id="getFormModuleByFormId" resultType="com.ccsens.form.bean.vo.FormVo$FormModuleVo">
SELECT
m.id,
fm.id as formModuleId,
m.type,
m.logo,
m.`name`,
m.`option`,
m.hierarchy,
w.answer
FROM
t_form_module fm
LEFT JOIN t_module m on fm.module_id = m.id
LEFT JOIN
(
SELECT
w.form_module_id as fmId,
w.answer
FROM
t_form_user u
LEFT JOIN t_form_write w on u.id = w.form_user_id
WHERE
u.form_id = #{formId}
and u.user_id = #{userId}
and u.rec_status = 0
and w.rec_status = 0
)w on fm.id = w.fmId and m.`option` = 0
WHERE
fm.form_id = #{formId}
and fm.rec_status = 0
and m.rec_status = 0
</select>
</mapper>

44
form/src/main/resources/mapper_dao/ModuleDao.xml

@ -96,5 +96,49 @@
and parent_id = #{parentId}
and rec_status = 0
</select>
<select id="queryOption" resultType="com.ccsens.form.bean.vo.FormVo$FormOptionVo">
SELECT
m.id,
m.optionKey,
m.optionValue,
m.sequence,
if(w.answer is null ,0,1) as choose
FROM
(
SELECT
id,
option_key as optionKey,
option_value as optionValue,
sequence
FROM
t_form_module_option
WHERE
form_module_id = #{formModuleId}
and parent_id = #{parentId}
and rec_status = 0
)m
LEFT JOIN
(
SELECT
w.answer
FROM
t_form_write w,
t_form_user u
WHERE
w.form_user_id = u.id
and w.form_module_id = #{formModuleId}
and u.user_id = #{userId}
and w.rec_status = 0
and u.rec_status = 0
)w on m.id = w.option_id
</select>
<select id="getMaxSequence" resultType="java.lang.Integer">
SELECT
MAX(sequence)
FROM
`t_form_module`
WHERE
form_id = #{formId}
</select>
</mapper>

258
form/src/main/resources/mapper_raw/CommonFileMapper.xml

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.form.persist.mapper.CommonFileMapper">
<resultMap id="BaseResultMap" type="com.ccsens.form.bean.po.CommonFile">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
<result column="location" jdbcType="VARCHAR" property="location" />
<result column="visit_location" jdbcType="VARCHAR" property="visitLocation" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, file_name, location, visit_location, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.form.bean.po.CommonFileExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_common_file
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_common_file
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from t_common_file
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.ccsens.form.bean.po.CommonFileExample">
delete from t_common_file
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.form.bean.po.CommonFile">
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>
<insert id="insertSelective" parameterType="com.ccsens.form.bean.po.CommonFile">
insert into t_common_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="fileName != null">
file_name,
</if>
<if test="location != null">
location,
</if>
<if test="visitLocation != null">
visit_location,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="recStatus != null">
rec_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="fileName != null">
#{fileName,jdbcType=VARCHAR},
</if>
<if test="location != null">
#{location,jdbcType=VARCHAR},
</if>
<if test="visitLocation != null">
#{visitLocation,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
#{recStatus,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.form.bean.po.CommonFileExample" resultType="java.lang.Long">
select count(*) from t_common_file
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_common_file
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.fileName != null">
file_name = #{record.fileName,jdbcType=VARCHAR},
</if>
<if test="record.location != null">
location = #{record.location,jdbcType=VARCHAR},
</if>
<if test="record.visitLocation != null">
visit_location = #{record.visitLocation,jdbcType=VARCHAR},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedAt != null">
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.form.bean.po.CommonFile">
update t_common_file
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="fileName != null">
file_name = #{fileName,jdbcType=VARCHAR},
</if>
<if test="location != null">
location = #{location,jdbcType=VARCHAR},
</if>
<if test="visitLocation != null">
visit_location = #{visitLocation,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.form.bean.po.CommonFile">
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}
</update>
</mapper>

14
form/src/main/resources/mapper_raw/FormBasicMapper.xml

@ -5,7 +5,7 @@
<id column="id" jdbcType="BIGINT" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="cover_image" jdbcType="VARCHAR" property="coverImage" />
<result column="cover_image" jdbcType="BIGINT" property="coverImage" />
<result column="access_path" jdbcType="VARCHAR" property="accessPath" />
<result column="qrcode_path" jdbcType="VARCHAR" property="qrcodePath" />
<result column="submit_status" jdbcType="TINYINT" property="submitStatus" />
@ -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},
</if>
<if test="coverImage != null">
#{coverImage,jdbcType=VARCHAR},
#{coverImage,jdbcType=BIGINT},
</if>
<if test="accessPath != null">
#{accessPath,jdbcType=VARCHAR},
@ -217,7 +217,7 @@
description = #{record.description,jdbcType=VARCHAR},
</if>
<if test="record.coverImage != null">
cover_image = #{record.coverImage,jdbcType=VARCHAR},
cover_image = #{record.coverImage,jdbcType=BIGINT},
</if>
<if test="record.accessPath != null">
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},
</if>
<if test="coverImage != null">
cover_image = #{coverImage,jdbcType=VARCHAR},
cover_image = #{coverImage,jdbcType=BIGINT},
</if>
<if test="accessPath != null">
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},

28
form/src/main/resources/mapper_raw/FormWriteMapper.xml

@ -5,6 +5,7 @@
<id column="id" jdbcType="BIGINT" property="id" />
<result column="form_user_id" jdbcType="BIGINT" property="formUserId" />
<result column="form_module_id" jdbcType="BIGINT" property="formModuleId" />
<result column="option_id" jdbcType="BIGINT" property="optionId" />
<result column="answer" jdbcType="VARCHAR" property="answer" />
<result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
@ -70,7 +71,8 @@
</where>
</sql>
<sql id="Base_Column_List">
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
</sql>
<select id="selectByExample" parameterType="com.ccsens.form.bean.po.FormWriteExample" resultMap="BaseResultMap">
select
@ -104,11 +106,13 @@
</delete>
<insert id="insert" parameterType="com.ccsens.form.bean.po.FormWrite">
insert into t_form_write (id, form_user_id, form_module_id,
answer, operator, created_at,
updated_at, rec_status)
option_id, answer, operator,
created_at, updated_at, rec_status
)
values (#{id,jdbcType=BIGINT}, #{formUserId,jdbcType=BIGINT}, #{formModuleId,jdbcType=BIGINT},
#{answer,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
#{optionId,jdbcType=BIGINT}, #{answer,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.ccsens.form.bean.po.FormWrite">
insert into t_form_write
@ -122,6 +126,9 @@
<if test="formModuleId != null">
form_module_id,
</if>
<if test="optionId != null">
option_id,
</if>
<if test="answer != null">
answer,
</if>
@ -148,6 +155,9 @@
<if test="formModuleId != null">
#{formModuleId,jdbcType=BIGINT},
</if>
<if test="optionId != null">
#{optionId,jdbcType=BIGINT},
</if>
<if test="answer != null">
#{answer,jdbcType=VARCHAR},
</if>
@ -183,6 +193,9 @@
<if test="record.formModuleId != null">
form_module_id = #{record.formModuleId,jdbcType=BIGINT},
</if>
<if test="record.optionId != null">
option_id = #{record.optionId,jdbcType=BIGINT},
</if>
<if test="record.answer != null">
answer = #{record.answer,jdbcType=VARCHAR},
</if>
@ -208,6 +221,7 @@
set id = #{record.id,jdbcType=BIGINT},
form_user_id = #{record.formUserId,jdbcType=BIGINT},
form_module_id = #{record.formModuleId,jdbcType=BIGINT},
option_id = #{record.optionId,jdbcType=BIGINT},
answer = #{record.answer,jdbcType=VARCHAR},
operator = #{record.operator,jdbcType=BIGINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
@ -226,6 +240,9 @@
<if test="formModuleId != null">
form_module_id = #{formModuleId,jdbcType=BIGINT},
</if>
<if test="optionId != null">
option_id = #{optionId,jdbcType=BIGINT},
</if>
<if test="answer != null">
answer = #{answer,jdbcType=VARCHAR},
</if>
@ -248,6 +265,7 @@
update t_form_write
set form_user_id = #{formUserId,jdbcType=BIGINT},
form_module_id = #{formModuleId,jdbcType=BIGINT},
option_id = #{optionId,jdbcType=BIGINT},
answer = #{answer,jdbcType=VARCHAR},
operator = #{operator,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},

6
util/src/main/java/com/ccsens/util/PropUtil.java

@ -27,6 +27,7 @@ public class PropUtil {
public static String saveWpsFile;
public static String queryVisitUrls;
public static String getWpsFilePath;
public static String accessPath;
@Value("${saveWpsFile:}")
public void setSaveWpsFile(String saveWpsFile) {
@ -93,4 +94,9 @@ public class PropUtil {
public void setSignUpUrl(String signUpUrl) {
PropUtil.signUpUrl = signUpUrl;
}
@Value("${accessPath:}")
public void setAccessPath(String accessPath) {
PropUtil.accessPath = accessPath;
}
}

3
util/src/main/java/com/ccsens/util/QrCodeUtil.java

@ -95,7 +95,7 @@ public class QrCodeUtil {
* 生成二位吗utf-8
* @return 返回文件位置不带前缀
*/
public String getQrCodeWithUtf8(String value, String filePath) throws Exception {
public static String getQrCodeWithUtf8(String value, String filePath) throws Exception {
//文件地址
String fileName = "qrCode/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
@ -108,6 +108,7 @@ public class QrCodeUtil {
Path path = FileSystems.getDefault().getPath(filePath + fileName);
MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path);
return fileName;
}

Loading…
Cancel
Save