dotnetcore / WTM

Use WTM to write .netcore app fast !!!
https://wtmdoc.walkingtec.cn
MIT License
4.22k stars 882 forks source link

文件上传 #247

Open gaotang opened 4 years ago

gaotang commented 4 years ago

有两个问题:

  1. 文件上传一定要登录授权才能使用,可不可以不用登录就能上传文件;
  2. 多文件上传生成表失败,我使用最新的NetCore2.2=>WTM 2.4.5的版本,COPY了文件里面多文件上传的DMEO,直接无法生成数据库失败。UploadMulti
liuliang-wt commented 4 years ago
  1. 目前文件上传只能登陆用户才可以
  2. 生成数据库时候报的具体错误是什么?
gaotang commented 4 years ago
  1. 具体我没有调试源码,就生成不了,我只做三步操作

  2. 更改配置文件,

  3. 添加数据库表实体类,如下: public class School : BasePoco { [Display(Name = "学校编码")] [Required(ErrorMessage = "{0}是必填项")] [RegularExpression("^[0-9]{3,3}$", ErrorMessage = "{0}必须是3位数字")] public string SchoolCode { get; set; } [Display(Name = "学校名称")] [StringLength(50, ErrorMessage = "{0}最多输入{1}个字符")] [Required(ErrorMessage = "{0}是必填项")] public string SchoolName { get; set; } //定义附件列表 public List Photos { get; set; } } //继承ISubFile的附件子表 public class SchoolPhoto : TopBasePoco, ISubFile { public int SchoolId { get; set; } public School School { get; set; } //ISubFile定义的字段 public Guid FileId { get; set; } public FileAttachment File { get; set; } public int order { get; set; } }

  4. DataAccess 项目中添加引用, //public DbSet School { get; set; },然后直接 Run项目就跑不来,注释掉这句话就可以,作者可以自己试试看

在 2020-01-11 12:35:18,"liuliang-wt" notifications@github.com 写道:

目前文件上传只能登陆用户才可以 生成数据库时候报的具体错误是什么?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

liuliang-wt commented 4 years ago

sorry,一直忘了回复了。 你的School类继承了BasePoco,默认他是Guid的主键,所以你SchoolPhoto表里的外键应该定义成 public Guid SchoolId, 而不是int。 在你启动项目的时候,注意看vs里的输出,他不能启动的时候肯定给你输出了错误,看那些错误描述可以比较快速的发现问题。

gaotang commented 4 years ago

ths, 没有细想,直接抄文档了。vs里的输出里面没有注意,多谢指出

在 2020-02-02 19:33:13,"liuliang-wt" notifications@github.com 写道:

sorry,一直忘了回复了。 你的School类继承了BasePoco,默认他是Guid的主键,所以你SchoolPhoto表里的外键应该定义成 public Guid SchoolId, 而不是int。 在你启动项目的时候,注意看vs里的输出,他不能启动的时候肯定给你输出了错误,看那些错误描述可以比较快速的发现问题。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.