一沙框架(yishaadmin)在后台保存或修改数据之前修改某个字段值的方法
1、在controller中
1 [HttpPost] 2 [AuthorizeFilter("device:devicetype:add,device:devicetype:edit")] 3 public async Task<ActionResult> SaveFormJson(DeviceTypeEntity entity) 4 { 5 entity.F_MaterialType = 1;//物料类型:1-设备 2-部件 6 TData<string> obj = await deviceTypeBLL.SaveForm(entity); 7 return Json(obj); 8 }
2、在BLL中
1 [HttpPost] 2 public async Task<TData<OperatorInfo>> Login([FromQuery] string userName, [FromQuery] string password, [FromQuery] string myCid) 3 { 4 TData<OperatorInfo> obj = new TData<OperatorInfo>(); 5 TData<UserEntity> userObj = await userBLL.CheckLogin(userName, password, (int)PlatformEnum.WebApi); 6 if (userObj.Tag == 1) 7 { 8 userObj.Data.ClientId = myCid;//修改字段ClientId的值为myCid 9 await new UserBLL().UpdateUser(userObj.Data); 10 await Operator.Instance.AddCurrent(userObj.Data.ApiToken); 11 obj.Data = await Operator.Instance.Current(userObj.Data.ApiToken); 12 } 13 obj.Tag = userObj.Tag; 14 obj.Message = userObj.Message; 15 return obj; 16 }