Example #1
0
        public UserModule(IUserMapper userMapper, IUserBaseService userBaseService)
        {
            //获取新增用户
            Post["/user/add"] = x =>
            {
                var entity   = this.Bind <UserBase>();
                var isRepeat = userBaseService.GetUserBase(entity.UserName) == null;
                if (!isRepeat)
                {
                    return(Response.AsErrorJson("用户名重复!"));
                }

                var data = userBaseService.AddUserBase(entity);
                return(Response.AsSuccessJson(data));
            };

            //初始化默认用户
            Post["/user/initDefault"] = x =>
            {
                var entity = new UserBase
                {
                    UserName = "******",
                    Password = "******"
                };
                userBaseService.AddUserBase(entity);

                return(Response.AsSuccessJson(entity));
            };
        }
Example #2
0
        public UserModule(IUserMapper userMapper, IUserBaseService userBaseService)
        {
            //获取新增用户
            Post["/user/add"] = x =>
            {
                var entity = this.Bind <UserBase>();
                entity.Id         = Guid.NewGuid().ToString();
                entity.CreateTime = DateTime.Now;

                var data = userBaseService.AddUserBase(entity);
                return(Response.AsSuccessJson(data));
            };
        }