美文网首页
店铺注册的dto(页面数据层)

店铺注册的dto(页面数据层)

作者: 相信灬你一直在 | 来源:发表于2018-08-03 15:59 被阅读0次

    ShopExecution.java

    package com.imooc.myo2o.dto;
    
    import java.util.List;
    
    import com.imooc.myo2o.entity.Shop;
    import com.imooc.myo2o.enums.ShopStateEnum;
    
    /**
     * 封装执行后结果
     */
    public class ShopExecution {
    
        // 结果状态
        private int state;
    
        // 状态标识
        private String stateInfo;
    
        // 店铺数量
        private int count;
    
        // 操作的shop(增删改店铺的时候用)
        private Shop shop;
    
        // 获取的shop列表(查询店铺列表的时候用)
        private List<Shop> shopList;
    
        public ShopExecution() {
        }
    
        // 失败的构造器
        public ShopExecution(ShopStateEnum stateEnum) {
            this.state = stateEnum.getState();
            this.stateInfo = stateEnum.getStateInfo();
        }
    
        // 成功的构造器
        public ShopExecution(ShopStateEnum stateEnum, Shop shop) {
            this.state = stateEnum.getState();
            this.stateInfo = stateEnum.getStateInfo();
            this.shop = shop;
        }
    
        // 成功的构造器
        public ShopExecution(ShopStateEnum stateEnum, List<Shop> shopList) {
            this.state = stateEnum.getState();
            this.stateInfo = stateEnum.getStateInfo();
            this.shopList = shopList;
        }
    
        public int getState() {
            return state;
        }
    
        public void setState(int state) {
            this.state = state;
        }
    
        public String getStateInfo() {
            return stateInfo;
        }
    
        public void setStateInfo(String stateInfo) {
            this.stateInfo = stateInfo;
        }
    
        public int getCount() {
            return count;
        }
    
        public void setCount(int count) {
            this.count = count;
        }
    
        public Shop getShop() {
            return shop;
        }
    
        public void setShop(Shop shop) {
            this.shop = shop;
        }
    
        public List<Shop> getShopList() {
            return shopList;
        }
    
        public void setShopList(List<Shop> shopList) {
            this.shopList = shopList;
        }
    
    }
    

    ShopStateEnum.java使用枚举类表示

    package com.imooc.myo2o.enums;
    
    /**
     * 使用枚举表述常量数据字典
     */
    public enum ShopStateEnum {
    
        CHECK(0, "审核中"),
        OFFLINE(-1, "非法商铺"),
        SUCCESS(1, "操作成功"),
        PASS(2, "通过认证"),
        INNER_ERROR(-1001, "操作失败"),
        NULL_SHOPID(-1002, "ShopId为空"),
        NULL_SHOP_INFO(-1003, "传入了空的信息");
    
        private int state;
    
        private String stateInfo;
    
        private ShopStateEnum(int state, String stateInfo) {
            this.state = state;
            this.stateInfo = stateInfo;
        }
    
        public int getState() {
            return state;
        }
    
        public String getStateInfo() {
            return stateInfo;
        }
    
        public static ShopStateEnum stateOf(int index) {
            for (ShopStateEnum state : values()) {
                if (state.getState() == index) {
                    return state;
                }
            }
            return null;
        }
    
    }
    

    相关文章

      网友评论

          本文标题:店铺注册的dto(页面数据层)

          本文链接:https://www.haomeiwen.com/subject/hmxuvftx.html