电子商务之Common类库分析(三)

电子商务之Common类库分析(三)

   首先介绍下公共对象类库下的公共对象类

   这些对象的作用就是简化数据传递操作,因为它们能够包含数据,并且为该信息提供统一的封装方法。

ShoppingCartEntity(购物车)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class ShoppingCartEntity
    {
        
public int ShoppingCartID { setget; }
        
public string CartGUID { setget; }
        
public int Quantity { setget; }
        
public int ProductID { setget; }
        
public DateTime DateCreated { setget; }
    }
}

 

ProductEntity类


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class ProductEntity
    {
        
public int ProductID { setget; }
        
public int ProductCategoryID { setget; }
        
public ProductCategoryEntity ProductCategory { setget; }
        
public string ProductName { setget; }
        
public string ProductImageName { setget; }
        
public string ProductDescription { setget; }
        
public int Quantity { setget; }
        
public Decimal ProductPrice { setget; }
        
public ProductEntity()
        {
            
this.ProductCategory = new ProductCategoryEntity();
        }
    }
}

 

ProductCategoryEntity(产品种类)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class ProductCategoryEntity
    {
        
public int ProductCategoryID { setget; }
        
public string ProductCategoryName { setget; }
    }
}

OrdersEntity(订单)

 

 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class OrdersEntity
    {
        
public int OrderID { setget; }
        
public int EndUserID { setget; }
        
public EndUserEntity EndUser { setget; }
        
public string TransactionID { setget; }
        
public DateTime OrderDate { setget; }
        
public AddressEntity ShippingAddress { setget; }
        
public int OrderStatusID { setget; }
        
public Decimal ShippingTotal { setget; }
        
public OrderDetailsEntity OrderDetails { setget; }
        
public Decimal SubTotal { setget; }
        
public Decimal OrderTotal { setget; }
        
public Decimal Tax { setget; }
        
public CreditCardEntity CreditCard { setget; }
        
public DateTime ShipDate { setget; }
        
public string TrackingNumber { setget; }
        
public OrdersEntity()
        {
            
this.EndUser = new EndUserEntity();
            
this.ShippingAddress = new AddressEntity();
            
this.CreditCard = new CreditCardEntity();
            
this.OrderDetails = new OrderDetailsEntity();
        }
    }
}

 

 OrderDetailsEntity(详细订单)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class OrderDetailsEntity
    {
        
public int OrderDetailID { setget; }
        
public int OrderID { setget; }
        
public int ProductID { setget; }
        
public ProductEntity[] Products { setget; }
        
public int Quantity { setget; }
 
    }
}

 

Enums类(用户类别)


using System;
using System.Collections.Generic;
using System.Text;

namespace Shop.Common
{
    
public class Enums
    {
        
public enum EndUserType
        {
            CUSTOMER 
= 1,
            ADMINISTRATOR 
= 2
        }
    }
}

 

EndUserTypeEntity类(用户类别)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class EndUserTypeEntity
    {
        
public int EndUserTypeID { setget; }
        
public string EndUserName { setget; }
    }
}

 

EndUserEntity(用户)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
/// <summary>
    
/// 用户实体类
    
/// </summary>
    public class EndUserEntity
    {
        
public int EndUserID { getset; }
        
public int EndUserTypeID { setget; }
        
public string UserName { setget; }
        
public AddressEntity UserAddress { setget; }
        
public int AddressID { setget; }
        
public ContactInformationEntity UserContactInformation { setget; }
        
public int ContactInformationID { setget; }
        
public string Password { setget; }
        
public bool IsSubscribed { setget; }
        
public EndUserEntity()
        {
            
this.UserAddress = new AddressEntity();
            
this.UserContactInformation = new ContactInformationEntity();
        }
    }
}

 

CreditCardEntity类(信用卡)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class CreditCardEntity
    {
        
public AddressEntity Address { setget; }
        
public string CardType { setget; }
        
public int ExpMonth { setget; }
        
public int ExpYear { setget; }
        
public string Number { setget; }
        
public string SecurityCode { setget; }
    }
}

 

ContactInformationEntity类 (联系信息)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class ContactInformationEntity
    {
        
public int ContactInformationID { setget; }
        
public string Phone { setget; }
        
public string Phone2 { setget; }
        
public string Fax { setget; }
        
public string Email { setget; }
    }
}

 

  AddressEntity类 (用户地址信息)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Common
{
    
public class CreditCardEntity
    {
        
public AddressEntity Address { setget; }
        
public string CardType { setget; }
        
public int ExpMonth { setget; }
        
public int ExpYear { setget; }
        
public string Number { setget; }
        
public string SecurityCode { setget; }
        
public CreditCardEntity()
        {
            
this.Address = new AddressEntity();
        }
    }
}

     从上看出基本上一张数据库表对应一个公共对象类,相信大家一扫都能明白。

     以前做法就是编写一个公共对象类紧接着将它和对数据库操作的类放在一起的,不像这个系统放在一起,另外我也是不会在公共对象类中使用另外一种公共数据类型的,你看这里EndUserEntity类引用了AddressEntity类和ContactInformationEntity类(这样还要注意编写构造函数,这里的类不是静态的所以要记得new一个,在构造函数中完成它),要是以前设计是不会放进去的,我会分别构造这三个类。我觉得这样只用一个类就涵盖了所有的数据很方便,但是数据类型很复杂,如果考虑到在客户端调用webservice存储数据肯定就复杂了,不知道json能不能传这样的复杂数据。反正这样设计可能使设计思路更清晰,代码简洁了。可以在这个类库下多加几个文件,一个文件中放入一个系统模块所需要的公共对象类,我想在扩展时候,思路更清晰了。

    上面有一个地方要注意一下就是smallmoney数据类型在数据对象变为Decima,以前会用double.不知道Decima会不会比double好?

   不知道大家的设计思路是怎样的,我希望大家说出自己的设计的思路,大家共同学习嘛,也希望高人指点。

同系列文章

参考资料

            电商架构分析

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值