1. DTO:添加店铺的返回类型

问题:为什么不直接用实体类Shop呢?

原因:在操作Shop的时候,必然会有一个状态。添加店铺,添加成功,还是添加失败?
如果添加失败,失败是一个什么状态,这些都是要记录的,并且要返回controller层去处理。
### 1.1 店铺操作枚举类ShopStateEnum.java
```#java
package com.csj2018.o2o.enums;

public enum ShopStateEnum {

CHECK(0,"审核中"),

OFFLINE(-1,"非法店铺"),

SUCCESS(1,"操作成功"),

PASS(2,"通过认证"),

INNER_ERROR(-1001,"内部系统错误"),

NULL_SHOPID(-1002,"ShopId为空");

private int state;

private String stateInfo;

private ShopStateEnum(int state,String stateInfo) {

this.state = state;

this.stateInfo = stateInfo;

}

public static ShopStateEnum stateOf(int state) {

for(ShopStateEnum stateEnum:values()) { //values()包含了枚举对象所有的值

if(stateEnum.getState() == state) {

return stateEnum;

}

}

return null;

}

public int getState() {

return state;

}

public String getStateInfo() {

return stateInfo;

}

}

###    1.2 ShopExecution.java
```#java
package com.csj2018.o2o.dto; import java.util.List; import com.csj2018.o2o.entity.Shop;
import com.csj2018.o2o.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;
} }

校园商铺-4店铺注册功能模块-4Dto之ShopExecution的实现的更多相关文章

  1. 校园商铺-4店铺注册功能模块-10店铺注册之js实现

    1. 建立js目录和文件 1.1 建立js目录 在webapp下新建文件夹js,再在js目录下新建shop文件夹. 1.2 js文件 js的功能: 1.从后台获取到店铺分类.区域等是信息,将它填充到前 ...

  2. 校园商铺-4店铺注册功能模块-6店铺注册之Controller层的实现

    1. 从request请求获取获取相关的值 HttpservletRequest request代表的是客户端的请求.当客户端通过http协议访问服务器的时候,http请求头中的所有信息,都封装在这个 ...

  3. 校园商铺-4店铺注册功能模块-8店铺注册之Controller层的改造

    不合理的地方: 1. 并不需要将InputStream转换成File类型,直接将InputStream传进入交给CommonsMultipartfile去处理就可以了 如果做这样的转换,每次都需要生成 ...

  4. 校园商铺-4店铺注册功能模块-3thumbnailator图片处理和封装Util

    1. 初步使用thumbnailator 1.1 下载依赖 <!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator - ...

  5. 校园商铺-4店铺注册功能模块-5店铺注册之Service层的实现

    1. 创建接口 ShopService.java package com.csj2018.o2o.service; import java.io.File; import com.csj2018.o2 ...

  6. 校园商铺-4店铺注册功能模块-1Dao层之更新店铺

    dao层增加更新店铺的方法 package com.csj2018.o2o.dao; import com.csj2018.o2o.entity.Shop; public interface Shop ...

  7. springboot项目整合-注册功能模块开发

    工程简介 准备工作:项目所用到的html界面以及sql文件链接如下:链接: https://pan.baidu.com/s/18loHJiKRC6FI6XkoANMSJg?pwd=nkz2 提取码: ...

  8. SSM到Spring Boot-从零开发校园商铺平台

    第1章 开发准备 本章包含课程介绍,同时讲解开发网站所需要准备的事情,并且带领大家从零开始搭建一个Maven Web. 1-1 课程导学 1-2 开发准备 第2章 项目设计和框架搭建 本章主要先带领大 ...

  9. SSM到Spring Boot从零开发校园商铺平台

    项目目的 特别 由于准备春招,所以希望各位看客方便的话,能去github上面帮我Star一下项目 https://github.com/Draymonders/Campus-Shop emmm, 已经 ...

随机推荐

  1. 【踩坑】IDEA 设置 JVM 参数

    1.可视化界面设置 Run->Edit Configuration... 然后设置 2.配置文件设置 打开 IDEA 安装目录,看到有一个 bin 目录,其中有两个 vmoptions 文件,需 ...

  2. springmvc Cacheable

    直接上代码: <cache:annotation-driven /> <bean id="cacheManager" class="org.spring ...

  3. jdk源码阅读-ConcurrentLinkedQueue(一)

    说明 concurrentLinkedQueue为无界非阻塞队列,是线程安全的 内部结构为链表的形式, 内部使用cas保存线程安全.采用cas保证原子性 什么是CAS CAS 操作包含三个操作数 —— ...

  4. zeromq protobuf例子

    https://github.com/AifiHenryMa/zeromq_protocolbuffer_demo https://github.com/protocolbuffers/protobu ...

  5. Python学习笔记(九)——字符串

    # 5.1 字符串的拼接 str1 = '我今天一共走了' num = 1280 str2 = '步' print(str1+str(num)+str2) # 计算字符串长度 print(len(st ...

  6. Java.util.Map的实现类有那些?

    1.HashMap 2.Hashtable 3.LinkedHashMap 4.TreeMap

  7. Batch - FOR %%a %%b

    总结 %%a refers to the name of the variable your for loop will write to. Quoted from for /?: FOR %vari ...

  8. Jmeter-【JSON Extractor】-响应结果中一级key取值

    一.请求返回样式 二.取code值 三.查看结果

  9. 阿里巴巴持续投入,etcd 正式加入 CNCF

    摘要: 2018 年 12 月 11 日,在 KubeCon + CloudNativeCon 北美峰会上,etcd 项目正式加入 CNCF. 2018 年 12 月 11 日,在 KubeCon + ...

  10. lua之table|模块|包

    一.table table是   Lua的一种数据结构用来帮助我们创建不同的数据类型,如:数字.字典等. Lua table使用关联型数组,你可以用任意类型的值来作数组的索引,但这个值不能是   ni ...