public async Task <ResultModel> Run(AcceptParam acceptParam, AppSetting appSetting, HttpContext context, long userId) { var req = acceptParam.AnalyzeParam <KeyReq <int> >(); if (req == null || req.Key <= 0) { return(ResultModel.GetParamErrorModel()); } if (userId == req.Key) { return(ResultModel.GetParamErrorModel("查询人与被关注人相同")); } var conn = appSetting.GetMysqlConn(context); var isExists = await DapperTools.IsExists(conn, EntityTools.GetTableName <AttentionInfo>(), new[] { $"{EntityTools.GetField<AttentionInfo>(nameof(AttentionInfo.AttentionUser))} ={req.Key}", $"{EntityTools.GetField<AttentionInfo>(nameof(AttentionInfo.UserId))} ={userId}", $"{nameof(BaseModel.ValidFlag)}={(int) ValidFlagMenu.UseFul}" }); return(ResultModel.GetSuccessModel(isExists)); }
public async Task <ResultModel> Run(AcceptParam acceptParam, AppSetting appSetting, HttpContext context) { var createUserInfoDto = acceptParam.AnalyzeParam <CreateUserInfoReq>(); string msg; if (createUserInfoDto == null) { return(ResultModel.GetNullErrorModel(string.Empty)); } //设置默认显示名为登录名 createUserInfoDto.DisplayName = createUserInfoDto.UserName; if ((msg = createUserInfoDto.ValidInfo()) != string.Empty) { return(ResultModel.GetParamErrorModel(string.Empty, msg)); } var conn = appSetting.GetMysqlConn(context); var userNameField = EntityTools.GetField <UserInfo>(nameof(UserInfo.UserName)); //查看用户名是否已存在 var isExists = await DapperTools.IsExists(conn, EntityTools.GetTableName <UserInfo>(), new List <string>() { $"{userNameField} = @{userNameField}" }, new { createUserInfoDto.UserName }); if (isExists) { return(ResultModel.GetParamErrorModel(string.Empty, "用户名已存在!")); } // Predicates.Field<UserInfo>(u => u.Id > 0, Operator.Eq, true); // Predicates.Exists<>() var result = await DapperTools.CreateItem(conn, EntityTools.GetTableName <UserInfo>(), createUserInfoDto); return(ResultModel.GetSuccessModel(string.Empty, result)); }