mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +08:00
h5 动态表单
This commit is contained in:
parent
dae6405f8e
commit
ddfd697ff9
@ -11,6 +11,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.ServletUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -39,7 +40,6 @@ public class FormController {
|
||||
|
||||
/**
|
||||
* save表单版本+1
|
||||
*
|
||||
*/
|
||||
@Operation(summary = "save表单版本+1")
|
||||
@PostMapping("/saveForm")
|
||||
@ -59,7 +59,7 @@ public class FormController {
|
||||
@PostMapping("/submit")
|
||||
public Boolean submitForm(@RequestBody SubmitFormRequest request, HttpServletRequest httpRequest) {
|
||||
// 获取客户端IP地址
|
||||
String ipAddress = getClientIpAddress(httpRequest);
|
||||
String ipAddress = ServletUtils.getClientIP();
|
||||
// 获取User-Agent
|
||||
String userAgent = httpRequest.getHeader("User-Agent");
|
||||
|
||||
@ -67,6 +67,7 @@ public class FormController {
|
||||
dto.setProjectId(request.getProjectId());
|
||||
//TODO TODO待完成 formId
|
||||
dto.setFormId(null);
|
||||
dto.setTempletFormId(null);
|
||||
dto.setFormData(request.getFormData());
|
||||
dto.setIpAddress(ipAddress);
|
||||
dto.setUserAgent(userAgent);
|
||||
@ -76,10 +77,10 @@ public class FormController {
|
||||
/**
|
||||
* 根据项目ID分页查询表单提交记录
|
||||
*
|
||||
* @param projectId 项目ID
|
||||
* @param fieldFilters 字段过滤条件
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @param projectId 项目ID
|
||||
* @param fieldFilters 字段过滤条件
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @return 表单提交记录分页数据
|
||||
*/
|
||||
@Operation(summary = "根据项目ID分页查询表单提交记录")
|
||||
@ -116,26 +117,6 @@ public class FormController {
|
||||
return formService.listFormDataByProjectId(projectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端IP地址
|
||||
*
|
||||
* @param request HttpServletRequest对象
|
||||
* @return 客户端IP地址
|
||||
*/
|
||||
private String getClientIpAddress(HttpServletRequest request) {
|
||||
String ipAddress = request.getHeader("X-Forwarded-For");
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.isEmpty() || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
}
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SubmitFormRequest {
|
||||
|
||||
@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -85,7 +86,7 @@ public class H5ProjectController {
|
||||
h5Project.setPreviewWidth(request.getPreviewWidth());
|
||||
h5Project.setPreviewHeight(request.getPreviewHeight());
|
||||
h5Project.setStatus(request.getStatus());
|
||||
|
||||
h5Project.setCreatedBy(LoginHelper.getUserId());
|
||||
boolean success = h5ProjectService.saveH5ProjectWithContent(h5Project, request.getContent(), request.getGroupIds());
|
||||
if (success) {
|
||||
return h5Project.getId();
|
||||
|
||||
@ -78,4 +78,7 @@ public class FormSubmission implements Serializable {
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
}
|
||||
@ -91,4 +91,6 @@ public class H5Project implements Serializable {
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
private Long createdBy;
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user