├── .gitattributes ├── .gitignore ├── Common ├── Common.csproj ├── DeepCopyHelper.cs └── Properties │ └── AssemblyInfo.cs ├── FastSchool.BLL ├── AccountBLL.cs ├── BaseBLL.cs ├── CommodityBLL.cs ├── FastSchool.BLL.csproj ├── OrderBLL.cs └── UserBLL.cs ├── FastSchool.Common ├── FastSchool.Common.csproj ├── MemoryCache.cs └── RandomNumber.cs ├── FastSchool.Interface ├── FastSchool.Interface.csproj ├── IAccountBLL.cs ├── IBaseBLL.cs ├── ICache.cs ├── ICommodityBLL.cs ├── IOrderBLL.cs └── IUserBLL.cs ├── FastSchool.Model ├── BaseModel.cs ├── Commodity.cs ├── Enum │ ├── EnumExpressType.cs │ └── EnumOrderState.cs ├── FastSchool.Model.csproj ├── FastSchoolDBContext.cs ├── Migrations │ ├── 20181121020849_INIT.Designer.cs │ ├── 20181121020849_INIT.cs │ └── FastSchoolDBContextModelSnapshot.cs ├── Order.cs └── User.cs ├── FastSchool.WebApi ├── Controllers │ ├── AccountController.cs │ ├── CommodityController.cs │ ├── OrderController.cs │ ├── TestController.cs │ └── UserController.cs ├── FastSchool.WebApi.csproj ├── Filters │ ├── ExceptionFilter.cs │ └── ModelStateFilter.cs ├── Models │ ├── ResultModel.cs │ ├── ViewModelBase.cs │ ├── ViewModelCommodity.cs │ ├── ViewModelOrder.cs │ ├── ViewModelOrderInfo.cs │ └── ViewModelUser.cs ├── Program.cs ├── Properties │ ├── PublishProfiles │ │ └── FolderProfile.pubxml │ └── launchSettings.json ├── Startup.cs ├── appsettings.Development.json ├── appsettings.json └── nlog.config ├── FastSchool.sln ├── FastSchoolApp.Common ├── AccountHelper.cs ├── DeepCopyHelper.cs ├── FastSchoolApp.Common.csproj ├── HttpHelper.cs └── JsonHelper.cs ├── FastSchoolApp.Model ├── AccountUserData.cs ├── BaseModel.cs ├── Commodity.cs ├── EnumOrderState.cs ├── ExpressTypeEnum.cs ├── FastSchoolApp.Model.csproj ├── ResultModel.cs ├── User.cs ├── UserOrder.cs └── UserOrderInfo.cs ├── FastSchoolApp.Services ├── AccountService.cs ├── BaseServices.cs ├── FastSchoolApp.Services.csproj ├── HomeService.cs └── UserService.cs ├── FastSchoolApp.ViewModel ├── AffirmOrderModel.cs ├── BaseModel.cs ├── Class1.cs ├── ExpressTypeEnum.cs ├── FastSchoolApp.ViewModel.csproj ├── NewInfoDetailedModel.cs ├── NewInfoModel.cs ├── OrderStatusEnum.cs ├── RegisterModel.cs ├── SecurityModel.cs ├── SendNewInfoModel.cs ├── UserDataModel.cs └── UserOrderModel.cs ├── FastSchoolApp ├── FastSchoolApp.Android │ ├── Assets │ │ └── AboutAssets.txt │ ├── FastSchoolApp.Android.csproj │ ├── MainActivity.cs │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── AboutResources.txt │ │ ├── Resource.designer.cs │ │ ├── drawable │ │ │ ├── bg.jpg │ │ │ ├── fasong.png │ │ │ ├── faxian.png │ │ │ ├── gerenzhongxin.png │ │ │ ├── home.png │ │ │ ├── icon_hulianwang.png │ │ │ ├── kg.jpg │ │ │ ├── logbg.jpg │ │ │ ├── suotou.png │ │ │ ├── xiaoyuhao.png │ │ │ └── yonghu.png │ │ ├── layout │ │ │ ├── Tabbar.axml │ │ │ └── Toolbar.axml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── icon.xml │ │ │ └── icon_round.xml │ │ ├── mipmap-hdpi │ │ │ ├── Icon.png │ │ │ └── launcher_foreground.png │ │ ├── mipmap-mdpi │ │ │ ├── icon.png │ │ │ └── launcher_foreground.png │ │ ├── mipmap-xhdpi │ │ │ ├── Icon.png │ │ │ └── launcher_foreground.png │ │ ├── mipmap-xxhdpi │ │ │ ├── Icon.png │ │ │ └── launcher_foreground.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── Icon.png │ │ │ └── launcher_foreground.png │ │ └── values │ │ │ ├── colors.xml │ │ │ └── styles.xml │ └── SplashActivity.cs ├── FastSchoolApp.iOS │ ├── AppDelegate.cs │ ├── Entitlements.plist │ ├── FastSchoolApp.iOS.csproj │ ├── Info.plist │ ├── Main.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Resources │ │ └── LaunchScreen.storyboard └── FastSchoolApp │ ├── App.xaml │ ├── App.xaml.cs │ ├── FastSchoolApp.csproj │ ├── Files │ └── UserData.json │ ├── Home │ ├── AffirmOrder.xaml │ ├── AffirmOrder.xaml.cs │ ├── HomeMasterDetailPage.xaml │ ├── HomeMasterDetailPage.xaml.cs │ ├── HomeMasterDetailPageMaster.xaml │ ├── HomeMasterDetailPageMaster.xaml.cs │ ├── HomeMasterDetailPageMenuItem.cs │ ├── NewInfo.xaml │ ├── NewInfo.xaml.cs │ ├── NewInfoDetailed.xaml │ ├── NewInfoDetailed.xaml.cs │ ├── SendNewInfo.xaml │ └── SendNewInfo.xaml.cs │ ├── Login │ ├── LoginPage.xaml │ ├── LoginPage.xaml.cs │ ├── Register.xaml │ └── Register.xaml.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── User │ ├── OrderInfo.xaml │ ├── OrderInfo.xaml.cs │ ├── Security.xaml │ ├── Security.xaml.cs │ ├── UserData.xaml │ ├── UserData.xaml.cs │ ├── UserOrder.xaml │ ├── UserOrder.xaml.cs │ ├── UserTabbedPage.xaml │ └── UserTabbedPage.xaml.cs │ └── ViewModel │ ├── AffirmOrderModel.cs │ ├── BaseModel.cs │ ├── NewInfoDetailedModel.cs │ ├── NewInfoModel.cs │ ├── OrderStatusEnum.cs │ ├── RegisterModel.cs │ ├── SecurityModel.cs │ ├── SendNewInfoModel.cs │ ├── UserDataModel.cs │ ├── UserOrderInfoModel.cs │ └── UserOrderModel.cs └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Common/Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {856FC8F9-81D5-4C62-8E1D-56EDFC30DDA0} 8 | Library 9 | Properties 10 | Common 11 | Common 12 | v4.6.1 13 | 512 14 | true 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 7.1 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 7.1 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Common/DeepCopyHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.Serialization.Formatters.Binary; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Xml.Serialization; 9 | 10 | namespace Common 11 | { 12 | /// 13 | /// 对象的深度拷贝(序列化的方式) 14 | /// 15 | public class DeepCopyHelper 16 | { 17 | /// 18 | /// xml序列化的方式实现深拷贝 19 | /// 20 | /// 21 | /// 22 | /// 23 | public static T XmlDeepCopy(T t) 24 | { 25 | //创建Xml序列化对象 26 | XmlSerializer xml = new XmlSerializer(typeof(T)); 27 | using (MemoryStream ms = new MemoryStream())//创建内存流 28 | { 29 | //将对象序列化到内存中 30 | xml.Serialize(ms, t); 31 | ms.Position = default;//将内存流的位置设为0 32 | return (T)xml.Deserialize(ms);//继续反序列化 33 | } 34 | } 35 | 36 | /// 37 | /// 二进制序列化的方式进行深拷贝 38 | /// 确保需要拷贝的类里的所有成员已经标记为 [Serializable] 如果没有加该特性特报错 39 | /// 40 | /// 41 | /// 42 | /// 43 | public static T BinaryDeepCopy(T t) 44 | { 45 | //创建二进制序列化对象 46 | BinaryFormatter bf = new BinaryFormatter(); 47 | using (MemoryStream ms = new MemoryStream())//创建内存流 48 | { 49 | //将对象序列化到内存中 50 | bf.Serialize(ms, t); 51 | ms.Position = default;//将内存流的位置设为0 52 | return (T)bf.Deserialize(ms);//继续反序列化 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("Common")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Common")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("856fc8f9-81d5-4c62-8e1d-56edfc30dda0")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 33 | //通过使用 "*",如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastSchool.BLL/AccountBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Interface; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | 5 | namespace FastSchool.BLL 6 | { 7 | public class AccountBLL : BaseBLL, IAccountBLL 8 | { 9 | public AccountBLL(DbContext dbContext) : base(dbContext) 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastSchool.BLL/CommodityBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Interface; 2 | using FastSchool.Model; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Query; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace FastSchool.BLL 11 | { 12 | public class CommodityBLL : BaseBLL, ICommodityBLL 13 | { 14 | public CommodityBLL(DbContext dbContext) : base(dbContext) 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FastSchool.BLL/FastSchool.BLL.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netcoreapp2.1 12 | 7.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /FastSchool.BLL/OrderBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Interface; 2 | using FastSchool.Model; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Query; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace FastSchool.BLL 13 | { 14 | public class OrderBLL : BaseBLL, IOrderBLL 15 | { 16 | public OrderBLL(DbContext dbContext) : base(dbContext) 17 | { 18 | 19 | } 20 | 21 | /// 22 | /// 创建订单 23 | /// 24 | /// 25 | /// 26 | /// 27 | public async Task CreateOrderAsync(Order order, Commodity commodity) 28 | { 29 | commodity.IsDelete = true; 30 | DbContext.Update(commodity); 31 | await DbContext.AddAsync(order); 32 | var result = await DbContext.SaveChangesAsync(); 33 | return result > 0; 34 | } 35 | 36 | //public async Task GetOrderIncludeEntiyAsync(Expression> whereLanbda, Expression>[] expressions) 37 | //{ 38 | 39 | // var result = DbContext.Set().AsNoTracking().IgnoreQueryFilters().Where(whereLanbda); 40 | // foreach (var item in expressions) 41 | // { 42 | // result = result.Include(item); 43 | // } 44 | // /*.Include(expression).ToList();*/ 45 | // return await result.FirstOrDefaultAsync(); 46 | // //await DbContext.Set().AsNoTracking().Where(whereLanbda).Include(expressions.FirstOrDefault()).IgnoreQueryFilters().FirstOrDefaultAsync(); 47 | //} 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FastSchool.BLL/UserBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Interface; 2 | using FastSchool.Model; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastSchool.BLL 10 | { 11 | public class UserBLL : BaseBLL, IUserBLL 12 | { 13 | public UserBLL(DbContext dbContext) : base(dbContext) 14 | { 15 | } 16 | 17 | public async Task ContainsAsync(User user) 18 | { 19 | return await base.DbSet().ContainsAsync(user); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /FastSchool.Common/FastSchool.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netcoreapp2.1 12 | 7.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /FastSchool.Common/MemoryCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using FastSchool.Interface; 3 | using Microsoft.Extensions.Caching.Memory; 4 | 5 | namespace FastSchool.Common 6 | { 7 | public class MemoryCache : ICache 8 | { 9 | public IMemoryCache Cache { get; } 10 | public MemoryCache(IMemoryCache memoryCache) 11 | { 12 | Cache = memoryCache; 13 | } 14 | 15 | public void Set(object key, T Tvalue) 16 | { 17 | Cache.Set(key, Tvalue); 18 | } 19 | 20 | public T Get(object key) 21 | { 22 | var b = Cache.TryGetValue(key, out T value); 23 | return b ? value : default; 24 | } 25 | 26 | public void Remove(object key) 27 | { 28 | Cache.Remove(key); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FastSchool.Common/RandomNumber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchool.Common 6 | { 7 | public class RandomNumber 8 | { 9 | private static Random Random { get; } 10 | static RandomNumber() 11 | { 12 | Random = new Random(Guid.NewGuid().GetHashCode()); 13 | } 14 | 15 | /// 16 | /// 随机数产生 17 | /// 18 | /// 最大传入11 19 | /// 20 | public static int GetRandomNumber(int forNumber = 1) 21 | { 22 | string result = default; 23 | if (forNumber > 11) 24 | return default; 25 | 26 | for (int i = 0; i < forNumber; i++) 27 | { 28 | result += Random.Next(0, 10); 29 | } 30 | return int.Parse(result); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /FastSchool.Interface/FastSchool.Interface.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netcoreapp2.1 12 | 7.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /FastSchool.Interface/IAccountBLL.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FastSchool.Interface 8 | { 9 | public interface IAccountBLL:IBaseBLL 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FastSchool.Interface/IBaseBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Query; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Linq.Expressions; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace FastSchool.Interface 12 | { 13 | public interface IBaseBLL 14 | { 15 | Task AddAsync(T t) where T : BaseModel; 16 | Task AddRangeAsync(IEnumerable entiys); 17 | Task UpdateAsync(T t) where T : BaseModel; 18 | Task FindAsync(Guid id) where T : BaseModel; 19 | Task GetEntiyAsync(Expression> expressions) where T : BaseModel; 20 | 21 | IQueryable GetEntiysInclude(Expression>[] expressions, Expression> whereExpressions = null) 22 | where T : BaseModel; 23 | 24 | IQueryable GetALLEntiy() where T : BaseModel; 25 | IQueryable GetALLEntiyByWhere(Expression> expressions) 26 | where T : BaseModel; 27 | 28 | (IQueryable, int) GetEntiyByPage( 29 | Expression> OrderLambda, 30 | int pageIndex, 31 | int pageSize, 32 | bool isEsc = true) 33 | where T : BaseModel; 34 | 35 | Task DeleteAsync(T t) where T : BaseModel; 36 | Task DeleteByIdAsync(Guid id) where T : BaseModel; 37 | DbSet DbSet() where T : BaseModel; 38 | Task SaveChangesAsync(); 39 | 40 | //Task GetEntiyIncludeAsync( 41 | // Expression> whereLanbda, 42 | // Expression>[] expressions) 43 | // where T : BaseModel; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /FastSchool.Interface/ICache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchool.Interface 6 | { 7 | public interface ICache 8 | { 9 | void Set(object key, T value); 10 | T Get(object key); 11 | void Remove(object key); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FastSchool.Interface/ICommodityBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace FastSchool.Interface 9 | { 10 | public interface ICommodityBLL : IBaseBLL 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastSchool.Interface/IOrderBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model; 2 | using Microsoft.EntityFrameworkCore.Query; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace FastSchool.Interface 11 | { 12 | public interface IOrderBLL : IBaseBLL 13 | { 14 | Task CreateOrderAsync(Order order, Commodity commodity); 15 | 16 | //Task GetOrderIncludeEntiyAsync(Expression> whereLanbda, Expression>[] expressions); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FastSchool.Interface/IUserBLL.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace FastSchool.Interface 8 | { 9 | public interface IUserBLL : IBaseBLL 10 | { 11 | Task ContainsAsync(User user); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FastSchool.Model/BaseModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace FastSchool.Model 7 | { 8 | /// 9 | /// 所有实体的基类 10 | /// 11 | public class BaseModel 12 | { 13 | public BaseModel() 14 | { 15 | Id = Guid.NewGuid(); 16 | Code = Guid.NewGuid(); 17 | CreateDateTime = DateTime.Now; 18 | IsDelete = false; 19 | } 20 | 21 | [Key] 22 | public Guid Id { get; set; } 23 | 24 | //唯一标识 25 | public Guid Code { get; set; } 26 | 27 | /// 28 | /// 创建时间 29 | /// 30 | public DateTime CreateDateTime { get; set; } 31 | 32 | /// 33 | /// 最后一次修改时间 34 | /// 35 | public DateTime LastEitDateTime { get; set; } 36 | 37 | /// 38 | /// 是否删除 39 | /// 40 | public bool IsDelete { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /FastSchool.Model/Commodity.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model.Enum; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.Text; 7 | 8 | namespace FastSchool.Model 9 | { 10 | /// 11 | /// 发布的商品表 12 | /// 13 | public class Commodity : BaseModel 14 | { 15 | public Commodity() 16 | { 17 | State = false; 18 | Ponus = 0.00M; 19 | } 20 | private ILazyLoader LazyLoader { get; set; } 21 | public Commodity(ILazyLoader lazyLoader) 22 | { 23 | LazyLoader = lazyLoader; 24 | State = false; 25 | Ponus = 0.00M; 26 | } 27 | 28 | /// 29 | /// 收货人姓名 30 | /// 31 | [StringLength(15), Required] 32 | public string Consignee { get; set; } 33 | 34 | [Required] 35 | /// 36 | /// 快递类型 37 | /// 38 | public EnumExpressType EnumExpressType { get; set; } 39 | 40 | [Required] 41 | /// 42 | /// 取货码 43 | /// 44 | public int PickUpCode { get; set; } 45 | 46 | /// 47 | /// 取货地址 48 | /// 49 | [StringLength(50), Required] 50 | public string PickUpAddress { get; set; } 51 | 52 | /// 53 | /// 配送地址 54 | /// 55 | [StringLength(50), Required] 56 | public string Sendaddress { get; set; } 57 | 58 | /// 59 | /// 悬赏金额 60 | /// 61 | public decimal Ponus { get; set; } 62 | 63 | /// 64 | /// 备注 65 | /// 66 | [StringLength(80)] 67 | public string Remarks { get; set; } 68 | 69 | /// 70 | /// 订单是否已完成,True表示完成了 71 | /// 72 | public bool State { get; set; } 73 | 74 | 75 | private User _user; 76 | [Required] 77 | /// 78 | /// 是谁发出来的 79 | /// 80 | public virtual User User 81 | { 82 | //配置导航属性懒加载 83 | get => LazyLoader.Load(this, ref _user); 84 | set => _user = value; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /FastSchool.Model/Enum/EnumExpressType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchool.Model.Enum 6 | { 7 | public enum EnumExpressType 8 | { 9 | EMS, 10 | 邮政包裹, 11 | 申通快递, 12 | 顺丰快递, 13 | 圆通快递, 14 | 韵达快递, 15 | 中通快递, 16 | 天天快递, 17 | 汇通快递, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FastSchool.Model/Enum/EnumOrderState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchool.Model.Enum 6 | { 7 | public enum EnumOrderState 8 | { 9 | 待处理, 10 | 已处理, 11 | 已完成, 12 | 已取消, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastSchool.Model/FastSchool.Model.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netcoreapp2.1 12 | 7.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | System.Web 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /FastSchool.Model/FastSchoolDBContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using System; 3 | 4 | namespace FastSchool.Model 5 | { 6 | /// 7 | /// EF数据上下文 8 | /// 9 | public class FastSchoolDBContext : DbContext 10 | { 11 | public FastSchoolDBContext() 12 | { 13 | 14 | } 15 | 16 | public FastSchoolDBContext(DbContextOptions options) : base(options) 17 | { 18 | 19 | } 20 | 21 | public DbSet User { get; set; } 22 | public DbSet Commodity { get; set; } 23 | public DbSet Order { get; set; } 24 | 25 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 26 | { 27 | if (!optionsBuilder.IsConfigured) 28 | { 29 | optionsBuilder 30 | .UseLazyLoadingProxies() 31 | .UseMySql("server=localhost;port=3306;database=FastSchoolDB;uid=root;pwd=123456;"); 32 | } 33 | base.OnConfiguring(optionsBuilder); 34 | } 35 | 36 | protected override void OnModelCreating(ModelBuilder modelBuilder) 37 | { 38 | //配置全局查询过滤 39 | modelBuilder.Entity(u => 40 | u.HasQueryFilter(n => 41 | n.IsDelete.Equals(false))); 42 | 43 | modelBuilder.Entity(u => 44 | u.HasQueryFilter(n => 45 | n.IsDelete.Equals(false) && n.State.Equals(false))); 46 | 47 | modelBuilder.Entity(u => 48 | u.HasQueryFilter(n => 49 | n.IsDelete.Equals(false))); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /FastSchool.Model/Order.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model.Enum; 2 | using Microsoft.EntityFrameworkCore.Infrastructure; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.Text; 7 | 8 | namespace FastSchool.Model 9 | { 10 | /// 11 | /// 订单表 12 | /// 13 | public class Order : BaseModel 14 | { 15 | public Order() 16 | { 17 | OrderNumber = $"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}_{Guid.NewGuid().ToString()}"; 18 | } 19 | private ILazyLoader LazyLoader { get; set; } 20 | public Order(ILazyLoader lazyLoader) 21 | { 22 | LazyLoader = lazyLoader; 23 | OrderNumber = $"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}_{Guid.NewGuid().ToString()}"; 24 | } 25 | /// 26 | /// 订单号 27 | /// 28 | [StringLength(200), Required] 29 | public string OrderNumber { get; set; } 30 | 31 | /// 32 | /// 订单状态 33 | /// 34 | [Required] 35 | public EnumOrderState OrderState { get; set; } 36 | 37 | 38 | private User _sendUser; 39 | [Required] 40 | /// 41 | /// 谁发出来的单子 42 | /// 43 | public virtual User SendUser 44 | { 45 | //配置导航属性懒加载 46 | get => LazyLoader.Load(this, ref _sendUser); 47 | set => _sendUser = value; 48 | } 49 | 50 | private User _user; 51 | /// 52 | /// 关联的用户,谁接的单子 53 | /// 54 | [Required] 55 | public virtual User User 56 | { 57 | //配置懒加载 58 | get => LazyLoader.Load(this, ref _user); 59 | set => _user = value; 60 | } 61 | 62 | private Commodity _commodity; 63 | [Required] 64 | /// 65 | /// 关联的订单,每个订单只能一个商品 66 | /// 67 | public virtual Commodity Commodity 68 | { 69 | //配置懒加载 70 | get => LazyLoader.Load(this, ref _commodity); 71 | set => _commodity = value; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /FastSchool.Model/User.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Infrastructure; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Text; 6 | 7 | namespace FastSchool.Model 8 | { 9 | /// 10 | /// 用户表 11 | /// 12 | public class User : BaseModel 13 | { 14 | public User() 15 | { 16 | 17 | } 18 | private ILazyLoader LazyLoader { get; set; } 19 | public User(ILazyLoader lazyLoader) 20 | { 21 | LazyLoader = lazyLoader; 22 | } 23 | 24 | /// 25 | /// 用户名 26 | /// 27 | [StringLength(15)] 28 | public string UserName { get; set; } 29 | 30 | [StringLength(50)] 31 | public string UserPwd { get; set; } 32 | 33 | /// 34 | /// 用户姓名 35 | /// 36 | [StringLength(15)] 37 | public string FullName { get; set; } 38 | 39 | /// 40 | /// 学号 41 | /// 42 | public long SchoolNumber { get; set; } 43 | 44 | /// 45 | /// 手机号 46 | /// 47 | public long Phone { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IdentityModel.Tokens.Jwt; 4 | using System.Linq; 5 | using System.Security.Claims; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using FastSchool.BLL; 9 | using FastSchool.Interface; 10 | using FastSchool.Model; 11 | using FastSchool.WebApi.Models; 12 | using Microsoft.AspNetCore.Http; 13 | using Microsoft.AspNetCore.Mvc; 14 | using Microsoft.Extensions.Configuration; 15 | using Microsoft.IdentityModel.Tokens; 16 | 17 | namespace FastSchool.WebApi.Controllers 18 | { 19 | /// 20 | /// 登录控制器 21 | /// 22 | [Route("api/[controller]")] 23 | [ApiController] 24 | public class AccountController : ControllerBase 25 | { 26 | private IConfiguration Configuration { get; } 27 | private IAccountBLL AccountBLL { get; } 28 | public AccountController(IConfiguration configuration, IAccountBLL accountBLL) 29 | { 30 | Configuration = configuration; 31 | AccountBLL = accountBLL; 32 | } 33 | 34 | /// 35 | /// 登录的Action,发token令牌 36 | /// 37 | /// 38 | /// 39 | [HttpPost(nameof(Login))] 40 | public async Task Login([FromBody]ViewModelUser user) 41 | { 42 | //验证用户名和密码 43 | var entiy = await AccountBLL.GetEntiyAsync(u => u.UserName.Equals(user.UserName) && u.UserPwd.Equals(user.UserPwd)); 44 | if (entiy == null) 45 | { 46 | //return new JsonResult(new ResultModel { }) 47 | return "error"; 48 | } 49 | // push the user’s name into a claim, so we can identify the user later on. 50 | var claims = new[] 51 | { 52 | new Claim(ClaimTypes.Name, user.UserName) 53 | }; 54 | //sign the token using a secret key.This secret will be shared between your API and anything that needs to check that the token is legit. 55 | var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SecurityKey"])); 56 | var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); 57 | //.NET Core’s JwtSecurityToken class takes on the heavy lifting and actually creates the token. 58 | /** 59 | * Claims (Payload) 60 | Claims 部分包含了一些跟这个 token 有关的重要信息。 JWT 标准规定了一些字段,下面节选一些字段: 61 | 62 | iss: The issuer of the token,token 是给谁的 发送者 63 | audience: 接收的 64 | sub: The subject of the token,token 主题 65 | exp: Expiration Time。 token 过期时间,Unix 时间戳格式 66 | iat: Issued At。 token 创建时间, Unix 时间戳格式 67 | jti: JWT ID。针对当前 token 的唯一标识 68 | 除了规定的字段外,可以包含其他任何 JSON 兼容的字段。 69 | * */ 70 | var token = new JwtSecurityToken( 71 | issuer: "jwttest", 72 | audience: "jwttest", 73 | claims: claims, 74 | expires: DateTime.Now.AddDays(10), 75 | signingCredentials: creds); 76 | var result = new JwtSecurityTokenHandler().WriteToken(token); 77 | return result; 78 | } 79 | 80 | [HttpPost] 81 | /// 82 | /// 注册的action 83 | /// 84 | /// 85 | /// 86 | public async Task Post([FromBody] ViewModelUser user) 87 | { 88 | var result = false; 89 | var entiy = await AccountBLL.GetEntiyAsync(u => u.UserName.Equals(user.UserName)); 90 | if (entiy == null) 91 | { 92 | User userEntiy = new User 93 | { 94 | LastEitDateTime = DateTime.Now, 95 | FullName = user.FullName, 96 | Phone = user.Phone, 97 | SchoolNumber = user.SchoolNumber, 98 | UserName = user.UserName, 99 | UserPwd = user.UserPwd, 100 | }; 101 | result = await AccountBLL.AddAsync(userEntiy); 102 | } 103 | return result ? Content("ok") : Content("error"); 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /FastSchool.WebApi/Controllers/CommodityController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Threading.Tasks; 6 | using FastSchool.Interface; 7 | using FastSchool.Model; 8 | using FastSchool.WebApi.Models; 9 | using Microsoft.AspNetCore.Authorization; 10 | using Microsoft.AspNetCore.Http; 11 | using Microsoft.AspNetCore.Mvc; 12 | 13 | namespace FastSchool.WebApi.Controllers 14 | { 15 | /// 16 | /// 商品的控制器 17 | /// 18 | [Route("api/[controller]")] 19 | [ApiController] 20 | [Authorize] 21 | public class CommodityController : ControllerBase 22 | { 23 | public ICache Cache { get; } 24 | public ICommodityBLL CommodityBLL { get; } 25 | public CommodityController(ICache cache, ICommodityBLL commodityBLL) 26 | { 27 | Cache = cache; 28 | CommodityBLL = commodityBLL; 29 | } 30 | 31 | /// 32 | /// 获取所有最新信息 33 | /// 34 | /// 35 | [HttpGet] 36 | public IActionResult Get() 37 | { 38 | var entiy = CommodityBLL.GetEntiysInclude( 39 | new Expression>[] { u => u.User }).OrderByDescending(u => u.CreateDateTime); 40 | var list = new List(); 41 | foreach (var item in entiy) 42 | { 43 | list.Add(new ViewModelCommodity 44 | { 45 | Code = item.Code, 46 | Consignee = item.Consignee, 47 | EnumExpressType = item.EnumExpressType, 48 | PickUpAddress = item.PickUpAddress, 49 | PickUpCode = item.PickUpCode, 50 | Ponus = item.Ponus.ToString("f2"), 51 | Remarks = item.Remarks, 52 | Sendaddress = item.Sendaddress, 53 | UserName = item.User.UserName, 54 | }); 55 | } 56 | return new JsonResult(list); 57 | } 58 | 59 | /// 60 | /// 通过ID获取 61 | /// 62 | /// 63 | /// 64 | [HttpGet("{Id}")] 65 | public async Task Get(Guid Id) 66 | { 67 | var entiy = await CommodityBLL.FindAsync(Id); 68 | return new JsonResult(entiy); 69 | } 70 | 71 | /// 72 | /// 添加实体 73 | /// 74 | /// 75 | /// 76 | [HttpPost] 77 | public async Task Post([FromBody]ViewModelCommodity commodity) 78 | { 79 | var error = "error"; 80 | var userName = commodity.UserName?.Trim(); 81 | if (string.IsNullOrWhiteSpace(userName)) 82 | return error; 83 | var user = await CommodityBLL.GetEntiyAsync(u => u.UserName.Equals(userName)); 84 | if (user == null) 85 | return error; 86 | var model = new Commodity 87 | { 88 | Consignee = commodity.Consignee, 89 | EnumExpressType = commodity.EnumExpressType, 90 | PickUpAddress = commodity.PickUpAddress, 91 | PickUpCode = commodity.PickUpCode, 92 | Sendaddress = commodity.Sendaddress, 93 | Remarks = commodity.Remarks, 94 | Ponus = Convert.ToDecimal(commodity.Ponus), 95 | LastEitDateTime = DateTime.Now, 96 | User = user, 97 | }; 98 | var b = await CommodityBLL.AddAsync(model); 99 | return b ? "ok" : "error"; 100 | } 101 | 102 | /// 103 | /// 修改 104 | /// 105 | /// 106 | /// 107 | [HttpPut] 108 | public IActionResult Put([FromBody]ViewModelCommodity commodity) 109 | { 110 | return default; 111 | } 112 | 113 | /// 114 | /// 删除 115 | /// 116 | /// 117 | /// 118 | [HttpDelete] 119 | public async Task Delete(Guid id) 120 | { 121 | var b = await CommodityBLL.DeleteByIdAsync(id); 122 | return b ? "ok" : "error"; 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /FastSchool.WebApi/Controllers/OrderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using FastSchool.Interface; 6 | using FastSchool.Model; 7 | using FastSchool.WebApi.Models; 8 | using Microsoft.AspNetCore.Authorization; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.AspNetCore.Mvc; 11 | using Microsoft.EntityFrameworkCore; 12 | 13 | namespace FastSchool.WebApi.Controllers 14 | { 15 | [Authorize] 16 | [Route("api/[controller]")] 17 | [ApiController] 18 | public class OrderController : ControllerBase 19 | { 20 | public IOrderBLL OrderBLL { get; } 21 | public OrderController(IOrderBLL orderBLL) 22 | { 23 | OrderBLL = orderBLL; 24 | } 25 | 26 | /// 27 | /// 获取订单列表 28 | /// 29 | /// 30 | [HttpGet("{userName}")] 31 | public IActionResult Get(string userName) 32 | { 33 | var entiys = OrderBLL.GetEntiysInclude( 34 | whereExpressions: u => u.User.UserName.Equals(userName), 35 | expressions: new System.Linq.Expressions.Expression>[] 36 | { u => u.Commodity }) 37 | .OrderByDescending(u => u.CreateDateTime) 38 | .IgnoreQueryFilters(); //IgnoreQueryFilters()取消全局过滤 39 | 40 | //OrderBLL.GetALLEntiyByWhere(u => u.User.UserName.Equals(userName)).IgnoreQueryFilters(); //暂时有问题,导航属性Commodity查不出,暂时不知道原因 41 | 42 | var list = new List(); 43 | foreach (var item in entiys) 44 | { 45 | var resultModel = new ViewModelOrder 46 | { 47 | UserName = item.User.UserName, 48 | SendUserName = item.SendUser.UserName, 49 | OrderNumber = item.OrderNumber, 50 | OrderState = item.OrderState, 51 | Code = item.Code, 52 | }; 53 | list.Add(resultModel); 54 | } 55 | //获取订单的action 56 | return new JsonResult(list); 57 | } 58 | 59 | /// 60 | /// 获取单个订单 61 | /// 62 | /// 63 | [HttpGet(nameof(GetOrderByCode) + "/{code}")] 64 | public async Task GetOrderByCode(Guid code) 65 | { 66 | var entiys = await OrderBLL.GetEntiysInclude(whereExpressions: o => o.Code.Equals(code), expressions: new System.Linq.Expressions.Expression>[] { 67 | o => o.Commodity, 68 | o => o.User, 69 | o => o.SendUser }).IgnoreQueryFilters().FirstOrDefaultAsync(); 70 | 71 | var result = new ViewModelOrderInfo 72 | { 73 | Code = entiys.Code, 74 | OrderNumber = entiys.OrderNumber, 75 | OrderState = entiys.OrderState, 76 | SendUserName = entiys.SendUser.UserName, 77 | UserName = entiys.User.UserName, 78 | EnumExpressType = entiys.Commodity.EnumExpressType, 79 | PickUpAddress = entiys.Commodity.PickUpAddress, 80 | PickUpCode = entiys.Commodity.PickUpCode, 81 | Ponus = entiys.Commodity.Ponus.ToString("F2"), 82 | Remarks = entiys.Commodity.Remarks, 83 | Sendaddress = entiys.Commodity.Sendaddress 84 | }; 85 | 86 | //获取订单的action 87 | return new JsonResult(result); 88 | } 89 | 90 | /// 91 | /// 下单 92 | /// 93 | /// 94 | [HttpPost("{code}/{userName}")] 95 | public async Task Post(Guid code, string userName) 96 | { 97 | var entiy = await OrderBLL.GetEntiyAsync(u => u.Code.Equals(code)); 98 | var thisUser = await OrderBLL.GetEntiyAsync(u => u.UserName.Equals(userName)); 99 | if (entiy == null && thisUser == null) 100 | return default; 101 | var order = new Order 102 | { 103 | Commodity = entiy, 104 | OrderState = Model.Enum.EnumOrderState.待处理, 105 | SendUser = entiy.User, 106 | User = thisUser, 107 | }; 108 | var b = await OrderBLL.CreateOrderAsync(order, entiy); 109 | return b ? "ok" : default; 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /FastSchool.WebApi/Controllers/UserController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using FastSchool.Interface; 6 | using FastSchool.Model; 7 | using FastSchool.WebApi.Models; 8 | using Microsoft.AspNetCore.Authorization; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.AspNetCore.Mvc; 11 | 12 | namespace FastSchool.WebApi.Controllers 13 | { 14 | [Authorize] 15 | [Route("api/[controller]")] 16 | [ApiController] 17 | public class UserController : ControllerBase 18 | { 19 | public IUserBLL UserBLL { get; } 20 | public UserController(IUserBLL userBLL) 21 | { 22 | UserBLL = userBLL; 23 | } 24 | 25 | [HttpGet("{userName}")] 26 | public async Task Get(string userName) 27 | { 28 | var entiy = await UserBLL.GetEntiyAsync(u => u.UserName.Equals(userName)); 29 | var user = new ViewModelUser 30 | { 31 | Phone = entiy.Phone, 32 | UserName = entiy.UserName, 33 | FullName = entiy.FullName, 34 | SchoolNumber = entiy.SchoolNumber, 35 | UserPwd = entiy.UserPwd, 36 | }; 37 | //用户名 / 姓名 / 学号 / 手机号 38 | return new JsonResult(user); 39 | } 40 | 41 | public IActionResult Post() 42 | { 43 | return default; 44 | } 45 | 46 | /// 47 | /// 修改个人资料 48 | /// 49 | /// 50 | /// 51 | [HttpPut] 52 | public async Task Put([FromBody]ViewModelUser viewModelUser) 53 | { 54 | //修改个人资料 55 | //接收:姓名 / 学号 / 手机号 56 | var user = await UserBLL.GetEntiyAsync(u => u.UserName.Equals(viewModelUser.UserName)); 57 | if (user == null) 58 | { 59 | return "error"; 60 | } 61 | if (!string.IsNullOrWhiteSpace(viewModelUser.FullName)) 62 | user.FullName = viewModelUser.FullName; 63 | if (viewModelUser.SchoolNumber != default) 64 | user.SchoolNumber = viewModelUser.SchoolNumber; 65 | if (viewModelUser.Phone != default) 66 | user.Phone = viewModelUser.Phone; 67 | var b = await UserBLL.UpdateAsync(user); 68 | return b ? "ok" : "error"; 69 | } 70 | 71 | /// 72 | /// 修改密码 73 | /// 74 | /// 75 | [HttpPut(nameof(EitPwd) + "/{oldPwd}")] 76 | public async Task EitPwd(string oldPwd, [FromBody]ViewModelUser viewModelUser) 77 | { 78 | //修改个人密码 79 | //接收:新密码 80 | var user = await UserBLL.GetEntiyAsync(u => u.UserName.Equals(viewModelUser.UserName)); 81 | if (user == null) 82 | { 83 | return NotFound("非法请求"); 84 | return new JsonResult(new ResultModel(-1, "密码错误")); 85 | } 86 | if (!user.UserPwd.Equals(oldPwd)) 87 | { 88 | return Ok("原密码错误"); 89 | } 90 | user.UserPwd = viewModelUser.UserPwd; 91 | var b = await UserBLL.UpdateAsync(user); 92 | return b ? Ok("ok") : Ok("error"); 93 | } 94 | 95 | 96 | public IActionResult Delete() 97 | { 98 | return default; 99 | } 100 | 101 | } 102 | } -------------------------------------------------------------------------------- /FastSchool.WebApi/FastSchool.WebApi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netcoreapp2.1 12 | 7.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Filters/ExceptionFilter.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.WebApi.Controllers; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.AspNetCore.Mvc.Filters; 5 | using Microsoft.Extensions.Logging; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace FastSchool.WebApi.Filters 12 | { 13 | public class ExceptionFilter : IExceptionFilter 14 | { 15 | private ILogger Logger { get; set; } 16 | public ExceptionFilter(ILoggerFactory _logger) 17 | { 18 | Logger = _logger.CreateLogger(); 19 | } 20 | public void OnException(ExceptionContext context) 21 | { 22 | if (context.ExceptionHandled == false) 23 | { 24 | var ex = context.Exception; 25 | Logger.LogError(new EventId(), ex, ex.Message); //写入日志 26 | context.Result = new ContentResult 27 | { 28 | Content = "error", 29 | StatusCode = StatusCodes.Status200OK, 30 | ContentType = "text/html" 31 | }; 32 | } 33 | context.ExceptionHandled = true; //异常已处理了 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FastSchool.WebApi/Filters/ModelStateFilter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.Filters; 3 | using Microsoft.AspNetCore.Mvc.ModelBinding; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastSchool.WebApi.Filters 10 | { 11 | public class ModelStateFilter : IActionFilter 12 | { 13 | public void OnActionExecuted(ActionExecutedContext context) 14 | { 15 | 16 | } 17 | 18 | public void OnActionExecuting(ActionExecutingContext context) 19 | { 20 | ModelStateDictionary modelState = context.ModelState; 21 | if (!modelState.IsValid) 22 | { 23 | context.Result = new BadRequestObjectResult(modelState); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Models/ResultModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace FastSchool.WebApi.Models 7 | { 8 | public class ResultModel 9 | { 10 | public ResultModel(int code, string msg, T result = default) 11 | { 12 | Code = code; 13 | Msg = msg; 14 | Result = result; 15 | } 16 | public int Code { get; set; } 17 | public string Msg { get; set; } 18 | public T Result { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Models/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace FastSchool.WebApi.Models 7 | { 8 | public class ViewModelBase 9 | { 10 | /// 11 | /// 唯一编号 12 | /// 13 | public Guid Code { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Models/ViewModelCommodity.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model.Enum; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace FastSchool.WebApi.Models 9 | { 10 | public class ViewModelCommodity : ViewModelBase 11 | { 12 | /// 13 | /// 收货人姓名 14 | /// 15 | [StringLength(15)] 16 | public string Consignee { get; set; } 17 | 18 | public EnumExpressType EnumExpressType { get; set; } 19 | 20 | [Required] 21 | /// 22 | /// 取货码 23 | /// 24 | public int PickUpCode { get; set; } 25 | 26 | /// 27 | /// 取货地址 28 | /// 29 | [StringLength(50), Required] 30 | public string PickUpAddress { get; set; } 31 | 32 | /// 33 | /// 配送地址 34 | /// 35 | [StringLength(50)] 36 | public string Sendaddress { get; set; } 37 | 38 | /// 39 | /// 悬赏金额 40 | /// 41 | public string Ponus { get; set; } 42 | 43 | /// 44 | /// 备注 45 | /// 46 | [StringLength(80)] 47 | public string Remarks { get; set; } 48 | 49 | [Required] 50 | /// 51 | /// 关联的用户名 52 | /// 53 | public string UserName { get; set; } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Models/ViewModelOrder.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model; 2 | using FastSchool.Model.Enum; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace FastSchool.WebApi.Models 9 | { 10 | public class ViewModelOrder : ViewModelBase 11 | { 12 | /// 13 | /// 订单号 14 | /// 15 | public string OrderNumber { get; set; } 16 | 17 | /// 18 | /// 订单状态 19 | /// 20 | public EnumOrderState OrderState { get; set; } 21 | 22 | /// 23 | /// 谁发出来的单子 24 | /// 25 | public string SendUserName { get; set; } 26 | 27 | /// 28 | /// 关联的用户,谁接的单子 29 | /// 30 | public string UserName { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Models/ViewModelOrderInfo.cs: -------------------------------------------------------------------------------- 1 | using FastSchool.Model.Enum; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace FastSchool.WebApi.Models 8 | { 9 | public class ViewModelOrderInfo : ViewModelOrder 10 | { 11 | public EnumExpressType EnumExpressType { get; set; } 12 | 13 | /// 14 | /// 取货码 15 | /// 16 | public int PickUpCode { get; set; } 17 | 18 | /// 19 | /// 取货地址 20 | /// 21 | public string PickUpAddress { get; set; } 22 | 23 | /// 24 | /// 配送地址 25 | /// 26 | public string Sendaddress { get; set; } 27 | 28 | /// 29 | /// 悬赏金额 30 | /// 31 | public string Ponus { get; set; } 32 | 33 | /// 34 | /// 备注 35 | /// 36 | public string Remarks { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Models/ViewModelUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace FastSchool.WebApi.Models 8 | { 9 | public class ViewModelUser : ViewModelBase 10 | { 11 | [StringLength(15)] 12 | public string UserName { get; set; } 13 | 14 | [StringLength(50)] 15 | public string UserPwd { get; set; } 16 | 17 | [StringLength(15)] 18 | public string FullName { get; set; } 19 | 20 | /// 21 | /// 学号 22 | /// 23 | public long SchoolNumber { get; set; } 24 | 25 | 26 | /// 27 | /// 手机号 28 | /// 29 | public long Phone { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | using NLog.Web; 11 | 12 | namespace FastSchool.WebApi 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateWebHostBuilder(args) 19 | .UseUrls("http://*:7677") 20 | .Build() 21 | .Run(); 22 | } 23 | 24 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 25 | WebHost.CreateDefaultBuilder(args) 26 | .UseStartup() 27 | .ConfigureLogging(logging => 28 | { 29 | logging.ClearProviders(); //移除已经注册的其他日志处理程序 30 | logging.SetMinimumLevel(LogLevel.Trace); //设置最小的日志级别 31 | }) 32 | .UseNLog(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Properties/PublishProfiles/FolderProfile.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | FileSystem 9 | FileSystem 10 | Release 11 | Any CPU 12 | 13 | True 14 | False 15 | netcoreapp2.1 16 | linux-x64 17 | e4c1ea39-3a99-496b-a704-bf7e3b1f9b1b 18 | true 19 | <_IsPortable>false 20 | bin\Release\netcoreapp2.1\publish\ 21 | True 22 | 23 | -------------------------------------------------------------------------------- /FastSchool.WebApi/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:6789", 7 | "sslPort": 0 8 | } 9 | }, 10 | "$schema": "http://json.schemastore.org/launchsettings.json", 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/Test", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "FastSchool.WebApi": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/Test", 24 | //10.88.240.56 25 | "applicationUrl": "http://localhost:5000", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /FastSchool.WebApi/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using FastSchool.BLL; 8 | using FastSchool.Common; 9 | using FastSchool.Interface; 10 | using FastSchool.Model; 11 | using FastSchool.WebApi.Filters; 12 | using Microsoft.AspNetCore.Authentication.JwtBearer; 13 | using Microsoft.AspNetCore.Builder; 14 | using Microsoft.AspNetCore.Hosting; 15 | using Microsoft.AspNetCore.HttpOverrides; 16 | using Microsoft.AspNetCore.Mvc; 17 | using Microsoft.EntityFrameworkCore; 18 | using Microsoft.Extensions.Configuration; 19 | using Microsoft.Extensions.DependencyInjection; 20 | using Microsoft.Extensions.Logging; 21 | using Microsoft.Extensions.Options; 22 | using Microsoft.IdentityModel.Tokens; 23 | using NLog.Extensions.Logging; 24 | using NLog.Web; 25 | 26 | namespace FastSchool.WebApi 27 | { 28 | public class Startup 29 | { 30 | public Startup(IConfiguration configuration) 31 | { 32 | Configuration = configuration; 33 | } 34 | 35 | public IConfiguration Configuration { get; } 36 | 37 | // This method gets called by the runtime. Use this method to add services to the container. 38 | /// 39 | /// 服务注入 40 | /// 41 | /// 42 | public void ConfigureServices(IServiceCollection services) 43 | { 44 | services.Configure(options => 45 | { 46 | options.KnownProxies.Add(IPAddress.Parse("10.0.0.100")); 47 | }); 48 | 49 | //Microsoft.EntityFrameworkCore.Proxies UseLazyLoadingProxies() 启用懒加载方法 50 | //读取配置文件中数据库连接字符串 51 | services.AddDbContext(option => option. 52 | UseLazyLoadingProxies(). 53 | UseMySql(Configuration.GetConnectionString("MySqlConnection"))); 54 | 55 | //添加jwt验证: 56 | services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 57 | .AddJwtBearer(options => 58 | { 59 | options.TokenValidationParameters = new TokenValidationParameters 60 | { 61 | ValidateIssuer = true,//是否验证Issuer 62 | ValidateAudience = true,//是否验证Audience 63 | ValidateLifetime = true,//是否验证失效时间 64 | ValidateIssuerSigningKey = true,//是否验证SecurityKey 65 | ValidAudience = "jwttest",//Audience 66 | ValidIssuer = "jwttest",//Issuer,这两项和前面签发jwt的设置一致 67 | IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SecurityKey"]))//拿到SecurityKey 68 | }; 69 | }); 70 | 71 | services.AddMemoryCache(); //使用内置缓存 72 | 73 | services.AddMvc( 74 | option => 75 | { 76 | option.Filters.Add(); //错误异常处理的Filter 77 | option.Filters.Add(); //实体验证的Filter 78 | } 79 | ).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 80 | 81 | #region 注册接口开始 82 | services.AddScoped(); //注入DbContext 83 | services.AddSingleton(); //注入Cach 84 | services.AddScoped(); 85 | services.AddScoped(); 86 | services.AddScoped(); 87 | services.AddScoped(); 88 | #endregion 注册接口结束 89 | } 90 | 91 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 92 | /// 93 | /// 中间件配置 94 | /// 95 | /// 96 | /// 97 | /// 98 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 99 | { 100 | if (env.IsDevelopment()) //判断是否为生产/调试模式,不用理他 101 | { 102 | app.UseDeveloperExceptionPage(); 103 | } 104 | 105 | //也不知道有什么用,好像是在响应报文里添加一些信息 106 | app.UseForwardedHeaders(new ForwardedHeadersOptions 107 | { 108 | ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto 109 | }); 110 | 111 | //配置身份验证 112 | app.UseAuthentication(); 113 | app.UseMvc(); 114 | 115 | //添加NLog 116 | loggerFactory.AddNLog(); 117 | env.ConfigureNLog("nlog.config"); //读取nlog配置文件 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /FastSchool.WebApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /FastSchool.WebApi/appsettings.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchool.WebApi/appsettings.json -------------------------------------------------------------------------------- /FastSchool.WebApi/nlog.config: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /FastSchoolApp.Common/AccountHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Common 6 | { 7 | public class AccountHelper 8 | { 9 | public static string LoginName { get; set; } 10 | 11 | public static string LoginKey { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FastSchoolApp.Common/DeepCopyHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.Serialization.Formatters.Binary; 4 | using System.Xml.Serialization; 5 | 6 | namespace FastSchoolApp.Common 7 | { 8 | /// 9 | /// 对象的深度拷贝(序列化的方式) 10 | /// 11 | public class DeepCopyHelper 12 | { 13 | /// 14 | /// xml序列化的方式实现深拷贝 15 | /// 16 | /// 17 | /// 18 | /// 19 | public static T XmlDeepCopy(T t) 20 | { 21 | //创建Xml序列化对象 22 | XmlSerializer xml = new XmlSerializer(typeof(T)); 23 | using (MemoryStream ms = new MemoryStream())//创建内存流 24 | { 25 | //将对象序列化到内存中 26 | xml.Serialize(ms, t); 27 | ms.Position = default;//将内存流的位置设为0 28 | return (T)xml.Deserialize(ms);//继续反序列化 29 | } 30 | } 31 | 32 | /// 33 | /// 二进制序列化的方式进行深拷贝 34 | /// 确保需要拷贝的类里的所有成员已经标记为 [Serializable] 如果没有加该特性特报错 35 | /// 36 | /// 37 | /// 38 | /// 39 | public static T BinaryDeepCopy(T t) 40 | { 41 | //创建二进制序列化对象 42 | BinaryFormatter bf = new BinaryFormatter(); 43 | using (MemoryStream ms = new MemoryStream())//创建内存流 44 | { 45 | //将对象序列化到内存中 46 | bf.Serialize(ms, t); 47 | ms.Position = default;//将内存流的位置设为0 48 | return (T)bf.Deserialize(ms);//继续反序列化 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /FastSchoolApp.Common/FastSchoolApp.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netstandard2.0 12 | 7.1 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /FastSchoolApp.Common/JsonHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Common 6 | { 7 | public class JsonHelper 8 | { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/AccountUserData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | /// 8 | /// 登录的用户信息,持久化 9 | /// 10 | public class AccountUserData 11 | { 12 | public string UserName { get; set; } 13 | public string LoginKey { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/BaseModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public class BaseModel 8 | { 9 | public Guid Code { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/Commodity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public class Commodity : BaseModel 8 | { 9 | public Commodity() 10 | { 11 | State = false; 12 | Ponus = "0.00"; 13 | Code = Guid.NewGuid(); 14 | } 15 | 16 | /// 17 | /// 收货人姓名 18 | /// 19 | public string Consignee { get; set; } 20 | 21 | /// 22 | /// 快递类型 23 | /// 24 | public ExpressTypeEnum EnumExpressType { get; set; } 25 | 26 | /// 27 | /// 取货码 28 | /// 29 | public int PickUpCode { get; set; } 30 | 31 | /// 32 | /// 取货地址 33 | /// 34 | public string PickUpAddress { get; set; } 35 | 36 | /// 37 | /// 配送地址 38 | /// 39 | public string Sendaddress { get; set; } 40 | 41 | /// 42 | /// 悬赏金额 43 | /// 44 | public string Ponus { get; set; } 45 | 46 | /// 47 | /// 备注 48 | /// 49 | public string Remarks { get; set; } 50 | 51 | /// 52 | /// 订单是否已完成,True表示完成了 53 | /// 54 | public bool State { get; set; } 55 | 56 | /// 57 | /// 是谁发出来的 58 | /// 59 | public string UserName { get; set; } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/EnumOrderState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public enum EnumOrderState 8 | { 9 | 待处理, 10 | 已处理, 11 | 已完成, 12 | 已取消, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/ExpressTypeEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public enum ExpressTypeEnum 8 | { 9 | EMS, 10 | 邮政包裹, 11 | 申通快递, 12 | 顺丰快递, 13 | 圆通快递, 14 | 韵达快递, 15 | 中通快递, 16 | 天天快递, 17 | 汇通快递, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/FastSchoolApp.Model.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netstandard2.0 12 | 7.1 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/ResultModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public class ResultModel 8 | { 9 | public int Code { get; set; } 10 | public string Msg { get; set; } 11 | public object Result { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FastSchoolApp.Model 4 | { 5 | public class User : BaseModel 6 | { 7 | public string UserName { get; set; } 8 | 9 | public string UserPwd { get; set; } 10 | 11 | public string FullName { get; set; } 12 | 13 | /// 14 | /// 学号 15 | /// 16 | public long SchoolNumber { get; set; } 17 | 18 | 19 | /// 20 | /// 手机号 21 | /// 22 | public long Phone { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/UserOrder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public class UserOrder : BaseModel 8 | { 9 | /// 10 | /// 订单号 11 | /// 12 | public string OrderNumber { get; set; } 13 | 14 | /// 15 | /// 订单状态 16 | /// 17 | public EnumOrderState OrderState { get; set; } 18 | 19 | /// 20 | /// 谁发出来的单子 21 | /// 22 | public string SendUserName { get; set; } 23 | 24 | /// 25 | /// 关联的用户,谁接的单子 26 | /// 27 | public string UserName { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /FastSchoolApp.Model/UserOrderInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Model 6 | { 7 | public class UserOrderInfo : UserOrder 8 | { 9 | //Code = entiys.Code, 10 | // OrderNumber = entiys.OrderNumber, 11 | // OrderState = entiys.OrderState, 12 | // SendUserName = entiys.SendUser.UserName, 13 | // UserName = entiys.User.UserName, 14 | 15 | // EnumExpressType = entiys.Commodity.EnumExpressType, 16 | // PickUpAddress = entiys.Commodity.PickUpAddress, 17 | // PickUpCode = entiys.Commodity.PickUpCode, 18 | // Ponus = entiys.Commodity.Ponus.ToString("F2"), 19 | // Remarks = entiys.Commodity.Remarks, 20 | // Sendaddress = entiys.Commodity.Sendaddress 21 | 22 | /// 23 | /// 快递类型 24 | /// 25 | public ExpressTypeEnum EnumExpressType { get; set; } 26 | 27 | /// 28 | /// 快递领取地址 29 | /// 30 | public string PickUpAddress { get; set; } 31 | 32 | /// 33 | /// 配送地址 34 | /// 35 | public string Sendaddress { get; set; } 36 | 37 | /// 38 | /// 取货码 39 | /// 40 | public int PickUpCode { get; set; } 41 | 42 | /// 43 | /// 赏金 44 | /// 45 | public string Ponus { get; set; } 46 | 47 | /// 48 | /// 备注 49 | /// 50 | public string Remarks { get; set; } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /FastSchoolApp.Services/AccountService.cs: -------------------------------------------------------------------------------- 1 | using FastSchoolApp.Common; 2 | using FastSchoolApp.Model; 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.Threading.Tasks; 6 | 7 | namespace FastSchoolApp.Services 8 | { 9 | public class AccountService : BaseServices 10 | { 11 | /// 12 | /// 登录的方法 13 | /// 14 | /// error代表登录失败 15 | public async Task LoginAsync(User user) 16 | { 17 | var url = $"{BaseUrl}/Account/Login"; 18 | var jsonData = JsonConvert.SerializeObject(user); 19 | var result = await HttpHelper.HttpPost(url, jsonData); 20 | return result; 21 | } 22 | 23 | /// 24 | /// 注册的方法 25 | /// 26 | /// 27 | public async Task RegisterAsync(User user) 28 | { 29 | var url = $"{BaseUrl}/Account"; 30 | var jsonData = JsonConvert.SerializeObject(user); 31 | var result = await HttpHelper.HttpPost(url, jsonData); 32 | return result.Equals("ok"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /FastSchoolApp.Services/BaseServices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.Services 6 | { 7 | public class BaseServices 8 | { 9 | //10.88.240.56 10 | //192.168.123.6 11 | //10.88.240.61 12 | /// 13 | /// 请求的url 14 | /// 15 | protected static string BaseUrl => "http://10.88.240.56:5051/api"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /FastSchoolApp.Services/FastSchoolApp.Services.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netstandard2.0 12 | 7.1 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /FastSchoolApp.Services/HomeService.cs: -------------------------------------------------------------------------------- 1 | using FastSchoolApp.Common; 2 | using FastSchoolApp.Model; 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastSchoolApp.Services 10 | { 11 | public class HomeService : BaseServices 12 | { 13 | /// 14 | /// 获取最新发布的信息 15 | /// 16 | /// List集合 17 | public async Task> GetNewInfoAsync() 18 | { 19 | var url = $"{BaseUrl}/Commodity"; 20 | var resultEntiys = await HttpHelper.HttpWebRequestGetAsync(url, authorization: AccountHelper.LoginKey); 21 | var resut = JsonConvert.DeserializeObject>(resultEntiys); 22 | return resut; 23 | } 24 | 25 | /// 26 | /// 发布新的商品 27 | /// 28 | /// true代表成功 29 | public async Task SendNewInfoAsync(Commodity commodity) 30 | { 31 | var url = $"{BaseUrl}/Commodity"; 32 | var postData = JsonConvert.SerializeObject(commodity); 33 | var result = await HttpHelper.HttpPost(url, postData, AccountHelper.LoginKey); 34 | return result.Equals("ok"); 35 | } 36 | 37 | /// 38 | /// 接单方法 39 | /// 40 | /// 商品code 41 | /// 42 | public async Task AffirmOrderAsync(Guid code) 43 | { 44 | var url = $"{BaseUrl}/Order/{code}/{AccountHelper.LoginName}"; 45 | var result = await HttpHelper.HttpPost(url, string.Empty, authorization: AccountHelper.LoginKey); 46 | return result.Equals("ok"); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FastSchoolApp.Services/UserService.cs: -------------------------------------------------------------------------------- 1 | using FastSchoolApp.Common; 2 | using FastSchoolApp.Model; 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace FastSchoolApp.Services 10 | { 11 | public class UserService : BaseServices 12 | { 13 | private static string UserUrl => $"{BaseUrl}/User"; 14 | 15 | /// 16 | /// 获取用户数据 17 | /// 18 | /// 19 | public async Task GetUserDataAsync() 20 | { 21 | var entiy = await HttpHelper.HttpWebRequestGetAsync($"{UserUrl}/{AccountHelper.LoginName}", AccountHelper.LoginKey); 22 | var user = JsonConvert.DeserializeObject(entiy); 23 | return user; 24 | } 25 | 26 | /// 27 | /// 获取用户订单列表 28 | /// 29 | /// 30 | public async Task> GetUserOrderAsync() 31 | { 32 | var url = $"{BaseUrl}/Order/{AccountHelper.LoginName}"; 33 | var entiys = await HttpHelper.HttpWebRequestGetAsync(url, AccountHelper.LoginKey); 34 | var result = JsonConvert.DeserializeObject>(entiys); 35 | return result; 36 | } 37 | 38 | /// 39 | /// 获取单个订单 40 | /// 41 | /// 订单code 42 | /// 43 | public async Task GetUserOrderInfoAsync(Guid code) 44 | { 45 | var url = $"{BaseUrl}/Order/GetOrderByCode/{code}"; 46 | var entiy = await HttpHelper.HttpWebRequestGetAsync(url, AccountHelper.LoginKey); 47 | var result = JsonConvert.DeserializeObject(entiy); 48 | return result; 49 | } 50 | 51 | /// 52 | /// 修改密码 53 | /// 54 | /// 55 | /// 修改成功返回true 56 | public async Task EitUserPwdAsync(string oldPwd, string newPwd) 57 | { 58 | var user = JsonConvert.SerializeObject(new 59 | { 60 | UserName = AccountHelper.LoginName, 61 | UserPwd = newPwd, 62 | }); 63 | var url = $"{UserUrl}/EitPwd/{oldPwd}"; 64 | var result = await HttpHelper.HttpPut(url, JsonConvert.SerializeObject(new User 65 | { 66 | UserName = AccountHelper.LoginName, 67 | UserPwd = newPwd 68 | }), AccountHelper.LoginKey); 69 | return result.Equals("ok"); 70 | } 71 | 72 | /// 73 | /// 修改个人资料 74 | /// 75 | /// 76 | /// 77 | public async Task EitUserDataAsync(User user) 78 | { 79 | var url = UserUrl; 80 | var putData = JsonConvert.SerializeObject(user); 81 | var result = await HttpHelper.HttpPut(url, putData, AccountHelper.LoginKey); 82 | return result.Equals("ok"); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/AffirmOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | 4 | namespace FastSchoolApp.ViewModel 5 | { 6 | public class AffirmOrderModel : BindableObject 7 | { 8 | public AffirmOrderModel() 9 | { 10 | ItemCommand = new Command(model => 11 | { 12 | //var entiy =model as Commodity 13 | 14 | }); 15 | //从这里获取数据源 16 | 17 | } 18 | public ICommand ItemCommand { get; private set; } 19 | 20 | public BindableProperty OrderNumberProperty = BindableProperty.Create("OrderNumber", 21 | typeof(string), 22 | typeof(AffirmOrderModel)); 23 | 24 | /// 25 | /// 订单号 26 | /// 27 | public string OrderNumber 28 | { 29 | get { return (string)GetValue(OrderNumberProperty); } 30 | set { SetValue(OrderNumberProperty, value); } 31 | } 32 | 33 | 34 | 35 | public BindableProperty GetGoodsCodeProperty = BindableProperty.Create("GetGoodsCode", 36 | typeof(int), 37 | typeof(AffirmOrderModel), 38 | new Random().Next(10000, 99999)); 39 | 40 | /// 41 | /// 取货码 42 | /// 43 | public int GetGoodsCode 44 | { 45 | get { return (int)GetValue(GetGoodsCodeProperty); } 46 | set { SetValue(GetGoodsCodeProperty, value); } 47 | } 48 | 49 | 50 | public BindableProperty GetGoodsAddressProperty = BindableProperty.Create( 51 | "GetGoodsAddress", 52 | typeof(string), 53 | typeof(AffirmOrderModel)); 54 | /// 55 | /// 取货地点 56 | /// 57 | public string GetGoodsAddress 58 | { 59 | get { return GetValue(GetGoodsAddressProperty).ToString(); } 60 | set { SetValue(GetGoodsAddressProperty, value); } 61 | } 62 | 63 | public BindableProperty SendAddressProperty = BindableProperty.Create( 64 | "SendAddress", 65 | typeof(string), 66 | typeof(AffirmOrderModel)); 67 | /// 68 | /// 收货地址 69 | /// 70 | public string SendAddress 71 | { 72 | get { return GetValue(SendAddressProperty).ToString(); } 73 | set { SetValue(SendAddressProperty, value); } 74 | } 75 | 76 | public BindableProperty OrderStatusProperty = BindableProperty.Create( 77 | "OrderStatus", 78 | typeof(OrderStatusEnum), 79 | typeof(AffirmOrderModel), OrderStatusEnum.下单成功); 80 | /// 81 | /// 订单状态 82 | /// 83 | public OrderStatusEnum OrderStatus 84 | { 85 | get { return (OrderStatusEnum)GetValue(SendAddressProperty); } 86 | set { SetValue(SendAddressProperty, value); } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/BaseModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.ViewModel 6 | { 7 | public class BaseModel 8 | { 9 | public virtual Guid Id { get; set; } 10 | public virtual Guid Code { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.ViewModel 6 | { 7 | class Class1 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/ExpressTypeEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.ViewModel 6 | { 7 | public enum ExpressTypeEnum 8 | { 9 | EMS, 10 | 邮政包裹, 11 | 申通快递, 12 | 顺丰快递, 13 | 圆通快递, 14 | 韵达快递, 15 | 中通快递, 16 | 天天快递, 17 | 汇通快递, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/FastSchoolApp.ViewModel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netstandard2.0 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/NewInfoDetailedModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Xamarin.Forms; 5 | 6 | namespace FastSchoolApp.ViewModel 7 | { 8 | public class NewInfoDetailedModel : BindableObject 9 | { 10 | 11 | public BindableProperty BonusProperty = BindableProperty.Create("Bonus", 12 | typeof(decimal), 13 | typeof(NewInfoDetailedModel)); 14 | /// 15 | /// 悬赏金额 16 | /// 17 | public decimal Bonus 18 | { 19 | get { return (decimal)GetValue(BonusProperty); } 20 | set { SetValue(BonusProperty, value); } 21 | } 22 | 23 | public BindableProperty ExpressTypeProperty = BindableProperty.Create( 24 | "ExpressType", 25 | typeof(ExpressTypeEnum), 26 | typeof(NewInfoDetailedModel)); 27 | /// 28 | /// 快递类型 29 | /// 30 | public ExpressTypeEnum ExpressType 31 | { 32 | get { return (ExpressTypeEnum)GetValue(BonusProperty); } 33 | set { SetValue(BonusProperty, value); } 34 | } 35 | 36 | 37 | public BindableProperty RemarksTypeProperty = BindableProperty.Create( 38 | "Remarks", 39 | typeof(string), 40 | typeof(NewInfoDetailedModel)); 41 | /// 42 | /// 备注 43 | /// 44 | public string Remarks 45 | { 46 | get { return GetValue(RemarksTypeProperty).ToString(); } 47 | set { SetValue(RemarksTypeProperty, value); } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/NewInfoModel.cs: -------------------------------------------------------------------------------- 1 | using FastSchoolApp.Home; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Windows.Input; 6 | using Xamarin.Forms; 7 | 8 | namespace FastSchoolApp.ViewModel 9 | { 10 | public class NewInfoModel : BindableObject 11 | { 12 | public NewInfoModel() 13 | { 14 | LoadData(); 15 | 16 | ItemTappedCommand = new Command(async obj => 17 | { 18 | //var entiy = obj as Commodity; 19 | 20 | 21 | var nav = App.Current.MainPage.Navigation; 22 | 23 | //传入拿到的实体 24 | await nav.PushAsync(new NavigationPage(new NewInfoDetailed())); 25 | }); 26 | } 27 | public ICommand ItemTappedCommand { get; private set; } 28 | 29 | void LoadData() 30 | { 31 | //获取数据 32 | 33 | } 34 | 35 | public BindableProperty TitleProperty = BindableProperty.Create( 36 | "Title", 37 | typeof(string), 38 | typeof(NewInfoModel)); 39 | public string Title 40 | { 41 | get 42 | { 43 | return GetValue(TitleProperty).ToString(); 44 | } 45 | set { SetValue(TitleProperty, value); } 46 | } 47 | 48 | public BindableProperty DetailedProperty = BindableProperty.Create("Detailed", typeof(string), typeof(NewInfoModel)); 49 | public string Detailed 50 | { 51 | get 52 | { 53 | return GetValue(DetailedProperty).ToString(); 54 | } 55 | set { SetValue(DetailedProperty, value); } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/OrderStatusEnum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastSchoolApp.ViewModel 6 | { 7 | public enum OrderStatusEnum 8 | { 9 | 下单成功, 10 | 下单失败 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/RegisterModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Xamarin.Forms; 5 | 6 | namespace FastSchoolApp.ViewModel 7 | { 8 | public class RegisterModel: BindableObject 9 | { 10 | public BindableProperty UserNameProperty = BindableProperty.Create("UserName", typeof(string), typeof(RegisterModel)); 11 | public string UserName { get; set; } 12 | public string UserPwd { get; set; } 13 | public string UserNewPwd { get; set; } 14 | public string UserFullName { get; set; } 15 | public long UserNumber { get; set; } 16 | public long UserPhone { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/SecurityModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Xamarin.Forms; 5 | 6 | namespace FastSchoolApp.ViewModel 7 | { 8 | public class SecurityModel : BindableObject 9 | { 10 | public BindableProperty OldPwdProperty = BindableProperty.Create("OldPwd", typeof(string), typeof(SecurityModel)); 11 | public string OldPwd { get; set; } 12 | public string Pwd { get; set; } 13 | public string PwdNew { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/SendNewInfoModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Xamarin.Forms; 5 | 6 | namespace FastSchoolApp.ViewModel 7 | { 8 | public class SendNewInfoModel : BindableObject 9 | { 10 | public BindableProperty ConsigneeNameProperty = BindableProperty.Create("ConsigneeName", typeof(string), typeof(SendNewInfoModel)); 11 | /// 12 | /// 收货人姓名 13 | /// 14 | public string ConsigneeName 15 | { 16 | get { return GetValue(ConsigneeNameProperty).ToString(); } 17 | set { SetValue(ConsigneeNameProperty, value); } 18 | } 19 | 20 | public BindableProperty ExpressTypeEnumProperty = BindableProperty.Create("ExpressType", typeof(ExpressTypeEnum), typeof(SendNewInfoModel)); 21 | /// 22 | /// 快递类型 最好用枚举 23 | /// 24 | public ExpressTypeEnum ExpressType 25 | { 26 | get { return (ExpressTypeEnum)GetValue(ExpressTypeEnumProperty); } 27 | set { SetValue(ExpressTypeEnumProperty, value); } 28 | } 29 | 30 | public BindableProperty GetGoodsCodeProperty = BindableProperty.Create("GetGoodsCode", typeof(int), typeof(SendNewInfoModel)); 31 | /// 32 | /// 取货码 33 | /// 34 | public int GetGoodsCode { 35 | get { return (int)GetValue(GetGoodsCodeProperty); } 36 | set { SetValue(GetGoodsCodeProperty, value); } 37 | } 38 | 39 | public BindableProperty GetGoodsAddressProperty = BindableProperty.Create("GetGoodsAddress", typeof(string), typeof(SendNewInfoModel)); 40 | /// 41 | /// 取货地点 42 | /// 43 | public string GetGoodsAddress { 44 | get { return (string)GetValue(GetGoodsAddressProperty); } 45 | set { SetValue(GetGoodsAddressProperty, value); } 46 | } 47 | 48 | public BindableProperty SendAddressProperty = BindableProperty.Create("SendAddress", typeof(string), typeof(SendNewInfoModel)); 49 | /// 50 | /// 收货地址 51 | /// 52 | public string SendAddress 53 | { 54 | get { return (string)GetValue(SendAddressProperty); } 55 | set { SetValue(SendAddressProperty, value); } 56 | } 57 | 58 | /// 59 | /// 悬赏金额 60 | /// 61 | public decimal Bonus { get; set; } 62 | 63 | /// 64 | /// 备注 65 | /// 66 | public string Remarks { get; set; } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/UserDataModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Xamarin.Forms; 5 | 6 | namespace FastSchoolApp.ViewModel 7 | { 8 | public class UserDataModel : BindableObject 9 | { 10 | public BindableProperty UserNameProperty = BindableProperty.Create( 11 | "UserName", 12 | typeof(string), 13 | typeof(UserDataModel)); 14 | public string UserName 15 | { 16 | get { return GetValue(UserNameProperty).ToString(); } 17 | set { SetValue(UserNameProperty, value); } 18 | } 19 | 20 | public BindableProperty UserFullNameProperty = BindableProperty.Create( 21 | "UserFullName", 22 | typeof(string), 23 | typeof(UserDataModel)); 24 | public string UserFullName 25 | { 26 | get { return GetValue(UserFullNameProperty).ToString(); } 27 | set { SetValue(UserFullNameProperty, value); } 28 | } 29 | 30 | public BindableProperty UserNumberProperty = BindableProperty.Create( 31 | "UserNumber", 32 | typeof(long), 33 | typeof(UserDataModel)); 34 | public long UserNumber 35 | { 36 | get { return (long)GetValue(UserNumberProperty); } 37 | set { SetValue(UserNumberProperty, value); } 38 | } 39 | 40 | public BindableProperty UserPhoneProperty = BindableProperty.Create( 41 | "UserPhone", 42 | typeof(long), 43 | typeof(UserDataModel)); 44 | public long UserPhone 45 | { 46 | get { return (long)GetValue(UserPhoneProperty); } 47 | set { SetValue(UserPhoneProperty, value); } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FastSchoolApp.ViewModel/UserOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Xamarin.Forms; 5 | 6 | namespace FastSchoolApp.ViewModel 7 | { 8 | public class UserOrderModel : BindableObject 9 | { 10 | 11 | public BindableProperty TitleProperty = BindableProperty.Create( 12 | "Title", 13 | typeof(string), 14 | typeof(UserDataModel)); 15 | public string Title 16 | { 17 | get { return (string)GetValue(TitleProperty); } 18 | set { SetValue(TitleProperty, value); } 19 | } 20 | 21 | public BindableProperty OrderNumberProperty = BindableProperty.Create( 22 | "OrderNumber", 23 | typeof(string), 24 | typeof(UserDataModel)); 25 | public string OrderNumber 26 | { 27 | get { return (string)GetValue(OrderNumberProperty); } 28 | set { SetValue(OrderNumberProperty, value); } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with you package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); 20 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Android.App; 4 | using Android.Content.PM; 5 | using Android.Runtime; 6 | using Android.Views; 7 | using Android.Widget; 8 | using Android.OS; 9 | 10 | namespace FastSchoolApp.Droid 11 | { 12 | [Activity(Label = "FastSchoolApp", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = false , ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] 13 | public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity 14 | { 15 | protected override void OnCreate(Bundle savedInstanceState) 16 | { 17 | TabLayoutResource = Resource.Layout.Tabbar; 18 | ToolbarResource = Resource.Layout.Toolbar; 19 | 20 | base.OnCreate(savedInstanceState); 21 | global::Xamarin.Forms.Forms.Init(this, savedInstanceState); 22 | LoadApplication(new App()); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Android.App; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("FastSchoolApp.Android")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("FastSchoolApp.Android")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: ComVisible(false)] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | 32 | // Add some common permissions, these can be removed if not needed 33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)] 34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] 35 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.xml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable-hdpi/ 12 | icon.png 13 | 14 | drawable-ldpi/ 15 | icon.png 16 | 17 | drawable-mdpi/ 18 | icon.png 19 | 20 | layout/ 21 | main.xml 22 | 23 | values/ 24 | strings.xml 25 | 26 | In order to get the build system to recognize Android resources, set the build action to 27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 28 | instead operate on resource IDs. When you compile an Android application that uses resources, 29 | the build system will package the resources for distribution and generate a class called 30 | "Resource" that contains the tokens for each one of the resources included. For example, 31 | for the above Resources layout, this is what the Resource class would expose: 32 | 33 | public class Resource { 34 | public class drawable { 35 | public const int icon = 0x123; 36 | } 37 | 38 | public class layout { 39 | public const int main = 0x456; 40 | } 41 | 42 | public class strings { 43 | public const int first_string = 0xabc; 44 | public const int second_string = 0xbcd; 45 | } 46 | } 47 | 48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main 49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first 50 | string in the dictionary file values/strings.xml. 51 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/bg.jpg -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/fasong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/fasong.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/faxian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/faxian.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/gerenzhongxin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/gerenzhongxin.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/home.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/icon_hulianwang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/icon_hulianwang.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/kg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/kg.jpg -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/logbg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/logbg.jpg -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/suotou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/suotou.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/xiaoyuhao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/xiaoyuhao.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/drawable/yonghu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/drawable/yonghu.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/layout/Tabbar.axml: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/layout/Toolbar.axml: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-anydpi-v26/icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-anydpi-v26/icon_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-hdpi/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-hdpi/Icon.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-hdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-hdpi/launcher_foreground.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-mdpi/icon.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-mdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-mdpi/launcher_foreground.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xhdpi/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xhdpi/Icon.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xhdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xhdpi/launcher_foreground.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxhdpi/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxhdpi/Icon.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxhdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxhdpi/launcher_foreground.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxxhdpi/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxxhdpi/Icon.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Crazyers/KauiXiaoAPP/bc52b510ac58fe1e18d0af03bfd0eea5fbb68f06/FastSchoolApp/FastSchoolApp.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | #3F51B5 5 | #303F9F 6 | #FF4081 7 | 8 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/Resources/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 26 | 27 | 30 | 31 | 32 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.Android/SplashActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content; 3 | using Android.OS; 4 | using Android.Runtime; 5 | using Android.Views; 6 | using Android.Widget; 7 | 8 | namespace FastSchoolApp.Droid 9 | { 10 | [Activity(Label = "FastSchoolApp", Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true)] 11 | public class SplashActivity : Activity 12 | { 13 | protected override void OnCreate(Bundle savedInstanceState) 14 | { 15 | base.OnCreate(savedInstanceState); 16 | StartActivity(typeof(MainActivity)); 17 | // Create your application here 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | 8 | namespace FastSchoolApp.iOS 9 | { 10 | // The UIApplicationDelegate for the application. This class is responsible for launching the 11 | // User Interface of the application, as well as listening (and optionally responding) to 12 | // application events from iOS. 13 | [Register("AppDelegate")] 14 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate 15 | { 16 | // 17 | // This method is invoked when the application has loaded and is ready to run. In this 18 | // method you should instantiate the window, load the UI into it and then make the window 19 | // visible. 20 | // 21 | // You have 17 seconds to return from this method, or iOS will terminate your application. 22 | // 23 | public override bool FinishedLaunching(UIApplication app, NSDictionary options) 24 | { 25 | global::Xamarin.Forms.Forms.Init(); 26 | LoadApplication(new App()); 27 | 28 | return base.FinishedLaunching(app, options); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 1 8 | 2 9 | 10 | UISupportedInterfaceOrientations 11 | 12 | UIInterfaceOrientationPortrait 13 | UIInterfaceOrientationLandscapeLeft 14 | UIInterfaceOrientationLandscapeRight 15 | 16 | UISupportedInterfaceOrientations~ipad 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationPortraitUpsideDown 20 | UIInterfaceOrientationLandscapeLeft 21 | UIInterfaceOrientationLandscapeRight 22 | 23 | MinimumOSVersion 24 | 8.0 25 | CFBundleDisplayName 26 | FastSchoolApp 27 | CFBundleIdentifier 28 | com.companyname.FastSchoolApp 29 | CFBundleVersion 30 | 1.0 31 | UILaunchStoryboardName 32 | LaunchScreen 33 | CFBundleName 34 | FastSchoolApp 35 | XSAppIconAssets 36 | Assets.xcassets/AppIcon.appiconset 37 | 38 | 39 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | 8 | namespace FastSchoolApp.iOS 9 | { 10 | public class Application 11 | { 12 | // This is the main entry point of the application. 13 | static void Main(string[] args) 14 | { 15 | // if you want to use a different Application Delegate class from "AppDelegate" 16 | // you can specify it here. 17 | UIApplication.Main(args, null, "AppDelegate"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastSchoolApp.iOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastSchoolApp.iOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp.iOS/Resources/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xamarin.Forms; 3 | using Xamarin.Forms.Xaml; 4 | 5 | [assembly: XamlCompilation(XamlCompilationOptions.Compile)] 6 | namespace FastSchoolApp 7 | { 8 | public partial class App : Application 9 | { 10 | public App() 11 | { 12 | 13 | InitializeComponent(); 14 | 15 | MainPage = new NavigationPage(new Login.LoginPage()); 16 | } 17 | protected override void OnStart() 18 | { 19 | // Handle when your app starts 20 | } 21 | 22 | protected override void OnSleep() 23 | { 24 | // Handle when your app sleeps 25 | } 26 | 27 | protected override void OnResume() 28 | { 29 | // Handle when your app resumes 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/FastSchoolApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SAK 5 | SAK 6 | SAK 7 | SAK 8 | 9 | 10 | 11 | netstandard2.0 12 | latest 13 | 14 | 15 | 16 | pdbonly 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Code 31 | 32 | 33 | 34 | 35 | 36 | MSBuild:UpdateDesignTimeXaml 37 | 38 | 39 | MSBuild:UpdateDesignTimeXaml 40 | 41 | 42 | MSBuild:UpdateDesignTimeXaml 43 | 44 | 45 | MSBuild:UpdateDesignTimeXaml 46 | 47 | 48 | MSBuild:UpdateDesignTimeXaml 49 | 50 | 51 | MSBuild:UpdateDesignTimeXaml 52 | 53 | 54 | MSBuild:UpdateDesignTimeXaml 55 | 56 | 57 | MSBuild:UpdateDesignTimeXaml 58 | 59 | 60 | MSBuild:UpdateDesignTimeXaml 61 | 62 | 63 | MSBuild:UpdateDesignTimeXaml 64 | 65 | 66 | MSBuild:UpdateDesignTimeXaml 67 | 68 | 69 | MSBuild:UpdateDesignTimeXaml 70 | 71 | 72 | MSBuild:UpdateDesignTimeXaml 73 | 74 | 75 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/Files/UserData.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": [ 3 | "**/bin", 4 | "**/bower_components", 5 | "**/jspm_packages", 6 | "**/node_modules", 7 | "**/obj", 8 | "**/platforms" 9 | ] 10 | } -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/Home/AffirmOrder.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 10 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 81 | 82 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/Login/LoginPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using FastSchoolApp.Common; 2 | using FastSchoolApp.Services; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | using Xamarin.Forms; 10 | using Xamarin.Forms.Xaml; 11 | 12 | namespace FastSchoolApp.Login 13 | { 14 | [XamlCompilation(XamlCompilationOptions.Compile)] 15 | public partial class LoginPage : ContentPage 16 | { 17 | private AccountService AccountService { get; } 18 | public LoginPage() 19 | { 20 | InitializeComponent(); 21 | AccountService = new AccountService(); 22 | } 23 | 24 | private async void userLoginBtn_Clicked(object sender, EventArgs e) 25 | { 26 | var name = userName.Text; 27 | var pwd = userPwd.Text; 28 | if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(pwd)) 29 | { 30 | await DisplayAlert("错误提示", "用户名或密码不能为空!", "确定"); 31 | return; 32 | } 33 | var result = await AccountService.LoginAsync(new Model.User 34 | { 35 | UserName = name, 36 | UserPwd = pwd 37 | }); 38 | if (result.Equals("error")) 39 | { 40 | await DisplayAlert("错误提示", "用户名或密码错误!", "确定"); 41 | return; 42 | } 43 | 44 | //把收到令牌记录起来,最好持久化。。。 45 | AccountHelper.LoginKey = $"Bearer {result}"; 46 | AccountHelper.LoginName = name; 47 | 48 | Application.Current.MainPage = new Home.HomeMasterDetailPage(); 49 | } 50 | 51 | private void userRegister_Clicked(object sender, EventArgs e) 52 | { 53 | Navigation.PushAsync(new Register(), true); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /FastSchoolApp/FastSchoolApp/Login/Register.xaml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 64 |