public BaseOutput SetAppConfigInfo([FromBody] SetAppConfigInfoInput input) { // 环境库 var tableName = _configService.GetConfigTableName(input.Environment); // 编辑或新增 var model = _mapper.Map <AppConfigModel>(input); if (model.Id > 0) { // 基础字段不容许更新 model.LastTime = DateTime.Now; model.Version = _adminDbContext.Queryable <AppConfigModel>().AS(tableName).Max(it => it.Version) + 1; _adminDbContext.Updateable(model).AS(tableName) .IgnoreColumns(it => new { it.CreateTime }) .ExecuteCommand(); } else { model.CreateTime = DateTime.Now; model.LastTime = DateTime.Now; model.Version = _adminDbContext.Queryable <AppConfigModel>().AS(tableName).Max(it => it.Version) + 1; _adminDbContext.Insertable(model).AS(tableName).ExecuteCommand(); } return(new BaseOutput { }); }
public async Task <SetAppConfigInfoOutput> SetAppConfigInfo(SetAppConfigInfoInput input) { // 环境库 Enum.TryParse <Env>(input.Environment, out var env); var tableName = "tb_appconfig_test"; switch (env) { case Env.dev: tableName = $"tb_appconfig_{Env.dev.ToString()}"; break; case Env.pro: tableName = $"tb_appconfig_{Env.pro.ToString()}"; break; case Env.prepro: tableName = $"tb_appconfig_{Env.prepro.ToString()}"; break; case Env.uat: tableName = $"tb_appconfig_{Env.uat.ToString()}"; break; default: throw new BucketException("plm_001", "环境不存在"); } // 编辑或新增 var model = _mapper.Map <AppConfigInfo>(input); if (model.Id > 0) { // 基础字段不容许更新 model.LastTime = DateTime.Now; model.Version = _dbContext.Queryable <AppConfigInfo>().AS(tableName).Max(it => it.Version) + 1; await _dbContext.Updateable(model).AS(tableName) .IgnoreColumns(it => new { it.CreateTime }) .ExecuteCommandAsync(); } else { model.CreateTime = DateTime.Now; model.LastTime = DateTime.Now; model.Version = _dbContext.Queryable <AppConfigInfo>().AS(tableName).Max(it => it.Version) + 1; await _dbContext.Insertable(model).AS(tableName) .ExecuteCommandAsync(); } return(new SetAppConfigInfoOutput { }); }
public async Task <SetAppConfigInfoOutput> SetAppConfigInfo(SetAppConfigInfoInput input) { var model = _mapper.Map <SetAppConfigInfoInput, AppConfigInfo>(input); if (model.Id > 0) { // 基础字段不容许更新 model.LastTime = DateTime.Now; model.Version = _dbContext.Queryable <AppConfigInfo>().Max(it => it.Version) + 1; await _dbContext.Updateable(model) .IgnoreColumns(it => new { it.CreateTime }) .ExecuteCommandAsync(); } else { model.CreateTime = DateTime.Now; model.LastTime = DateTime.Now; model.Version = _dbContext.Queryable <AppConfigInfo>().Max(it => it.Version) + 1; await _dbContext.Insertable(model) .ExecuteCommandAsync(); } return(new SetAppConfigInfoOutput { }); }
public async Task <SetAppConfigInfoOutput> SetAppConfigInfo([FromBody] SetAppConfigInfoInput input) { return(await _configBusniess.SetAppConfigInfo(input)); }