diff --git a/src/YhCore.WebApi/Controllers/Api/Common/CommonController.cs b/src/YhCore.WebApi/Controllers/Api/Common/CommonController.cs index 4a1a8fa..7ae60a4 100644 --- a/src/YhCore.WebApi/Controllers/Api/Common/CommonController.cs +++ b/src/YhCore.WebApi/Controllers/Api/Common/CommonController.cs @@ -77,7 +77,7 @@ namespace YhCore.WebApi.Controllers.Api.Common /// 添加字典。 [HttpPost("AddDic")] - public async Task AddDic([FromForm] Common_Dictionary model) + public async Task AddDic([FromBody] Common_Dictionary model) { if (model == null) throw new DException("参数错误!"); @@ -94,7 +94,7 @@ namespace YhCore.WebApi.Controllers.Api.Common /// 更新字典。 [HttpPost("UpdateDic")] - public async Task UpdateDic([FromForm] Common_Dictionary model) + public async Task UpdateDic([FromBody] Common_Dictionary model) { if (model == null) throw new DException("参数有误!"); model.Schserid = SchSerID(); @@ -103,7 +103,7 @@ namespace YhCore.WebApi.Controllers.Api.Common /// 编辑字典名称。 [HttpPost("EditDic")] - public async Task EditDic([FromForm] Common_Dictionary model) + public async Task EditDic([FromBody] Common_Dictionary model) { if (model == null) throw new DException("参数有误!"); model.Schserid = SchSerID(); @@ -112,7 +112,7 @@ namespace YhCore.WebApi.Controllers.Api.Common /// 添加发文部门。 [HttpPost("AddDeptDic")] - public async Task AddDeptDic([FromForm] Common_Dictionary model) + public async Task AddDeptDic([FromBody] Common_Dictionary model) { if (model == null) throw new DException("参数有误!"); @@ -129,7 +129,7 @@ namespace YhCore.WebApi.Controllers.Api.Common /// 更新发文部门。 [HttpPost("UpdateDeptDic")] - public async Task UpdateDeptDic([FromForm] Common_Dictionary model) + public async Task UpdateDeptDic([FromBody] Common_Dictionary model) { if (model == null) throw new DException("参数有误!"); model.Schserid = SchSerID(); diff --git a/src/YhCore.WebApi/Controllers/Api/DocPrint/WY_listController.cs b/src/YhCore.WebApi/Controllers/Api/DocPrint/WY_listController.cs index 3770114..cb648e4 100644 --- a/src/YhCore.WebApi/Controllers/Api/DocPrint/WY_listController.cs +++ b/src/YhCore.WebApi/Controllers/Api/DocPrint/WY_listController.cs @@ -86,7 +86,11 @@ namespace YhCore.WebApi.Controllers.Api.DocPrint [HttpPost("AddDictionaryType")] public async Task AddDictionaryType([FromForm] Common_Dictionary model) { - if (model == null) throw new DException("参数错误!"); + // 表单绑定实例不会为 null,但字段名拼错(如 TypelD≠TypeId)时必填列会为 null, + // SaveChanges 才抛"不能将 NULL 插入列"(code:6 无从排查)——在入口显式校验给出可读错误。 + if (model == null || string.IsNullOrWhiteSpace(model.typeID) + || string.IsNullOrWhiteSpace(model.typeName) || string.IsNullOrWhiteSpace(model.Name)) + throw new DException("参数错误:typeID、typeName、Name 均不能为空(注意表单字段名拼写,TypeId≠TypelD)"); model.Schserid = SchSerID(); await _dict.AddDicAsync(model); } @@ -95,7 +99,9 @@ namespace YhCore.WebApi.Controllers.Api.DocPrint [HttpPost("EditDictionaryType")] public async Task EditDictionaryType([FromForm] Common_Dictionary model) { - if (model == null) throw new DException("参数有误!"); + if (model == null || model.SerID <= 0 || string.IsNullOrWhiteSpace(model.typeID) + || string.IsNullOrWhiteSpace(model.typeName) || string.IsNullOrWhiteSpace(model.Name)) + throw new DException("参数错误:SerID、typeID、typeName、Name 均不能为空(注意表单字段名拼写,TypeId≠TypelD)"); model.Schserid = SchSerID(); await _dict.EditDicAsync(model); } diff --git a/src/YhCore.WebApi/appsettings.json b/src/YhCore.WebApi/appsettings.json index f8eb830..884594d 100644 --- a/src/YhCore.WebApi/appsettings.json +++ b/src/YhCore.WebApi/appsettings.json @@ -36,7 +36,7 @@ "Enabled": true, "BaseHost": "http://base.yunhaixingtong.com", "BasePath": "/userbase", - "SchClassPath": "/bschclass", + "SchClassPath": "/userclass", "AppKey": "100002", "AppSecret": "2314a3b158b24a838b2b9b69fd3db118" }