-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ab692e
commit 64bc861
Showing
15 changed files
with
365 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
backend/backend.Api/Migrations/20190424013234_CreateUserTable.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
backend/backend.Api/Migrations/20190424013234_CreateUserTable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
namespace backend.Api.Migrations | ||
{ | ||
public partial class CreateUserTable : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "user", | ||
columns: table => new | ||
{ | ||
id = table.Column<Guid>(nullable: false), | ||
user_name = table.Column<string>(maxLength: 64, nullable: true), | ||
nick_name = table.Column<string>(maxLength: 64, nullable: true), | ||
phone = table.Column<string>(maxLength: 64, nullable: true), | ||
email = table.Column<string>(maxLength: 64, nullable: true), | ||
is_verify_phone = table.Column<int>(nullable: false), | ||
is_verify_email = table.Column<int>(nullable: false), | ||
password = table.Column<string>(maxLength: 64, nullable: true), | ||
user_role = table.Column<int>(nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_user", x => x.id); | ||
}); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "user"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// <auto-generated /> | ||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using backend.Api.Data; | ||
|
||
namespace backend.Api.Migrations | ||
{ | ||
[DbContext(typeof(MyContext))] | ||
partial class MyContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "2.1.8-servicing-32085") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 64); | ||
|
||
modelBuilder.Entity("backend.Core.Entities.User", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnName("id"); | ||
|
||
b.Property<string>("Email") | ||
.HasColumnName("email") | ||
.HasMaxLength(64); | ||
|
||
b.Property<int>("IsVerifyEmail") | ||
.HasColumnName("is_verify_email"); | ||
|
||
b.Property<int>("IsVerifyPhone") | ||
.HasColumnName("is_verify_phone"); | ||
|
||
b.Property<string>("NickName") | ||
.HasColumnName("nick_name") | ||
.HasMaxLength(64); | ||
|
||
b.Property<string>("Password") | ||
.HasColumnName("password") | ||
.HasMaxLength(64); | ||
|
||
b.Property<string>("Phone") | ||
.HasColumnName("phone") | ||
.HasMaxLength(64); | ||
|
||
b.Property<string>("UserName") | ||
.HasColumnName("user_name") | ||
.HasMaxLength(64); | ||
|
||
b.Property<int>("UserRole") | ||
.HasColumnName("user_role"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("user"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace backend.Core.Customers | ||
{ | ||
public class CustomerEnum | ||
{ | ||
public enum UserRole | ||
{ | ||
Admin = 1, | ||
User = 11 | ||
} | ||
|
||
public enum HttpCode | ||
{ | ||
Success = 200, | ||
NotFound = 404, | ||
Forbidden = 403, | ||
ServerError = 500 | ||
} | ||
|
||
public enum Verification | ||
{ | ||
True = 1, | ||
False = 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Text; | ||
|
||
namespace backend.Core.Entities | ||
{ | ||
public abstract class Entity | ||
{ | ||
[Column("id")] | ||
public Guid Id { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Text; | ||
using backend.Core.Customers; | ||
|
||
namespace backend.Core.Entities | ||
{ | ||
[Table("user")] | ||
public class User: Entity | ||
{ | ||
[Column("user_name"), MaxLength(64)] | ||
public string UserName { get; set; } | ||
[Column("nick_name"), MaxLength(64)] | ||
public string NickName { get; set; } | ||
[Column("phone"), MaxLength(64)] | ||
public string Phone { get; set; } | ||
[Column("email"), MaxLength(64)] | ||
public string Email { get; set; } | ||
[Column("is_verify_phone")] | ||
public CustomerEnum.Verification IsVerifyPhone { get; set; } | ||
[Column("is_verify_email")] | ||
public CustomerEnum.Verification IsVerifyEmail { get; set; } | ||
[Column("password"), MaxLength(64)] | ||
public string Password { get; set; } | ||
[Column("user_role")] | ||
public CustomerEnum.UserRole UserRole { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace backend.Core.Helper | ||
{ | ||
public class Crypto | ||
{ | ||
public static readonly string Key = "MPSRenew"; | ||
public static DESCryptoServiceProvider DesCsp = new DESCryptoServiceProvider(); | ||
|
||
public static string DesEncrypt(string value) | ||
{ | ||
var buffer = Encoding.UTF8.GetBytes(value); | ||
var ms = new MemoryStream(); | ||
var encStream = new CryptoStream(ms, DesCsp.CreateEncryptor(Encoding.UTF8.GetBytes(Key), Encoding.UTF8.GetBytes(Key)), CryptoStreamMode.Write); | ||
encStream.Write(buffer, 0, buffer.Length); | ||
encStream.FlushFinalBlock(); | ||
return Convert.ToBase64String(ms.ToArray()).Replace("+", "%"); | ||
} | ||
|
||
public static string DesDecrypt(string value) | ||
{ | ||
value = value.Replace("%", "+"); | ||
var buffer = Convert.FromBase64String(value); | ||
var ms = new MemoryStream(); | ||
var decStream = new CryptoStream(ms, | ||
DesCsp.CreateDecryptor(Encoding.UTF8.GetBytes(Key), Encoding.UTF8.GetBytes(Key)), | ||
CryptoStreamMode.Read); | ||
decStream.Write(buffer, 0, buffer.Length); | ||
decStream.FlushFinalBlock(); | ||
return Encoding.UTF8.GetString(ms.ToArray()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using backend.Core.Customers; | ||
using Newtonsoft.Json; | ||
|
||
namespace backend.Core.Helper | ||
{ | ||
public static class ReturnJson | ||
{ | ||
public class Return | ||
{ | ||
[JsonProperty("code")] | ||
public CustomerEnum.HttpCode Code { get; set; } | ||
[JsonProperty("data")] | ||
public object Data { get; set; } | ||
} | ||
|
||
public static Return Success(object data = null) | ||
{ | ||
var model = new Return | ||
{ | ||
Code = CustomerEnum.HttpCode.Success, | ||
Data = data | ||
}; | ||
|
||
return model; | ||
} | ||
|
||
|
||
public static Return NotFound(object data = null) | ||
{ | ||
var model = new Return | ||
{ | ||
Code = CustomerEnum.HttpCode.NotFound, | ||
Data = data | ||
}; | ||
|
||
return model; | ||
} | ||
|
||
public static Return ServerError(object data = null) | ||
{ | ||
var model = new Return | ||
{ | ||
Code = CustomerEnum.HttpCode.ServerError, | ||
Data = data | ||
}; | ||
|
||
return model; | ||
} | ||
|
||
public static Return Forbidden(object data = null) | ||
{ | ||
var model = new Return | ||
{ | ||
Code = CustomerEnum.HttpCode.Forbidden, | ||
Data = data | ||
}; | ||
|
||
return model; | ||
} | ||
} | ||
} |
Oops, something went wrong.