├── README.md ├── favicon.ico ├── o2o.gif ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── tyron │ │ └── o2o │ │ ├── cache │ │ ├── JedisPoolWriper.java │ │ └── JedisUtil.java │ │ ├── dao │ │ ├── AreaDao.java │ │ ├── HeadLineDao.java │ │ ├── LocalAuthDao.java │ │ ├── PersonInfoDao.java │ │ ├── ProductCategoryDao.java │ │ ├── ProductDao.java │ │ ├── ProductImgDao.java │ │ ├── ShopCategoryDao.java │ │ └── ShopDao.java │ │ ├── dto │ │ ├── HeadLineExecution.java │ │ ├── LocalAuthExecution.java │ │ ├── PersonInfoExecution.java │ │ ├── ProductCategoryExecution.java │ │ ├── ProductExecution.java │ │ ├── Result.java │ │ ├── ShopCategoryExecution.java │ │ └── ShopExecution.java │ │ ├── entity │ │ ├── Area.java │ │ ├── HeadLine.java │ │ ├── LocalAuth.java │ │ ├── PersonInfo.java │ │ ├── Product.java │ │ ├── ProductCategory.java │ │ ├── ProductImg.java │ │ ├── Shop.java │ │ ├── ShopCategory.java │ │ └── WechatAuth.java │ │ ├── enums │ │ ├── EnableStatusEnum.java │ │ ├── HeadLineStateEnum.java │ │ ├── LocalAuthStateEnum.java │ │ ├── OperationStatusEnum.java │ │ ├── PersonInfoStateEnum.java │ │ ├── PersonInfoStatusEnum.java │ │ ├── PersonInfoTypeEnum.java │ │ ├── ProductCategoryStateEnum.java │ │ ├── ProductStateEnum.java │ │ ├── ShopCategoryStateEnum.java │ │ └── ShopStateEnum.java │ │ ├── exceptions │ │ ├── AreaOperationException.java │ │ ├── HeadLineOperationException.java │ │ ├── LocalAuthOperationException.java │ │ ├── PersonInfoOperationException.java │ │ ├── ProductCategoryOperationException.java │ │ ├── ProductOperationException.java │ │ ├── ShopCategoryOperationException.java │ │ └── ShopOperationException.java │ │ ├── interceptor │ │ └── shopadmin │ │ │ ├── ShopLoginInterceptor.java │ │ │ └── ShopPermissionInterceptor.java │ │ ├── service │ │ ├── AreaService.java │ │ ├── CacheService.java │ │ ├── HeadLineService.java │ │ ├── LocalAuthService.java │ │ ├── PersonInfoService.java │ │ ├── ProductCategoryService.java │ │ ├── ProductService.java │ │ ├── ShopCategoryService.java │ │ ├── ShopService.java │ │ └── impl │ │ │ ├── AreaServiceImpl.java │ │ │ ├── CacheServiceImpl.java │ │ │ ├── HeadLineServiveImpl.java │ │ │ ├── LocalAuthServiceImpl.java │ │ │ ├── PersonInfoServiceImpl.java │ │ │ ├── ProductCategoryServiceImpl.java │ │ │ ├── ProductServiceImpl.java │ │ │ ├── ShopCategoryServiceImpl.java │ │ │ └── ShopServiceImpl.java │ │ ├── util │ │ ├── CodeUtil.java │ │ ├── DESUtil.java │ │ ├── EncryptPropertyPlaceholderConfigurer.java │ │ ├── HttpServletRequestUtil.java │ │ ├── ImageUtil.java │ │ ├── MD5.java │ │ ├── PageCalculator.java │ │ └── PathUtil.java │ │ └── web │ │ ├── AreaController.java │ │ ├── front │ │ ├── FrontController.java │ │ ├── MainPageController.java │ │ ├── ProductDetailController.java │ │ ├── ShopDetailController.java │ │ └── ShopListController.java │ │ ├── local │ │ ├── AdminController.java │ │ └── LocalAuthController.java │ │ └── shopadmin │ │ ├── ProductCategoryController.java │ │ ├── ProductManagementController.java │ │ ├── ShopAdminController.java │ │ └── ShopManagementController.java ├── resources │ ├── jdbc.properties │ ├── logback.xml │ ├── mapper │ │ ├── AreaDao.xml │ │ ├── HeadLineDao.xml │ │ ├── LocalAuthDao.xml │ │ ├── PersonInfoDao.xml │ │ ├── ProductCategoryDao.xml │ │ ├── ProductDao.xml │ │ ├── ProductImgDao.xml │ │ ├── ShopCategoryDao.xml │ │ └── ShopDao.xml │ ├── mybatis-config.xml │ ├── redis.properties │ ├── spring │ │ ├── spring-dao.xml │ │ ├── spring-redis.xml │ │ ├── spring-service.xml │ │ └── spring-web.xml │ ├── sql │ │ └── o2o.sql │ └── watermark.jpg └── webapp │ ├── WEB-INF │ ├── html │ │ ├── admin │ │ │ ├── changepwd.html │ │ │ ├── login.html │ │ │ └── register.html │ │ ├── front │ │ │ ├── index.html │ │ │ ├── productdetail.html │ │ │ ├── shopdetail.html │ │ │ └── shoplist.html │ │ └── shop │ │ │ ├── productcategorymanagement.html │ │ │ ├── productmanagement.html │ │ │ ├── productoperation.html │ │ │ ├── shoplist.html │ │ │ ├── shopmanagement.html │ │ │ └── shopoperation.html │ └── web.xml │ ├── index.jsp │ └── resources │ ├── css │ ├── front │ │ ├── index.css │ │ ├── productdetail.css │ │ ├── shopdetail.css │ │ └── shoplist.css │ └── shop │ │ ├── productcategorymanage.css │ │ ├── productmanage.css │ │ ├── shoplist.css │ │ └── shopmanagement.css │ └── js │ ├── admin │ ├── changepwd.js │ ├── login.js │ └── register.js │ ├── common │ └── common.js │ ├── front │ ├── index.js │ ├── productdetail.js │ ├── shopdetail.js │ └── shoplist.js │ └── shop │ ├── productcategorymanage.js │ ├── productmanage.js │ ├── productoperation.js │ ├── shoplist.js │ ├── shopmanagement.js │ └── shopoperation.js └── test ├── java └── com │ └── tyron │ └── o2o │ ├── BaseTest.java │ ├── dao │ ├── AreaDaoTest.java │ ├── HeadLineDaoTest.java │ ├── LocalAuthDaoTest.java │ ├── PersonInfoDaoTest.java │ ├── ProductCategoryDaoTest.java │ ├── ProductDaoTest.java │ ├── ProductImgDaoTest.java │ ├── ShopCategoryDaoTest.java │ └── ShopDaoTest.java │ └── service │ ├── AreaServiceTest.java │ ├── ProductServiceTest.java │ └── ShopServiceTest.java └── resources └── watermark.jpg /README.md: -------------------------------------------------------------------------------- 1 | # SSM到Spring Boot -从零开发校园商铺平台 2 | 3 | [![Travis](https://img.shields.io/badge/language-Java-yellow.svg)](http://tyronblog.com/tags/school-o2o)
4 | 5 | ### 核心技术栈: 6 | 7 | **前端**:前端UI库 SUI Mobile/ jQuery/ Chrome UA
8 | **后端**:SSM/Spring Boot/图片开源工具 Thumbnailator / 验证码组件Kaptcha/作业调度框架 Quartz/ Shell
9 | **平台**:Web/微信服务号/微信测试号
10 | **数据库**:MySQL
11 | **缓存**:Redis
12 | **部署**:阿里云
13 | 14 | 慕课网教程:[SSM到Spring Boot-从零开发校园商铺平台-慕课网实战](https://coding.imooc.com/class/144.html) 15 | 16 | ### 项目演示 17 | ![校园商铺演示](https://github.com/tyronczt/imooc-o2o/blob/master/o2o.gif)
18 | 19 | ### 校园商铺搭建过程 20 | CSDN专栏 [SSM到Spring Boot从零开发校园商铺平台](https://blog.csdn.net/tian330726/category_9291698.html) 21 | > 不全,有几篇审核不通过 22 | 23 | 24 | [1、环境搭建及测试](http://tyronblog.com/archives/o2o-1)- - -**附免费视频教程**
25 | [2、Logback配置与使用](https://tyron.blog.csdn.net/article/details/79692046)
26 | [3、店铺注册功能模块(一)](http://tyronblog.com/archives/o2o-3)
27 | [4、店铺注册功能模块(二)](https://tyron.blog.csdn.net/article/details/80878536)
28 | [5、店铺编辑和列表修改](http://tyronblog.com/archives/o2o-5)
29 | [6、商品类别模块](https://tyron.blog.csdn.net/article/details/82808818)
30 | [7、商品模块](https://tyron.blog.csdn.net/article/details/83933094)
31 | [8、前端页面模块](http://tyronblog.com/archives/o2o-8)
32 | [9、阿里云部署](https://tyron.blog.csdn.net/article/details/84996587)
33 | [10、DES加密](https://tyron.blog.csdn.net/article/details/85255912)
34 | [11、Redis缓存](https://tyron.blog.csdn.net/article/details/86619065)
35 | [12、用户登录、注册、修改密码](https://tyron.blog.csdn.net/article/details/91904437)
36 | [13、登录、权限拦截器](http://tyronblog.com/archives/o2o-13)
37 | [14、定期备份数据](http://tyronblog.com/archives/o2o-14)
38 | 线上演示地址:http://o2o.tyronblog.com:8090/o2o/front/index 39 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyronczt/imooc-o2o/7f62ccb6e080cc8fe5c2c277b5ff232e5bbab979/favicon.ico -------------------------------------------------------------------------------- /o2o.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyronczt/imooc-o2o/7f62ccb6e080cc8fe5c2c277b5ff232e5bbab979/o2o.gif -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/cache/JedisPoolWriper.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.cache; 2 | 3 | import redis.clients.jedis.JedisPool; 4 | import redis.clients.jedis.JedisPoolConfig; 5 | 6 | /** 7 | * @Description: 强指定redis的JedisPool接口构造函数,这样才能在centos成功创建jedispool 8 | * 9 | * @author tyronchen 10 | * @date 2018年12月26日 11 | */ 12 | public class JedisPoolWriper { 13 | private JedisPool jedisPool; 14 | 15 | public JedisPoolWriper(final JedisPoolConfig poolConfig, final String host, final int port) { 16 | try { 17 | jedisPool = new JedisPool(poolConfig, host, port); 18 | } catch (Exception e) { 19 | e.printStackTrace(); 20 | } 21 | } 22 | 23 | public JedisPool getJedisPool() { 24 | return jedisPool; 25 | } 26 | 27 | public void setJedisPool(JedisPool jedisPool) { 28 | this.jedisPool = jedisPool; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/AreaDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.Area; 6 | 7 | /** 8 | * @Description: 区域数据接口 9 | * 10 | * @author tyronchen 11 | * @date 2018年3月24日 12 | */ 13 | public interface AreaDao { 14 | 15 | /** 16 | * 查询区域信息 17 | * 18 | * @return 19 | */ 20 | List selectArea(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/HeadLineDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.tyron.o2o.entity.HeadLine; 8 | 9 | /** 10 | * @Description: 首页头条数据接口 11 | * 12 | * @author: tyron 13 | * @date: 2018年11月25日 14 | */ 15 | 16 | public interface HeadLineDao { 17 | 18 | /** 19 | * 添加首页头条 20 | * 21 | * @param headLine 22 | * @return 23 | */ 24 | int insertHeadLine(HeadLine headLine); 25 | 26 | /** 27 | * 根据传入的查询条件查询头条信息列表 28 | * 29 | * @param headLineCondition 30 | * @return 31 | */ 32 | List selectHeadLineList(@Param("headLineConditon") HeadLine headLineCondition); 33 | 34 | /** 35 | * 根据Id列表查询头条信息列表 36 | * 37 | * @param lineIdList 38 | * @return 39 | */ 40 | List selectHeadLineByIds(List lineIdList); 41 | 42 | /** 43 | * 根据头条Id查询头条信息 44 | * 45 | * @param lineId 46 | * @return 47 | */ 48 | HeadLine selectHeadLineById(long lineId); 49 | 50 | /** 51 | * 更新头条信息 52 | * 53 | * @param headLine 54 | * @return 55 | */ 56 | int updateHeadLine(HeadLine headLine); 57 | 58 | /** 59 | * 根据Id删除头条 60 | * 61 | * @param headLineId 62 | * @return 63 | */ 64 | int deleteHeadLine(long headLineId); 65 | 66 | /** 67 | * 批量删除头条记录 68 | * 69 | * @param lineIdList 70 | * @return 71 | */ 72 | int batchDeleteHeadLine(List lineIdList); 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/LocalAuthDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.tyron.o2o.entity.LocalAuth; 8 | 9 | /** 10 | * @Description: 用户登录接口 11 | * 12 | * @author tyronchen 13 | * @date 2019年5月18日 14 | */ 15 | public interface LocalAuthDao { 16 | 17 | /** 18 | * 根据账号密码查询用户信息 19 | * 20 | * @param username 用户名 21 | * @param password 密码 22 | * @return 用户信息 23 | */ 24 | LocalAuth queryLocalByUsernameAndPwd(@Param("username") String username, @Param("password") String password); 25 | 26 | /** 27 | * 根据账号查询用户信息 28 | * 29 | * @param username 用户名 30 | * @return 用户信息 31 | */ 32 | LocalAuth queryLocalByUsername(String username); 33 | 34 | /** 35 | * 根据用户ID查询用户信息 36 | * 37 | * @param localAuthId 用户ID 38 | * @return 用户信息 39 | */ 40 | LocalAuth queryLocalByLocalAuthId(long localAuthId); 41 | 42 | /** 43 | * 添加平台账号 44 | * 45 | * @param localAuth 用户信息 46 | * @return 添加成功条数 47 | */ 48 | int insertLocalAuth(LocalAuth localAuth); 49 | 50 | /** 51 | * 通过username,password更改密码 52 | * 53 | * @param username 用户名 54 | * @param password 原密码 55 | * @param newPassword 新密码 56 | * @param lastEditTime 最后修改时间 57 | * @return 修改成功数 58 | */ 59 | int updateLocalAuth(@Param("username") String username, @Param("password") String password, 60 | @Param("newPassword") String newPassword, @Param("lastEditTime") Date lastEditTime); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/PersonInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import com.tyron.o2o.entity.PersonInfo; 4 | 5 | /** 6 | * @Description: 用户信息接口 7 | * 8 | * @author tyronchen 9 | * @date 2019年6月3日 10 | */ 11 | public interface PersonInfoDao { 12 | 13 | /** 14 | * 根据用户ID查询用户信息 15 | * 16 | * @param userId 用户ID 17 | * @return 用户信息 18 | */ 19 | PersonInfo queryInfoByUserId(long userId); 20 | 21 | /** 22 | * 添加平台账号 23 | * 24 | * @param user 用户信息 25 | * @return 添加成功条数 26 | */ 27 | int insertPersonInfo(PersonInfo user); 28 | 29 | /** 30 | * 修改用户信息 31 | * 32 | * @param user 用户信息 33 | * @return 修改成功数 34 | */ 35 | int updatePersonInfo(PersonInfo user); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/ProductCategoryDao.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.tyron.o2o.dao; 5 | 6 | import java.util.List; 7 | 8 | import org.apache.ibatis.annotations.Param; 9 | 10 | import com.tyron.o2o.entity.ProductCategory; 11 | 12 | /** 13 | * @Description: 产品类别数据接口 14 | * 15 | * @author: tyron 16 | * @date: 2018年9月21日 17 | */ 18 | public interface ProductCategoryDao { 19 | 20 | /** 21 | * 根据店铺id查询店铺商品列表 22 | * 23 | * @param shopId 24 | * @return 25 | */ 26 | List selectProductCategoryList(long shopId); 27 | 28 | /** 29 | * 批量添加商品类别 30 | * 31 | * @param productCategoryList 商品类别列表 32 | * @return 33 | */ 34 | int batchInsertProductCategory(List productCategoryList); 35 | 36 | /** 37 | * 删除商品类别 38 | * 39 | * @param productCategoryId 商品类别Id 40 | * @param shopId 店铺Id,使删除操作更安全 41 | * @return 42 | */ 43 | int deleteProductCategory(@Param("productCategoryId") long productCategoryId, @Param("shopId") long shopId); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/ProductDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.tyron.o2o.entity.Product; 8 | 9 | /** 10 | * @Description: 商品数据接口 11 | * 12 | * @author: tyron 13 | * @date: 2018年10月26日 14 | */ 15 | 16 | public interface ProductDao { 17 | 18 | /** 19 | * 查询商品列表并分页,输入条件:商品名(模糊),商品状态,店铺Id,商品类别 20 | * 21 | * @param productCondition 查询条件 22 | * @param rowIndex 行数 23 | * @param pageSize 每页数 24 | * @return 25 | */ 26 | List selectProductList(@Param("productCondition") Product productCondition, @Param("rowIndex") int rowIndex, 27 | @Param("pageSize") int pageSize); 28 | 29 | /** 30 | * 根据条件查询商品总数 31 | * 32 | * @param productCondition 查询条件 33 | * @return 34 | */ 35 | int selectProductCount(@Param("productCondition") Product productCondition); 36 | 37 | /** 38 | * 插入商品 39 | * 40 | * @param product 41 | * @return 42 | */ 43 | int insertProduct(Product product); 44 | 45 | /** 46 | * 根据商品Id查询商品详情 47 | * 48 | * @param productId 49 | * @return 50 | */ 51 | Product selectProductByProductId(long productId); 52 | 53 | /** 54 | * 更新商品信息 55 | * 56 | * @param product 57 | * @return 58 | */ 59 | int updateProduct(Product product); 60 | 61 | /** 62 | * 删除商品类别时将商品记录中的类别项置空 63 | * 64 | * @param productCategoryId 65 | * @return 66 | */ 67 | int updateProductCategoryToNull(long productCategoryId); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/ProductImgDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.ProductImg; 6 | 7 | /** 8 | * @Description: 商品图片数据接口 9 | * 10 | * @author: tyron 11 | * @date: 2018年10月27日 12 | */ 13 | 14 | public interface ProductImgDao { 15 | 16 | /** 17 | * 批量插入商品图片 18 | * 19 | * @param productImgList 商品图片列表 20 | * @return 21 | */ 22 | 23 | int batchInsertProductImg(List productImgList); 24 | 25 | /** 26 | * 根据商品Id删除商品详情图 27 | * 28 | * @param productId 29 | * @return 30 | */ 31 | int deleteProductImgByProductId(Long productId); 32 | 33 | /** 34 | * 根据商品Id获取商品详情图列表 35 | * 36 | * @param productId 37 | * @return 38 | */ 39 | List selectProductImgListByProductId(long productId); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/ShopCategoryDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.tyron.o2o.entity.ShopCategory; 8 | 9 | /** 10 | * @Description: 店铺类别数据接口 11 | * 12 | * @author tyronchen 13 | * @date 2018年5月27日 14 | */ 15 | public interface ShopCategoryDao { 16 | 17 | /** 18 | * 根据查询条件获取分页列表 19 | * 需求:1、首页展示一级目录(即parent_id 为 null的店铺类别) 20 | * 2、点进去某个一级目录加载对应目录下的子目录 21 | * 3、店铺只能挂在店铺二级类别下 22 | * 4、在首页点击某个一级店铺目录 进入店铺展示页面的时候 需要加载对应目录下的子目录 23 | * 24 | * @param shopCategoryCondition 查询条件 25 | * @return 26 | */ 27 | List selectShopCategory(@Param("shopCategoryCondition") ShopCategory shopCategoryCondition); 28 | 29 | /** 30 | * 新增商品分类 31 | * 32 | * @param shopCategory 33 | * @return 34 | */ 35 | int insertShopCategory(ShopCategory shopCategory); 36 | 37 | /** 38 | * 修改商品分类 39 | * 40 | * @param shopCategory 41 | * @return 42 | */ 43 | int updateShopCategory(ShopCategory shopCategory); 44 | 45 | /** 46 | * 根据Id查询商品分类信息 47 | * 48 | * @param shopCategoryId 49 | * @return 50 | */ 51 | ShopCategory selectShopCategoryById(long shopCategoryId); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dao/ShopDao.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import com.tyron.o2o.entity.Shop; 8 | 9 | /** 10 | * @Description: 店铺数据接口 11 | * 12 | * @author tyronchen 13 | * @date 2018年3月31日 14 | */ 15 | public interface ShopDao { 16 | 17 | /** 18 | * 19 | * 带有分页功能的查询商铺列表 。 可输入的查询条件:商铺名(要求模糊查询) 区域Id 商铺状态 商铺类别 owner 20 | * (注意在sqlmapper中按照前端入参拼装不同的查询语句) 21 | * 22 | * @param shopConditionShop 23 | * @param rowIndex:从第几行开始取 24 | * @param pageSize:返回多少行数据(页面上的数据量) 25 | * 比如 rowIndex为1,pageSize为5 即为 从第一行开始取,取5行数据 26 | * @return 27 | */ 28 | List selectShopList(@Param("shopCondition") Shop shopCondition, @Param("rowIndex") int rowIndex, 29 | @Param("pageSize") int pageSize); 30 | 31 | /** 32 | * 按照条件查询 符合前台传入的条件的商铺的总数 33 | * 34 | * @param shopCondition 35 | * @return 36 | */ 37 | int selectShopCount(@Param("shopCondition") Shop shopCondition); 38 | 39 | /** 40 | * 新增店铺 41 | * 42 | * @param shop 43 | * @return 44 | */ 45 | int insertShop(Shop shop); 46 | 47 | /** 48 | * 更新店铺 49 | * 50 | * @param shop 51 | * @return 52 | */ 53 | int updateShop(Shop shop); 54 | 55 | /** 56 | * 根据shopId查询shop 57 | * 58 | * @param shopId 59 | * @return 60 | */ 61 | Shop selectByShopId(long shopId); 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/HeadLineExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.HeadLine; 6 | import com.tyron.o2o.enums.HeadLineStateEnum; 7 | import com.tyron.o2o.enums.OperationStatusEnum; 8 | 9 | /** 10 | * @Description: 封装操作HeadLine的返回结果,包括操作状态和HeadLine信息 11 | * 12 | * @author tyronchen 13 | * @date 2019年1月23日 14 | */ 15 | public class HeadLineExecution { 16 | // 结果状态 17 | private int state; 18 | 19 | // 状态标识 20 | private String stateInfo; 21 | 22 | // 店铺数量 23 | private int count; 24 | 25 | // 操作的headLine 26 | private HeadLine headLine; 27 | 28 | // 获取的列表 29 | private List headLineList; 30 | 31 | public HeadLineExecution() { 32 | } 33 | 34 | // 失败的构造器 35 | public HeadLineExecution(HeadLineStateEnum stateEnum) { 36 | this.state = stateEnum.getState(); 37 | this.stateInfo = stateEnum.getStateInfo(); 38 | } 39 | 40 | // 失败的构造器 41 | public HeadLineExecution(OperationStatusEnum stateEnum) { 42 | this.state = stateEnum.getState(); 43 | this.stateInfo = stateEnum.getStateInfo(); 44 | } 45 | 46 | // 成功的构造器 47 | public HeadLineExecution(OperationStatusEnum success, HeadLine headLine) { 48 | this.state = success.getState(); 49 | this.stateInfo = success.getStateInfo(); 50 | this.headLine = headLine; 51 | } 52 | 53 | // 成功的构造器 54 | public HeadLineExecution(OperationStatusEnum stateEnum, List headLineList) { 55 | this.state = stateEnum.getState(); 56 | this.stateInfo = stateEnum.getStateInfo(); 57 | this.headLineList = headLineList; 58 | } 59 | 60 | public int getState() { 61 | return state; 62 | } 63 | 64 | public void setState(int state) { 65 | this.state = state; 66 | } 67 | 68 | public String getStateInfo() { 69 | return stateInfo; 70 | } 71 | 72 | public void setStateInfo(String stateInfo) { 73 | this.stateInfo = stateInfo; 74 | } 75 | 76 | public int getCount() { 77 | return count; 78 | } 79 | 80 | public void setCount(int count) { 81 | this.count = count; 82 | } 83 | 84 | public HeadLine getHeadLine() { 85 | return headLine; 86 | } 87 | 88 | public void setHeadLine(HeadLine headLine) { 89 | this.headLine = headLine; 90 | } 91 | 92 | public List getHeadLineList() { 93 | return headLineList; 94 | } 95 | 96 | public void setHeadLineList(List headLineList) { 97 | this.headLineList = headLineList; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/LocalAuthExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.enums.LocalAuthStateEnum; 6 | import com.tyron.o2o.enums.OperationStatusEnum; 7 | import com.tyron.o2o.entity.LocalAuth; 8 | 9 | /** 10 | * @Description: 本地账号返回信息 11 | * 12 | * @author tyronchen 13 | * @date 2019年5月20日 14 | */ 15 | public class LocalAuthExecution { 16 | // 结果状态 17 | private int state; 18 | 19 | // 状态标识 20 | private String stateInfo; 21 | 22 | private int count; 23 | 24 | private LocalAuth localAuth; 25 | 26 | private List localAuthList; 27 | 28 | public LocalAuthExecution() { 29 | } 30 | 31 | // 失败的构造器 32 | public LocalAuthExecution(LocalAuthStateEnum stateEnum) { 33 | this.state = stateEnum.getState(); 34 | this.stateInfo = stateEnum.getStateInfo(); 35 | } 36 | 37 | // 成功的构造器 38 | public LocalAuthExecution(OperationStatusEnum stateEnum) { 39 | this.state = stateEnum.getState(); 40 | this.stateInfo = stateEnum.getStateInfo(); 41 | } 42 | 43 | // 成功的构造器 44 | public LocalAuthExecution(OperationStatusEnum stateEnum, LocalAuth localAuth) { 45 | this.state = stateEnum.getState(); 46 | this.stateInfo = stateEnum.getStateInfo(); 47 | this.localAuth = localAuth; 48 | } 49 | 50 | // 成功的构造器 51 | public LocalAuthExecution(OperationStatusEnum stateEnum, List localAuthList) { 52 | this.state = stateEnum.getState(); 53 | this.stateInfo = stateEnum.getStateInfo(); 54 | this.localAuthList = localAuthList; 55 | } 56 | 57 | public int getState() { 58 | return state; 59 | } 60 | 61 | public void setState(int state) { 62 | this.state = state; 63 | } 64 | 65 | public String getStateInfo() { 66 | return stateInfo; 67 | } 68 | 69 | public void setStateInfo(String stateInfo) { 70 | this.stateInfo = stateInfo; 71 | } 72 | 73 | public int getCount() { 74 | return count; 75 | } 76 | 77 | public void setCount(int count) { 78 | this.count = count; 79 | } 80 | 81 | public LocalAuth getLocalAuth() { 82 | return localAuth; 83 | } 84 | 85 | public void setLocalAuth(LocalAuth localAuth) { 86 | this.localAuth = localAuth; 87 | } 88 | 89 | public List getLocalAuthList() { 90 | return localAuthList; 91 | } 92 | 93 | public void setLocalAuthList(List localAuthList) { 94 | this.localAuthList = localAuthList; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/PersonInfoExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.PersonInfo; 6 | import com.tyron.o2o.enums.OperationStatusEnum; 7 | import com.tyron.o2o.enums.PersonInfoStateEnum; 8 | 9 | /** 10 | * @Description: 用户信息返回信息 11 | * 12 | * @author tyronchen 13 | * @date 2019年6月5日 14 | */ 15 | public class PersonInfoExecution { 16 | // 结果状态 17 | private int state; 18 | 19 | // 状态标识 20 | private String stateInfo; 21 | 22 | private int count; 23 | 24 | private PersonInfo localAuth; 25 | 26 | private List localAuthList; 27 | 28 | public PersonInfoExecution() { 29 | } 30 | 31 | // 失败的构造器 32 | public PersonInfoExecution(PersonInfoStateEnum stateEnum) { 33 | this.state = stateEnum.getState(); 34 | this.stateInfo = stateEnum.getStateInfo(); 35 | } 36 | 37 | // 成功的构造器 38 | public PersonInfoExecution(OperationStatusEnum stateEnum) { 39 | this.state = stateEnum.getState(); 40 | this.stateInfo = stateEnum.getStateInfo(); 41 | } 42 | 43 | // 成功的构造器 44 | public PersonInfoExecution(OperationStatusEnum stateEnum, PersonInfo localAuth) { 45 | this.state = stateEnum.getState(); 46 | this.stateInfo = stateEnum.getStateInfo(); 47 | this.localAuth = localAuth; 48 | } 49 | 50 | // 成功的构造器 51 | public PersonInfoExecution(OperationStatusEnum stateEnum, List localAuthList) { 52 | this.state = stateEnum.getState(); 53 | this.stateInfo = stateEnum.getStateInfo(); 54 | this.localAuthList = localAuthList; 55 | } 56 | 57 | public int getState() { 58 | return state; 59 | } 60 | 61 | public void setState(int state) { 62 | this.state = state; 63 | } 64 | 65 | public String getStateInfo() { 66 | return stateInfo; 67 | } 68 | 69 | public void setStateInfo(String stateInfo) { 70 | this.stateInfo = stateInfo; 71 | } 72 | 73 | public int getCount() { 74 | return count; 75 | } 76 | 77 | public void setCount(int count) { 78 | this.count = count; 79 | } 80 | 81 | public PersonInfo getPersonInfo() { 82 | return localAuth; 83 | } 84 | 85 | public void setPersonInfo(PersonInfo localAuth) { 86 | this.localAuth = localAuth; 87 | } 88 | 89 | public List getPersonInfoList() { 90 | return localAuthList; 91 | } 92 | 93 | public void setPersonInfoList(List localAuthList) { 94 | this.localAuthList = localAuthList; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/ProductCategoryExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.ProductCategory; 6 | import com.tyron.o2o.enums.OperationStatusEnum; 7 | import com.tyron.o2o.enums.ProductCategoryStateEnum; 8 | 9 | /** 10 | * 11 | * @Description: 封装操作ProductCategory的返回结果,包括操作状态和ProductCategory信息 12 | * 13 | * @author: tyron 14 | * @date: 2018年9月22日 15 | */ 16 | public class ProductCategoryExecution { 17 | 18 | private int state; 19 | private String stateInfo; 20 | 21 | // 因为是批量操作,所以使用List 22 | private List productCategoryList; 23 | 24 | private int count; 25 | 26 | /** 27 | * 28 | * 29 | * @Title:ProductCategoryExecution 30 | * 31 | * @Description:空的构造函数 32 | */ 33 | public ProductCategoryExecution() { 34 | super(); 35 | } 36 | 37 | /** 38 | * 39 | * @Title:ProductCategoryExecution 40 | * 41 | * @Description:操作成功的时候使用的构造函数,返回操作状态和ProductCategory集合,以及操作成功的行数 42 | * 43 | * @param productCategoryStateEnum 44 | * @param productCategoryList 45 | * @param count 46 | */ 47 | public ProductCategoryExecution(OperationStatusEnum operationStatusEnum, 48 | List productCategoryList, int count) { 49 | this.state = operationStatusEnum.getState(); 50 | this.stateInfo = operationStatusEnum.getStateInfo(); 51 | this.productCategoryList = productCategoryList; 52 | this.count = count; 53 | } 54 | 55 | /** 56 | * @Title:ProductCategoryExecution 57 | * 58 | * @Description:操作失败的时候返回的信息,仅包含状态和状态描述即可 59 | * 60 | * @param productCategoryStateEnum 61 | */ 62 | public ProductCategoryExecution(ProductCategoryStateEnum productCategoryStateEnum) { 63 | this.state = productCategoryStateEnum.getState(); 64 | this.stateInfo = productCategoryStateEnum.getStateInfo(); 65 | } 66 | 67 | public int getState() { 68 | return state; 69 | } 70 | 71 | public void setState(int state) { 72 | this.state = state; 73 | } 74 | 75 | public String getStateInfo() { 76 | return stateInfo; 77 | } 78 | 79 | public void setStateInfo(String stateInfo) { 80 | this.stateInfo = stateInfo; 81 | } 82 | 83 | public List getProductCategoryList() { 84 | return productCategoryList; 85 | } 86 | 87 | public void setProductCategoryList(List productCategoryList) { 88 | this.productCategoryList = productCategoryList; 89 | } 90 | 91 | public int getCount() { 92 | return count; 93 | } 94 | 95 | public void setCount(int count) { 96 | this.count = count; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/ProductExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.Product; 6 | import com.tyron.o2o.enums.OperationStatusEnum; 7 | import com.tyron.o2o.enums.ProductStateEnum; 8 | 9 | /** 10 | * 11 | * @Description: 商品返回结果信息 12 | * 13 | * @author: tyron 14 | * @date: 2018年10月27日 15 | */ 16 | public class ProductExecution { 17 | 18 | // 结果状态 19 | private int state; 20 | 21 | // 状态标识 22 | private String stateInfo; 23 | 24 | // 商品数量 25 | private int count; 26 | 27 | // 操作的Product(增删改商品的时候用) 28 | private Product Product; 29 | 30 | // 获取的Product列表(查询商品列表的时候用) 31 | private List ProductList; 32 | 33 | public ProductExecution() { 34 | } 35 | 36 | // 商品操作失败的时候使用的构造器 37 | public ProductExecution(ProductStateEnum stateEnum) { 38 | this.state = stateEnum.getState(); 39 | this.stateInfo = stateEnum.getStateInfo(); 40 | } 41 | 42 | // 商品操作成功的时候使用的构造器 43 | public ProductExecution(OperationStatusEnum stateEnum, Product Product) { 44 | this.state = stateEnum.getState(); 45 | this.stateInfo = stateEnum.getStateInfo(); 46 | this.Product = Product; 47 | } 48 | 49 | // 商品操作成功的时候使用的构造器 50 | public ProductExecution(OperationStatusEnum stateEnum, List ProductList) { 51 | this.state = stateEnum.getState(); 52 | this.stateInfo = stateEnum.getStateInfo(); 53 | this.ProductList = ProductList; 54 | } 55 | 56 | public int getState() { 57 | return state; 58 | } 59 | 60 | public void setState(int state) { 61 | this.state = state; 62 | } 63 | 64 | public String getStateInfo() { 65 | return stateInfo; 66 | } 67 | 68 | public void setStateInfo(String stateInfo) { 69 | this.stateInfo = stateInfo; 70 | } 71 | 72 | public int getCount() { 73 | return count; 74 | } 75 | 76 | public void setCount(int count) { 77 | this.count = count; 78 | } 79 | 80 | public Product getProduct() { 81 | return Product; 82 | } 83 | 84 | public void setProduct(Product Product) { 85 | this.Product = Product; 86 | } 87 | 88 | public List getProductList() { 89 | return ProductList; 90 | } 91 | 92 | public void setProductList(List ProductList) { 93 | this.ProductList = ProductList; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/Result.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | /** 4 | * 5 | * @Description: 封装json对象,所有返回结果都使用它 6 | * 7 | * @author: tyron 8 | * @date: 2018年9月22日 9 | */ 10 | public class Result { 11 | 12 | private boolean success;// 是否成功标志 13 | 14 | private T data;// 成功时返回的数据 15 | 16 | private String errorMsg;// 错误信息 17 | 18 | private int errorCode; 19 | 20 | public Result() { 21 | } 22 | 23 | // 成功时的构造器 24 | public Result(boolean success, T data) { 25 | this.success = success; 26 | this.data = data; 27 | } 28 | 29 | // 错误时的构造器 30 | public Result(boolean success, int errorCode, String errorMsg) { 31 | this.success = success; 32 | this.errorMsg = errorMsg; 33 | this.errorCode = errorCode; 34 | } 35 | 36 | public boolean isSuccess() { 37 | return success; 38 | } 39 | 40 | public void setSuccess(boolean success) { 41 | this.success = success; 42 | } 43 | 44 | public T getData() { 45 | return data; 46 | } 47 | 48 | public void setData(T data) { 49 | this.data = data; 50 | } 51 | 52 | public String getErrorMsg() { 53 | return errorMsg; 54 | } 55 | 56 | public void setErrorMsg(String errorMsg) { 57 | this.errorMsg = errorMsg; 58 | } 59 | 60 | public int getErrorCode() { 61 | return errorCode; 62 | } 63 | 64 | public void setErrorCode(int errorCode) { 65 | this.errorCode = errorCode; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/ShopCategoryExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.ShopCategory; 6 | import com.tyron.o2o.enums.OperationStatusEnum; 7 | import com.tyron.o2o.enums.ShopCategoryStateEnum; 8 | 9 | /** 10 | * @Description: 店铺类别类别返回结果信息 11 | * 12 | * @author tyronchen 13 | * @date 2018年11月29日 14 | */ 15 | public class ShopCategoryExecution { 16 | 17 | // 结果状态 18 | private int state; 19 | 20 | // 状态标识 21 | private String stateInfo; 22 | 23 | // 操作的shopCategory(增删改店铺类别的时候用) 24 | private ShopCategory shopCategory; 25 | 26 | // 获取的shopCategory列表(查询店铺类别列表的时候用) 27 | private List shopCategoryList; 28 | 29 | public ShopCategoryExecution() { 30 | } 31 | 32 | // 店铺类别操作失败的时候使用的构造器 33 | public ShopCategoryExecution(ShopCategoryStateEnum stateEnum) { 34 | this.state = stateEnum.getState(); 35 | this.stateInfo = stateEnum.getStateInfo(); 36 | } 37 | 38 | // 店铺类别操作成功的时候使用的构造器,基本操作 39 | public ShopCategoryExecution(OperationStatusEnum stateEnum, ShopCategory shopCategory) { 40 | this.state = stateEnum.getState(); 41 | this.stateInfo = stateEnum.getStateInfo(); 42 | this.shopCategory = shopCategory; 43 | } 44 | 45 | // 店铺类别操作成功的时候使用的构造器 46 | public ShopCategoryExecution(OperationStatusEnum stateEnum, List shopCategoryList) { 47 | this.state = stateEnum.getState(); 48 | this.stateInfo = stateEnum.getStateInfo(); 49 | this.shopCategoryList = shopCategoryList; 50 | } 51 | 52 | public int getState() { 53 | return state; 54 | } 55 | 56 | public void setState(int state) { 57 | this.state = state; 58 | } 59 | 60 | public String getStateInfo() { 61 | return stateInfo; 62 | } 63 | 64 | public void setStateInfo(String stateInfo) { 65 | this.stateInfo = stateInfo; 66 | } 67 | 68 | public ShopCategory getShopCategory() { 69 | return shopCategory; 70 | } 71 | 72 | public void setShopCategory(ShopCategory shopCategory) { 73 | this.shopCategory = shopCategory; 74 | } 75 | 76 | public List getShopCategoryList() { 77 | return shopCategoryList; 78 | } 79 | 80 | public void setShopCategoryList(List shopCategoryList) { 81 | this.shopCategoryList = shopCategoryList; 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/dto/ShopExecution.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.Shop; 6 | import com.tyron.o2o.enums.OperationStatusEnum; 7 | import com.tyron.o2o.enums.ShopStateEnum; 8 | 9 | /** 10 | * @Description: 店铺返回结果信息 11 | * 12 | * @author tyronchen 13 | * @date 2018年4月10日 14 | */ 15 | public class ShopExecution { 16 | 17 | // 结果状态 18 | private int state; 19 | 20 | // 状态标识 21 | private String stateInfo; 22 | 23 | // 店铺数量 24 | private int count; 25 | 26 | // 操作的shop(增删改店铺的时候用) 27 | private Shop shop; 28 | 29 | // 获取的shop列表(查询店铺列表的时候用) 30 | private List shopList; 31 | 32 | public ShopExecution() { 33 | } 34 | 35 | // 店铺操作失败的时候使用的构造器 36 | public ShopExecution(ShopStateEnum stateEnum) { 37 | this.state = stateEnum.getState(); 38 | this.stateInfo = stateEnum.getStateInfo(); 39 | } 40 | 41 | // 店铺操作成功的时候使用的构造器,基本操作 42 | public ShopExecution(OperationStatusEnum stateEnum, Shop shop) { 43 | this.state = stateEnum.getState(); 44 | this.stateInfo = stateEnum.getStateInfo(); 45 | this.shop = shop; 46 | } 47 | 48 | // 店铺操作成功的时候使用的构造器 49 | public ShopExecution(ShopStateEnum stateEnum, Shop shop) { 50 | this.state = stateEnum.getState(); 51 | this.stateInfo = stateEnum.getStateInfo(); 52 | this.shop = shop; 53 | } 54 | 55 | // 店铺操作成功的时候使用的构造器 56 | public ShopExecution(OperationStatusEnum stateEnum, List shopList) { 57 | this.state = stateEnum.getState(); 58 | this.stateInfo = stateEnum.getStateInfo(); 59 | this.shopList = shopList; 60 | } 61 | 62 | public int getState() { 63 | return state; 64 | } 65 | 66 | public void setState(int state) { 67 | this.state = state; 68 | } 69 | 70 | public String getStateInfo() { 71 | return stateInfo; 72 | } 73 | 74 | public void setStateInfo(String stateInfo) { 75 | this.stateInfo = stateInfo; 76 | } 77 | 78 | public int getCount() { 79 | return count; 80 | } 81 | 82 | public void setCount(int count) { 83 | this.count = count; 84 | } 85 | 86 | public Shop getShop() { 87 | return shop; 88 | } 89 | 90 | public void setShop(Shop shop) { 91 | this.shop = shop; 92 | } 93 | 94 | public List getShopList() { 95 | return shopList; 96 | } 97 | 98 | public void setShopList(List shopList) { 99 | this.shopList = shopList; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/Area.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 区域实体类 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class Area { 12 | 13 | // ID 14 | private Integer areaId; 15 | // 名称 16 | private String areaName; 17 | // 权重 18 | private Integer priority; 19 | // 创建时间 20 | private Date createTime; 21 | // 更新时间 22 | private Date lastEditTime; 23 | 24 | public Integer getAreaId() { 25 | return areaId; 26 | } 27 | 28 | public void setAreaId(Integer areaId) { 29 | this.areaId = areaId; 30 | } 31 | 32 | public String getAreaName() { 33 | return areaName; 34 | } 35 | 36 | public void setAreaName(String areaName) { 37 | this.areaName = areaName; 38 | } 39 | 40 | public Integer getPriority() { 41 | return priority; 42 | } 43 | 44 | public void setPriority(Integer priority) { 45 | this.priority = priority; 46 | } 47 | 48 | public Date getCreateTime() { 49 | return createTime; 50 | } 51 | 52 | public void setCreateTime(Date createTime) { 53 | this.createTime = createTime; 54 | } 55 | 56 | public Date getLastEditTime() { 57 | return lastEditTime; 58 | } 59 | 60 | public void setLastEditTime(Date lastEditTime) { 61 | this.lastEditTime = lastEditTime; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "Area [areaId=" + areaId + ", areaName=" + areaName + ", priority=" + priority + ", createTime=" 67 | + createTime + ", lastEditTime=" + lastEditTime + "]"; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/HeadLine.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 头条实体类 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月23日 10 | */ 11 | public class HeadLine { 12 | private Long lineId; 13 | private String lineName; 14 | private String lineLink; 15 | private String lineImg; 16 | private Integer priority; 17 | private Integer enableStatus; 18 | private Date createTime; 19 | private Date lastEditTime; 20 | 21 | public Long getLineId() { 22 | return lineId; 23 | } 24 | 25 | public void setLineId(Long lineId) { 26 | this.lineId = lineId; 27 | } 28 | 29 | public String getLineName() { 30 | return lineName; 31 | } 32 | 33 | public void setLineName(String lineName) { 34 | this.lineName = lineName; 35 | } 36 | 37 | public String getLineLink() { 38 | return lineLink; 39 | } 40 | 41 | public void setLineLink(String lineLink) { 42 | this.lineLink = lineLink; 43 | } 44 | 45 | public String getLineImg() { 46 | return lineImg; 47 | } 48 | 49 | public void setLineImg(String lineImg) { 50 | this.lineImg = lineImg; 51 | } 52 | 53 | public Integer getPriority() { 54 | return priority; 55 | } 56 | 57 | public void setPriority(Integer priority) { 58 | this.priority = priority; 59 | } 60 | 61 | public Integer getEnableStatus() { 62 | return enableStatus; 63 | } 64 | 65 | public void setEnableStatus(Integer enableStatus) { 66 | this.enableStatus = enableStatus; 67 | } 68 | 69 | public Date getCreateTime() { 70 | return createTime; 71 | } 72 | 73 | public void setCreateTime(Date createTime) { 74 | this.createTime = createTime; 75 | } 76 | 77 | public Date getLastEditTime() { 78 | return lastEditTime; 79 | } 80 | 81 | public void setLastEditTime(Date lastEditTime) { 82 | this.lastEditTime = lastEditTime; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/LocalAuth.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 本地用户信息 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class LocalAuth { 12 | // 主键ID 13 | private Long localAuthId; 14 | private String username; 15 | private String password; 16 | private Date createTime; 17 | private Date lastEditTime; 18 | // 个人信息 19 | private PersonInfo personInfo; 20 | 21 | public Long getLocalAuthId() { 22 | return localAuthId; 23 | } 24 | 25 | public void setLocalAuthId(Long localAuthId) { 26 | this.localAuthId = localAuthId; 27 | } 28 | 29 | public String getUsername() { 30 | return username; 31 | } 32 | 33 | public void setUsername(String username) { 34 | this.username = username; 35 | } 36 | 37 | public String getPassword() { 38 | return password; 39 | } 40 | 41 | public void setPassword(String password) { 42 | this.password = password; 43 | } 44 | 45 | public Date getCreateTime() { 46 | return createTime; 47 | } 48 | 49 | public void setCreateTime(Date createTime) { 50 | this.createTime = createTime; 51 | } 52 | 53 | public Date getLastEditTime() { 54 | return lastEditTime; 55 | } 56 | 57 | public void setLastEditTime(Date lastEditTime) { 58 | this.lastEditTime = lastEditTime; 59 | } 60 | 61 | public PersonInfo getPersonInfo() { 62 | return personInfo; 63 | } 64 | 65 | public void setPersonInfo(PersonInfo personInfo) { 66 | this.personInfo = personInfo; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/PersonInfo.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 用户信息 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class PersonInfo { 12 | 13 | private Long userId; 14 | private Long localAuthId; 15 | private String name; 16 | private String profileImg; 17 | private String gender; 18 | private String email; 19 | private Integer enableStatus; 20 | private Integer userType; 21 | private Date createTime; 22 | private Date lastEditTime; 23 | 24 | public Long getUserId() { 25 | return userId; 26 | } 27 | 28 | public void setUserId(Long userId) { 29 | this.userId = userId; 30 | } 31 | 32 | public Long getLocalAuthId() { 33 | return localAuthId; 34 | } 35 | 36 | public void setLocalAuthId(Long localAuthId) { 37 | this.localAuthId = localAuthId; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public String getProfileImg() { 49 | return profileImg; 50 | } 51 | 52 | public void setProfileImg(String profileImg) { 53 | this.profileImg = profileImg; 54 | } 55 | 56 | public String getGender() { 57 | return gender; 58 | } 59 | 60 | public void setGender(String gender) { 61 | this.gender = gender; 62 | } 63 | 64 | public String getEmail() { 65 | return email; 66 | } 67 | 68 | public void setEmail(String email) { 69 | this.email = email; 70 | } 71 | 72 | public Integer getEnableStatus() { 73 | return enableStatus; 74 | } 75 | 76 | public void setEnableStatus(Integer enableStatus) { 77 | this.enableStatus = enableStatus; 78 | } 79 | 80 | public Integer getUserType() { 81 | return userType; 82 | } 83 | 84 | public void setUserType(Integer userType) { 85 | this.userType = userType; 86 | } 87 | 88 | public Date getCreateTime() { 89 | return createTime; 90 | } 91 | 92 | public void setCreateTime(Date createTime) { 93 | this.createTime = createTime; 94 | } 95 | 96 | public Date getLastEditTime() { 97 | return lastEditTime; 98 | } 99 | 100 | public void setLastEditTime(Date lastEditTime) { 101 | this.lastEditTime = lastEditTime; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | /** 7 | * @Description: 商品实体类 8 | * 9 | * @author tyronchen 10 | * @date 2018年3月24日 11 | */ 12 | public class Product { 13 | private Long productId; 14 | private String productName; 15 | private String productDesc; 16 | private String imgAddr;// 简略图 17 | private String normalPrice;// 原价 18 | private String promotionPrice;// 折后价 19 | private Integer priority; 20 | private Date createTime; 21 | private Date lastEditTime; 22 | private Integer enableStatus;// 0、下架,1、在前端展示系统展示 23 | private Integer point; 24 | 25 | private List productImgList;// 产品对应的详情列表,一对多 26 | private ProductCategory productCategory;// 产品所属产品目录 27 | private Shop shop;// 产品所属店铺 28 | 29 | public Long getProductId() { 30 | return productId; 31 | } 32 | 33 | public void setProductId(Long productId) { 34 | this.productId = productId; 35 | } 36 | 37 | public String getProductName() { 38 | return productName; 39 | } 40 | 41 | public void setProductName(String productName) { 42 | this.productName = productName; 43 | } 44 | 45 | public String getProductDesc() { 46 | return productDesc; 47 | } 48 | 49 | public void setProductDesc(String productDesc) { 50 | this.productDesc = productDesc; 51 | } 52 | 53 | public String getImgAddr() { 54 | return imgAddr; 55 | } 56 | 57 | public void setImgAddr(String imgAddr) { 58 | this.imgAddr = imgAddr; 59 | } 60 | 61 | public String getNormalPrice() { 62 | return normalPrice; 63 | } 64 | 65 | public void setNormalPrice(String normalPrice) { 66 | this.normalPrice = normalPrice; 67 | } 68 | 69 | public String getPromotionPrice() { 70 | return promotionPrice; 71 | } 72 | 73 | public void setPromotionPrice(String promotionPrice) { 74 | this.promotionPrice = promotionPrice; 75 | } 76 | 77 | public Integer getPriority() { 78 | return priority; 79 | } 80 | 81 | public void setPriority(Integer priority) { 82 | this.priority = priority; 83 | } 84 | 85 | public Date getCreateTime() { 86 | return createTime; 87 | } 88 | 89 | public void setCreateTime(Date createTime) { 90 | this.createTime = createTime; 91 | } 92 | 93 | public Date getLastEditTime() { 94 | return lastEditTime; 95 | } 96 | 97 | public void setLastEditTime(Date lastEditTime) { 98 | this.lastEditTime = lastEditTime; 99 | } 100 | 101 | public Integer getEnableStatus() { 102 | return enableStatus; 103 | } 104 | 105 | public void setEnableStatus(Integer enableStatus) { 106 | this.enableStatus = enableStatus; 107 | } 108 | 109 | public Integer getPoint() { 110 | return point; 111 | } 112 | 113 | public void setPoint(Integer point) { 114 | this.point = point; 115 | } 116 | 117 | public List getProductImgList() { 118 | return productImgList; 119 | } 120 | 121 | public void setProductImgList(List productImgList) { 122 | this.productImgList = productImgList; 123 | } 124 | 125 | public ProductCategory getProductCategory() { 126 | return productCategory; 127 | } 128 | 129 | public void setProductCategory(ProductCategory productCategory) { 130 | this.productCategory = productCategory; 131 | } 132 | 133 | public Shop getShop() { 134 | return shop; 135 | } 136 | 137 | public void setShop(Shop shop) { 138 | this.shop = shop; 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/ProductCategory.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 商品类别实体类 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class ProductCategory { 12 | private Long productCategoryId; 13 | private Long shopId; 14 | private String productCategoryName; 15 | private String productCategoryDesc; 16 | private Integer priority; 17 | private Date createTime; 18 | private Date lastEditTime; 19 | 20 | public Long getProductCategoryId() { 21 | return productCategoryId; 22 | } 23 | 24 | public void setProductCategoryId(Long productCategoryId) { 25 | this.productCategoryId = productCategoryId; 26 | } 27 | 28 | public Long getShopId() { 29 | return shopId; 30 | } 31 | 32 | public void setShopId(Long shopId) { 33 | this.shopId = shopId; 34 | } 35 | 36 | public String getProductCategoryName() { 37 | return productCategoryName; 38 | } 39 | 40 | public void setProductCategoryName(String productCategoryName) { 41 | this.productCategoryName = productCategoryName; 42 | } 43 | 44 | public String getProductCategoryDesc() { 45 | return productCategoryDesc; 46 | } 47 | 48 | public void setProductCategoryDesc(String productCategoryDesc) { 49 | this.productCategoryDesc = productCategoryDesc; 50 | } 51 | 52 | public Integer getPriority() { 53 | return priority; 54 | } 55 | 56 | public void setPriority(Integer priority) { 57 | this.priority = priority; 58 | } 59 | 60 | public Date getCreateTime() { 61 | return createTime; 62 | } 63 | 64 | public void setCreateTime(Date createTime) { 65 | this.createTime = createTime; 66 | } 67 | 68 | public Date getLastEditTime() { 69 | return lastEditTime; 70 | } 71 | 72 | public void setLastEditTime(Date lastEditTime) { 73 | this.lastEditTime = lastEditTime; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/ProductImg.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 商品图片实体类 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class ProductImg { 12 | private Long productImgId; 13 | private String imgAddr; 14 | private String imgDesc; 15 | private Integer priority; 16 | private Date createTime; 17 | private Long productId; 18 | 19 | // 与product联合查询字段 20 | private String piImgAddr; 21 | private String piImgDesc; 22 | 23 | public Long getProductImgId() { 24 | return productImgId; 25 | } 26 | 27 | public void setProductImgId(Long productImgId) { 28 | this.productImgId = productImgId; 29 | } 30 | 31 | public String getImgAddr() { 32 | return imgAddr; 33 | } 34 | 35 | public void setImgAddr(String imgAddr) { 36 | this.imgAddr = imgAddr; 37 | } 38 | 39 | public String getImgDesc() { 40 | return imgDesc; 41 | } 42 | 43 | public void setImgDesc(String imgDesc) { 44 | this.imgDesc = imgDesc; 45 | } 46 | 47 | public Integer getPriority() { 48 | return priority; 49 | } 50 | 51 | public void setPriority(Integer priority) { 52 | this.priority = priority; 53 | } 54 | 55 | public Date getCreateTime() { 56 | return createTime; 57 | } 58 | 59 | public void setCreateTime(Date createTime) { 60 | this.createTime = createTime; 61 | } 62 | 63 | public Long getProductId() { 64 | return productId; 65 | } 66 | 67 | public void setProductId(Long productId) { 68 | this.productId = productId; 69 | } 70 | 71 | public String getPiImgAddr() { 72 | return piImgAddr; 73 | } 74 | 75 | public void setPiImgAddr(String piImgAddr) { 76 | this.piImgAddr = piImgAddr; 77 | } 78 | 79 | public String getPiImgDesc() { 80 | return piImgDesc; 81 | } 82 | 83 | public void setPiImgDesc(String piImgDesc) { 84 | this.piImgDesc = piImgDesc; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/ShopCategory.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 商品类别实体类 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class ShopCategory { 12 | 13 | private Long shopCategoryId; 14 | private String shopCategoryName; 15 | private String shopCategoryDesc; 16 | private String shopCategoryImg; 17 | private Integer priority; 18 | private Date createTime; 19 | private Date lastEditTime; 20 | private ShopCategory parent; 21 | 22 | public Long getShopCategoryId() { 23 | return shopCategoryId; 24 | } 25 | 26 | public void setShopCategoryId(Long shopCategoryId) { 27 | this.shopCategoryId = shopCategoryId; 28 | } 29 | 30 | public String getShopCategoryName() { 31 | return shopCategoryName; 32 | } 33 | 34 | public void setShopCategoryName(String shopCategoryName) { 35 | this.shopCategoryName = shopCategoryName; 36 | } 37 | 38 | public String getShopCategoryDesc() { 39 | return shopCategoryDesc; 40 | } 41 | 42 | public void setShopCategoryDesc(String shopCategoryDesc) { 43 | this.shopCategoryDesc = shopCategoryDesc; 44 | } 45 | 46 | public String getShopCategoryImg() { 47 | return shopCategoryImg; 48 | } 49 | 50 | public void setShopCategoryImg(String shopCategoryImg) { 51 | this.shopCategoryImg = shopCategoryImg; 52 | } 53 | 54 | public Integer getPriority() { 55 | return priority; 56 | } 57 | 58 | public void setPriority(Integer priority) { 59 | this.priority = priority; 60 | } 61 | 62 | public Date getCreateTime() { 63 | return createTime; 64 | } 65 | 66 | public void setCreateTime(Date createTime) { 67 | this.createTime = createTime; 68 | } 69 | 70 | public Date getLastEditTime() { 71 | return lastEditTime; 72 | } 73 | 74 | public void setLastEditTime(Date lastEditTime) { 75 | this.lastEditTime = lastEditTime; 76 | } 77 | 78 | public ShopCategory getParent() { 79 | return parent; 80 | } 81 | 82 | public void setParent(ShopCategory parent) { 83 | this.parent = parent; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/entity/WechatAuth.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.entity; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @Description: 微信用户实体类 7 | * 8 | * @author tyronchen 9 | * @date 2018年3月24日 10 | */ 11 | public class WechatAuth { 12 | private Long wechatAuthId; 13 | private Long userId; 14 | private String openId; 15 | private Date createTime; 16 | private PersonInfo personInfo; 17 | 18 | public Long getWechatAuthId() { 19 | return wechatAuthId; 20 | } 21 | 22 | public void setWechatAuthId(Long wechatAuthId) { 23 | this.wechatAuthId = wechatAuthId; 24 | } 25 | 26 | public Long getUserId() { 27 | return userId; 28 | } 29 | 30 | public void setUserId(Long userId) { 31 | this.userId = userId; 32 | } 33 | 34 | public String getOpenId() { 35 | return openId; 36 | } 37 | 38 | public void setOpenId(String openId) { 39 | this.openId = openId; 40 | } 41 | 42 | public Date getCreateTime() { 43 | return createTime; 44 | } 45 | 46 | public void setCreateTime(Date createTime) { 47 | this.createTime = createTime; 48 | } 49 | 50 | public PersonInfo getPersonInfo() { 51 | return personInfo; 52 | } 53 | 54 | public void setPersonInfo(PersonInfo personInfo) { 55 | this.personInfo = personInfo; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/EnableStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 使用状态枚举 5 | * 6 | * @author tyronchen 7 | * @date 2018年4月15日 8 | */ 9 | public enum EnableStatusEnum { 10 | UNAVAILABLE(0, "不可用"), AVAILABLE(1, "可用"), CHECK(2, "审核中"); 11 | private int state; 12 | private String stateInfo; 13 | 14 | private EnableStatusEnum(int state, String stateInfo) { 15 | this.state = state; 16 | this.stateInfo = stateInfo; 17 | } 18 | 19 | public int getState() { 20 | return state; 21 | } 22 | 23 | public String getStateInfo() { 24 | return stateInfo; 25 | } 26 | 27 | // 根据传入的state值返回相应的状态值 28 | public static EnableStatusEnum stateOf(int index) { 29 | for (EnableStatusEnum state : values()) { 30 | if (state.getState() == index) { 31 | return state; 32 | } 33 | } 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/HeadLineStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 头条状态枚举类 5 | * 6 | * @author tyronchen 7 | * @date 2019年1月23日 8 | */ 9 | public enum HeadLineStateEnum { 10 | 11 | EMPTY(-2001, "头条信息为空"), EDIT_ERROR(-2002, "编辑头条信息失败"), DELETE_ERROR(-2003, "删除头条信息失败"); 12 | 13 | private int state; 14 | 15 | private String stateInfo; 16 | 17 | private HeadLineStateEnum(int state, String stateInfo) { 18 | this.state = state; 19 | this.stateInfo = stateInfo; 20 | } 21 | 22 | public int getState() { 23 | return state; 24 | } 25 | 26 | public String getStateInfo() { 27 | return stateInfo; 28 | } 29 | 30 | public static HeadLineStateEnum stateOf(int index) { 31 | for (HeadLineStateEnum state : values()) { 32 | if (state.getState() == index) { 33 | return state; 34 | } 35 | } 36 | return null; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/LocalAuthStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 本地账号信息操作枚举类 5 | * 6 | * @author tyronchen 7 | * @date 2019年5月20日 8 | */ 9 | public enum LocalAuthStateEnum { 10 | LOGINFAIL(-1, "密码或帐号输入有误"), NULL_AUTH_INFO(-1001, "注册信息为空"), ERROR_UPDATE(-1002, "更新失败,用户名或密码输入有误"); 11 | 12 | private int state; 13 | 14 | private String stateInfo; 15 | 16 | private LocalAuthStateEnum(int state, String stateInfo) { 17 | this.state = state; 18 | this.stateInfo = stateInfo; 19 | } 20 | 21 | public int getState() { 22 | return state; 23 | } 24 | 25 | public String getStateInfo() { 26 | return stateInfo; 27 | } 28 | 29 | public static LocalAuthStateEnum stateOf(int index) { 30 | for (LocalAuthStateEnum state : values()) { 31 | if (state.getState() == index) { 32 | return state; 33 | } 34 | } 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/OperationStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 操作状态枚举 5 | * 6 | * @author tyronchen 7 | * @date 2018年11月29日 8 | */ 9 | public enum OperationStatusEnum { 10 | 11 | SUCCESS(1, "操作成功"), ERROR(-1001, "操作失败"), VERIFYCODE_ERROR(-1002, "验证码输入有误,请重新输入"), PIC_EMPTY(-1003, "上传图片不能为空"), 12 | PIC_UPLOAD_ERROR(-1004, "创建图片失败"), PAGIN_EMPTY(-1005, "缺少分页参数"); 13 | 14 | private int state; 15 | private String stateInfo; 16 | 17 | private OperationStatusEnum(int state, String stateInfo) { 18 | this.state = state; 19 | this.stateInfo = stateInfo; 20 | } 21 | 22 | public int getState() { 23 | return state; 24 | } 25 | 26 | public String getStateInfo() { 27 | return stateInfo; 28 | } 29 | 30 | // 根据传入的state值返回相应的状态值 31 | public static OperationStatusEnum stateOf(int index) { 32 | for (OperationStatusEnum state : values()) { 33 | if (state.getState() == index) { 34 | return state; 35 | } 36 | } 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/PersonInfoStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 用户信息操作枚举类 5 | * 6 | * @author tyronchen 7 | * @date 2019年6月5日 8 | */ 9 | public enum PersonInfoStateEnum { 10 | NULL_PERSON_INFO(-1001, "注册信息为空"); 11 | 12 | private int state; 13 | 14 | private String stateInfo; 15 | 16 | private PersonInfoStateEnum(int state, String stateInfo) { 17 | this.state = state; 18 | this.stateInfo = stateInfo; 19 | } 20 | 21 | public int getState() { 22 | return state; 23 | } 24 | 25 | public String getStateInfo() { 26 | return stateInfo; 27 | } 28 | 29 | public static PersonInfoStateEnum stateOf(int index) { 30 | for (PersonInfoStateEnum state : values()) { 31 | if (state.getState() == index) { 32 | return state; 33 | } 34 | } 35 | return null; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/PersonInfoStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 用户可用状态信息 5 | * 6 | * @author tyronchen 7 | * @date 2019年6月2日 8 | */ 9 | public enum PersonInfoStatusEnum { 10 | 11 | ALLOW(1, "允许"), NOT_ALLOW(0, "不允许"); 12 | private int state; 13 | private String stateInfo; 14 | 15 | private PersonInfoStatusEnum(int state, String stateInfo) { 16 | this.state = state; 17 | this.stateInfo = stateInfo; 18 | } 19 | 20 | public int getState() { 21 | return state; 22 | } 23 | 24 | public String getStateInfo() { 25 | return stateInfo; 26 | } 27 | 28 | // 根据传入的state值返回相应的状态值 29 | public static PersonInfoStatusEnum stateOf(int index) { 30 | for (PersonInfoStatusEnum state : values()) { 31 | if (state.getState() == index) { 32 | return state; 33 | } 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/PersonInfoTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 用户身份状态信息 5 | * 6 | * @author tyronchen 7 | * @date 2019年6月2日 8 | */ 9 | public enum PersonInfoTypeEnum { 10 | 11 | CUSTOMER(1, "顾客"), OWNER(2, "店家"), ADMIN(3, "管理员"); 12 | private int state; 13 | private String stateInfo; 14 | 15 | private PersonInfoTypeEnum(int state, String stateInfo) { 16 | this.state = state; 17 | this.stateInfo = stateInfo; 18 | } 19 | 20 | public int getState() { 21 | return state; 22 | } 23 | 24 | public String getStateInfo() { 25 | return stateInfo; 26 | } 27 | 28 | // 根据传入的state值返回相应的状态值 29 | public static PersonInfoTypeEnum stateOf(int index) { 30 | for (PersonInfoTypeEnum state : values()) { 31 | if (state.getState() == index) { 32 | return state; 33 | } 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/ProductCategoryStateEnum.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.tyron.o2o.enums; 5 | 6 | /** 7 | * @Description: 商品类别状态枚举 8 | * 9 | * @author: tyron 10 | * @date: 2018年9月22日 11 | */ 12 | 13 | public enum ProductCategoryStateEnum { 14 | 15 | NULL_SHOP(-2001, "Shop信息为空"), EMPETY_LIST(-2002, "请输入商品目录信息"), DELETE_ERROR(-2003, "商品类别删除失败"), EDIT_ERROR(-2004, "商品类别编辑失败"); 16 | 17 | private int state; 18 | private String stateInfo; 19 | 20 | /** 21 | * @Description:构造函数 22 | * 23 | * @param state 24 | * @param stateInfo 25 | */ 26 | private ProductCategoryStateEnum(int state, String stateInfo) { 27 | this.state = state; 28 | this.stateInfo = stateInfo; 29 | } 30 | 31 | public int getState() { 32 | return state; 33 | } 34 | 35 | public String getStateInfo() { 36 | return stateInfo; 37 | } 38 | 39 | /** 40 | * @Description: 通过state获取productCategoryStateEnum,从而可以调用ProductCategoryStateEnum 41 | * #getStateInfo()获取stateInfo 42 | * 43 | * @param index 44 | */ 45 | public static ProductCategoryStateEnum stateOf(int index) { 46 | for (ProductCategoryStateEnum productCategoryStateEnum : values()) { 47 | if (productCategoryStateEnum.getState() == index) { 48 | return productCategoryStateEnum; 49 | } 50 | } 51 | return null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/ProductStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 商品状态枚举 5 | * 6 | * @author: tyron 7 | * @date: 2018年10月27日 8 | */ 9 | public enum ProductStateEnum { 10 | 11 | PRODUCT_EMPTY(-2001, "请输入商品信息"), EDIT_ERROR(-2002, "商品编辑失败"), EMPTY(-2003, "商品为空"), 12 | PRODUCT_ID_EMPTY(-2004, "商品ID为空"),; 13 | 14 | private int state; 15 | private String stateInfo; 16 | 17 | /** 18 | * @Description:私有构造函数,禁止外部初始化改变定义的常量 19 | * 20 | * @param state 21 | * @param stateInfo 22 | */ 23 | private ProductStateEnum(int state, String stateInfo) { 24 | this.state = state; 25 | this.stateInfo = stateInfo; 26 | } 27 | 28 | /** 29 | * @Description: 仅设置get方法,禁用set 30 | */ 31 | public int getState() { 32 | return state; 33 | } 34 | 35 | public String getStateInfo() { 36 | return stateInfo; 37 | } 38 | 39 | /** 40 | * 41 | * @Description: 定义换成pulic static 暴漏给外部,通过state获取ShopStateEnum 42 | * values()获取全部的enum常量 43 | * 44 | * @param state 45 | * @return: ShopStateEnum 46 | */ 47 | public static ProductStateEnum stateOf(int state) { 48 | for (ProductStateEnum stateEnum : values()) { 49 | if (stateEnum.getState() == state) { 50 | return stateEnum; 51 | } 52 | } 53 | return null; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/ShopCategoryStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 店铺类别 5 | * 6 | * @author: tyron 7 | * @date: 2018年11月29日 8 | */ 9 | 10 | public enum ShopCategoryStateEnum { 11 | 12 | EDIT_ERROR(-2001, "店铺编辑失败"), NULL_SHOP_CATEGORY(-2002, "shopCategory信息为空"); 13 | 14 | private int state; 15 | private String stateInfo; 16 | 17 | /** 18 | * @Description:构造函数 19 | * 20 | * @param state 21 | * @param stateInfo 22 | */ 23 | private ShopCategoryStateEnum(int state, String stateInfo) { 24 | this.state = state; 25 | this.stateInfo = stateInfo; 26 | } 27 | 28 | public int getState() { 29 | return state; 30 | } 31 | 32 | public String getStateInfo() { 33 | return stateInfo; 34 | } 35 | 36 | /** 37 | * @Description: 通过state获取shopCategoryStateEnum, 从而可以调用ShopCategoryStateEnum 38 | * #getStateInfo()获取stateInfo 39 | * 40 | * @param index 41 | */ 42 | public static ShopCategoryStateEnum stateOf(int index) { 43 | for (ShopCategoryStateEnum shopCategoryStateEnum : values()) { 44 | if (shopCategoryStateEnum.getState() == index) { 45 | return shopCategoryStateEnum; 46 | } 47 | } 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/enums/ShopStateEnum.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.enums; 2 | 3 | /** 4 | * @Description: 店铺状态枚举 5 | * 6 | * @author tyronchen 7 | * @date 2018年4月10日 8 | */ 9 | public enum ShopStateEnum { 10 | CHECK(0, "审核中"), PASS(1, "通过认证"), OFFLINE(-2001, "非法商铺"), EDIT_ERROR(-2002, "店铺操作失败"), 11 | NULL_SHOPID(-2003, "ShopId为空"), NULL_SHOP_INFO(-2004, "店铺信息为空"); 12 | 13 | private int state; 14 | private String stateInfo; 15 | 16 | private ShopStateEnum(int state, String stateInfo) { 17 | this.state = state; 18 | this.stateInfo = stateInfo; 19 | } 20 | 21 | public int getState() { 22 | return state; 23 | } 24 | 25 | public String getStateInfo() { 26 | return stateInfo; 27 | } 28 | 29 | // 根据传入的state值返回相应的状态值 30 | public static ShopStateEnum stateOf(int index) { 31 | for (ShopStateEnum state : values()) { 32 | if (state.getState() == index) { 33 | return state; 34 | } 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/AreaOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 区域操作异常 5 | * 6 | * @author tyronchen 7 | * @date 2018年12月15日 8 | */ 9 | public class AreaOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public AreaOperationException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/HeadLineOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 头条操作异常 5 | * 6 | * @author tyronchen 7 | * @date 2019年1月24日 8 | */ 9 | public class HeadLineOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public HeadLineOperationException(String msg) { 14 | super(msg); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/LocalAuthOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 本地账号操作异常 5 | * 6 | * @author tyronchen 7 | * @date 2019年5月20日 8 | */ 9 | public class LocalAuthOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public LocalAuthOperationException(String msg) { 14 | super(msg); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/PersonInfoOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 用户信息操作异常 5 | * 6 | * @author tyronchen 7 | * @date 2019年6月5日 8 | */ 9 | public class PersonInfoOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public PersonInfoOperationException(String msg) { 14 | super(msg); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/ProductCategoryOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 商品类别操作异常 5 | * 6 | * @author: tyron 7 | * @date: 2018年9月22日 8 | */ 9 | public class ProductCategoryOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public ProductCategoryOperationException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/ProductOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 商品操作异常 5 | * 6 | * @author: tyron 7 | * @date: 2018年10月27日 8 | */ 9 | public class ProductOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public ProductOperationException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/ShopCategoryOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 店铺类别操作异常 5 | * 6 | * @author tyronchen 7 | * @date 2018年11月29日 8 | */ 9 | public class ShopCategoryOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public ShopCategoryOperationException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/exceptions/ShopOperationException.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.exceptions; 2 | 3 | /** 4 | * @Description: 店铺操作异常 5 | * 6 | * @author tyronchen 7 | * @date 2018年4月15日 8 | */ 9 | public class ShopOperationException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public ShopOperationException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/interceptor/shopadmin/ShopLoginInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.interceptor.shopadmin; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 7 | 8 | import com.tyron.o2o.entity.PersonInfo; 9 | import com.tyron.o2o.enums.EnableStatusEnum; 10 | import com.tyron.o2o.enums.PersonInfoTypeEnum; 11 | 12 | /** 13 | * @Description: 店家管理系统登录拦截器 14 | * 15 | * @author tyronchen 16 | * @date 2019年5月17日 17 | */ 18 | public class ShopLoginInterceptor extends HandlerInterceptorAdapter { 19 | 20 | /** 21 | * 主要做事前拦截,即用户操作前执行,改写preHandler里的逻辑,进行用户操作权限的拦截 22 | * 23 | * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(javax.servlet.http.HttpServletRequest, 24 | * javax.servlet.http.HttpServletResponse, java.lang.Object) 25 | */ 26 | @Override 27 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 28 | throws Exception { 29 | System.out.println(">>>ShopLoginInterceptor>>>>>>>在请求处理之前进行调用(Controller方法调用之前)"); 30 | // 从session中获取用户信息 31 | Object userObj = request.getSession().getAttribute("user"); 32 | // 如果用户信息存在 33 | if (userObj != null) { 34 | // 将session中的用户信息转换为PersonInfo实体类对象 35 | PersonInfo user = (PersonInfo) userObj; 36 | // 用户存在且可用,并且用户类型为店家或者管理员 37 | if (user != null && user.getUserId() != null && user.getUserId() > 0 38 | && user.getEnableStatus().equals(EnableStatusEnum.AVAILABLE.getState()) 39 | && (user.getUserType().equals(PersonInfoTypeEnum.OWNER.getState()) 40 | || user.getUserType().equals(PersonInfoTypeEnum.ADMIN.getState()))) { 41 | // 如果通过验证,则返回true,用户正常执行后续操作 42 | return true; 43 | } 44 | } 45 | // 不满足登录条件,则直接跳转后台用户登录页面 46 | String loginUrl = request.getContextPath() + "/admin/login?userType=back"; 47 | response.sendRedirect(loginUrl); 48 | return false; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/interceptor/shopadmin/ShopPermissionInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.interceptor.shopadmin; 2 | 3 | import java.util.List; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 9 | 10 | import com.tyron.o2o.entity.Shop; 11 | 12 | /** 13 | * @Description: 店铺操作权限拦截器 14 | * 15 | * @author tyronchen 16 | * @date 2019年6月24日 17 | */ 18 | public class ShopPermissionInterceptor extends HandlerInterceptorAdapter { 19 | 20 | @Override 21 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 22 | throws Exception { 23 | System.out.println(">>>ShopPermissionInterceptor>>>>>>>在请求处理之前进行调用(Controller方法调用之前)"); 24 | // 从session中获取当前选择的店铺 25 | Shop currentShop = (Shop) request.getSession().getAttribute("currentShop"); 26 | @SuppressWarnings("unchecked") 27 | // 获取session中当前用户可操作的店铺列表 28 | List shopList = (List) request.getSession().getAttribute("shopList"); 29 | // 非空判断 30 | if (currentShop != null && shopList != null) { 31 | // 遍历 32 | for (Shop shop : shopList) { 33 | // 如果当前店铺在可操作的列表则返回true,进行后续操作 34 | if (shop.getShopId() == currentShop.getShopId()) { 35 | return true; 36 | } 37 | } 38 | } 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/AreaService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.util.List; 4 | 5 | import com.tyron.o2o.entity.Area; 6 | 7 | /** 8 | * @Description: 区域业务接口 9 | * 10 | * @author tyronchen 11 | * @date 2018年3月24日 12 | */ 13 | public interface AreaService { 14 | public final static String AREA_LIST_KEY = "arealist"; 15 | 16 | /** 17 | * 获取区域列表,将区域信息放入缓存中 18 | * 19 | * @return 20 | */ 21 | List getAreaList(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/CacheService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | /** 4 | * @Description: 缓存服务接口 5 | * 6 | * @author tyronchen 7 | * @date 2019年1月26日 8 | */ 9 | public interface CacheService { 10 | 11 | /** 12 | * 依据key前缀匹配原则删除缓存数据 13 | * 14 | * @param keyPrefix 15 | */ 16 | void removeFromCache(String keyPrefix); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/HeadLineService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import org.springframework.web.multipart.MultipartFile; 7 | 8 | import com.tyron.o2o.dto.HeadLineExecution; 9 | import com.tyron.o2o.entity.HeadLine; 10 | 11 | /** 12 | * @Description: 首页头条业务接口 13 | * 14 | * @author: tyron 15 | * @date: 2018年11月26日 16 | */ 17 | 18 | public interface HeadLineService { 19 | public final static String HL_LIST_KEY = "headlinelist"; 20 | 21 | /** 22 | * 根据条件查询头条列表 23 | * 24 | * @param headLineCondition 25 | * @return 26 | * @throws IOException 27 | */ 28 | List getHeadLineList(HeadLine headLineCondition) throws IOException; 29 | 30 | /** 31 | * 添加头条记录 32 | * 33 | * @param headLine 34 | * @param headLineImg 35 | * @return 36 | */ 37 | HeadLineExecution addHeadLine(HeadLine headLine, MultipartFile headLineImg); 38 | 39 | /** 40 | * 修改头条记录 41 | * 42 | * @param headLine 43 | * @param headLineImg 44 | * @return 45 | */ 46 | HeadLineExecution modifyHeadLine(HeadLine headLine, MultipartFile headLineImg); 47 | 48 | /** 49 | * 删除头条 50 | * 51 | * @param headLineId 52 | * @return 53 | */ 54 | HeadLineExecution removeHeadLine(long headLineId); 55 | 56 | /** 57 | * 删除头条列表 58 | * 59 | * @param headLineIdList 60 | * @return 61 | */ 62 | HeadLineExecution removeHeadLineList(List headLineIdList); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/LocalAuthService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import com.tyron.o2o.dto.LocalAuthExecution; 4 | import com.tyron.o2o.entity.LocalAuth; 5 | import com.tyron.o2o.exceptions.LocalAuthOperationException; 6 | 7 | /** 8 | * @Description: 本地用户信息服务层接口 9 | * 10 | * @author tyronchen 11 | * @date 2019年5月20日 12 | */ 13 | public interface LocalAuthService { 14 | 15 | /** 16 | * 根据用户名、密码查询本地用户信息 17 | * 18 | * @param username 用户名 19 | * @param password 密码 20 | * @return 用户信息 21 | */ 22 | LocalAuth getLocalAuthByUsernameAndPwd(String username, String password); 23 | 24 | /** 25 | * 根据用户名查询本地用户信息 26 | * 27 | * @param username 用户名 28 | * @return 用户信息 29 | */ 30 | LocalAuth getLocalAuthByUsername(String username); 31 | 32 | /** 33 | * 根据用户ID查询本地用户信息 34 | * 35 | * @param localAuthId 用户ID 36 | * @return 用户信息 37 | */ 38 | LocalAuth queryLocalByLocalAuthId(long localAuthId); 39 | 40 | /** 41 | * 保存本地账号信息 42 | * 43 | * @param localAuth 本地用户 44 | * @return 操作返回信息 45 | * @throws LocalAuthOperationException 继承runtimeException结合事务使用 46 | */ 47 | LocalAuthExecution saveLocalAuth(LocalAuth localAuth) throws LocalAuthOperationException; 48 | 49 | /** 50 | * 修改本地账号登录密码 51 | * 52 | * @param username 用户名 53 | * @param password 原密码 54 | * @param newPassword 新密码 55 | * @return 操作返回信息 56 | * @throws LocalAuthOperationException 继承runtimeException结合事务使用 57 | */ 58 | LocalAuthExecution modifyLocalAuth(String username, String password, String newPassword) 59 | throws LocalAuthOperationException; 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/PersonInfoService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import com.tyron.o2o.dto.PersonInfoExecution; 4 | import com.tyron.o2o.entity.PersonInfo; 5 | 6 | /** 7 | * @Description: 用户信息服务层接口 8 | * 9 | * @author tyronchen 10 | * @date 2019年6月5日 11 | */ 12 | public interface PersonInfoService { 13 | 14 | /** 15 | * 根据用户ID查询用户信息 16 | * 17 | * @param userId 用户ID 18 | * @return 用户信息 19 | */ 20 | PersonInfo queryInfoByUserId(long userId); 21 | 22 | /** 23 | * 添加平台账号 24 | * 25 | * @param user 用户信息 26 | * @return 操作返回信息 27 | */ 28 | PersonInfoExecution insertPersonInfo(PersonInfo user); 29 | 30 | /** 31 | * 修改用户信息 32 | * 33 | * @param user 用户信息 34 | * @return 操作返回信息 35 | */ 36 | PersonInfoExecution updatePersonInfo(PersonInfo user); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/ProductCategoryService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.tyron.o2o.service; 5 | 6 | import java.util.List; 7 | 8 | import com.tyron.o2o.dto.ProductCategoryExecution; 9 | import com.tyron.o2o.entity.ProductCategory; 10 | import com.tyron.o2o.exceptions.ProductCategoryOperationException; 11 | 12 | /** 13 | * @Description: 店铺的商品类别业务接口 14 | * 15 | * @author: tyron 16 | * @date: 2018年9月21日 17 | */ 18 | 19 | public interface ProductCategoryService { 20 | 21 | /** 22 | * 查询指定某个店铺下的所有商品列表信息 23 | * 24 | * @param shopId 25 | * @return 26 | */ 27 | List getProductCategoryList(Long shopId); 28 | 29 | /** 30 | * 批量添加商品类别 31 | * 32 | * @param productCategoryList 33 | * @return 34 | * @throws ProductCategoryOperationException 35 | */ 36 | ProductCategoryExecution batchAddProductCategory(List productCategoryList) 37 | throws ProductCategoryOperationException; 38 | 39 | /** 40 | * 将此类别下的商品里的类别id置空,再删除该商品类别 41 | * 42 | * @param productCategoryId 43 | * @param shopId 44 | * @return 45 | * @throws ProductCategoryOperationException 46 | */ 47 | ProductCategoryExecution deleteProductCategory(long productCategoryId, long shopId) 48 | throws ProductCategoryOperationException; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | import com.tyron.o2o.dto.ProductExecution; 8 | import com.tyron.o2o.entity.Product; 9 | import com.tyron.o2o.exceptions.ProductOperationException; 10 | 11 | /** 12 | * @Description: 商品业务接口 13 | * 14 | * @author: tyron 15 | * @date: 2018年10月27日 16 | */ 17 | 18 | public interface ProductService { 19 | 20 | /** 21 | * 添加商品信息以及图片处理 22 | * 23 | * @param product 商品信息 24 | * @param productImg 商品缩略图 25 | * @param productImgList 商品图片列表 26 | * @return 27 | * @throws ProductOperationException 28 | */ 29 | ProductExecution addProduct(Product product, MultipartFile productImg, List productImgList) 30 | throws ProductOperationException; 31 | 32 | /** 33 | * 查询商品列表并分页,可输入的条件有:商品名(模糊),商品状态,店铺Id,商品类别 34 | * 35 | * @param productCondition 查询条件 36 | * @param pageIndex 页码 37 | * @param pageSize 每页条数 38 | * @return 39 | */ 40 | ProductExecution getProductList(Product productCondition, int pageIndex, int pageSize); 41 | 42 | /** 43 | * 根据商品Id查询商品详情 44 | * 45 | * @param productId 商品ID 46 | * @return 47 | */ 48 | Product getProductById(long productId); 49 | 50 | /** 51 | * 修改商品信息以及图片处理 52 | * 53 | * @param product 商品信息 54 | * @param productImg 商品缩略图 55 | * @param productImgList 商品图片列表 56 | * @return 57 | * @throws ProductOperationException 58 | */ 59 | ProductExecution modifyProduct(Product product, MultipartFile productImg, List productImgList) 60 | throws ProductOperationException; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/ShopCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | import com.tyron.o2o.dto.ShopCategoryExecution; 8 | import com.tyron.o2o.entity.ShopCategory; 9 | 10 | /** 11 | * @Description: 店鋪类别业务接口 12 | * 13 | * @author tyronchen 14 | * @date 2018年5月27日 15 | */ 16 | public interface ShopCategoryService { 17 | public final static String SC_LIST_KEY = "shopcategorylist"; 18 | 19 | /** 20 | * 条件获取店铺类别分页列表 21 | * 22 | * @param shopCategoryCondition 查询条件 23 | * @return 24 | */ 25 | List getShopCategoryList(ShopCategory shopCategoryCondition); 26 | 27 | /** 28 | * 新增商品分类 29 | * 30 | * @param shopCategory 31 | * @param shopCategoryImg 32 | * @return 33 | */ 34 | ShopCategoryExecution addShopCategory(ShopCategory shopCategory, MultipartFile shopCategoryImg); 35 | 36 | /** 37 | * 修改商品分类 38 | * 39 | * @param shopCategory 40 | * @return 41 | */ 42 | ShopCategoryExecution modifyShopCategory(ShopCategory shopCategory, MultipartFile shopCategoryImg); 43 | 44 | /** 45 | * 根据Id查询商品分类信息 46 | * 47 | * @param shopCategory 48 | * @return 49 | */ 50 | ShopCategory getShopCategoryById(long shopCategoryId); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/ShopService.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | import com.tyron.o2o.dto.ShopExecution; 6 | import com.tyron.o2o.entity.Shop; 7 | import com.tyron.o2o.exceptions.ShopOperationException; 8 | 9 | /** 10 | * @Description: 店铺业务接口 11 | * 12 | * @author tyronchen 13 | * @date 2018年4月13日 14 | */ 15 | public interface ShopService { 16 | 17 | /** 18 | * 根据id查询店铺详情 19 | * 20 | * @param shopId 21 | * @return 22 | */ 23 | Shop getByShopId(long shopId); 24 | 25 | /** 26 | * 添加店铺 27 | * 28 | * @param shop 29 | * @param shopImg 30 | * @return 31 | */ 32 | ShopExecution addShop(Shop shop, MultipartFile shopImg) throws ShopOperationException; 33 | 34 | /** 35 | * 修改店铺 36 | * 37 | * @param shop 38 | * @param shopImg 39 | * @return 40 | */ 41 | ShopExecution modifyShop(Shop shop, MultipartFile shopImg) throws ShopOperationException; 42 | 43 | /** 44 | * 获取店铺分页列表 45 | * 46 | * @param shopCondition 店铺查询条件 47 | * @param pageIndex 第几页 48 | * @param pageSize 每页条数 49 | * @return 50 | * @throws ShopOperationException 51 | */ 52 | ShopExecution getShopList(Shop shopCondition, int pageIndex, int pageSize) throws ShopOperationException; 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/impl/AreaServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service.impl; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import com.fasterxml.jackson.core.JsonParseException; 14 | import com.fasterxml.jackson.core.JsonProcessingException; 15 | import com.fasterxml.jackson.databind.JavaType; 16 | import com.fasterxml.jackson.databind.JsonMappingException; 17 | import com.fasterxml.jackson.databind.ObjectMapper; 18 | import com.tyron.o2o.cache.JedisUtil; 19 | import com.tyron.o2o.dao.AreaDao; 20 | import com.tyron.o2o.entity.Area; 21 | import com.tyron.o2o.exceptions.AreaOperationException; 22 | import com.tyron.o2o.service.AreaService; 23 | 24 | /** 25 | * @Description: 区域业务接口实现 26 | * 27 | * @author tyronchen 28 | * @date 2018年3月24日 29 | */ 30 | @Service 31 | public class AreaServiceImpl implements AreaService { 32 | 33 | @Autowired 34 | private AreaDao areaDao; 35 | @Autowired 36 | private JedisUtil.Keys jedisKeys; 37 | @Autowired 38 | private JedisUtil.Strings jedisStrings; 39 | 40 | private static Logger logger = LoggerFactory.getLogger(AreaServiceImpl.class); 41 | 42 | /* 43 | * (non-Javadoc) 44 | * 45 | * @see com.tyron.o2o.service.AreaService#getAreaList() 46 | */ 47 | @Override 48 | @Transactional 49 | public List getAreaList() { 50 | // key 51 | String key = AREA_LIST_KEY; 52 | List areaList = null; 53 | ObjectMapper mapper = new ObjectMapper(); 54 | // 如果Redis中未存在key 55 | if (!jedisKeys.exists(key)) { 56 | // 数据库中获取区域列表 57 | areaList = areaDao.selectArea(); 58 | String jsonString = null; 59 | // 将list转换为String 60 | try { 61 | jsonString = mapper.writeValueAsString(areaList); 62 | } catch (JsonProcessingException e) { 63 | e.printStackTrace(); 64 | logger.error(e.getMessage()); 65 | throw new AreaOperationException(e.getMessage()); 66 | } 67 | jedisStrings.set(key, jsonString); 68 | } 69 | // Redis中存在key,则取出 70 | else { 71 | // 将String转换为List 72 | String jsonString = jedisStrings.get(key); 73 | JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, Area.class); 74 | try { 75 | areaList = mapper.readValue(jsonString, javaType); 76 | } catch (JsonParseException e) { 77 | e.printStackTrace(); 78 | logger.error(e.getMessage()); 79 | throw new AreaOperationException(e.getMessage()); 80 | } catch (JsonMappingException e) { 81 | e.printStackTrace(); 82 | logger.error(e.getMessage()); 83 | throw new AreaOperationException(e.getMessage()); 84 | } catch (IOException e) { 85 | e.printStackTrace(); 86 | logger.error(e.getMessage()); 87 | throw new AreaOperationException(e.getMessage()); 88 | } 89 | } 90 | 91 | return areaList; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/impl/CacheServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service.impl; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.tyron.o2o.cache.JedisUtil; 9 | import com.tyron.o2o.service.CacheService; 10 | 11 | /** 12 | * @Description: 缓存服务接口实现 13 | * 14 | * @author tyronchen 15 | * @date 2019年1月26日 16 | */ 17 | @Service 18 | public class CacheServiceImpl implements CacheService { 19 | 20 | @Autowired 21 | private JedisUtil.Keys jedisKeys; 22 | 23 | /* 24 | * (non-Javadoc) 25 | * 26 | * @see com.tyron.o2o.service.CacheService#removeFromCache(java.lang.String) 27 | */ 28 | @Override 29 | public void removeFromCache(String keyPrefix) { 30 | Set keySet = jedisKeys.keys(keyPrefix + "*"); 31 | for (String key : keySet) { 32 | jedisKeys.del(key); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/service/impl/PersonInfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service.impl; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.tyron.o2o.dao.PersonInfoDao; 9 | import com.tyron.o2o.dto.PersonInfoExecution; 10 | import com.tyron.o2o.entity.PersonInfo; 11 | import com.tyron.o2o.enums.OperationStatusEnum; 12 | import com.tyron.o2o.enums.PersonInfoStateEnum; 13 | import com.tyron.o2o.exceptions.PersonInfoOperationException; 14 | import com.tyron.o2o.service.PersonInfoService; 15 | 16 | /** 17 | * @Description: 用户信息服务层接口实现类 18 | * 19 | * @author tyronchen 20 | * @date 2019年6月5日 21 | */ 22 | @Service 23 | public class PersonInfoServiceImpl implements PersonInfoService { 24 | 25 | @Autowired 26 | private PersonInfoDao personInfoDao; 27 | 28 | /* 29 | * (non-Javadoc) 30 | * 31 | * @see com.tyron.o2o.service.PersonInfoService#queryInfoByUserId(long) 32 | */ 33 | @Override 34 | public PersonInfo queryInfoByUserId(long userId) { 35 | return personInfoDao.queryInfoByUserId(userId); 36 | } 37 | 38 | /* 39 | * (non-Javadoc) 40 | * 41 | * @see 42 | * com.tyron.o2o.service.PersonInfoService#insertPersonInfo(com.tyron.o2o.entity 43 | * .PersonInfo) 44 | */ 45 | @Override 46 | public PersonInfoExecution insertPersonInfo(PersonInfo user) { 47 | // 空值判断 48 | if (user == null || user.getLocalAuthId() == null || user.getName() == null) { 49 | return new PersonInfoExecution(PersonInfoStateEnum.NULL_PERSON_INFO); 50 | } 51 | // 设置默认信息 52 | user.setCreateTime(new Date()); 53 | try { 54 | int effectedNum = personInfoDao.insertPersonInfo(user); 55 | if (effectedNum <= 0) { 56 | throw new PersonInfoOperationException("用户信息新增失败"); 57 | } else { 58 | return new PersonInfoExecution(OperationStatusEnum.SUCCESS, user); 59 | } 60 | } catch (Exception e) { 61 | throw new PersonInfoOperationException("insertPersonInfo error:" + e.getMessage()); 62 | } 63 | } 64 | 65 | /* 66 | * (non-Javadoc) 67 | * 68 | * @see 69 | * com.tyron.o2o.service.PersonInfoService#updatePersonInfo(com.tyron.o2o.entity 70 | * .PersonInfo) 71 | */ 72 | @Override 73 | public PersonInfoExecution updatePersonInfo(PersonInfo user) { 74 | // 空值判断 75 | if (user == null || user.getUserId() == null || user.getLocalAuthId() == null || user.getName() == null) { 76 | return new PersonInfoExecution(PersonInfoStateEnum.NULL_PERSON_INFO); 77 | } 78 | // 设置默认信息 79 | user.setLastEditTime(new Date()); 80 | try { 81 | int effectedNum = personInfoDao.updatePersonInfo(user); 82 | if (effectedNum <= 0) { 83 | throw new PersonInfoOperationException("用户信息修改失败"); 84 | } else { 85 | return new PersonInfoExecution(OperationStatusEnum.SUCCESS, user); 86 | } 87 | } catch (Exception e) { 88 | throw new PersonInfoOperationException("insertPersonInfo error:" + e.getMessage()); 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/CodeUtil.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import com.google.code.kaptcha.Constants; 6 | 7 | /** 8 | * @Description: 工具类 9 | * 10 | * @author tyronchen 11 | * @date 2018年5月28日 12 | */ 13 | public class CodeUtil { 14 | 15 | /** 16 | * 对比校验码 17 | * 18 | * @param request 19 | * @return 20 | */ 21 | public static boolean checkVerifyCode(HttpServletRequest request) { 22 | // 获取输入的校验码 23 | String verifyCodeActual = HttpServletRequestUtil.getString(request, "verifyCodeActual"); 24 | // 获取图片中的校验码 25 | String verifyCodeExpexted = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); 26 | // 对比 27 | if (verifyCodeActual == null || !verifyCodeActual.equalsIgnoreCase(verifyCodeExpexted)) { 28 | return false; 29 | } 30 | return true; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/DESUtil.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | import java.security.Key; 4 | import java.security.SecureRandom; 5 | 6 | import javax.crypto.Cipher; 7 | import javax.crypto.KeyGenerator; 8 | 9 | import sun.misc.BASE64Decoder; 10 | import sun.misc.BASE64Encoder; 11 | 12 | /** 13 | * @Description: DES是一种对称加密算法。 所谓对称加密算法就是指使用相同的密钥 14 | * 15 | * @author tyronchen 16 | * @date 2018年12月25日 17 | */ 18 | @SuppressWarnings("restriction") 19 | public class DESUtil { 20 | private static Key key; 21 | // 设置密钥key 22 | private static String KEY_STR = "s2_I$-!#eu_3y2*4D-8^2{A3R_E}I5%&U#I@-O;!"; 23 | private static String CHARSETNAME = "UTF-8"; 24 | private static String ALGORITHM = "DES"; 25 | 26 | static { 27 | try { 28 | // 生成DES算法对象 29 | KeyGenerator generator = KeyGenerator.getInstance(ALGORITHM); 30 | // 运行SHA1安全策略 31 | SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); 32 | // 设置上密钥种子 33 | secureRandom.setSeed(KEY_STR.getBytes()); 34 | // 初始化基于SHA1的算法对象 35 | generator.init(secureRandom); 36 | // 生成密钥对象 37 | key = generator.generateKey(); 38 | generator = null; 39 | } catch (Exception e) { 40 | throw new RuntimeException(e); 41 | } 42 | } 43 | 44 | /** 45 | * 获取加密后的信息 46 | * 47 | * @param str 待加密字符串 48 | * @return 49 | */ 50 | public static String getEncryptString(String str) { 51 | // 基于BASE64编码,接收byte[]并转换为String 52 | BASE64Encoder base64encoder = new BASE64Encoder(); 53 | try { 54 | // 按UTF-8编码 55 | byte[] bytes = str.getBytes(CHARSETNAME); 56 | // 获取加密对象 57 | Cipher cipher = Cipher.getInstance(ALGORITHM); 58 | // 初始化密码信息 59 | cipher.init(Cipher.ENCRYPT_MODE, key); 60 | // 加密 61 | byte[] doFinal = cipher.doFinal(bytes); 62 | // byte[] to encode好的String并返回 63 | return base64encoder.encode(doFinal); 64 | } catch (Exception e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | 69 | /** 70 | * 获取解密之后的信息 71 | * 72 | * @param str 待解密字符串 73 | * @return 74 | */ 75 | public static String getDecryptString(String str) { 76 | // 基于BASE64编码,接收byte[]并转换为String 77 | BASE64Decoder base64decoder = new BASE64Decoder(); 78 | try { 79 | // 将字符串decode成byte[] 80 | byte[] bytes = base64decoder.decodeBuffer(str); 81 | // 获取解密对象 82 | Cipher cipher = Cipher.getInstance(ALGORITHM); 83 | // 初始化解密信息 84 | cipher.init(Cipher.DECRYPT_MODE, key); 85 | // 解密 86 | byte[] doFinal = cipher.doFinal(bytes); 87 | // 返回解密之后的信息 88 | return new String(doFinal, CHARSETNAME); 89 | } catch (Exception e) { 90 | throw new RuntimeException(e); 91 | } 92 | } 93 | 94 | // 测试 95 | public static void main(String[] args) { 96 | System.out.println(getEncryptString("47.98.109.124")); 97 | System.out.println(getDecryptString("YshtT9w5IlQ=")); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/EncryptPropertyPlaceholderConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; 4 | 5 | /** 6 | * @Description: 继承PropertyPlaceholderConfigurer,重写convertProperty 7 | * 8 | * @author tyronchen 9 | * @date 2018年12月25日 10 | */ 11 | public class EncryptPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { 12 | // 需要加密的字段数组 13 | private String[] encryptPropNames = { "jdbc.username", "jdbc.password", "redis.hostname" }; 14 | 15 | /** 16 | * 对关键的属性进行转换 17 | */ 18 | @Override 19 | protected String convertProperty(String propertyName, String propertyValue) { 20 | // 判断是否加密 21 | if (isEncryptProp(propertyName)) { 22 | // 解密 23 | String decryptValue = DESUtil.getDecryptString(propertyValue); 24 | return decryptValue; 25 | } else { 26 | return propertyValue; 27 | } 28 | } 29 | 30 | /** 31 | * 判断该属性是否加密 32 | * 33 | * @param propertyName 34 | * @return 35 | */ 36 | private boolean isEncryptProp(String propertyName) { 37 | for (String encryptpropertyName : encryptPropNames) { 38 | if (encryptpropertyName.equals(propertyName)) 39 | return true; 40 | } 41 | return false; 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/HttpServletRequestUtil.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * @Description: 请求工具类 7 | * 8 | * @author tyronchen 9 | * @date 2018年4月15日 10 | */ 11 | 12 | public class HttpServletRequestUtil { 13 | 14 | public static int getInt(HttpServletRequest request, String key) { 15 | try { 16 | return Integer.decode(request.getParameter(key)); 17 | } catch (Exception e) { 18 | return -1; 19 | } 20 | } 21 | 22 | public static long getLong(HttpServletRequest request, String key) { 23 | try { 24 | return Long.valueOf(request.getParameter(key)); 25 | } catch (Exception e) { 26 | return -1; 27 | } 28 | } 29 | 30 | public static Double getDouble(HttpServletRequest request, String key) { 31 | try { 32 | return Double.valueOf(request.getParameter(key)); 33 | } catch (Exception e) { 34 | return -1d; 35 | } 36 | } 37 | 38 | public static Boolean getBoolean(HttpServletRequest request, String key) { 39 | try { 40 | return Boolean.valueOf(request.getParameter(key)); 41 | } catch (Exception e) { 42 | return false; 43 | } 44 | } 45 | 46 | public static String getString(HttpServletRequest request, String key) { 47 | try { 48 | String result = request.getParameter(key); 49 | if (result != null) { 50 | result = result.trim(); 51 | } 52 | if ("".equals(result)) { 53 | result = null; 54 | } 55 | return result; 56 | } catch (Exception e) { 57 | return null; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/MD5.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | import java.security.MessageDigest; 4 | 5 | /** 6 | * Md5工具类 7 | */ 8 | public class MD5 { 9 | 10 | /** 11 | * 对传入的String进行MD5加密 12 | */ 13 | public static final String getMd5(String s) { 14 | char hexDigits[] = { '5', '0', '5', '6', '2', '9', '6', '2', '5', 'q', 'b', 'l', 'e', 's', 's', 'y' }; 15 | try { 16 | char str[]; 17 | // 将传入的字符串转换为byte数组 18 | byte strTemp[] = s.getBytes(); 19 | // 获取MD5加密对象 20 | MessageDigest mdTemp = MessageDigest.getInstance("MD5"); 21 | // 传入需要加密的目标数组 22 | mdTemp.update(strTemp); 23 | // 获取加密后的数组 24 | byte md[] = mdTemp.digest(); 25 | int j = md.length; 26 | str = new char[j * 2]; 27 | int k = 0; 28 | // 将数组位移 29 | for (int i = 0; i < j; i++) { 30 | byte byte0 = md[i]; 31 | str[k++] = hexDigits[byte0 >>> 4 & 0xf]; 32 | str[k++] = hexDigits[byte0 & 0xf]; 33 | } 34 | 35 | return new String(str); 36 | } catch (Exception e) { 37 | return null; 38 | } 39 | } 40 | 41 | public static void main(String[] args) { 42 | System.out.println(MD5.getMd5("1234")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/PageCalculator.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | /** 4 | * @Description: 分页计算工具类 5 | * 6 | * @author tyronchen 7 | * @date 2018年4月15日 8 | */ 9 | public class PageCalculator { 10 | 11 | /** 12 | * 根据页数和每页数量查询行数 13 | * 14 | * @param pageIndex 页码数 15 | * @param pageSize 每页数量 16 | * @return 17 | */ 18 | public static int calculateRowIndex(int pageIndex, int pageSize) { 19 | return (pageIndex > 0) ? (pageIndex - 1) * pageSize : 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/util/PathUtil.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.util; 2 | 3 | /** 4 | * @Description: 路径工具类 5 | * 6 | * @author tyronchen 7 | * @date 2018年4月11日 8 | */ 9 | public class PathUtil { 10 | 11 | // 获取操作系统的分隔符 12 | private static String separator = System.getProperty("file.separator"); 13 | 14 | /** 15 | * 获取存放图片路径 16 | */ 17 | public static String getImgBasePath() { 18 | // 获取操作系统的信息 19 | String os = System.getProperty("os.name"); 20 | String basePath = ""; 21 | // 如果是window操作系统 22 | if (os.toLowerCase().startsWith("win")) { 23 | basePath = "D:/eclipse/tyron/image"; // Windows系统 24 | } else { 25 | basePath = "/home/tyron/image"; // 除了Windows系统 26 | } 27 | 28 | // 更换分隔符 29 | basePath = basePath.replace("/", separator); 30 | return basePath; 31 | } 32 | 33 | /** 34 | * 获取店铺照片路径 35 | */ 36 | public static String getShopImagePath(long shopId) { 37 | String imagePath = "/upload/item/shop" + shopId + "/"; 38 | return imagePath.replace("/", separator); 39 | } 40 | 41 | /** 42 | * 获取首页头图路径 43 | */ 44 | public static String getHeadLineImagePath() { 45 | String imagePath = "/upload/item/headLine/"; 46 | return imagePath.replace("/", separator); 47 | } 48 | 49 | /** 50 | * 获取店铺类别路径 51 | */ 52 | public static String getShopCategoryImagePath() { 53 | String imagePath = "/upload/item/shopcategory/"; 54 | return imagePath.replace("/", separator); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/web/AreaController.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.web; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.ResponseBody; 15 | 16 | import com.tyron.o2o.entity.Area; 17 | import com.tyron.o2o.service.AreaService; 18 | 19 | /** 20 | * @Description: 区域控制器 21 | * 22 | * @author tyronchen 23 | * @date 2018年3月24日 24 | */ 25 | @Controller 26 | @RequestMapping("/superadmin") 27 | public class AreaController { 28 | Logger logger = LoggerFactory.getLogger(AreaController.class); 29 | 30 | @Autowired 31 | private AreaService areaService; 32 | 33 | /** 34 | * 区域列表 35 | * 36 | * @return 37 | */ 38 | @RequestMapping(value = "/listarea", method = RequestMethod.GET) 39 | @ResponseBody 40 | public Map listArea() { 41 | Map modelMap = new HashMap<>(); 42 | List areaList = new ArrayList<>(); 43 | try { 44 | areaList = areaService.getAreaList(); 45 | modelMap.put("rows", areaList); 46 | modelMap.put("total", areaList.size()); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | modelMap.put("success", false); 50 | modelMap.put("errMsg", e.toString()); 51 | } 52 | return modelMap; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/web/front/FrontController.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.web.front; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | /** 8 | * @Description: 前端页面控制器 9 | * 10 | * @author: tyron 11 | * @date: 2018年11月28日 12 | */ 13 | @Controller 14 | @RequestMapping("/front") 15 | public class FrontController { 16 | 17 | /** 18 | * 前端首页 19 | * 20 | * @return 21 | */ 22 | @RequestMapping(value = "/index", method = RequestMethod.GET) 23 | public String index() { 24 | return "front/index"; 25 | } 26 | 27 | /** 28 | * 店铺列表页路由 29 | * 30 | * @return 31 | */ 32 | @RequestMapping(value = "/shoplist", method = RequestMethod.GET) 33 | public String shopList() { 34 | return "front/shoplist"; 35 | } 36 | 37 | /** 38 | * 店铺详情页路由 39 | * 40 | * @return 41 | */ 42 | @RequestMapping(value = "/shopdetail", method = RequestMethod.GET) 43 | public String shopDetail() { 44 | return "front/shopdetail"; 45 | } 46 | 47 | /** 48 | * 商品详情页路由 49 | * 50 | * @return 51 | */ 52 | @RequestMapping(value = "/productdetail", method = RequestMethod.GET) 53 | public String productDetail() { 54 | return "front/productdetail"; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/web/front/MainPageController.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.web.front; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import com.tyron.o2o.entity.HeadLine; 15 | import com.tyron.o2o.entity.ShopCategory; 16 | import com.tyron.o2o.enums.EnableStatusEnum; 17 | import com.tyron.o2o.service.HeadLineService; 18 | import com.tyron.o2o.service.ShopCategoryService; 19 | 20 | /** 21 | * @Description: 首页控制层 22 | * 23 | * @author: tyron 24 | * @date: 2018年11月26日 25 | */ 26 | 27 | @Controller 28 | @RequestMapping("/front") 29 | public class MainPageController { 30 | 31 | @Autowired 32 | private ShopCategoryService shopCategoryService; 33 | 34 | @Autowired 35 | private HeadLineService headLineService; 36 | 37 | /** 38 | * 初始化前端展示系统的主页信息,包括获取一级店铺类别列表一级头条列表 39 | * 40 | * @return 41 | */ 42 | @RequestMapping(value = "/listmainpageinfo", method = RequestMethod.GET) 43 | @ResponseBody 44 | public Map listMainPageInfo() { 45 | Map modelMap = new HashMap<>(); 46 | List shopCategoryList = new ArrayList<>(); 47 | try { 48 | // 获取一级店铺列表(即parentId为空的shopCategory) 49 | shopCategoryList = shopCategoryService.getShopCategoryList(null); 50 | modelMap.put("shopCategoryList", shopCategoryList); 51 | } catch (Exception e) { 52 | modelMap.put("success", false); 53 | modelMap.put("errMsg", e.getMessage()); 54 | return modelMap; 55 | } 56 | 57 | // 构建头条列表 58 | List headLineList = new ArrayList<>(); 59 | try { 60 | // 获取状态可用的头条列表 61 | HeadLine headLineCondition = new HeadLine(); 62 | headLineCondition.setEnableStatus(EnableStatusEnum.AVAILABLE.getState()); 63 | headLineList = headLineService.getHeadLineList(headLineCondition); 64 | modelMap.put("headLineList", headLineList); 65 | } catch (Exception e) { 66 | modelMap.put("success", false); 67 | modelMap.put("errMsg", e.getMessage()); 68 | return modelMap; 69 | } 70 | modelMap.put("success", true); 71 | return modelMap; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/web/front/ProductDetailController.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.web.front; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import com.tyron.o2o.entity.Product; 15 | import com.tyron.o2o.enums.ProductStateEnum; 16 | import com.tyron.o2o.service.ProductService; 17 | import com.tyron.o2o.util.HttpServletRequestUtil; 18 | 19 | /** 20 | * @Description: 商品详情控制器 21 | * 22 | * @author tyronchen 23 | * @date 2018年12月2日 24 | */ 25 | @Controller 26 | @RequestMapping("/front") 27 | public class ProductDetailController { 28 | 29 | @Autowired 30 | private ProductService productService; 31 | 32 | /** 33 | * 获取商品详情 34 | * 35 | * @param request 36 | * @return 37 | */ 38 | @RequestMapping(value = "/listproductdetailpageinfo", method = RequestMethod.GET) 39 | @ResponseBody 40 | private Map listProductDetailPageInfo(HttpServletRequest request) { 41 | Map modelMap = new HashMap(); 42 | long productId = HttpServletRequestUtil.getLong(request, "productId"); 43 | Product product = null; 44 | if (productId != -1) { 45 | // 获取商品详情 46 | product = productService.getProductById(productId); 47 | modelMap.put("product", product); 48 | modelMap.put("success", true); 49 | } else { 50 | modelMap.put("success", false); 51 | modelMap.put("errMsg", ProductStateEnum.PRODUCT_ID_EMPTY.getStateInfo()); 52 | } 53 | return modelMap; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/web/local/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.web.local; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | /** 7 | * @Description: 管理账号 8 | * 9 | * @author tyronchen 10 | * @date 2019年6月7日 11 | */ 12 | @Controller 13 | @RequestMapping("/admin") 14 | public class AdminController { 15 | 16 | /** 17 | * 用户注册 18 | * 19 | * @return 20 | */ 21 | @RequestMapping(value = "register") 22 | public String register() { 23 | return "admin/register"; 24 | } 25 | 26 | /** 27 | * 用户登录 28 | * 29 | * @return 30 | */ 31 | @RequestMapping(value = "login") 32 | public String login() { 33 | return "admin/login"; 34 | } 35 | 36 | /** 37 | * 用户修改密码 38 | * 39 | * @return 40 | */ 41 | @RequestMapping(value = "changepwd") 42 | public String changePwd() { 43 | return "admin/changepwd"; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/tyron/o2o/web/shopadmin/ShopAdminController.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.web.shopadmin; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | /** 8 | * @Description: 店铺管理员控制器 9 | * 10 | * @author tyronchen 11 | * @date 2018年4月15日 12 | */ 13 | @Controller 14 | @RequestMapping(value = "shopadmin", method = { RequestMethod.GET }) 15 | public class ShopAdminController { 16 | 17 | /** 18 | * 店铺操作页面 19 | * 20 | * @return 21 | */ 22 | @RequestMapping(value = "shopoperation") 23 | public String shopOperation() { 24 | return "shop/shopoperation"; 25 | } 26 | 27 | /** 28 | * 店铺列表页面 29 | * 30 | * @return 31 | */ 32 | @RequestMapping(value = "/shoplist", method = RequestMethod.GET) 33 | public String shopList() { 34 | return "shop/shoplist"; 35 | } 36 | 37 | /** 38 | * 店铺管理页面 39 | * 40 | * @return 41 | */ 42 | @RequestMapping(value = "/shopmanagement", method = RequestMethod.GET) 43 | public String shopManagement() { 44 | return "shop/shopmanagement"; 45 | } 46 | 47 | /** 48 | * 商品类别管理页面 49 | * 50 | * @return 51 | */ 52 | @RequestMapping(value = "/productcategorymanagement", method = RequestMethod.GET) 53 | public String productCategoryManagement() { 54 | return "shop/productcategorymanagement"; 55 | } 56 | 57 | /** 58 | * 商品操作页面 59 | * 60 | * @return 61 | */ 62 | @RequestMapping(value = "/productoperation", method = RequestMethod.GET) 63 | public String productOperation() { 64 | return "shop/productoperation"; 65 | } 66 | 67 | /** 68 | * 商品管理页面 69 | * 70 | * @return 71 | */ 72 | @RequestMapping(value = "/productmanagement", method = RequestMethod.GET) 73 | public String productManagement() { 74 | return "shop/productmanagement"; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://localhost:3306/o2o?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false 3 | jdbc.username=YshtT9w5IlQ= 4 | jdbc.password=B3kf2Nn+dgALnx+m0/bAVw== -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ${log.pattern} 21 | 22 | 23 | 24 | 25 | 26 | 27 | ${log.filePath}/debug.log 28 | 29 | ${log.filePath}/debug/debug.%d{yyyy-MM-dd}.log.gz 30 | 31 | ${log.maxHistory} 32 | 33 | 34 | ${log.pattern} 35 | 36 | 37 | DEBUG 38 | ACCEPT 39 | DENY 40 | 41 | 42 | 43 | 44 | 45 | 46 | ${log.filePath}/info.log 47 | 48 | ${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gz 49 | 50 | ${log.maxHistory} 51 | 52 | 53 | ${log.pattern} 54 | 55 | 56 | INFO 57 | ACCEPT 58 | DENY 59 | 60 | 61 | 62 | 63 | 64 | 65 | ${log.filePath}/error.log 66 | 67 | ${log.filePath}/error/error.%d{yyyy-MM-dd}.log.gz 68 | 69 | ${log.maxHistory} 70 | 71 | 72 | ${log.pattern} 73 | 74 | 75 | ERROR 76 | ACCEPT 77 | DENY 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/main/resources/mapper/AreaDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | -------------------------------------------------------------------------------- /src/main/resources/mapper/HeadLineDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 26 | 27 | 44 | 45 | 47 | INSERT INTO 48 | tb_head_line 49 | (line_name, line_link, line_img, priority, enable_status, create_time, 50 | last_edit_time) 51 | VALUES(#{lineName}, #{lineLink}, #{lineImg}, 52 | #{priority}, #{enableStatus}, #{createTime}, #{lastEditTime}); 53 | 54 | 55 | 56 | update tb_head_line 57 | 58 | 59 | line_name = #{lineName}, 60 | line_link = #{lineLink}, 61 | line_img = #{lineImg}, 62 | priority = #{priority}, 63 | enable_status = #{enableStatus}, 64 | last_edit_time = #{lastEditTime} 65 | 66 | where line_id = #{lineId} 67 | 68 | 69 | 85 | 86 | 87 | DELETE FROM 88 | tb_head_line 89 | WHERE 90 | line_id = 91 | #{lineId} 92 | 93 | 94 | 95 | DELETE FROM 96 | tb_head_line 97 | WHERE line_id IN 98 | 99 | #{lineId} 100 | 101 | 102 | -------------------------------------------------------------------------------- /src/main/resources/mapper/LocalAuthDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 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 | 32 | INSERT INTO 33 | tb_local_auth(username,password,create_time,last_edit_time) 34 | VALUES 35 | (#{username},#{password},#{createTime},#{lastEditTime}) 36 | 37 | 38 | 39 | update tb_local_auth 40 | 41 | password=#{newPassword}, 42 | last_edit_time=#{lastEditTime} 43 | 44 | where 45 | username=#{username} AND password=#{password} 46 | 47 | 48 | 72 | 73 | 98 | 99 | 115 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PersonInfoDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | INSERT INTO 22 | tb_person_info(local_auth_id,name,profile_img,email,gender,enable_status,user_type,create_time,last_edit_time) 23 | VALUES 24 | (#{localAuthId},#{name},#{profileImg},#{email},#{gender},#{enableStatus},#{userType},#{createTime},#{lastEditTime}) 25 | 26 | 27 | 28 | update tb_person_info 29 | 30 | name = #{name}, 31 | profile_img = #{profileImg}, 32 | email = #{email}, 33 | gender = #{gender}, 34 | enable_status = #{enableStatus}, 35 | user_type = #{userType}, 36 | last_edit_time = #{lastEditTime} 37 | 38 | where 39 | user_id=#{userId} 40 | 41 | 42 | 58 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ProductCategoryDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 15 | 16 | 17 | INSERT INTO tb_product_category(product_category_name,shop_id,priority,create_time) 18 | VALUES 19 | 20 | ( 21 | #{productCategory.productCategoryName}, 22 | #{productCategory.shopId}, 23 | #{productCategory.priority}, 24 | #{productCategory.createTime} 25 | ) 26 | 27 | 28 | 29 | 30 | DELETE FROM 31 | tb_product_category 32 | WHERE 33 | product_category_id = #{productCategoryId} 34 | and 35 | shop_id = #{shopId} 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ProductImgDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | INSERT INTO tb_product_img ( 10 | img_addr, 11 | img_desc, 12 | product_id, 13 | priority, 14 | create_time 15 | ) VALUES 16 | 17 | ( 18 | #{productImg.imgAddr}, 19 | #{productImg.imgDesc}, 20 | #{productImg.productId}, 21 | #{productImg.priority}, 22 | #{productImg.createTime} 23 | ) 24 | 25 | 26 | 27 | 28 | DELETE FROM 29 | tb_product_img 30 | WHERE 31 | product_id = #{produtId} 32 | 33 | 34 | 49 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ShopCategoryDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 30 | 31 | 32 | INSERT INTO tb_shop_category 33 | (shop_category_name, shop_category_desc, shop_category_img, priority, create_time, last_edit_time, parent_id) 34 | VALUES(#{shopCategoryName},#{shopCategoryDesc},#{shopCategoryImg},#{priority},#{createTime},#{lastEditTime},#{parent.shopCategoryId}); 35 | 36 | 37 | 38 | update tb_shop_category 39 | 40 | 41 | shop_category_name = #{shopCategoryName}, 42 | shop_category_desc = #{shopCategoryDesc}, 43 | shop_category_img = #{shopCategoryImg}, 44 | priority = #{priority}, 45 | parent_id = #{parent.shopCategoryId}, 46 | last_edit_time = #{lastEditTime} 47 | 48 | where shop_category_id = #{shopCategoryId} 49 | 50 | 51 | 66 | -------------------------------------------------------------------------------- /src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/redis.properties: -------------------------------------------------------------------------------- 1 | redis.hostname=5XeQPDLcqJr81CT2Q/H7VQ== 2 | redis.port=6379 3 | redis.database=0 4 | redis.pool.maxActive=600 5 | redis.pool.maxIdle=300 6 | redis.pool.maxWait=3000 7 | redis.pool.testOnBorrow=true -------------------------------------------------------------------------------- /src/main/resources/spring/spring-dao.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 14 | classpath:jdbc.properties 15 | classpath:redis.properties 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 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-redis.xml: -------------------------------------------------------------------------------- 1 | 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 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-service.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 41 | 42 | 43 | text/html;charset=UTF-8 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/main/resources/watermark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyronczt/imooc-o2o/7f62ccb6e080cc8fe5c2c277b5ff232e5bbab979/src/main/resources/watermark.jpg -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/admin/changepwd.html: -------------------------------------------------------------------------------- 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 | 41 |
    42 |
    43 |
    44 |
  • 45 |
  • 46 |
    47 |
    48 | 49 |
    50 |
    51 |
    52 | 53 |
    54 |
    55 |
    56 |
  • 57 |
  • 58 |
    59 |
    60 | 61 |
    62 |
    63 |
    64 | 65 |
    66 |
    67 |
    68 |
  • 69 |
  • 70 |
    71 |
    72 | 73 |
    74 |
    75 | 78 |
    79 | 点击更换 81 |
    82 |
    83 |
    84 |
  • 85 | 86 |
87 |
88 |
89 |
90 |
91 | 返回登录 93 |
94 |
95 | 提交 96 |
97 |
98 |
99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/admin/login.html: -------------------------------------------------------------------------------- 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 | 41 |
    42 |
    43 |
    44 |
  • 45 | 60 |
61 |
62 |
63 |
64 |
65 | 注册 66 |
67 |
68 | 提交 69 |
70 |
71 |
72 |
73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/admin/register.html: -------------------------------------------------------------------------------- 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 |
    41 | 42 |
    43 |
    44 |
    45 |
  • 46 |
  • 47 |
    48 |
    49 | 50 |
    51 |
    52 |
    53 | 54 |
    55 |
    56 |
    57 |
  • 58 |
  • 59 |
    60 |
    61 | 62 |
    63 |
    64 | 67 |
    68 | 点击更换 70 |
    71 |
    72 |
    73 |
  • 74 |
75 |
76 |
77 |
78 |
79 | 返回登录 81 |
82 |
83 | 提交 84 |
85 |
86 |
87 |
88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/front/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 小天的服装店 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |

小天的服装店

20 |
21 | 31 |
32 | 33 |
34 |
35 | 44 |
45 |
46 |
47 |
48 | 全部商店 49 |
50 |
51 | 60 |
61 |
62 |
63 | 64 |
65 |
66 |
67 |

68 | 登录 69 |

70 |

71 | 修改密码 72 |

73 |

74 | 退出系统 75 |

76 |
77 |
78 |
79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/shop/productcategorymanagement.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 商品分类 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 返回 21 | 22 |

商品分类

23 |
24 |
25 |
26 |
27 |
商品目录
28 |
优先级
29 |
操作
30 |
31 | 32 |
33 |
34 | 35 | 36 |
37 |
38 |
39 | 新增 40 |
41 |
42 | 提交 43 |
44 |
45 |
46 |
47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/shop/productmanagement.html: -------------------------------------------------------------------------------- 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 | 35 |
36 |
37 |
38 |
39 |
40 | 返回 41 |
42 |
43 | 新增 44 |
45 |
46 |
47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/shop/shoplist.html: -------------------------------------------------------------------------------- 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 | 44 |
45 |
46 |
47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/html/shop/shopmanagement.html: -------------------------------------------------------------------------------- 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 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | Archetype Created Web Application 6 | 7 | 8 | 9 | Kaptcha 10 | com.google.code.kaptcha.servlet.KaptchaServlet 11 | 12 | 13 | 14 | kaptcha.border 15 | no 16 | 17 | 18 | 19 | kaptcha.textproducer.font.color 20 | red 21 | 22 | 23 | 24 | kaptcha.image.width 25 | 135 26 | 27 | 28 | 29 | kaptcha.textproducer.char.string 30 | ACDEFHKPRSTRWX345679 31 | 32 | 33 | 34 | kaptcha.image.height 35 | 50 36 | 37 | 38 | 39 | kaptcha.textproducer.font.size 40 | 43 41 | 42 | 43 | 44 | kaptcha.noise.color 45 | black 46 | 47 | 48 | 49 | kaptcha.textproducer.char.length 50 | 4 51 | 52 | 53 | 54 | kaptcha.textproducer.font.names 55 | Arial 56 | 57 | 58 | 59 | 60 | Kaptcha 61 | /Kaptcha 62 | 63 | 64 | 65 | 66 | spring-dispatcher 67 | org.springframework.web.servlet.DispatcherServlet 68 | 70 | 71 | contextConfigLocation 72 | classpath:spring/spring-*.xml 73 | 74 | 75 | 76 | spring-dispatcher 77 | 78 | / 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/webapp/resources/css/front/index.css: -------------------------------------------------------------------------------- 1 | .index-banner { 2 | height: 35%; 3 | padding-bottom: 0.4rem; 4 | } 5 | .img-wrap { 6 | overflow: hidden; 7 | } 8 | .banner-img { 9 | width: 100%; 10 | height: 100%; 11 | } 12 | .total-shop-button { 13 | height: 1.5rem; 14 | line-height: 1.5rem; 15 | padding-left: 0.85rem; 16 | margin-bottom: 0.4rem; 17 | position: relative; 18 | cursor: pointer; 19 | } 20 | .total-shop-button:before { 21 | content: ''; 22 | display: inline-block; 23 | position: absolute; 24 | left: 0; 25 | width: 0.15rem; 26 | height: 1.5rem; 27 | background-color: #0894ec; 28 | } 29 | .shop-classify { 30 | height: 4.6rem; 31 | padding: 0.6rem; 32 | cursor: pointer; 33 | } 34 | .shop-classify > .word { 35 | width: 65%; 36 | height: 100%; 37 | overflow: hidden; 38 | float: left; 39 | } 40 | .shop-classify > .word > p { 41 | margin: 0; 42 | } 43 | .shop-classify > .word > .shop-title { 44 | margin: 0; 45 | font-size: 0.8rem; 46 | } 47 | .shop-classify > .word > .shop-desc { 48 | margin: 0; 49 | font-size: 0.4rem; 50 | } 51 | .shop-classify > .shop-img { 52 | width: 2.4rem; 53 | height: 2.4rem; 54 | margin-left: 0.2rem; 55 | display: inline-block; 56 | } 57 | .shop-classify > .shop-classify-img-warp { 58 | width: 30%; 59 | height: 100%; 60 | margin-left: 0.2rem; 61 | display: inline-block; 62 | } 63 | .shop-classify > .shop-classify-img-warp > .shop-img { 64 | width: 100%; 65 | height: 100%; 66 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/front/productdetail.css: -------------------------------------------------------------------------------- 1 | .shopdetail-button-div { 2 | margin: 0 .3rem; 3 | } 4 | .shopdetail-button-div > .button { 5 | width: 30%; 6 | height: 1.5rem; 7 | line-height: 1.5rem; 8 | display: inline-block; 9 | margin: 1%; 10 | overflow: hidden; 11 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/front/shopdetail.css: -------------------------------------------------------------------------------- 1 | .detail-search { 2 | height: 2.2rem; 3 | padding-right: .5rem; 4 | padding-left: .5rem; 5 | background-color: #f7f7f8; 6 | } 7 | .infinite-scroll-preloader { 8 | margin-top: -5px; 9 | } 10 | .shopdetail-button-div { 11 | margin: 0 .3rem; 12 | } 13 | .shopdetail-button-div > .button { 14 | width: 30%; 15 | height: 1.5rem; 16 | line-height: 1.5rem; 17 | display: inline-block; 18 | margin: 1%; 19 | overflow: hidden; 20 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/front/shoplist.css: -------------------------------------------------------------------------------- 1 | .infinite-scroll-preloader { 2 | margin-top: -5px; 3 | } 4 | .shoplist-button-div { 5 | margin: 0 .3rem; 6 | } 7 | .shoplist-button-div > .button { 8 | width: 30%; 9 | height: 1.5rem; 10 | line-height: 1.5rem; 11 | display: inline-block; 12 | margin: 1%; 13 | overflow: hidden; 14 | } 15 | .select-wrap { 16 | margin: 0 .5rem; 17 | } 18 | .select { 19 | border: 1px solid #0894ec; 20 | color: #0894ec; 21 | background-color: #efeff4; 22 | width: 100%; 23 | height: 1.5rem; 24 | font-size: .7rem; 25 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/shop/productcategorymanage.css: -------------------------------------------------------------------------------- 1 | .row-product-category { 2 | border: 1px solid #999; 3 | padding: .5rem; 4 | border-bottom: none; 5 | } 6 | .row-product-category:last-child { 7 | border-bottom: 1px solid #999; 8 | } 9 | .category-input { 10 | border: none; 11 | background-color: #eee; 12 | } 13 | .product-category-name { 14 | white-space: nowrap; 15 | overflow-x: scroll; 16 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/shop/productmanage.css: -------------------------------------------------------------------------------- 1 | .row-product { 2 | border: 1px solid #999; 3 | padding: .5rem; 4 | border-bottom: none; 5 | } 6 | .row-product:last-child { 7 | border-bottom: 1px solid #999; 8 | } 9 | .product-name { 10 | white-space: nowrap; 11 | overflow-x: scroll; 12 | } 13 | .product-wrap a { 14 | margin-right: 1rem; 15 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/shop/shoplist.css: -------------------------------------------------------------------------------- 1 | .row-shop { 2 | border: 1px solid #999; 3 | padding: .5rem; 4 | border-bottom: none; 5 | } 6 | .row-shop:last-child { 7 | border-bottom: 1px solid #999; 8 | } 9 | .shop-name { 10 | white-space: nowrap; 11 | overflow-x: scroll; 12 | } 13 | .shop-wrap a { 14 | 15 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/css/shop/shopmanagement.css: -------------------------------------------------------------------------------- 1 | .mb { 2 | margin-bottom: .5rem; 3 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/js/admin/changepwd.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | var url = '/o2o/user/changepwd'; 3 | $('#submit').click(function() { 4 | var username = $('#username').val(); 5 | if (!username) { 6 | $.toast('请输入用户名!'); 7 | return; 8 | } 9 | var password = $('#password').val(); 10 | if (!password) { 11 | $.toast('请输入密码!'); 12 | return; 13 | } else if(password.length < 6){ 14 | $.toast('密码长度至少六位'); 15 | return; 16 | } 17 | var newPassword = $('#newPassword').val(); 18 | if (!newPassword) { 19 | $.toast('请输入密码!'); 20 | return; 21 | } else if(newPassword.length < 6){ 22 | $.toast('密码长度至少六位'); 23 | return; 24 | } 25 | var renewpwd = $('#renewPassword').val(); 26 | // 新密码和确认密码不相同 27 | if (newPassword != renewpwd) { 28 | $.toast('新密码和确认密码输入不相同,请重新输入'); 29 | return; 30 | } 31 | // 新密码和原密码相同 32 | if (newPassword == password) { 33 | $.toast('新密码和原密码相同,请重新输入'); 34 | return; 35 | } 36 | var formData = new FormData(); 37 | formData.append('username', username); 38 | formData.append('password', password); 39 | formData.append('newPassword', newPassword); 40 | var verifyCodeActual = $('#j_captcha').val(); 41 | if (!verifyCodeActual) { 42 | $.toast('请输入验证码!'); 43 | return; 44 | } 45 | formData.append("verifyCodeActual", verifyCodeActual); 46 | $.ajax({ 47 | url : url, 48 | type : 'POST', 49 | data : formData, 50 | contentType : false, 51 | processData : false, 52 | cache : false, 53 | success : function(data) { 54 | if (data.success) { 55 | $.toast('密码修改成功!'); 56 | // 延时2秒 57 | setTimeout(function () { 58 | window.location.href = '/o2o/admin/login?userType=' + getQueryString('userType'); 59 | }, 2000); 60 | } else { 61 | $.toast(data.errMsg); 62 | $('#captcha_img').click(); 63 | } 64 | } 65 | }); 66 | }); 67 | 68 | $('#back').click(function() { 69 | window.location.href = '/o2o/admin/login?userType=' + getQueryString('userType'); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/admin/login.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | var userType = getQueryString('userType'); 3 | var loginUrl = '/o2o/user/login'; 4 | var loginCount = 0; 5 | 6 | $('#submit').click(function() { 7 | var username = $('#username').val(); 8 | var password = $('#psw').val(); 9 | var verifyCodeActual = $('#j_captcha').val(); 10 | var needVerify = false; 11 | if (loginCount >= 3) { 12 | if (!verifyCodeActual) { 13 | $.toast('请输入验证码!'); 14 | return; 15 | } else { 16 | needVerify = true; 17 | } 18 | } 19 | $.ajax({ 20 | url : loginUrl, 21 | async : false, 22 | cache : false, 23 | type : "post", 24 | dataType : 'json', 25 | data : { 26 | username : username, 27 | password : password, 28 | verifyCodeActual : verifyCodeActual, 29 | needVerify : needVerify, 30 | userType : userType 31 | }, 32 | success : function(data) { 33 | if (data.success) { 34 | // 延时1秒 35 | setTimeout(function() { 36 | $.toast('登录成功!'); 37 | }, 1000); 38 | 39 | // 没有后台登录权限 40 | if (data.errMsg) { 41 | $.toast(data.errMsg); 42 | // 延时3秒 43 | setTimeout(function() { 44 | window.location.href = '/o2o/front/index'; 45 | }, 3000); 46 | } 47 | // 仅当有权限登录成功且链接中带有back属性时跳转后台 48 | else if (userType == "back") { 49 | // 延时3秒 50 | setTimeout(function() { 51 | window.location.href = '/o2o/shopadmin/shoplist'; 52 | }, 3000); 53 | } 54 | // 登录成功的其他情况都跳转前台 55 | else { 56 | // 延时3秒 57 | setTimeout(function() { 58 | window.location.href = '/o2o/front/index'; 59 | }, 3000); 60 | } 61 | } else { 62 | $.toast(data.errMsg); 63 | loginCount++; 64 | if (loginCount >= 3) { 65 | $('#verifyPart').show(); 66 | } 67 | } 68 | } 69 | }); 70 | }); 71 | 72 | $('#register').click(function() { 73 | window.location.href = '/o2o/admin/register?userType=back'; 74 | }); 75 | }); -------------------------------------------------------------------------------- /src/main/webapp/resources/js/admin/register.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | var registerUrl = '/o2o/user/register'; 3 | var checkUsernameUrl = '/o2o/user/checkusername'; 4 | $('#submit').click(function() { 5 | var username = $('#username').val(); 6 | if (!username) { 7 | $.toast('请输入用户名!'); 8 | return; 9 | } 10 | var pwd = $('#password').val(); 11 | if (!pwd) { 12 | $.toast('请输入密码!'); 13 | return; 14 | } else if(pwd.length < 6){ 15 | $.toast('密码长度至少六位'); 16 | return; 17 | } 18 | var repwd = $('#repassword').val(); 19 | // 密码不相同 20 | if (pwd != repwd) { 21 | $.toast('两次密码输入不相同,请重新输入'); 22 | return; 23 | } 24 | var verifyCodeActual = $('#j_captcha').val(); 25 | if (!verifyCodeActual) { 26 | $.toast('请输入验证码!'); 27 | return; 28 | } 29 | $.ajax({ 30 | url : registerUrl, 31 | type : "post", 32 | dataType : 'json', 33 | data : { 34 | username : username, 35 | password : pwd, 36 | verifyCodeActual : verifyCodeActual 37 | }, 38 | async : false, 39 | cache : false, 40 | success : function(data) { 41 | if (data.success) { 42 | $.toast('注册成功!'); 43 | // 延时2秒 44 | setTimeout(function () { 45 | window.location.href = '/o2o/admin/login?userType=' + getQueryString('userType'); 46 | }, 2000); 47 | } else { 48 | $.toast(data.errMsg); 49 | $('#captcha_img').click(); 50 | } 51 | } 52 | }); 53 | }); 54 | 55 | $('#back').click(function() { 56 | window.location.href = '/o2o/admin/login?userType=' + getQueryString('userType'); 57 | }); 58 | 59 | // 异步检查用户名是否已存在 60 | $("#username").blur(function checkUsername() { 61 | var username = $('#username').val(); 62 | // 用户名存在 63 | if (username) { 64 | $.ajax({ 65 | url : checkUsernameUrl, 66 | type : "post", 67 | dataType : 'json', 68 | data : { 69 | username : username 70 | }, 71 | async : false, 72 | cache : false, 73 | success : function(data) { 74 | if (!data.success) { 75 | $.toast(data.errMsg); 76 | // 提示重名后清空 77 | $("#username").val(""); 78 | } 79 | } 80 | }); 81 | } 82 | }); 83 | }); 84 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/common/common.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 基础类js 3 | */ 4 | 5 | /** 6 | * 点击更换验证码 7 | * 8 | * @param img 9 | */ 10 | function changeVerifyCode(img) { 11 | img.src = "../Kaptcha?" + Math.floor(Math.random() * 100); 12 | } 13 | 14 | /** 15 | * 根据属性名获取QueryString中所带的属性值 16 | * 17 | * @param name:属性名 18 | */ 19 | function getQueryString(name) { 20 | var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); 21 | var r = window.location.search.substr(1).match(reg); 22 | if (r != null) { 23 | return decodeURIComponent(r[2]); 24 | } 25 | return ''; 26 | } 27 | 28 | /** 29 | * 格式化日期 30 | */ 31 | Date.prototype.Format = function(fmt) { 32 | var o = { 33 | "M+" : this.getMonth() + 1, // 月份 34 | "d+" : this.getDate(), // 日 35 | "h+" : this.getHours(), // 小时 36 | "m+" : this.getMinutes(), // 分 37 | "s+" : this.getSeconds(), // 秒 38 | "q+" : Math.floor((this.getMonth() + 3) / 3), // 季度 39 | "S" : this.getMilliseconds() 40 | // 毫秒 41 | }; 42 | if (/(y+)/.test(fmt)) 43 | fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "") 44 | .substr(4 - RegExp.$1.length)); 45 | for ( var k in o) 46 | if (new RegExp("(" + k + ")").test(fmt)) 47 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) 48 | : (("00" + o[k]).substr(("" + o[k]).length))); 49 | return fmt; 50 | } -------------------------------------------------------------------------------- /src/main/webapp/resources/js/front/index.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | // 定义访问后台获取头条列表以及一级商铺类别列表的URL 3 | var url = '/o2o/front/listmainpageinfo'; 4 | 5 | // 访问后台获取头条列表以及一级商铺类别 6 | $.getJSON(url, function (data) { 7 | if (data.success) { 8 | // 定义变量,接收后台传递过来的头条列表数据 9 | var headLineList = data.headLineList; 10 | var swiperHtml = ''; 11 | // 遍历头条列表,并拼接出轮播图组 12 | headLineList.map(function (item, index) { 13 | swiperHtml += '' 14 | + '
' 15 | + '' 16 | + '
'; 17 | }); 18 | // 将轮播图组赋值给前端HTML空间 19 | $('.swiper-wrapper').html(swiperHtml); 20 | // 设置轮播图轮换时间为1秒 21 | $(".swiper-container").swiper({ 22 | autoplay: 1000, 23 | // 用户对轮播图进行操作时,是否自动停止autoplay 24 | autoplayDisableOnInteraction: false 25 | }); 26 | // 获取后台传递过来的一级商铺类别列表 27 | var shopCategoryList = data.shopCategoryList; 28 | var categoryHtml = ''; 29 | // 遍历台传递过来的一级商铺类别列表 拼接col-50 两两一行的类别 30 | shopCategoryList.map(function (item, index) { 31 | categoryHtml += '' 32 | + '
' 33 | + '
' 34 | + '

'+ item.shopCategoryName +'

' 35 | + '

'+ item.shopCategoryDesc +'

' 36 | + '
' 37 | + '
' 38 | + '' 39 | + '
' 40 | + '
'; 41 | }); 42 | $('.row').html(categoryHtml); 43 | } else { 44 | alert(data.errMsg); 45 | } 46 | }); 47 | 48 | // 我的 49 | $('#me').click(function () { 50 | $.openPanel('#panel-left-demo'); 51 | }); 52 | 53 | // 点击特定的分类 54 | $('.row').on('click', '.shop-classify', function (e) { 55 | var shopCategoryId = e.currentTarget.dataset.category; 56 | var newUrl = '/o2o/front/shoplist?parentId=' + shopCategoryId; 57 | window.location.href = newUrl; 58 | }); 59 | 60 | // 用户登录 61 | $('#login').click(function() { 62 | window.location.href = '/o2o/admin/login'; 63 | }); 64 | 65 | // 修改密码 66 | $('#change-pwd').click(function() { 67 | window.location.href = '/o2o/admin/changepwd'; 68 | }); 69 | 70 | // 退出登录 71 | $('#log-out').click(function () { 72 | $.ajax({ 73 | url : "/o2o/user/logout", 74 | type : "post", 75 | contentType : false, 76 | processData : false, 77 | cache : false, 78 | success : function(data) { 79 | if (data.success) { 80 | window.location.href = '/o2o/admin/login'; 81 | } 82 | }, 83 | error : function(data, error) { 84 | alert(error); 85 | } 86 | }); 87 | }); 88 | 89 | }); 90 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/front/productdetail.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | var productId = getQueryString('productId'); 3 | var productUrl = '/o2o/front/listproductdetailpageinfo?productId=' + productId; 4 | 5 | $.getJSON( 6 | productUrl,function(data) { 7 | if (data.success) { 8 | var product = data.product; 9 | $('#product-img').attr('src', product.imgAddr); 10 | $('#product-time').text(new Date(product.lastEditTime) .Format("yyyy-MM-dd")); 11 | $('#product-name').text(product.productName); 12 | $('#product-desc').text(product.productDesc); 13 | // 获取商品详情图片列表 14 | var productDetailImgList = product.productImgList; 15 | var swiperHtml = ''; 16 | productDetailImgList.map(function(item, index) { 17 | swiperHtml += '' 18 | + '
' 19 | + '' 20 | + '
'; 21 | }); 22 | // 生成购买商品的二维码供商家扫描 23 | // imgListHtml += '
'; 24 | $('.swiper-wrapper').html(swiperHtml); 25 | // 设置轮播图轮换时间为1秒 26 | $(".swiper-container").swiper({ 27 | autoplay: 1000, 28 | // 用户对轮播图进行操作时,是否自动停止autoplay 29 | autoplayDisableOnInteraction: true 30 | }); 31 | } 32 | }); 33 | $('#me').click(function() { 34 | $.openPanel('#panel-left-demo'); 35 | }); 36 | $.init(); 37 | }); 38 | -------------------------------------------------------------------------------- /src/main/webapp/resources/js/shop/productmanage.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | // 获取此店铺下的商品列表的url 3 | var listUrl = '/o2o/shopadmin/getproductlistbyshop?pageIndex=1&pageSize=999'; 4 | // 商品上/下架 5 | var statusUrl = '/o2o/shopadmin/modifyproduct'; 6 | 7 | /** 8 | * 获取商品列表 9 | */ 10 | function getList() { 11 | $.getJSON(listUrl, function(data) { 12 | if (data.success) { 13 | var productList = data.productList; 14 | var tempHtml = ''; 15 | // 遍历商品信息,并拼接 16 | productList.map(function(item, index) { 17 | var textOp = "下架"; 18 | var contraryStatus = 0; 19 | // 状态值为0,表明商品已下架,操作变为“上架” 20 | if (item.enableStatus == 0) { 21 | textOp = "上架"; 22 | contraryStatus = 1; 23 | } else { 24 | contraryStatus = 0; 25 | } 26 | tempHtml += '' + '
' 27 | + '
' 28 | + item.productName 29 | + '
' 30 | + '
' 31 | + item.priority 32 | + '
' 33 | + '
' 34 | + '编辑' 39 | + '' 44 | + textOp 45 | + '' 46 | + '预览' 51 | + '
' 52 | + '
'; 53 | }); 54 | $('.product-wrap').html(tempHtml); 55 | } 56 | }); 57 | } 58 | 59 | getList(); 60 | 61 | /** 62 | * 商品列表绑定链接事件 63 | */ 64 | $('.product-wrap').on('click','a',function(e) { 65 | var target = $(e.currentTarget); 66 | // 点击“编辑”按钮 67 | if (target.hasClass('edit')) { 68 | window.location.href = '/o2o/shopadmin/productoperation?productId=' + e.currentTarget.dataset.id; 69 | } 70 | // 点击“上/下架”按钮 71 | else if (target.hasClass('status')) { 72 | changeItemStatus(e.currentTarget.dataset.id, e.currentTarget.dataset.status); 73 | } 74 | // 点击“预览按钮” 75 | else if (target.hasClass('preview')) { 76 | window.location.href = '/o2o/front/productdetail?productId=' + e.currentTarget.dataset.id; 77 | } 78 | }); 79 | 80 | /** 81 | * 商品上下架 82 | */ 83 | function changeItemStatus(id, enableStatus) { 84 | var product = {}; 85 | product.productId = id; 86 | product.enableStatus = enableStatus; 87 | $.confirm('确定么?', function() { 88 | $.ajax({ 89 | url : statusUrl, 90 | type : 'POST', 91 | data : { 92 | productStr : JSON.stringify(product), 93 | statusChange : true 94 | }, 95 | dataType : 'json', 96 | success : function(data) { 97 | if (data.success) { 98 | $.toast('操作成功!'); 99 | getList(); 100 | } else { 101 | $.toast('操作失败!'); 102 | } 103 | } 104 | }); 105 | }); 106 | } 107 | }); -------------------------------------------------------------------------------- /src/main/webapp/resources/js/shop/shoplist.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // 调用,加载数据 4 | getshoplist(); 5 | 6 | function getshoplist() { 7 | $.ajax({ 8 | url : "/o2o/shopadmin/getshoplist", 9 | type : "get", 10 | dataType : "json", 11 | success : function(data) { 12 | if (data.success) { 13 | handleList(data.shopList); 14 | handleUser(data.user); 15 | } 16 | } 17 | }); 18 | } 19 | 20 | // 显示名字 21 | function handleUser(data) { 22 | $('#user-name').text(data.name); 23 | } 24 | 25 | // 拼接店铺 26 | function handleList(data) { 27 | var shopListHtml = ''; 28 | data.map(function(item, index) { 29 | shopListHtml += '
' 30 | + item.shopName + '
' 31 | + shopStatus(item.enableStatus) 32 | + '
' 33 | + goShop(item.enableStatus, item.shopId) + '
' 34 | }); 35 | $('.shop-wrap').html(shopListHtml); 36 | } 37 | 38 | function shopStatus(status) { 39 | if (status == 0) { 40 | return '审核中'; 41 | } else if (status == 1) { 42 | return '审核通过'; 43 | } else { 44 | return '店铺非法'; 45 | } 46 | } 47 | 48 | // 进入到商铺的管理页面,请求/shopadmin/shopmanagement ,进入到管理页面 49 | function goShop(status, shopId) { 50 | if (status == 1) { 51 | return '进入'; 53 | } else { 54 | return ''; 55 | } 56 | } 57 | 58 | // 修改密码 59 | $('#change-pwd').click(function() { 60 | window.location.href = '/o2o/admin/changepwd?userType=back'; 61 | }); 62 | 63 | // 退出登录 64 | $('#log-out').click(function () { 65 | $.ajax({ 66 | url : "/o2o/user/logout", 67 | type : "post", 68 | contentType : false, 69 | processData : false, 70 | cache : false, 71 | success : function(data) { 72 | if (data.success) { 73 | window.location.href = '/o2o/admin/login?userType=back'; 74 | } 75 | }, 76 | error : function(data, error) { 77 | alert(error); 78 | } 79 | }); 80 | }); 81 | 82 | }); -------------------------------------------------------------------------------- /src/main/webapp/resources/js/shop/shopmanagement.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | 3 | // 获取shopId 4 | var shopId = getQueryString("shopId"); 5 | // 商铺管理的url 6 | var shopInfoUrl = '/o2o/shopadmin/getshopmanageInfo?shopId=' + shopId; 7 | 8 | $.getJSON(shopInfoUrl,function (data) { 9 | // 如果后台返回redirect=true,则跳转后台到设置的url 10 | if(data.redirect){ 11 | window.location.href = data.url; 12 | }else{ 13 | // 如果后台返回redirect=false,则设置shopId并给 按钮设置超链接属性(即编辑商铺) 14 | if (data.shopId != undefined && data.shopId != null){ 15 | shopId = data.shopId; 16 | } 17 | $('#shopInfo').attr('href','/o2o/shopadmin/shopoperation?shopId=' + shopId); 18 | $('#productCategory').attr('href','/o2o/shopadmin/productcategorymanagement'); 19 | } 20 | }); 21 | 22 | 23 | }); -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.test.context.ContextConfiguration; 5 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 6 | 7 | /** 8 | * @Description: 测试基类 配置spring和junit整合,junit启动时加载springIOC容器 spring-test,junit 9 | * 10 | * @author tyronchen 11 | * @date 2018年3月24日 12 | */ 13 | @RunWith(SpringJUnit4ClassRunner.class) 14 | @ContextConfiguration({ "classpath:spring/spring-dao.xml", "classpath:spring/spring-service.xml", 15 | "classpath:spring/spring-redis.xml" }) 16 | public class BaseTest { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/AreaDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.tyron.o2o.BaseTest; 9 | import com.tyron.o2o.entity.Area; 10 | 11 | /** 12 | * @Description: 区域接口测试 13 | * 14 | * @author tyronchen 15 | * @date 2018年3月24日 16 | */ 17 | 18 | public class AreaDaoTest extends BaseTest { 19 | 20 | @Autowired 21 | private AreaDao areaDao; 22 | 23 | @Test 24 | public void testQueryArea() { 25 | List areaList = areaDao.selectArea(); 26 | System.out.println("dao测试:" + areaList.toString()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/HeadLineDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | import org.junit.Ignore; 9 | import org.junit.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import com.tyron.o2o.BaseTest; 14 | import com.tyron.o2o.entity.HeadLine; 15 | import com.tyron.o2o.enums.EnableStatusEnum; 16 | import com.tyron.o2o.util.ImageUtil; 17 | import com.tyron.o2o.util.PathUtil; 18 | 19 | /** 20 | * @Description: 首页头条数据接口测试 21 | * 22 | * @author: tyron 23 | * @date: 2018年11月25日 24 | */ 25 | 26 | public class HeadLineDaoTest extends BaseTest { 27 | 28 | @Autowired 29 | private HeadLineDao headLineDao; 30 | 31 | @Test 32 | public void testInsertHeadLine() throws Exception { 33 | HeadLine headLine = new HeadLine(); 34 | headLine.setCreateTime(new Date()); 35 | headLine.setEnableStatus(EnableStatusEnum.AVAILABLE.getState()); 36 | String filePath = "D:\\eclipse\\pic\\头图4.jpg"; 37 | MultipartFile multipartFile = ImageUtil.path2MultipartFile(filePath); 38 | String dest = PathUtil.getHeadLineImagePath(); 39 | String generateHeadImg = ImageUtil.generateHeadImg(multipartFile, dest); 40 | headLine.setLineImg(generateHeadImg); 41 | headLine.setLineLink("链接4"); 42 | headLine.setLineName("头图4"); 43 | headLine.setPriority(4); 44 | int effectNum = headLineDao.insertHeadLine(headLine); 45 | System.out.println("insertNum:" + effectNum); 46 | } 47 | 48 | @Test 49 | @Ignore 50 | public void testModifyHeadLine() throws Exception { 51 | HeadLine currHeadLine = new HeadLine(); 52 | currHeadLine.setLastEditTime(new Date()); 53 | currHeadLine.setLineId(1L); 54 | // 删除原有图片 55 | HeadLine origHeadLine = headLineDao.selectHeadLineById(1L); 56 | ImageUtil.deleteFileOrPath(origHeadLine.getLineImg()); 57 | currHeadLine.setLineLink("链接2"); 58 | currHeadLine.setLineName("头图2"); 59 | String filePath = "D:\\eclipse\\pic\\头图2.jpg"; 60 | MultipartFile multipartFile = ImageUtil.path2MultipartFile(filePath); 61 | String dest = PathUtil.getHeadLineImagePath(); 62 | String generateHeadImg = ImageUtil.generateHeadImg(multipartFile, dest); 63 | currHeadLine.setLineImg(generateHeadImg); 64 | currHeadLine.setPriority(2); 65 | int effectNum = headLineDao.updateHeadLine(currHeadLine); 66 | System.out.println("insertNum:" + effectNum); 67 | } 68 | 69 | @Test 70 | @Ignore 71 | public void testDeleteHeadLine() throws Exception { 72 | HeadLine headLine = new HeadLine(); 73 | headLine.setLineId(1L); 74 | headLine.setEnableStatus(EnableStatusEnum.UNAVAILABLE.getState()); 75 | headLine.setLastEditTime(new Date()); 76 | int effectNum = headLineDao.updateHeadLine(headLine); 77 | System.out.println("insertNum:" + effectNum); 78 | } 79 | 80 | @Test 81 | @Ignore 82 | public void testSelectHeadLine() throws Exception { 83 | List headLineList = headLineDao.selectHeadLineList(new HeadLine()); 84 | assertEquals(1, headLineList.size()); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/LocalAuthDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Date; 6 | 7 | import org.junit.Ignore; 8 | import org.junit.Test; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | 11 | import com.tyron.o2o.BaseTest; 12 | import com.tyron.o2o.entity.LocalAuth; 13 | import com.tyron.o2o.entity.PersonInfo; 14 | 15 | /** 16 | * @Description: 本地用户信息数据层测试 17 | * 18 | * @author tyronchen 19 | * @date 2019年5月20日 20 | */ 21 | public class LocalAuthDaoTest extends BaseTest { 22 | 23 | @Autowired 24 | private LocalAuthDao localAuthDao; 25 | private static final String username = "root"; 26 | private static final String password = "123456"; 27 | 28 | /** 29 | * 测试插入用户 30 | * 31 | * @throws Exception 32 | */ 33 | @Test 34 | @Ignore 35 | public void testInsertLocalAuth() throws Exception { 36 | // 新增一条本地用户 37 | LocalAuth localAuth = new LocalAuth(); 38 | PersonInfo personInfo = new PersonInfo(); 39 | personInfo.setUserId(1L); 40 | localAuth.setPersonInfo(personInfo); 41 | // 设置用户名和密码 42 | localAuth.setUsername(username); 43 | localAuth.setPassword(password); 44 | localAuth.setCreateTime(new Date()); 45 | int effectNum = localAuthDao.insertLocalAuth(localAuth); 46 | assertEquals(1, effectNum); 47 | } 48 | 49 | /** 50 | * 根据用户名和账号查询用户 51 | */ 52 | @Test 53 | public void testQueryLocalByUsernameAndPwd() { 54 | LocalAuth localAuth = localAuthDao.queryLocalByUsernameAndPwd(username, password); 55 | assertEquals("张三", localAuth.getPersonInfo().getName()); 56 | } 57 | 58 | /** 59 | * 根据用户Id查询本地账号信息 60 | */ 61 | @Test 62 | @Ignore 63 | public void testQueryLocalByLocalAuthId() { 64 | LocalAuth localAuth = localAuthDao.queryLocalByLocalAuthId(1L); 65 | assertEquals("张三", localAuth.getPersonInfo().getName()); 66 | } 67 | 68 | /** 69 | * 更新账号信息 70 | */ 71 | @Test 72 | @Ignore 73 | public void testUpdateLocalAuth() { 74 | Date now = new Date(); 75 | int effectNum = localAuthDao.updateLocalAuth(username, password, "654321", now); 76 | assertEquals(1, effectNum); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/PersonInfoDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.util.Date; 6 | 7 | import org.junit.Ignore; 8 | import org.junit.Test; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | 11 | import com.tyron.o2o.BaseTest; 12 | import com.tyron.o2o.entity.PersonInfo; 13 | import com.tyron.o2o.enums.PersonInfoStatusEnum; 14 | import com.tyron.o2o.enums.PersonInfoTypeEnum; 15 | 16 | /** 17 | * @Description: 用户信息数据层测试 18 | * 19 | * @author tyronchen 20 | * @date 2019年6月3日 21 | */ 22 | public class PersonInfoDaoTest extends BaseTest { 23 | 24 | @Autowired 25 | private PersonInfoDao personInfoDao; 26 | 27 | /** 28 | * 测试插入用户 29 | * 30 | * @throws Exception 31 | */ 32 | @Test 33 | @Ignore 34 | public void testInsertPersonInfo() throws Exception { 35 | // 新增一条用户 36 | PersonInfo personInfo = new PersonInfo(); 37 | personInfo.setLocalAuthId(1L); 38 | // 注册一个有权限访问的顾客 39 | personInfo.setEnableStatus(PersonInfoStatusEnum.ALLOW.getState()); 40 | personInfo.setUserType(PersonInfoTypeEnum.CUSTOMER.getState()); 41 | personInfo.setCreateTime(new Date()); 42 | personInfo.setGender("男"); 43 | personInfo.setEmail("a@a.com"); 44 | personInfo.setName("顾客a"); 45 | int effectNum = personInfoDao.insertPersonInfo(personInfo); 46 | assertEquals(1, effectNum); 47 | } 48 | 49 | /** 50 | * 根据用户Id查询本地账号信息 51 | */ 52 | @Test 53 | @Ignore 54 | public void testQueryInfoByUserId() { 55 | PersonInfo personInfo = personInfoDao.queryInfoByUserId(2L); 56 | assertEquals("顾客a", personInfo.getName()); 57 | } 58 | 59 | /** 60 | * 更新账号信息 61 | */ 62 | @Test 63 | public void testUpdatePersonInfo() { 64 | PersonInfo personInfo = new PersonInfo(); 65 | personInfo.setLastEditTime(new Date()); 66 | personInfo.setUserId(2L); 67 | personInfo.setName("顾客aa"); 68 | int effectNum = personInfoDao.updatePersonInfo(personInfo); 69 | assertEquals(1, effectNum); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/ProductCategoryDaoTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.tyron.o2o.dao; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | import org.junit.Ignore; 11 | import org.junit.Test; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | 14 | import com.tyron.o2o.BaseTest; 15 | import com.tyron.o2o.entity.ProductCategory; 16 | 17 | /** 18 | * @Description: 店铺类别dao层测试 19 | * 20 | * @author: tyron 21 | * @date: 2018年9月21日 22 | */ 23 | 24 | public class ProductCategoryDaoTest extends BaseTest { 25 | 26 | @Autowired 27 | private ProductCategoryDao productCategoryDao; 28 | 29 | @Test 30 | @Ignore 31 | public void testQueryByShopId() throws Exception { 32 | long shopId = 1; 33 | List productCategoryList = productCategoryDao.selectProductCategoryList(shopId); 34 | System.out.println("该店铺的类别数:" + productCategoryList.size()); 35 | } 36 | 37 | @Test 38 | @Ignore 39 | public void testBatchInsertProductCategory() { 40 | ProductCategory pc1 = new ProductCategory(); 41 | pc1.setCreateTime(new Date()); 42 | pc1.setPriority(1); 43 | pc1.setShopId(1L); 44 | pc1.setProductCategoryName("商品类别1"); 45 | ProductCategory pc2 = new ProductCategory(); 46 | pc2.setCreateTime(new Date()); 47 | pc2.setPriority(2); 48 | pc2.setShopId(1L); 49 | pc2.setProductCategoryName("商品类别2"); 50 | List pcList = new ArrayList<>(); 51 | pcList.add(pc1); 52 | pcList.add(pc2); 53 | int effectNum = productCategoryDao.batchInsertProductCategory(pcList); 54 | System.out.println(effectNum); 55 | } 56 | 57 | @Test 58 | public void testDeleteProductCategory() throws Exception { 59 | long shopId = 1L; 60 | List productCategories = productCategoryDao.selectProductCategoryList(shopId); 61 | for (ProductCategory productCategory : productCategories) { 62 | if ("嘿嘿".equals(productCategory.getProductCategoryName())) { 63 | int effectedNum = productCategoryDao.deleteProductCategory(productCategory.getProductCategoryId(), 64 | shopId); 65 | System.out.println("被删除的数量" + effectedNum); 66 | } 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/ProductDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import org.junit.Ignore; 7 | import org.junit.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | 10 | import com.tyron.o2o.BaseTest; 11 | import com.tyron.o2o.entity.Product; 12 | import com.tyron.o2o.entity.ProductCategory; 13 | import com.tyron.o2o.entity.Shop; 14 | import com.tyron.o2o.enums.EnableStatusEnum; 15 | 16 | /** 17 | * @Description: 商品测试 18 | * 19 | * @author: tyron 20 | * @date: 2018年10月27日 21 | */ 22 | public class ProductDaoTest extends BaseTest { 23 | 24 | @Autowired 25 | private ProductDao productDao; 26 | 27 | @Test 28 | @Ignore 29 | public void testInsertProduct() { 30 | Shop shop = new Shop(); 31 | shop.setShopId(1L); 32 | ProductCategory productCategory = new ProductCategory(); 33 | productCategory.setProductCategoryId(1L); 34 | Product product = new Product(); 35 | product.setCreateTime(new Date()); 36 | product.setEnableStatus(EnableStatusEnum.AVAILABLE.getState()); 37 | product.setProductName("1"); 38 | product.setProductDesc("11"); 39 | product.setImgAddr("111"); 40 | product.setNormalPrice("1111"); 41 | product.setPromotionPrice("11111"); 42 | product.setPriority(1); 43 | product.setProductCategory(productCategory); 44 | product.setShop(shop); 45 | int effectNum = productDao.insertProduct(product); 46 | System.out.println("effectNum:" + effectNum); 47 | } 48 | 49 | @Test 50 | @Ignore 51 | public void testQueryProductByProductId() throws Exception { 52 | Long productId = 1L; 53 | Product product = productDao.selectProductByProductId(productId); 54 | System.out.println("productImgSize:" + product.getProductImgList().size()); 55 | } 56 | 57 | @Test 58 | @Ignore 59 | public void testUpdateProduct() throws Exception { 60 | Product product = new Product(); 61 | product.setProductId(1L); 62 | ProductCategory productCategory = new ProductCategory(); 63 | productCategory.setProductCategoryId(1L); 64 | Shop shop = new Shop(); 65 | shop.setShopId(1L); 66 | product.setShop(shop); 67 | product.setProductCategory(productCategory); 68 | product.setProductName("测试修改商品"); 69 | int effectNum = productDao.updateProduct(product); 70 | System.out.println("effectNum:" + effectNum); 71 | } 72 | 73 | @Test 74 | @Ignore 75 | public void testQueryProductList() throws Exception { 76 | Product productCondition = new Product(); 77 | // 分页查询 78 | List list = productDao.selectProductList(productCondition, 0, 5); 79 | System.out.println("list.size:" + list.size()); 80 | // 查询总数 81 | int productCount = productDao.selectProductCount(productCondition); 82 | System.out.println("productCount:" + productCount); 83 | 84 | // 使用条件查询 85 | productCondition.setProductName("秋"); 86 | // 条件分页查询 87 | List conditionList = productDao.selectProductList(productCondition, 0, 5); 88 | System.out.println("conditionList.size:" + conditionList.size()); 89 | // 条件查询总数 90 | int conditionProductCount = productDao.selectProductCount(productCondition); 91 | System.out.println("conditionProductCount:" + conditionProductCount); 92 | } 93 | 94 | @Test 95 | public void testUpdateProductCategoryToNull() throws Exception { 96 | int effectNum = productDao.updateProductCategoryToNull(15L); 97 | System.out.println("effectNum:" + effectNum); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/ProductImgDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import org.junit.Ignore; 8 | import org.junit.Test; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | 11 | import com.tyron.o2o.BaseTest; 12 | import com.tyron.o2o.entity.ProductImg; 13 | 14 | /** 15 | * @Description: 商品图片测试 16 | * 17 | * @author: tyron 18 | * @date: 2018年10月27日 19 | */ 20 | public class ProductImgDaoTest extends BaseTest { 21 | 22 | @Autowired 23 | private ProductImgDao productImgDao; 24 | 25 | @Test 26 | public void testBatchInsertProductImg() { 27 | // 在productId为1的商品中添加两个图片记录 28 | ProductImg productImg1 = new ProductImg(); 29 | productImg1.setCreateTime(new Date()); 30 | productImg1.setImgAddr("图片1"); 31 | productImg1.setImgDesc("测试图片1"); 32 | productImg1.setPriority(1); 33 | productImg1.setProductId(1L); 34 | ProductImg productImg2 = new ProductImg(); 35 | productImg2.setCreateTime(new Date()); 36 | productImg2.setImgAddr("图片2"); 37 | productImg2.setImgDesc("测试图片2"); 38 | productImg2.setPriority(2); 39 | productImg2.setProductId(1L); 40 | List productImgs = new ArrayList<>(); 41 | productImgs.add(productImg1); 42 | productImgs.add(productImg2); 43 | int effectNum = productImgDao.batchInsertProductImg(productImgs); 44 | System.out.println("effectNum:" + effectNum); 45 | } 46 | 47 | @Test 48 | @Ignore 49 | public void testDeleteProductImgByProductId() throws Exception { 50 | // 删除商品详情记录 51 | Long productId = 1L; 52 | int effectNum = productImgDao.deleteProductImgByProductId(productId); 53 | System.out.println("effectNum:" + effectNum); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/ShopCategoryDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import org.junit.Ignore; 7 | import org.junit.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.multipart.MultipartFile; 10 | 11 | import com.tyron.o2o.BaseTest; 12 | import com.tyron.o2o.entity.ShopCategory; 13 | import com.tyron.o2o.util.ImageUtil; 14 | import com.tyron.o2o.util.PathUtil; 15 | 16 | /** 17 | * @Description: 店铺类别测试 18 | * 19 | * @author tyronchen 20 | * @date 2018年5月27日 21 | */ 22 | public class ShopCategoryDaoTest extends BaseTest { 23 | 24 | @Autowired 25 | private ShopCategoryDao shopCategoryDao; 26 | 27 | @Test 28 | @Ignore 29 | public void testInsertShopCategory() throws Exception { 30 | ShopCategory shopCategory = new ShopCategory(); 31 | shopCategory.setCreateTime(new Date()); 32 | shopCategory.setPriority(4); 33 | shopCategory.setShopCategoryName("外套"); 34 | shopCategory.setShopCategoryDesc("男装"); 35 | String filePath = "D:\\eclipse\\pic\\外套.jpg"; 36 | MultipartFile multipartFile = ImageUtil.path2MultipartFile(filePath); 37 | String dest = PathUtil.getShopCategoryImagePath(); 38 | String generateHeadImg = ImageUtil.generateShopCategoryImg(multipartFile, dest); 39 | shopCategory.setShopCategoryImg(generateHeadImg); 40 | ShopCategory parentShopCategory = new ShopCategory(); 41 | parentShopCategory.setShopCategoryId(4L); 42 | shopCategory.setParent(parentShopCategory); 43 | int effectNum = shopCategoryDao.insertShopCategory(shopCategory); 44 | System.out.println("effectNum:" + effectNum); 45 | } 46 | 47 | @Test 48 | public void testModifyShopCategory() throws Exception { 49 | ShopCategory currShopCategory = new ShopCategory(); 50 | currShopCategory.setLastEditTime(new Date()); 51 | currShopCategory.setShopCategoryId(10L); 52 | // 删除原有图片 53 | ShopCategory origShopCategory = shopCategoryDao.selectShopCategoryById(10L); 54 | ImageUtil.deleteFileOrPath(origShopCategory.getShopCategoryImg()); 55 | currShopCategory.setPriority(4); 56 | currShopCategory.setShopCategoryName("短袖"); 57 | currShopCategory.setShopCategoryDesc("男装"); 58 | String filePath = "D:\\eclipse\\pic\\短袖.jpg"; 59 | MultipartFile multipartFile = ImageUtil.path2MultipartFile(filePath); 60 | String dest = PathUtil.getShopCategoryImagePath(); 61 | String generateHeadImg = ImageUtil.generateShopCategoryImg(multipartFile, dest); 62 | currShopCategory.setShopCategoryImg(generateHeadImg); 63 | ShopCategory parentShopCategory = new ShopCategory(); 64 | parentShopCategory.setShopCategoryId(4L); 65 | currShopCategory.setParent(parentShopCategory); 66 | int effectNum = shopCategoryDao.updateShopCategory(currShopCategory); 67 | System.out.println("effectNum:" + effectNum); 68 | } 69 | 70 | @Test 71 | @Ignore 72 | public void testQueryShopCategory() { 73 | List shopCategoryList = shopCategoryDao.selectShopCategory(new ShopCategory()); 74 | System.out.println(shopCategoryList.size()); 75 | ShopCategory testCategory = new ShopCategory(); 76 | ShopCategory parentCategory = new ShopCategory(); 77 | parentCategory.setShopCategoryId(1L); 78 | testCategory.setParent(parentCategory); 79 | shopCategoryList = shopCategoryDao.selectShopCategory(testCategory); 80 | System.out.println(shopCategoryList.get(0).getShopCategoryName()); 81 | } 82 | 83 | @Test 84 | @Ignore 85 | public void testQueryShopCategory2() { 86 | List shopCategoryList = shopCategoryDao.selectShopCategory(null); 87 | System.out.println("shopCategoryList.size():" + shopCategoryList.size()); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/dao/ShopDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.dao; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import org.junit.Ignore; 7 | import org.junit.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | 10 | import com.tyron.o2o.BaseTest; 11 | import com.tyron.o2o.entity.Area; 12 | import com.tyron.o2o.entity.PersonInfo; 13 | import com.tyron.o2o.entity.Shop; 14 | import com.tyron.o2o.entity.ShopCategory; 15 | import com.tyron.o2o.enums.EnableStatusEnum; 16 | 17 | /** 18 | * @Description: 测试店铺接口 19 | * 20 | * @author tyronchen 21 | * @date 2018年3月31日 22 | */ 23 | public class ShopDaoTest extends BaseTest { 24 | 25 | @Autowired 26 | private ShopDao shopDao; 27 | 28 | @Test 29 | public void testQueryShopList() { 30 | Shop shopCondition = new Shop(); 31 | ShopCategory childCategory = new ShopCategory(); 32 | ShopCategory parentCategory = new ShopCategory(); 33 | parentCategory.setShopCategoryId(4L); 34 | childCategory.setParent(parentCategory); 35 | shopCondition.setShopCategory(childCategory); 36 | List shopList = shopDao.selectShopList(shopCondition, 0, 3); 37 | System.out.println("查询店铺列表的大小:" + shopList.size()); 38 | int shopCount = shopDao.selectShopCount(shopCondition); 39 | System.out.println("店铺列表总数大小:" + shopCount); 40 | } 41 | 42 | @Test 43 | @Ignore 44 | public void testInsertShop() { 45 | Shop shop = new Shop(); 46 | PersonInfo owner = new PersonInfo(); 47 | ShopCategory shopCategory = new ShopCategory(); 48 | Area area = new Area(); 49 | owner.setUserId(1L); 50 | area.setAreaId(1); 51 | shopCategory.setShopCategoryId(1L); 52 | shop.setOwner(owner); 53 | shop.setShopCategory(shopCategory); 54 | shop.setArea(area); 55 | shop.setShopAddr("test"); 56 | shop.setShopName("test店铺"); 57 | shop.setShopDesc("test"); 58 | shop.setShopImg("test"); 59 | shop.setPhone("test"); 60 | shop.setPriority(1); 61 | shop.setCreateTime(new Date()); 62 | shop.setEnableStatus(EnableStatusEnum.AVAILABLE.getState()); 63 | shop.setAdvice("审核中"); 64 | int effectNum = shopDao.insertShop(shop); 65 | System.out.println("effectNum:" + effectNum); 66 | } 67 | 68 | @Test 69 | @Ignore 70 | public void testUpdateShop() { 71 | Shop shop = new Shop(); 72 | shop.setShopId(1L); 73 | shop.setShopAddr("test@111"); 74 | shop.setShopName("@test@111"); 75 | shop.setShopDesc("test111"); 76 | shop.setShopImg("test111"); 77 | shop.setPhone("test111"); 78 | shop.setLastEditTime(new Date()); 79 | int effectNum = shopDao.updateShop(shop); 80 | System.out.println("effectNum:" + effectNum); 81 | } 82 | 83 | @Test 84 | @Ignore 85 | public void testQueryShop() { 86 | Shop shop = shopDao.selectByShopId(1); 87 | System.out.println("areaName:" + shop.getArea().getAreaName()); 88 | System.out.println("shopCategoryName:" + shop.getShopCategory().getShopCategoryName()); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/service/AreaServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import com.tyron.o2o.BaseTest; 9 | import com.tyron.o2o.entity.Area; 10 | 11 | /** 12 | * @Description: 区域业务测试 13 | * 14 | * @author tyronchen 15 | * @date 2018年3月24日 16 | */ 17 | public class AreaServiceTest extends BaseTest { 18 | 19 | @Autowired 20 | private AreaService areaService; 21 | 22 | @Test 23 | public void testQueryArea() { 24 | List areaList = areaService.getAreaList(); 25 | System.out.println("service测试:" + areaList.toString()); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/service/ProductServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | import org.junit.Ignore; 9 | import org.junit.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import com.tyron.o2o.BaseTest; 14 | import com.tyron.o2o.dto.ProductExecution; 15 | import com.tyron.o2o.entity.Product; 16 | import com.tyron.o2o.entity.ProductCategory; 17 | import com.tyron.o2o.entity.Shop; 18 | import com.tyron.o2o.enums.EnableStatusEnum; 19 | import com.tyron.o2o.util.ImageUtil; 20 | 21 | /** 22 | * 23 | * @Description: 商品业务测试 24 | * 25 | * @author: tyron 26 | * @date: 2018年11月11日 27 | */ 28 | public class ProductServiceTest extends BaseTest { 29 | 30 | @Autowired 31 | private ProductService productService; 32 | 33 | @Test 34 | @Ignore 35 | public void testAddShop() throws IOException { 36 | Product product = new Product(); 37 | Shop shop = new Shop(); 38 | shop.setShopId(1L); 39 | product.setShop(shop); 40 | ProductCategory productCategory = new ProductCategory(); 41 | productCategory.setProductCategoryId(1L); 42 | product.setProductCategory(productCategory); 43 | product.setProductName("测试商品1"); 44 | product.setProductDesc("测试商品1描述"); 45 | product.setPriority(11); 46 | product.setEnableStatus(EnableStatusEnum.AVAILABLE.getState()); 47 | product.setLastEditTime(new Date()); 48 | product.setCreateTime(new Date()); 49 | String filePath0 = "D:\\eclipse\\pic\\IMG_2837.JPG"; 50 | List productImgList = new ArrayList<>(); 51 | String filePath1 = "D:\\eclipse\\pic\\IMG_2808.JPG"; 52 | MultipartFile productImg1 = ImageUtil.path2MultipartFile(filePath1); 53 | productImgList.add(productImg1); 54 | String filePath2 = "D:\\eclipse\\pic\\IMG_2814.JPG"; 55 | MultipartFile productImg2 = ImageUtil.path2MultipartFile(filePath2); 56 | productImgList.add(productImg2); 57 | ProductExecution se = productService.addProduct(product, ImageUtil.path2MultipartFile(filePath0), 58 | productImgList); 59 | System.out.println("ProductExecution.state" + se.getState()); 60 | System.out.println("ProductExecution.stateInfo" + se.getStateInfo()); 61 | } 62 | 63 | @Test 64 | public void testModifyShop() throws IOException { 65 | Product product = new Product(); 66 | Shop shop = new Shop(); 67 | shop.setShopId(1L); 68 | product.setShop(shop); 69 | ProductCategory productCategory = new ProductCategory(); 70 | productCategory.setProductCategoryId(2L); 71 | product.setProductId(3L); 72 | product.setProductCategory(productCategory); 73 | product.setProductName("测试商品2"); 74 | product.setProductDesc("测试商品2描述"); 75 | product.setPriority(22); 76 | product.setEnableStatus(EnableStatusEnum.AVAILABLE.getState()); 77 | product.setLastEditTime(new Date()); 78 | product.setCreateTime(new Date()); 79 | String filePath0 = "D:\\eclipse\\pic\\1.JPG"; 80 | List productImgList = new ArrayList<>(); 81 | String filePath1 = "D:\\eclipse\\pic\\2.JPG"; 82 | MultipartFile productImg1 = ImageUtil.path2MultipartFile(filePath1); 83 | productImgList.add(productImg1); 84 | String filePath2 = "D:\\eclipse\\pic\\3.JPG"; 85 | MultipartFile productImg2 = ImageUtil.path2MultipartFile(filePath2); 86 | productImgList.add(productImg2); 87 | ProductExecution se = productService.modifyProduct(product, ImageUtil.path2MultipartFile(filePath0), 88 | productImgList); 89 | System.out.println("ProductExecution.state" + se.getState()); 90 | System.out.println("ProductExecution.stateInfo" + se.getStateInfo()); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/test/java/com/tyron/o2o/service/ShopServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.tyron.o2o.service; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.util.Date; 7 | 8 | import org.apache.commons.io.IOUtils; 9 | import org.junit.Ignore; 10 | import org.junit.Test; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.mock.web.MockMultipartFile; 13 | import org.springframework.web.multipart.MultipartFile; 14 | 15 | import com.tyron.o2o.BaseTest; 16 | import com.tyron.o2o.dto.ShopExecution; 17 | import com.tyron.o2o.entity.Area; 18 | import com.tyron.o2o.entity.PersonInfo; 19 | import com.tyron.o2o.entity.Shop; 20 | import com.tyron.o2o.entity.ShopCategory; 21 | 22 | /** 23 | * @Description: 店铺业务测试 24 | * 25 | * @author tyronchen 26 | * @date 2018年4月15日 27 | */ 28 | public class ShopServiceTest extends BaseTest { 29 | 30 | @Autowired 31 | private ShopService shopService; 32 | 33 | @Test 34 | @Ignore 35 | public void testGetShopList() { 36 | 37 | Shop shopCondition = new Shop(); 38 | PersonInfo personInfo = new PersonInfo(); 39 | personInfo.setUserId(1L); 40 | 41 | shopCondition.setOwner(personInfo); 42 | shopCondition.setShopName("奶茶"); 43 | 44 | ShopExecution se = shopService.getShopList(shopCondition, 1, 2); 45 | System.out.println("查询得到店铺数:" + se.getShopList().size()); 46 | System.out.println("店铺总数:" + se.getCount()); 47 | se = shopService.getShopList(shopCondition, 2, 2); 48 | System.out.println("查询得到店铺数:" + se.getShopList().size()); 49 | System.out.println("店铺总数:" + se.getCount()); 50 | } 51 | 52 | @Test 53 | @Ignore 54 | public void testModifyShop() throws IOException { 55 | Shop shop = new Shop(); 56 | shop.setShopId(1L); 57 | shop.setShopName("修改店铺测试"); 58 | String filePath = "F:\\luffy.jpg"; 59 | shopService.modifyShop(shop, path2MultipartFile(filePath)); 60 | System.out.println("修改后图片:" + shop.getShopImg()); 61 | } 62 | 63 | @Test 64 | public void testAddShop() throws IOException { 65 | Shop shop = new Shop(); 66 | PersonInfo owner = new PersonInfo(); 67 | ShopCategory shopCategory = new ShopCategory(); 68 | Area area = new Area(); 69 | owner.setUserId(1L); 70 | area.setAreaId(1); 71 | shopCategory.setShopCategoryId(1L); 72 | shop.setOwner(owner); 73 | shop.setShopCategory(shopCategory); 74 | shop.setArea(area); 75 | shop.setShopAddr("testService"); 76 | shop.setShopName("test店铺Service"); 77 | shop.setShopDesc("testService"); 78 | shop.setShopImg("testService"); 79 | shop.setPhone("testService"); 80 | shop.setPriority(1); 81 | shop.setCreateTime(new Date()); 82 | shop.setAdvice("审核中"); 83 | String filePath = "D:\\soft\\luffy.jpg"; 84 | ShopExecution se = shopService.addShop(shop, path2MultipartFile(filePath)); 85 | System.out.println("ShopExecution.state" + se.getState()); 86 | System.out.println("ShopExecution.stateInfo" + se.getStateInfo()); 87 | } 88 | 89 | /** 90 | * filePath to MultipartFile 91 | * 92 | * @param filePath 93 | * @throws IOException 94 | */ 95 | private MultipartFile path2MultipartFile(String filePath) throws IOException { 96 | File file = new File(filePath); 97 | FileInputStream input = new FileInputStream(file); 98 | MultipartFile multipartFile = new MockMultipartFile("file", file.getName(), "text/plain", 99 | IOUtils.toByteArray(input)); 100 | return multipartFile; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/test/resources/watermark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tyronczt/imooc-o2o/7f62ccb6e080cc8fe5c2c277b5ff232e5bbab979/src/test/resources/watermark.jpg --------------------------------------------------------------------------------