mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +08:00
调整表单提交
This commit is contained in:
parent
84e189a831
commit
201a370180
@ -36,6 +36,19 @@ public class FormController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private JSON json;
|
private JSON json;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save表单版本+1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Operation(summary = "save表单版本+1")
|
||||||
|
@PostMapping("/saveForm")
|
||||||
|
public Boolean saveForm(@RequestBody SubmitFormRequest request, HttpServletRequest httpRequest) {
|
||||||
|
//TODO待完成
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交表单数据
|
* 提交表单数据
|
||||||
*
|
*
|
||||||
@ -52,8 +65,10 @@ public class FormController {
|
|||||||
|
|
||||||
H5FormSubmissionDTO dto = new H5FormSubmissionDTO();
|
H5FormSubmissionDTO dto = new H5FormSubmissionDTO();
|
||||||
dto.setProjectId(request.getProjectId());
|
dto.setProjectId(request.getProjectId());
|
||||||
dto.setFormData(json.toJSON(request.getFormData()));
|
//TODO TODO待完成 formId
|
||||||
dto.setIpAddress(JSON.ipToLong(ipAddress));
|
dto.setFormId(null);
|
||||||
|
dto.setFormData(request.getFormData());
|
||||||
|
dto.setIpAddress(ipAddress);
|
||||||
dto.setUserAgent(userAgent);
|
dto.setUserAgent(userAgent);
|
||||||
return formService.submitFormData(dto);
|
return formService.submitFormData(dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.luban.api.convert;
|
package com.luban.api.convert;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.luban.api.dto.H5FormSubmissionDTO;
|
import com.luban.api.dto.H5FormSubmissionDTO;
|
||||||
import com.luban.api.entity.FormSubmission;
|
import com.luban.api.entity.FormSubmission;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@ -27,7 +28,11 @@ public class FormSubmissionConvert {
|
|||||||
|
|
||||||
H5FormSubmissionDTO dto = new H5FormSubmissionDTO();
|
H5FormSubmissionDTO dto = new H5FormSubmissionDTO();
|
||||||
BeanUtils.copyProperties(entity, dto);
|
BeanUtils.copyProperties(entity, dto);
|
||||||
// 将数字形式的IP地址转换为字符串
|
// 将JSON格式的formData转换为Map
|
||||||
|
if (entity.getFormData() != null) {
|
||||||
|
dto.setFormData(JSONUtil.toBean(entity.getFormData(), java.util.Map.class));
|
||||||
|
}
|
||||||
|
// 将IP地址转换为字符串
|
||||||
dto.setIpAddress(entity.getIpAddress());
|
dto.setIpAddress(entity.getIpAddress());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
@ -62,6 +67,10 @@ public class FormSubmissionConvert {
|
|||||||
}
|
}
|
||||||
FormSubmission entity = new FormSubmission();
|
FormSubmission entity = new FormSubmission();
|
||||||
BeanUtils.copyProperties(dto, entity);
|
BeanUtils.copyProperties(dto, entity);
|
||||||
|
// 将formData Map转换为JSON字符串
|
||||||
|
if (dto.getFormData() != null) {
|
||||||
|
entity.setFormData(JSONUtil.toJsonStr(dto.getFormData()));
|
||||||
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,49 +1,52 @@
|
|||||||
package com.luban.api.dto;
|
package com.luban.api.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单数据传输对象
|
* H5表单提交数据传输对象
|
||||||
*
|
*
|
||||||
* @author your-name
|
* @author your-name
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Schema(title = "H5表单提交对象")
|
||||||
public class H5FormSubmissionDTO {
|
public class H5FormSubmissionDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键ID
|
* 项目ID
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* H5Project的ID
|
|
||||||
*/
|
*/
|
||||||
|
@Schema(title = "项目ID")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
/**
|
||||||
|
* 模板表单ID
|
||||||
|
*/
|
||||||
|
@Schema(title = "模板表单ID")
|
||||||
|
private Long templetFormId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交者IP地址(IPv4为数字存储)
|
* 表单ID
|
||||||
*/
|
*/
|
||||||
private Long ipAddress;
|
@Schema(title = "表单ID")
|
||||||
|
private String formId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户代理信息
|
* 表单数据
|
||||||
*/
|
*/
|
||||||
|
@Schema(title = "表单数据")
|
||||||
|
private Map<String, Object> formData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IP地址
|
||||||
|
*/
|
||||||
|
@Schema(title = "IP地址")
|
||||||
|
private String ipAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户代理
|
||||||
|
*/
|
||||||
|
@Schema(title = "用户代理")
|
||||||
private String userAgent;
|
private String userAgent;
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单数据(JSON格式存储)
|
|
||||||
*/
|
|
||||||
private String formData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间戳
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间戳
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,11 +37,23 @@ public class FormSubmission implements Serializable {
|
|||||||
@TableField("project_id")
|
@TableField("project_id")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板表单ID
|
||||||
|
*/
|
||||||
|
@TableField("templet_form_id")
|
||||||
|
private Long templetFormId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单ID
|
||||||
|
*/
|
||||||
|
@TableField("form_id")
|
||||||
|
private String formId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交者IP地址
|
* 提交者IP地址
|
||||||
*/
|
*/
|
||||||
@TableField("ip_address")
|
@TableField("ip_address")
|
||||||
private Long ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户代理信息
|
* 用户代理信息
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user