src/ZKEACMS.FormGenerator/Controllers/FormDataController.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Easy.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ZKEACMS.FormGenerator.Models;
using ZKEACMS.FormGenerator.Service;
using Easy.Extend;
using Easy.Mvc.Authorize;
using Microsoft.AspNetCore.Authorization;
using System.Net;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Primitives;
using ZKEACMS.Filter;
using Easy;

namespace ZKEACMS.FormGenerator.Controllers
{
    [DefaultAuthorize(Policy = PermissionKeys.ViewFormData)]
    public class FormDataController : BasicController<FormData, int, IFormDataService>
    {
        private const string ExcelContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        private readonly ILocalize _localize;
        public FormDataController(IFormDataService service, ILocalize localize) : base(service)
        {
            _localize = localize;
        }

        [HttpPost, AllowAnonymous, ValidateAntiForgeryToken, RenderRefererPage]
        public IActionResult Submit(string FormId)
        {
            if (FormId.IsNullOrWhiteSpace()) return BadRequest();

            var result = Service.SaveForm(Request.Form, FormId);
            ModelState.Merge(result);
            if (!result.HasViolation)
            {
                TempData["Message"] = _localize.Get("Form have submited");
            }
            return View(result.Result.Form);
        }

        [HttpPost, DefaultAuthorize(Policy = PermissionKeys.ManageFormData)]
        public override IActionResult Delete(int id)
        {
            return base.Delete(id);
        }
        [DefaultAuthorize(Policy = PermissionKeys.ExportFormData)]
        public IActionResult Export(int id)
        {
            return File(Service.Export(id), ExcelContentType);
        }
        [DefaultAuthorize(Policy = PermissionKeys.ExportFormData)]
        public IActionResult ExportForm(string id)
        {
后面还有 4 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。