Esempio n. 1
0
    {/// <summary>
     ///  添加管理员
     /// </summary>
     /// <param name="admin"></param>
     /// <returns></returns>
        public async Task <IdResp <string> > AddAdmin(AdminInfoMo admin)
        {
            // 判断是否已经绑定
            var exitAdminRes = await AdminInfoRep.Instance.GetAdminByUId(admin.u_id);

            if (exitAdminRes.IsSuccess())
            {
                return(new IdResp <string>().WithResp(RespTypes.ObjectExist, "当前用户已经存在绑定管理员"));
            }
            if (!exitAdminRes.IsRespType(RespTypes.ObjectNull))
            {
                return(new IdResp <string>().WithResp(exitAdminRes));
            }

            // 判断用户本身是否存在问题
            var userRes = await InsContainer <IUserServiceProxy> .Instance.GetUserById(admin.u_id);

            if (!userRes.IsSuccess())
            {
                return(new IdResp <string>().WithResp(userRes));
            }

            if (userRes.data.status < 0)
            {
                return(new IdResp <string>().WithResp(RespTypes.ObjectExist, "当前绑定用户状态异常!"));
            }

            // 执行添加
            admin.InitialBaseFromContext();
            admin.avatar = userRes.data.avatar;

            return(await AdminInfoRep.Instance.Add(admin));
        }
Esempio n. 2
0
        public static AdminInfoMo MapToAdminInfo(this AddAdminReq req)
        {
            var infoMo = new AdminInfoMo
            {
                admin_name = req.admin_name,
                u_id       = req.u_id
            };

            return(infoMo);
        }
Esempio n. 3
0
        private static Resp <UserIdentity> InitialAdminIdentity(AdminInfoMo admin, SocialPlatform fromPlat)
        {
            var checkRes = CheckIdentityStatus(admin.status);

            if (!checkRes.IsSuccess())
            {
                return(new Resp <UserIdentity>().WithResp(checkRes));
            }

            var identity = new UserIdentity
            {
                id     = admin.u_id.ToString(),    // 使用用户表的Id
                name   = admin.admin_name,
                avatar = admin.avatar,
                //from_plat = (int) fromPlat,

                auth_type = admin.admin_type == AdminType.Supper
                    ? PortalAuthorizeType.SuperAdmin
                    : PortalAuthorizeType.Admin
            };

            return(new Resp <UserIdentity>(identity));
        }