├── .gitignore ├── README.md ├── doc ├── idea 快捷键.md └── tomcat.md.md ├── foodie-api ├── foodie-api.iml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── muxin │ │ │ ├── Application.java │ │ │ ├── aspect │ │ │ └── ServiceLogAspect.java │ │ │ ├── config │ │ │ ├── CorsConfig.java │ │ │ └── Swagger2.java │ │ │ └── controller │ │ │ ├── AddressController.java │ │ │ ├── BaseController.java │ │ │ ├── IndexController.java │ │ │ ├── ItemsController.java │ │ │ ├── OrdersController.java │ │ │ ├── PassportController.java │ │ │ └── ShopcatController.java │ └── resources │ │ ├── application.yml │ │ └── log4j.properties │ └── test │ └── java │ └── com │ └── test │ └── TransTest.java ├── foodie-common ├── foodie-common.iml ├── pom.xml └── src │ └── main │ └── java │ ├── com │ └── muxin │ │ ├── enums │ │ ├── CommentLevel.java │ │ ├── OrderStatusEnum.java │ │ ├── PayMethod.java │ │ ├── ProductCategory.java │ │ ├── Sex.java │ │ └── YesOrNo.java │ │ └── utils │ │ ├── CookieUtils.java │ │ ├── DateUtil.java │ │ ├── DesensitizationUtil.java │ │ ├── JSONResult.java │ │ ├── JsonUtils.java │ │ ├── MD5Utils.java │ │ ├── MobileEmailUtils.java │ │ └── PagedGridResult.java │ └── org │ ├── .gitignore │ └── n3r │ └── idworker │ ├── Code.java │ ├── DayCode.java │ ├── Id.java │ ├── IdWorker.java │ ├── InvalidSystemClock.java │ ├── RandomCodeStrategy.java │ ├── Sid.java │ ├── Test.java │ ├── WorkerIdStrategy.java │ ├── strategy │ ├── DayPrefixRandomCodeStrategy.java │ ├── DefaultRandomCodeStrategy.java │ ├── DefaultWorkerIdStrategy.java │ └── FileLock.java │ └── utils │ ├── HttpReq.java │ ├── IPv4Utils.java │ ├── Ip.java │ ├── Props.java │ ├── Serializes.java │ └── Utils.java ├── foodie-mapper ├── foodie-mapper.iml ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── muxin │ │ ├── mapper │ │ ├── AddressMapper.java │ │ ├── CarouselMapper.java │ │ ├── CategoryCustomMapper.java │ │ ├── CategoryMapper.java │ │ ├── ItemsCommentsMapper.java │ │ ├── ItemsCustomMapper.java │ │ ├── ItemsImgMapper.java │ │ ├── ItemsMapper.java │ │ ├── ItemsParamMapper.java │ │ ├── ItemsSpecMapper.java │ │ ├── OrderItemsMapper.java │ │ ├── OrderStatusMapper.java │ │ ├── OrdersMapper.java │ │ ├── StuMapper.java │ │ └── UsersMapper.java │ │ └── my │ │ └── mapper │ │ └── MyMapper.java │ └── resources │ └── mapper │ ├── CarouselMapper.xml │ ├── CategoryMapper.xml │ ├── CategoryMapperCustom.xml │ ├── ItemsCommentsMapper.xml │ ├── ItemsCustomMapper.xml │ ├── ItemsImgMapper.xml │ ├── ItemsMapper.xml │ ├── ItemsParamMapper.xml │ ├── ItemsSpecMapper.xml │ ├── OrderItemsMapper.xml │ ├── OrderStatusMapper.xml │ ├── OrdersMapper.xml │ ├── StuMapper.xml │ ├── UsersMapper.xml │ └── addressMapper.xml ├── foodie-pojo ├── foodie-pojo.iml ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── muxin │ └── pojo │ ├── Carousel.java │ ├── Category.java │ ├── ItemParams.java │ ├── Items.java │ ├── ItemsComments.java │ ├── ItemsImg.java │ ├── ItemsSpec.java │ ├── OrderItems.java │ ├── OrderStatus.java │ ├── Orders.java │ ├── Stu.java │ ├── UserAddress.java │ ├── Users.java │ ├── bo │ ├── AddressBO.java │ ├── ShopcartBO.java │ ├── SubmitOrderBO.java │ └── UserBO.java │ └── vo │ ├── CategoryVO.java │ ├── CommentLevelCountsVO.java │ ├── ItemCommentVO.java │ ├── ItemInfoVO.java │ ├── NewItemsVO.java │ ├── SearchItemsVO.java │ ├── ShopcartVO.java │ ├── SimpleItemVO.java │ └── SubCategoryVO.java ├── foodie-service ├── foodie-service.iml ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── muxin │ └── service │ ├── AddressService.java │ ├── CarouselService.java │ ├── CategoryService.java │ ├── ItemService.java │ ├── OrderService.java │ ├── TestTransService.java │ ├── UserService.java │ └── impl │ ├── AddressServiceImpl.java │ ├── CarouselServiceImpl.java │ ├── CategoryServiceImpl.java │ ├── ItemServiceImpl.java │ ├── OrderServiceImpl.java │ └── UserServiceImpl.java ├── foodie.iml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # IDEA Items 26 | *.iml 27 | .idea/ 28 | 29 | pmd_result.log 30 | mvn_pmd.sh 31 | 32 | # Package Files # 33 | .settings 34 | .idea 35 | .metadata 36 | target 37 | classes 38 | .jupiter 39 | .project 40 | .classpath 41 | *.lock 42 | *.DS_Store 43 | *.swp 44 | *.out 45 | *.iml 46 | /bin/ 47 | 48 | # target 49 | /target/ 50 | foodie-api/target/* 51 | foodie-common/target/* 52 | foodie-mapper/target/* 53 | foodie-pojo/target/* 54 | foodie-service/target/* 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # foodie 2 | foodie 是使用java做的电商网站,目的是为了学习java技术。 3 | -------------------------------------------------------------------------------- /doc/idea 快捷键.md: -------------------------------------------------------------------------------- 1 | ## idea 快捷键 2 | 3 | 4 | 5 | | 快捷键 | 作用 | 6 | | ----------- | --------------------------- | 7 | | alt + / | 代码补全 | 8 | | control + i | Select Methods to Implement | 9 | | | | 10 | | | | 11 | | | | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /doc/tomcat.md.md: -------------------------------------------------------------------------------- 1 | cd apache-tomcat-9.0.30 2 | chmod -R 777 bin 3 | ./startup.sh -------------------------------------------------------------------------------- /foodie-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie 7 | com.muxin 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | foodie-api 13 | 14 | 18 | 19 | 20 | com.muxin 21 | foodie-service 22 | 1.0-SNAPSHOT 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | test 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/Application.java: -------------------------------------------------------------------------------- 1 | package com.muxin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | import tk.mybatis.spring.annotation.MapperScan; 7 | 8 | /** 9 | * @program: foodie 10 | * @description: 11 | * @author: Mr.Wang 12 | * @create: 2019-25 21:50 13 | */ 14 | @SpringBootApplication 15 | // 扫描 mybatis 通用 mapper 所在的包 16 | @MapperScan(basePackages = "com.muxin.mapper") 17 | // 扫描所有包以及相关组件包 18 | @ComponentScan(basePackages = {"com.muxin", "org.n3r.idworker"}) 19 | public class Application { 20 | public static void main(String[] args) { 21 | SpringApplication.run(Application.class, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/aspect/ServiceLogAspect.java: -------------------------------------------------------------------------------- 1 | package com.muxin.aspect; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * @program: foodie 12 | * @description: 13 | * @author: Mr.Wang 14 | * @create: 2019-31 19:42 15 | */ 16 | @Aspect 17 | @Component 18 | public class ServiceLogAspect { 19 | 20 | public static final Logger log = 21 | LoggerFactory.getLogger(ServiceLogAspect.class); 22 | 23 | 24 | /** 25 | * AOP通知: 26 | * 1. 前置通知:在方法调用之前执行 27 | * 2. 后置通知:在方法正常调用之后执行 28 | * 3. 环绕通知:在方法调用之前和之后,都分别可以执行的通知 29 | * 4. 异常通知:如果在方法调用过程中发生异常,则通知 30 | * 5. 最终通知:在方法调用之后执行 31 | */ 32 | 33 | /** 34 | * 切面表达式: 35 | * execution 代表所要执行的表达式主体 36 | * 第一处 「*」代表方法返回类型 「*」代表所有类型 37 | * 第二处 「包名」代表aop监控的类所在的包 38 | * 第三处 「..」代表该包以及其子包下的所有类方法 39 | * 第四处 「*」 代表类名,「*」代表所有类 40 | * 第五处 「*(..)」 「*」代表类中的方法名,「..」代表方法中的任何参数 41 | * 42 | * @param joinPoint 43 | * @return 44 | * @throws Throwable 45 | */ 46 | @Around("execution(* com.muxin.service.impl..*.*(..))") 47 | public Object recordTimeLog(ProceedingJoinPoint joinPoint) throws Throwable { 48 | 49 | log.info("====== 开始执行 {}.{} ======", 50 | joinPoint.getTarget().getClass(), 51 | joinPoint.getSignature().getName()); 52 | 53 | // 记录开始时间 54 | long begin = System.currentTimeMillis(); 55 | 56 | // 执行目标 service 57 | Object result = joinPoint.proceed(); 58 | 59 | // 记录结束时间 60 | long end = System.currentTimeMillis(); 61 | long takeTime = end - begin; 62 | 63 | if (takeTime > 3000) { 64 | log.error("====== 执行结束,耗时:{} 毫秒 ======", takeTime); 65 | } else if (takeTime > 2000) { 66 | log.warn("====== 执行结束,耗时:{} 毫秒 ======", takeTime); 67 | } else { 68 | log.info("====== 执行结束,耗时:{} 毫秒 ======", takeTime); 69 | } 70 | 71 | return result; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package com.muxin.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.cors.CorsConfiguration; 6 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 7 | import org.springframework.web.filter.CorsFilter; 8 | 9 | /** 10 | * @program: foodie 11 | * @description: 12 | * @author: Mr.Wang 13 | * @create: 2019-30 22:34 14 | */ 15 | @Configuration 16 | public class CorsConfig { 17 | 18 | public CorsConfig() { 19 | 20 | } 21 | 22 | @Bean 23 | public CorsFilter corsFilter() { 24 | // 1. 添加cors配置信息 25 | CorsConfiguration config = new CorsConfiguration(); 26 | config.addAllowedOrigin("http://localhost:8080"); 27 | 28 | // 设置是否发送cookie信息 29 | config.setAllowCredentials(true); 30 | 31 | // 设置允许请求的方式 32 | config.addAllowedMethod("*"); 33 | 34 | // 设置允许的header 35 | config.addAllowedHeader("*"); 36 | 37 | // 2. 为url添加映射路径 38 | UrlBasedCorsConfigurationSource corsSource = new UrlBasedCorsConfigurationSource(); 39 | corsSource.registerCorsConfiguration("/**", config); 40 | 41 | // 3. 返回重新定义好的crosSource 42 | return new CorsFilter(corsSource ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/config/Swagger2.java: -------------------------------------------------------------------------------- 1 | package com.muxin.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.service.Contact; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | /** 15 | * @program: foodie 16 | * @description: 17 | * @author: Mr.Wang 18 | * @create: 2019-29 16:59 19 | */ 20 | @Configuration 21 | @EnableSwagger2 22 | public class Swagger2 { 23 | 24 | // http://localhost:8088/swagger-ui.html 原路径 25 | // http://localhost:8088/doc.html 26 | // 配置swagger2核心配置docket 27 | @Bean 28 | public Docket createRestApi() { 29 | return new Docket(DocumentationType.SWAGGER_2) // 指定api类型为swagger2 30 | .apiInfo(apiInfo()) // 用于定义api文档汇总信息 31 | .select() 32 | .apis(RequestHandlerSelectors 33 | .basePackage("com.muxin.controller")) // 指定controller包 34 | .paths(PathSelectors.any()) // 所有controller 35 | .build(); 36 | } 37 | 38 | private ApiInfo apiInfo() { 39 | return new ApiInfoBuilder() 40 | .title("天天吃货 电商平台接口api") // 文档页标题 41 | .contact(new Contact("muxin", 42 | "https://www.yaoyaoniu.com", 43 | "wgy952046097@gmail.com" 44 | )) // 联系人信息 45 | .description("转为天天吃货提供的api文档") // 详细信息 46 | .version("1.0.1") // 文档版本号 47 | .termsOfServiceUrl("https://www.yaoyaoniu.com") // 网站地址 48 | .build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/AddressController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import com.muxin.pojo.UserAddress; 4 | import com.muxin.pojo.bo.AddressBO; 5 | import com.muxin.service.AddressService; 6 | import com.muxin.utils.JSONResult; 7 | import com.muxin.utils.MobileEmailUtils; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @program: foodie 18 | * @description: 19 | * @author: Mr.Wang 20 | * @create: 2019-25 21:53 21 | */ 22 | @Api(value = "地址相关", tags={ "地址相关的api接口"}) 23 | @RequestMapping("address") 24 | @RestController 25 | public class AddressController { 26 | 27 | /** 28 | * 用户在确认订单页面,可以针对收货地址做如下操作: 29 | * 1. 查询用户的所有收货地址列表 30 | * 2. 新增收货地址 31 | * 3. 删除收货地址 32 | * 4. 修改收货地址 33 | * 5. 设置默认地址 34 | * 35 | */ 36 | 37 | @Autowired 38 | private AddressService addressService; 39 | 40 | @ApiOperation(value = "根据用户id查询收货地址列表", notes = "根据用户id查询收货地址列表", httpMethod = "POST") 41 | @PostMapping("/list") 42 | public JSONResult list(@RequestParam String userId) { 43 | if (StringUtils.isBlank(userId)) { 44 | return JSONResult.errorMsg(""); 45 | } 46 | 47 | List list = addressService.queryAll(userId); 48 | return JSONResult.ok(list); 49 | } 50 | 51 | private JSONResult checkAddress(AddressBO addressBO) { 52 | String receiver = addressBO.getReceiver(); 53 | if (StringUtils.isBlank(receiver)) { 54 | return JSONResult.errorMsg("收货人不能为空"); 55 | } 56 | if (receiver.length() > 12) { 57 | return JSONResult.errorMsg("收货人姓名不能太长"); 58 | } 59 | 60 | String mobile = addressBO.getMobile(); 61 | if (StringUtils.isBlank(mobile)) { 62 | return JSONResult.errorMsg("收货人手机号不能为空"); 63 | } 64 | if (mobile.length() != 11) { 65 | return JSONResult.errorMsg("收货人手机号长度不正确"); 66 | } 67 | boolean isMobileOk = MobileEmailUtils.checkMobileIsOk(mobile); 68 | if (!isMobileOk) { 69 | return JSONResult.errorMsg("收货人手机号格式不正确"); 70 | } 71 | 72 | String province = addressBO.getProvince(); 73 | String city = addressBO.getCity(); 74 | String district = addressBO.getDistrict(); 75 | String detail = addressBO.getDetail(); 76 | if (StringUtils.isBlank(province) || 77 | StringUtils.isBlank(city) || 78 | StringUtils.isBlank(district) || 79 | StringUtils.isBlank(detail)) { 80 | return JSONResult.errorMsg("收货地址信息不能为空"); 81 | } 82 | 83 | return JSONResult.ok(); 84 | } 85 | 86 | @ApiOperation(value = "用户新增地址", notes = "用户新增地址", httpMethod = "POST") 87 | @PostMapping("/add") 88 | public JSONResult add( 89 | @RequestBody AddressBO addressBO) { 90 | 91 | JSONResult checkRes = checkAddress(addressBO); 92 | if (checkRes.getStatus() != 200) { 93 | return checkRes; 94 | } 95 | 96 | addressService.addNewUserAddress(addressBO); 97 | 98 | return JSONResult.ok(); 99 | } 100 | 101 | @ApiOperation(value = "用户修改地址", notes = "用户修改地址", httpMethod = "POST") 102 | @PostMapping("/update") 103 | public JSONResult update(@RequestBody AddressBO addressBO) { 104 | 105 | if (StringUtils.isBlank(addressBO.getAddressId())) { 106 | return JSONResult.errorMsg("修改地址错误: addressId不能为空"); 107 | } 108 | 109 | JSONResult checkRes = checkAddress(addressBO); 110 | if (checkRes.getStatus() != 200) { 111 | return checkRes; 112 | } 113 | 114 | addressService.updateUserAddress(addressBO); 115 | 116 | return JSONResult.ok(); 117 | } 118 | 119 | @ApiOperation(value = "用户删除地址", notes = "用户删除地址", httpMethod = "POST") 120 | @PostMapping("/delete") 121 | public JSONResult delete( 122 | @RequestParam String userId, 123 | @RequestParam String addressId) { 124 | 125 | if (StringUtils.isBlank(userId) || StringUtils.isBlank(addressId)) { 126 | return JSONResult.errorMsg(""); 127 | } 128 | 129 | addressService.deleteUserAddress(userId, addressId); 130 | return JSONResult.ok(); 131 | } 132 | 133 | @ApiOperation(value = "用户设置默认地址", notes = "用户设置默认地址", httpMethod = "POST") 134 | @PostMapping("/setDefault") 135 | public JSONResult setDefault( 136 | 137 | @RequestParam String userId, 138 | @RequestParam String addressId) { 139 | 140 | if (StringUtils.isBlank(userId) || StringUtils.isBlank(addressId)) { 141 | return JSONResult.errorMsg(""); 142 | } 143 | 144 | addressService.updateUserAddressToBeDefault(userId, addressId); 145 | return JSONResult.ok(); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/BaseController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | 5 | @Controller 6 | public class BaseController { 7 | 8 | public static final String FOODIE_SHOPCART = "shopcart"; 9 | public static final Integer COMMENT_PAGE_SIZE = 10; 10 | public static final Integer PAGE_SIZE = 20; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import com.muxin.enums.YesOrNo; 4 | import com.muxin.pojo.Carousel; 5 | import com.muxin.pojo.Category; 6 | import com.muxin.pojo.vo.CategoryVO; 7 | import com.muxin.pojo.vo.NewItemsVO; 8 | import com.muxin.service.CarouselService; 9 | import com.muxin.service.CategoryService; 10 | import com.muxin.utils.JSONResult; 11 | import io.swagger.annotations.Api; 12 | import io.swagger.annotations.ApiOperation; 13 | import io.swagger.annotations.ApiParam; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.web.bind.annotation.GetMapping; 18 | import org.springframework.web.bind.annotation.PathVariable; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import javax.servlet.http.HttpServletRequest; 23 | import javax.servlet.http.HttpSession; 24 | import java.util.List; 25 | 26 | /** 27 | * @program: foodie 28 | * @description: 29 | * @author: Mr.Wang 30 | * @create: 2019-25 21:53 31 | */ 32 | @Api(value = "首页", tags={ "首页展示的相关接口"}) 33 | @RestController 34 | @RequestMapping("index") 35 | public class IndexController { 36 | 37 | @Autowired 38 | private CarouselService carouselService; 39 | 40 | @Autowired 41 | private CategoryService categoryService; 42 | 43 | @ApiOperation(value = "获取首页轮播图列表", notes = "获取首页轮播图列表", httpMethod = "GET") 44 | @GetMapping("/carousel") 45 | public JSONResult carousel() { 46 | List list = carouselService.queryAll(YesOrNo.YES.type); 47 | return JSONResult.ok(list); 48 | } 49 | 50 | /** 51 | * 首页分类展示需求: 52 | * 1. 第一次刷新主页查询大分类,渲染展示到首页 53 | * 2. 如果鼠标上移到大分类,则加载其子分类的内容,如果已经存在子分类,则不需要加载 54 | */ 55 | @ApiOperation(value = "获取商品分类(一级分类)", notes = "获取商品分类(一级分类)", httpMethod = "GET") 56 | @GetMapping("/cats") 57 | public JSONResult cats() { 58 | List list = categoryService.queryAllRootLevelCat(); 59 | return JSONResult.ok(list); 60 | } 61 | 62 | /** 63 | * 首页分类展示需求: 64 | * 1. 第一次刷新主页查询大分类,渲染展示到首页 65 | * 2. 如果鼠标上移到大分类,则加载其子分类的内容,如果已经存在子分类,则不需要加载 66 | */ 67 | @ApiOperation(value = "获取商品子分类", notes = "获取商品分类", httpMethod = "GET") 68 | @GetMapping("/subCat/{rootCatId}") 69 | public JSONResult subCat( 70 | @ApiParam(name = "rootCatId", value = "一级分类id", required = true) 71 | @PathVariable Integer rootCatId) { 72 | 73 | if (rootCatId == null) { 74 | return JSONResult.errorMsg("分类不存在"); 75 | } 76 | 77 | List list = categoryService.getSubCatList(rootCatId); 78 | return JSONResult.ok(list); 79 | } 80 | 81 | /** 82 | * 首页分类展示需求: 83 | * 1. 第一次刷新主页查询大分类,渲染展示到首页 84 | * 2. 如果鼠标上移到大分类,则加载其子分类的内容,如果已经存在子分类,则不需要加载 85 | */ 86 | @ApiOperation(value = "查询每个一级分类下的最新6条商品数据", notes = "查询每个一级分类下的最新6条商品数据", httpMethod = "GET") 87 | @GetMapping("/sixNewItems/{rootCatId}") 88 | public JSONResult sixNewItems( 89 | @ApiParam(name = "rootCatId", value = "一级分类id", required = true) 90 | @PathVariable Integer rootCatId) { 91 | 92 | if (rootCatId == null) { 93 | return JSONResult.errorMsg("分类不存在"); 94 | } 95 | 96 | List list = categoryService.getSixNewItemsLazy(rootCatId); 97 | return JSONResult.ok(list); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/ItemsController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import com.muxin.pojo.*; 4 | import com.muxin.pojo.vo.CommentLevelCountsVO; 5 | import com.muxin.pojo.vo.ItemInfoVO; 6 | import com.muxin.pojo.vo.ShopcartVO; 7 | import com.muxin.service.ItemService; 8 | import com.muxin.utils.JSONResult; 9 | import com.muxin.utils.PagedGridResult; 10 | import io.swagger.annotations.Api; 11 | import io.swagger.annotations.ApiOperation; 12 | import io.swagger.annotations.ApiParam; 13 | import io.swagger.models.auth.In; 14 | import org.apache.commons.lang3.StringUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * @program: foodie 22 | * @description: 23 | * @author: Mr.Wang 24 | * @create: 2019-25 21:53 25 | */ 26 | @Api(value = "商品接口", tags = {"商品信息展示的相关接口"}) 27 | @RestController 28 | @RequestMapping("items") 29 | public class ItemsController extends BaseController { 30 | 31 | @Autowired 32 | private ItemService itemService; 33 | 34 | @ApiOperation(value = "查询商品详情", notes = "查询商品详情", httpMethod = "GET") 35 | @GetMapping("/info/{itemId}") 36 | public JSONResult info( 37 | @ApiParam(name = "itemId", value = "商品id", required = true) 38 | @PathVariable String itemId) { 39 | 40 | if (StringUtils.isBlank(itemId)) { 41 | return JSONResult.errorMsg("商品不存在"); 42 | } 43 | 44 | Items item = itemService.queryItemById(itemId); 45 | List itemsImgList = itemService.queryItemImgList(itemId); 46 | List itemsSpecList = itemService.queryItemSpecList(itemId); 47 | ItemParams itemParams = itemService.queryItemParam(itemId); 48 | 49 | 50 | ItemInfoVO itemInfoVO = new ItemInfoVO(); 51 | itemInfoVO.setItem(item); 52 | itemInfoVO.setItemImgList(itemsImgList); 53 | itemInfoVO.setItemSpecList(itemsSpecList); 54 | itemInfoVO.setItemParams(itemParams); 55 | 56 | return JSONResult.ok(itemInfoVO); 57 | } 58 | 59 | @ApiOperation(value = "查询商品评价等级", notes = "查询商品评价等级", httpMethod = "GET") 60 | @GetMapping("/commentLevel") 61 | public JSONResult commentLevel( 62 | @ApiParam(name = "itemId", value = "商品id", required = true) 63 | @RequestParam String itemId) { 64 | 65 | if (StringUtils.isBlank(itemId)) { 66 | return JSONResult.errorMsg(null); 67 | } 68 | 69 | CommentLevelCountsVO countsVO = itemService.queryCommentCounts(itemId); 70 | 71 | return JSONResult.ok(countsVO); 72 | } 73 | 74 | @ApiOperation(value = "查询商品评论", notes = "查询商品评论", httpMethod = "GET") 75 | @GetMapping("/comments") 76 | public JSONResult comments( 77 | @ApiParam(name = "itemId", value = "商品id", required = true) 78 | @RequestParam String itemId, 79 | @ApiParam(name = "level", value = "评价等级", required = false) 80 | @RequestParam Integer level, 81 | @ApiParam(name = "page", value = "当前第几页", required = false) 82 | @RequestParam Integer page, 83 | @ApiParam(name = "pageSize", value = "分页页数", required = false) 84 | @RequestParam Integer pageSize) { 85 | 86 | if (StringUtils.isBlank(itemId)) { 87 | return JSONResult.errorMsg(null); 88 | } 89 | 90 | if (page == null) { 91 | page = 1; 92 | } 93 | 94 | if (pageSize == null) { 95 | pageSize = COMMENT_PAGE_SIZE; 96 | } 97 | 98 | PagedGridResult grid = itemService.queryPagedComment(itemId, level, page, pageSize); 99 | 100 | return JSONResult.ok(grid); 101 | } 102 | 103 | // 用于用户长时间未登录网站,刷新购物车中的数据(主要是商品价格),类似京东淘宝 104 | @ApiOperation(value = "根据商品规格ids查找最新的商品数据", notes = "根据商品规格ids查找最新的商品数据", httpMethod = "GET") 105 | @GetMapping("/refresh") 106 | public JSONResult refresh( 107 | @ApiParam(name = "itemSpecIds", value = "拼接的规格ids", required = true, example = "1001,1003,1005") 108 | @RequestParam String itemSpecIds) { 109 | 110 | if (StringUtils.isBlank(itemSpecIds)) { 111 | return JSONResult.ok(); 112 | } 113 | 114 | List list = itemService.queryItemsBySpecIds(itemSpecIds); 115 | 116 | return JSONResult.ok(list); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/OrdersController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import com.muxin.enums.PayMethod; 4 | import com.muxin.pojo.bo.SubmitOrderBO; 5 | import com.muxin.service.OrderService; 6 | import com.muxin.utils.CookieUtils; 7 | import com.muxin.utils.JSONResult; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | /** 17 | * @program: foodie 18 | * @description: 19 | * @author: Mr.Wang 20 | * @create: 2019-25 21:53 21 | */ 22 | @Api(value = "订单相关", tags = {"订单相关的api接口"}) 23 | @RequestMapping("orders") 24 | @RestController 25 | public class OrdersController extends BaseController { 26 | 27 | @Autowired 28 | private OrderService orderService; 29 | 30 | 31 | @ApiOperation(value = "用户下单", notes = "用户下单", httpMethod = "POST") 32 | @PostMapping("/create") 33 | public JSONResult create(@RequestBody SubmitOrderBO submitOrderBO, HttpServletRequest request, HttpServletResponse response) { 34 | 35 | if (submitOrderBO.getPayMethod() != PayMethod.WEIXIN.type 36 | && submitOrderBO.getPayMethod() != PayMethod.ALIPAY.type) { 37 | return JSONResult.errorMsg("支付方式不支持!"); 38 | } 39 | 40 | System.out.println(submitOrderBO.toString()); 41 | 42 | // 1. 创建订单 43 | String orderId = orderService.createOrder(submitOrderBO); 44 | 45 | // 2. 移除购物车中已结算(已提交)的商品 46 | /** 47 | * 1001 48 | * 2002 -> 用户购买 49 | * 3003 -> 用户购买 50 | * 4004 51 | */ 52 | 53 | // TODO 整合redis之后,完善购物车中的已结算商品清除,并且同步到前端的cookie 54 | CookieUtils.setCookie(request, response, FOODIE_SHOPCART, "", true); 55 | 56 | // 3. 向支付中心发送当前订单,用于保存支付中心的订单数据 57 | 58 | return JSONResult.ok(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/PassportController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import com.muxin.pojo.bo.UserBO; 4 | import com.muxin.pojo.Users; 5 | import com.muxin.service.UserService; 6 | import com.muxin.utils.CookieUtils; 7 | import com.muxin.utils.JSONResult; 8 | import com.muxin.utils.JsonUtils; 9 | import com.muxin.utils.MD5Utils; 10 | import io.swagger.annotations.Api; 11 | import io.swagger.annotations.ApiOperation; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import javax.servlet.http.HttpServletRequest; 17 | import javax.servlet.http.HttpServletResponse; 18 | 19 | /** 20 | * @program: foodie 21 | * @description: 22 | * @author: Mr.Wang 23 | * @create: 2019-23 20:26 24 | */ 25 | @Api(value = "注册登录", tags = {"用于注册登录的相关接口"}) 26 | @RestController 27 | @RequestMapping("passport") 28 | public class PassportController { 29 | 30 | @Autowired 31 | private UserService userService; 32 | 33 | @ApiOperation(value = "用户名是否存在", notes = "用户名是否存在", httpMethod = "GET") 34 | @GetMapping("/usernameIsExist") 35 | public JSONResult usernameIsExist(@RequestParam String username) { 36 | 37 | // 1. 判断用户名不能为空 38 | if (StringUtils.isBlank(username)) { 39 | return JSONResult.errorMsg("用户名不能为空"); 40 | } 41 | 42 | // 2. 查找注册的用户名是否存在 43 | boolean isExist = userService.queryUsernameIsExist(username); 44 | if (isExist) { 45 | return JSONResult.errorMsg("用户名已经存在"); 46 | } 47 | 48 | // 3. 请求成功,用户名没有重复 49 | return JSONResult.ok(); 50 | 51 | } 52 | 53 | @ApiOperation(value = "用户注册", notes = "用户注册", httpMethod = "POST") 54 | @PostMapping("/regist") 55 | public JSONResult regist(@RequestBody UserBO userBO, 56 | HttpServletRequest request, HttpServletResponse response) { 57 | 58 | String username = userBO.getUsername(); 59 | String password = userBO.getPassword(); 60 | String confirmPwd = userBO.getConfirmPassword(); 61 | 62 | // 0. 判断用户名和密码不为空 63 | if (StringUtils.isBlank(username) || 64 | StringUtils.isBlank(password) || 65 | StringUtils.isBlank(confirmPwd)) { 66 | return JSONResult.errorMsg("用户名或密码不能为空"); 67 | } 68 | 69 | // 1. 查询用户名是否存在 70 | boolean isExist = userService.queryUsernameIsExist(username); 71 | if (isExist) { 72 | return JSONResult.errorMsg("用户名已经存在"); 73 | } 74 | 75 | // 2. 密码长度不能少于6位 76 | if (password.length() < 6) { 77 | return JSONResult.errorMsg("密码长度不能少于6位"); 78 | } 79 | 80 | // 3. 判断两次输入密码是否一致 81 | if(!password.equals(confirmPwd)) { 82 | return JSONResult.errorMsg("两次密码输入不一致"); 83 | } 84 | 85 | // 4. 实现注册 86 | Users userResult = userService.createUser(userBO); 87 | 88 | userResult = setNullProperty(userResult); 89 | 90 | CookieUtils.setCookie(request, response, "user", JsonUtils.objectToJson(userResult), true); 91 | 92 | 93 | // 3. 请求成功,用户名没有重复 94 | return JSONResult.ok(); 95 | 96 | } 97 | 98 | @ApiOperation(value = "用户登录", notes = "用户登录", httpMethod = "POST") 99 | @PostMapping("/login") 100 | public JSONResult login(@RequestBody UserBO userBO, 101 | HttpServletRequest request, HttpServletResponse response) throws Exception { 102 | 103 | String username = userBO.getUsername(); 104 | String password = userBO.getPassword(); 105 | 106 | // 0. 判断用户名和密码不为空 107 | if (StringUtils.isBlank(username) || 108 | StringUtils.isBlank(password)) { 109 | return JSONResult.errorMsg("用户名或密码不能为空"); 110 | } 111 | 112 | // 1. 实现登录 113 | Users userResult = userService.queryUserForLogin(username, MD5Utils.getMD5Str(password)); 114 | 115 | if (userResult == null) { 116 | return JSONResult.errorMsg("用户名或密码不正确"); 117 | } 118 | 119 | userResult = setNullProperty(userResult); 120 | 121 | CookieUtils.setCookie(request, response, "user", JsonUtils.objectToJson(userResult), true); 122 | 123 | // TODO 生成用户token,存入redis会话 124 | // TODO 同步购物车数据 125 | 126 | // 3. 请求成功,用户名没有重复 127 | return JSONResult.ok(userResult); 128 | } 129 | 130 | private Users setNullProperty(Users userResult) { 131 | userResult.setPassword(null); 132 | userResult.setMobile(null); 133 | userResult.setEmail(null); 134 | userResult.setCreatedTime(null); 135 | userResult.setUpdatedTime(null); 136 | userResult.setBirthday(null); 137 | 138 | return userResult; 139 | } 140 | 141 | @ApiOperation(value = "用户退出登录", notes = "用户退出登录", httpMethod = "POST") 142 | @PostMapping("/logout") 143 | public JSONResult logout(@RequestParam String userId, 144 | HttpServletRequest request, HttpServletResponse response) { 145 | 146 | // 清除用户的相关信息的cookie 147 | CookieUtils.deleteCookie(request, response, "user"); 148 | 149 | // TODO 用户退出登录,需要清空购物车 150 | // TODO 分布式会话中需要清除用户数据 151 | 152 | return JSONResult.ok(); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /foodie-api/src/main/java/com/muxin/controller/ShopcatController.java: -------------------------------------------------------------------------------- 1 | package com.muxin.controller; 2 | 3 | import com.muxin.enums.YesOrNo; 4 | import com.muxin.pojo.Carousel; 5 | import com.muxin.pojo.Category; 6 | import com.muxin.pojo.bo.ShopcartBO; 7 | import com.muxin.pojo.vo.CategoryVO; 8 | import com.muxin.pojo.vo.NewItemsVO; 9 | import com.muxin.service.CarouselService; 10 | import com.muxin.service.CategoryService; 11 | import com.muxin.utils.JSONResult; 12 | import io.swagger.annotations.Api; 13 | import io.swagger.annotations.ApiOperation; 14 | import io.swagger.annotations.ApiParam; 15 | import org.apache.commons.lang3.StringUtils; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.http.HttpRequest; 18 | import org.springframework.web.bind.annotation.*; 19 | 20 | import javax.servlet.http.HttpServletRequest; 21 | import javax.servlet.http.HttpServletResponse; 22 | import java.util.List; 23 | 24 | /** 25 | * @program: foodie 26 | * @description: 27 | * @author: Mr.Wang 28 | * @create: 2019-25 21:53 29 | */ 30 | @Api(value = "购物车接口controller", tags={ "购物车接口相关的api"}) 31 | @RequestMapping("shopcart") 32 | @RestController 33 | public class ShopcatController { 34 | 35 | @ApiOperation(value = "添加商品到购物车", notes = "添加商品到购物车", httpMethod = "POST") 36 | @PostMapping("/add") 37 | public JSONResult add( 38 | @RequestParam String userId, 39 | @RequestBody ShopcartBO shopcartBO, 40 | HttpServletRequest request, 41 | HttpServletResponse response 42 | ) { 43 | if (StringUtils.isBlank(userId)) { 44 | return JSONResult.errorMsg(""); 45 | } 46 | 47 | // TODO 前端用户在登录的情况下,添加商品到购物车,会同时在后端同步购物车到redis缓存 48 | 49 | return JSONResult.ok(); 50 | } 51 | 52 | @ApiOperation(value = "从购物车中删除商品", notes = "从购物车中删除商品", httpMethod = "POST") 53 | @PostMapping("/del") 54 | public JSONResult del( 55 | @RequestParam String userId, 56 | @RequestBody String itemSpecId, 57 | HttpServletRequest request, 58 | HttpServletResponse response 59 | ) { 60 | if (StringUtils.isBlank(userId) || StringUtils.isBlank(itemSpecId)) { 61 | return JSONResult.errorMsg("参数不能为空"); 62 | } 63 | 64 | // TODO 用户在删除购物车中的商品数据,如果此时用户已经登录,则需同步删除后端购物车中的商品 65 | 66 | return JSONResult.ok(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /foodie-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 内置tomcat 2 | ############################################################ 3 | # 4 | # web访问端口号 约定:8088 5 | ############################################################ 6 | server: 7 | port: 8088 8 | tomcat: 9 | uri-encoding: UTF-8 10 | max-http-header-size: 80KB 11 | 12 | ############################################################ 13 | # 14 | # 配置数据源信息 15 | # 16 | ############################################################ 17 | spring: 18 | datasource: # 数据源的相关配置 19 | type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP 20 | # driver-class-name: com.mysql.jdbc.Driver # mysql驱动 21 | # url: jdbc:mysql://localhost:3306/foodie-shop-dev?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 22 | url: jdbc:mysql://localhost:3306/foodie-shop-dev?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true 23 | driver: com.mysql.cj.jdbc.Driver 24 | 25 | username: root 26 | password: 2340666 27 | hikari: 28 | connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQ 29 | minimum-idle: 5 # 最小连接数 30 | maximum-pool-size: 20 # 最大连接数 31 | auto-commit: true # 自动提交 32 | idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 33 | pool-name: DateSourceHikariCP # 连接池名字 34 | max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 35 | connection-test-query: SELECT 1 36 | 37 | ############################################################ 38 | # 39 | # mybatis 配置 40 | # 41 | ############################################################ 42 | mybatis: 43 | type-aliases-package: com.muxin.pojo # 所有POJO类所在包路径 44 | mapper-locations: classpath:mapper/*.xml # mapper映射文件 45 | configuration: 46 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 47 | 48 | ############################################################ 49 | # 50 | # mybatis mapper 配置 51 | # 52 | ############################################################ 53 | # 通用 Mapper 配置 54 | mapper: 55 | mappers: com.muxin.my.mapper.MyMapper 56 | not-empty: false # 在进行数据库操作的时候,判断表达式 username != null,是否追加 username != '' 57 | identity: MYSQL 58 | 59 | # 分页插件配置 60 | pagehelper: 61 | helperDialect: mysql 62 | supportMethodsArguments: true 63 | -------------------------------------------------------------------------------- /foodie-api/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG,stdout,file 2 | log4j.additivity.org.apache=true 3 | 4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 5 | log4j.appender.stdout.threshold=INFO 6 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}:%L - %m%n 8 | 9 | log4j.appender.file=org.apache.log4j.DailyRollingFileAppender 10 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.file.DatePattern='.'yyyy-MM-dd-HH-mm 12 | log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 13 | log4j.appender.file.Threshold=INFO 14 | log4j.appender.file.append=true 15 | log4j.appender.file.File=/Users/wgy/All/my-code/java/foodie-log/mylog.log 16 | -------------------------------------------------------------------------------- /foodie-api/src/test/java/com/test/TransTest.java: -------------------------------------------------------------------------------- 1 | package com.test; 2 | 3 | import com.muxin.service.TestTransService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | /** 7 | * @program: foodie 8 | * @description: 9 | * @author: Mr.Wang 10 | * @create: 2019-18 12:45 11 | */ 12 | //@RunWith(SpringRunner.class) 13 | //@SpringBootTest(classes = Application.class) 14 | public class TransTest { 15 | 16 | @Autowired 17 | private TestTransService testTransService; 18 | 19 | // @Test 20 | public void myTest() { 21 | testTransService.testPropagationTrans(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /foodie-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie 7 | com.muxin 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | 13 | jar 14 | 15 | foodie-common 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/enums/CommentLevel.java: -------------------------------------------------------------------------------- 1 | package com.muxin.enums; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 商品评价等级枚举 6 | * @author: Mr.Wang 7 | * @create: 2020-02 11:29 8 | */ 9 | public enum CommentLevel { 10 | GOOD(1, "好评"), 11 | NORMAL(2, "中评"), 12 | BAD(3, "差评"); 13 | 14 | public final Integer type; 15 | public final String value; 16 | 17 | CommentLevel(Integer type, String value) { 18 | this.type = type; 19 | this.value = value; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/enums/OrderStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.muxin.enums; 2 | 3 | public enum OrderStatusEnum { 4 | 5 | WAIT_PAY(10, "待付款"), 6 | WAIT_DELIVER(20, "已付款,待发货"), 7 | WAIT_RECEIVE(30, "已发货,待收货"), 8 | SUCCESS(40, "交易成功"), 9 | CLOSE(50, "交易关闭"); 10 | 11 | public final Integer type; 12 | public final String value; 13 | 14 | OrderStatusEnum(Integer type,String value) { 15 | this.type = type; 16 | this.value = value; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/enums/PayMethod.java: -------------------------------------------------------------------------------- 1 | package com.muxin.enums; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 商品评价等级枚举 6 | * @author: Mr.Wang 7 | * @create: 2020-02 11:29 8 | */ 9 | public enum PayMethod { 10 | WEIXIN(1, "微信"), 11 | ALIPAY(2, "支付宝"); 12 | 13 | public final Integer type; 14 | public final String value; 15 | 16 | PayMethod(Integer type, String value) { 17 | this.type = type; 18 | this.value = value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/enums/ProductCategory.java: -------------------------------------------------------------------------------- 1 | package com.muxin.enums; 2 | 3 | public enum ProductCategory { 4 | firstLevel(1, "一级"), 5 | secondLevel(2, "二级"), 6 | thirdLevel(3, "三级"); 7 | 8 | public final Integer type; 9 | public final String value; 10 | 11 | ProductCategory(Integer type, String value) { 12 | this.type = type; 13 | this.value = value; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/enums/Sex.java: -------------------------------------------------------------------------------- 1 | package com.muxin.enums; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 性别 枚举 6 | * @author: Mr.Wang 7 | * @create: 2019-28 22:47 8 | */ 9 | public enum Sex { 10 | woman(0, "女"), 11 | man(1, "男"), 12 | secret(2, "保密"); 13 | 14 | public final Integer type; 15 | public final String value; 16 | 17 | Sex(Integer type, String value) { 18 | this.type = type; 19 | this.value = value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/enums/YesOrNo.java: -------------------------------------------------------------------------------- 1 | package com.muxin.enums; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 是否枚举 6 | * @author: Mr.Wang 7 | * @create: 2020-02 11:29 8 | */ 9 | public enum YesOrNo { 10 | NO(0, "否"), 11 | YES(1, "是"); 12 | 13 | public final Integer type; 14 | public final String value; 15 | 16 | YesOrNo(Integer type, String value) { 17 | this.type = type; 18 | this.value = value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/utils/DesensitizationUtil.java: -------------------------------------------------------------------------------- 1 | package com.muxin.utils; 2 | 3 | /** 4 | * 通用脱敏工具类 5 | * 可用于: 6 | * 用户名 7 | * 手机号 8 | * 邮箱 9 | * 地址等 10 | */ 11 | public class DesensitizationUtil { 12 | 13 | private static final int SIZE = 6; 14 | private static final String SYMBOL = "*"; 15 | 16 | public static void main(String[] args) { 17 | String name = commonDisplay("muxin"); 18 | String mobile = commonDisplay("13900000000"); 19 | String mail = commonDisplay("wgy952046097@gmail.com"); 20 | String address = commonDisplay("北京大运河东路888号"); 21 | 22 | System.out.println(name); 23 | System.out.println(mobile); 24 | System.out.println(mail); 25 | System.out.println(address); 26 | } 27 | 28 | /** 29 | * 通用脱敏方法 30 | * @param value 31 | * @return 32 | */ 33 | public static String commonDisplay(String value) { 34 | if (null == value || "".equals(value)) { 35 | return value; 36 | } 37 | int len = value.length(); 38 | int pamaone = len / 2; 39 | int pamatwo = pamaone - 1; 40 | int pamathree = len % 2; 41 | StringBuilder stringBuilder = new StringBuilder(); 42 | if (len <= 2) { 43 | if (pamathree == 1) { 44 | return SYMBOL; 45 | } 46 | stringBuilder.append(SYMBOL); 47 | stringBuilder.append(value.charAt(len - 1)); 48 | } else { 49 | if (pamatwo <= 0) { 50 | stringBuilder.append(value.substring(0, 1)); 51 | stringBuilder.append(SYMBOL); 52 | stringBuilder.append(value.substring(len - 1, len)); 53 | 54 | } else if (pamatwo >= SIZE / 2 && SIZE + 1 != len) { 55 | int pamafive = (len - SIZE) / 2; 56 | stringBuilder.append(value.substring(0, pamafive)); 57 | for (int i = 0; i < SIZE; i++) { 58 | stringBuilder.append(SYMBOL); 59 | } 60 | if ((pamathree == 0 && SIZE / 2 == 0) || (pamathree != 0 && SIZE % 2 != 0)) { 61 | stringBuilder.append(value.substring(len - pamafive, len)); 62 | } else { 63 | stringBuilder.append(value.substring(len - (pamafive + 1), len)); 64 | } 65 | } else { 66 | int pamafour = len - 2; 67 | stringBuilder.append(value.substring(0, 1)); 68 | for (int i = 0; i < pamafour; i++) { 69 | stringBuilder.append(SYMBOL); 70 | } 71 | stringBuilder.append(value.substring(len - 1, len)); 72 | } 73 | } 74 | return stringBuilder.toString(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/utils/JSONResult.java: -------------------------------------------------------------------------------- 1 | package com.muxin.utils; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | 6 | /** 7 | * 8 | * @Title: JSONResult.java 9 | * @Package com.muxin.utils 10 | * @Description: 自定义响应数据结构 11 | * 本类可提供给 H5/ios/安卓/公众号/小程序 使用 12 | * 前端接受此类数据(json object)后,可自行根据业务去实现相关功能 13 | * 14 | * 200:表示成功 15 | * 500:表示错误,错误信息在msg字段中 16 | * 501:bean验证错误,不管多少个错误都以map形式返回 17 | * 502:拦截器拦截到用户token出错 18 | * 555:异常抛出信息 19 | * 556: 用户qq校验异常 20 | * @Copyright: Copyright (c) 2020 21 | * @Company: www.yaoyaoniu.com 22 | * @author muxin 23 | * @version V1.0 24 | */ 25 | public class JSONResult { 26 | 27 | // 定义jackson对象 28 | private static final ObjectMapper MAPPER = new ObjectMapper(); 29 | 30 | // 响应业务状态 31 | private Integer status; 32 | 33 | // 响应消息 34 | private String msg; 35 | 36 | // 响应中的数据 37 | private Object data; 38 | 39 | @JsonIgnore 40 | private String ok; // 不使用 41 | 42 | public static JSONResult build(Integer status, String msg, Object data) { 43 | return new JSONResult(status, msg, data); 44 | } 45 | 46 | public static JSONResult build(Integer status, String msg, Object data, String ok) { 47 | return new JSONResult(status, msg, data, ok); 48 | } 49 | 50 | public static JSONResult ok(Object data) { 51 | return new JSONResult(data); 52 | } 53 | 54 | public static JSONResult ok() { 55 | return new JSONResult(null); 56 | } 57 | 58 | public static JSONResult errorMsg(String msg) { 59 | return new JSONResult(500, msg, null); 60 | } 61 | 62 | public static JSONResult errorMap(Object data) { 63 | return new JSONResult(501, "error", data); 64 | } 65 | 66 | public static JSONResult errorTokenMsg(String msg) { 67 | return new JSONResult(502, msg, null); 68 | } 69 | 70 | public static JSONResult errorException(String msg) { 71 | return new JSONResult(555, msg, null); 72 | } 73 | 74 | public static JSONResult errorUserQQ(String msg) { 75 | return new JSONResult(556, msg, null); 76 | } 77 | 78 | public JSONResult() { 79 | 80 | } 81 | 82 | public JSONResult(Integer status, String msg, Object data) { 83 | this.status = status; 84 | this.msg = msg; 85 | this.data = data; 86 | } 87 | 88 | public JSONResult(Integer status, String msg, Object data, String ok) { 89 | this.status = status; 90 | this.msg = msg; 91 | this.data = data; 92 | this.ok = ok; 93 | } 94 | 95 | public JSONResult(Object data) { 96 | this.status = 200; 97 | this.msg = "OK"; 98 | this.data = data; 99 | } 100 | 101 | public Boolean isOK() { 102 | return this.status == 200; 103 | } 104 | 105 | public Integer getStatus() { 106 | return status; 107 | } 108 | 109 | public void setStatus(Integer status) { 110 | this.status = status; 111 | } 112 | 113 | public String getMsg() { 114 | return msg; 115 | } 116 | 117 | public void setMsg(String msg) { 118 | this.msg = msg; 119 | } 120 | 121 | public Object getData() { 122 | return data; 123 | } 124 | 125 | public void setData(Object data) { 126 | this.data = data; 127 | } 128 | 129 | public String getOk() { 130 | return ok; 131 | } 132 | 133 | public void setOk(String ok) { 134 | this.ok = ok; 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.muxin.utils; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.JavaType; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 11 | * @Title: JsonUtils.java 12 | * @Package com.muxin.utils 13 | * @Description: json转换类 14 | * Copyright: Copyright (c) 15 | * Company: www.yaoyaoniu.com 16 | * 17 | * @author muxin 18 | */ 19 | public class JsonUtils { 20 | 21 | // 定义jackson对象 22 | private static final ObjectMapper MAPPER = new ObjectMapper(); 23 | 24 | /** 25 | * 将对象转换成json字符串。 26 | * @param data 27 | * @return 28 | */ 29 | public static String objectToJson(Object data) { 30 | try { 31 | String string = MAPPER.writeValueAsString(data); 32 | return string; 33 | } catch (JsonProcessingException e) { 34 | e.printStackTrace(); 35 | } 36 | return null; 37 | } 38 | 39 | /** 40 | * 将json结果集转化为对象 41 | * 42 | * @param jsonData json数据 43 | * @param beanType 对象中的object类型 44 | * @return 45 | */ 46 | public static T jsonToPojo(String jsonData, Class beanType) { 47 | try { 48 | T t = MAPPER.readValue(jsonData, beanType); 49 | return t; 50 | } catch (Exception e) { 51 | e.printStackTrace(); 52 | } 53 | return null; 54 | } 55 | 56 | /** 57 | * 将json数据转换成pojo对象list 58 | * @param jsonData 59 | * @param beanType 60 | * @return 61 | */ 62 | public static List jsonToList(String jsonData, Class beanType) { 63 | JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType); 64 | try { 65 | List list = MAPPER.readValue(jsonData, javaType); 66 | return list; 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | 71 | return null; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/utils/MD5Utils.java: -------------------------------------------------------------------------------- 1 | package com.muxin.utils; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | 5 | import java.security.MessageDigest; 6 | 7 | public class MD5Utils { 8 | 9 | /** 10 | * 11 | * @Title: MD5Utils.java 12 | * @Package com.muxin.utils 13 | * @Description: 对字符串进行md5加密 14 | */ 15 | public static String getMD5Str(String strValue) throws Exception { 16 | MessageDigest md5 = MessageDigest.getInstance("MD5"); 17 | String newstr = Base64.encodeBase64String(md5.digest(strValue.getBytes())); 18 | return newstr; 19 | } 20 | 21 | public static void main(String[] args) { 22 | try { 23 | String md5 = getMD5Str("muxin"); 24 | System.out.println(md5); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/utils/MobileEmailUtils.java: -------------------------------------------------------------------------------- 1 | package com.muxin.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class MobileEmailUtils { 7 | 8 | public static boolean checkMobileIsOk(String mobile) { 9 | String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$"; 10 | Pattern p = Pattern.compile(regex); 11 | Matcher m = p.matcher(mobile); 12 | boolean isMatch = m.matches(); 13 | return isMatch; 14 | } 15 | 16 | public static boolean checkEmailIsOk(String email) { 17 | boolean isMatch = true; 18 | if (!email.matches("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+")) { 19 | isMatch = false; 20 | } 21 | return isMatch; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/com/muxin/utils/PagedGridResult.java: -------------------------------------------------------------------------------- 1 | package com.muxin.utils; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 7 | * @Title: PagedGridResult.java 8 | * @Package com.muxin.utils 9 | * @Description: 用来返回分页Grid的数据格式 10 | * Copyright: Copyright (c) 2019 11 | */ 12 | public class PagedGridResult { 13 | 14 | private int page; // 当前页数 15 | private int total; // 总页数 16 | private long records; // 总记录数 17 | private List rows; // 每行显示的内容 18 | 19 | public int getPage() { 20 | return page; 21 | } 22 | public void setPage(int page) { 23 | this.page = page; 24 | } 25 | public int getTotal() { 26 | return total; 27 | } 28 | public void setTotal(int total) { 29 | this.total = total; 30 | } 31 | public long getRecords() { 32 | return records; 33 | } 34 | public void setRecords(long records) { 35 | this.records = records; 36 | } 37 | public List getRows() { 38 | return rows; 39 | } 40 | public void setRows(List rows) { 41 | this.rows = rows; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/Code.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultRandomCodeStrategy; 4 | 5 | public class Code { 6 | private static RandomCodeStrategy strategy; 7 | 8 | static { 9 | RandomCodeStrategy strategy = new DefaultRandomCodeStrategy(); 10 | strategy.init(); 11 | configure(strategy); 12 | } 13 | 14 | public static synchronized void configure(RandomCodeStrategy custom) { 15 | if (strategy == custom) return; 16 | if (strategy != null) strategy.release(); 17 | 18 | strategy = custom; 19 | } 20 | 21 | /** 22 | * Next Unique code. 23 | * The max length will be 1024-Integer.MAX-Integer.MAX(2147483647) which has 4+10+10+2*1=26 characters. 24 | * The min length will be 0-0. 25 | * 26 | * @return unique string code. 27 | */ 28 | public static synchronized String next() { 29 | long workerId = Id.getWorkerId(); 30 | int prefix = strategy.prefix(); 31 | int next = strategy.next(); 32 | 33 | return String.format("%d-%03d-%06d", workerId, prefix, next); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/DayCode.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DayPrefixRandomCodeStrategy; 4 | 5 | public class DayCode { 6 | static RandomCodeStrategy strategy; 7 | 8 | static { 9 | DayPrefixRandomCodeStrategy dayPrefixCodeStrategy = new DayPrefixRandomCodeStrategy("yyMM"); 10 | dayPrefixCodeStrategy.setMinRandomSize(7); 11 | dayPrefixCodeStrategy.setMaxRandomSize(7); 12 | strategy = dayPrefixCodeStrategy; 13 | strategy.init(); 14 | } 15 | 16 | public static synchronized String next() { 17 | return String.format("%d-%04d-%07d", Id.getWorkerId(), strategy.prefix(), strategy.next()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/Id.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultWorkerIdStrategy; 4 | 5 | public class Id { 6 | private static WorkerIdStrategy workerIdStrategy; 7 | private static IdWorker idWorker; 8 | 9 | static { 10 | configure(DefaultWorkerIdStrategy.instance); 11 | } 12 | 13 | public static synchronized void configure(WorkerIdStrategy custom) { 14 | if (workerIdStrategy == custom) return; 15 | 16 | if (workerIdStrategy != null) workerIdStrategy.release(); 17 | workerIdStrategy = custom; 18 | workerIdStrategy.initialize(); 19 | idWorker = new IdWorker(workerIdStrategy.availableWorkerId()); 20 | } 21 | 22 | public static long next() { 23 | return idWorker.nextId(); 24 | } 25 | 26 | public static long getWorkerId() { 27 | return idWorker.getWorkerId(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/IdWorker.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.security.SecureRandom; 7 | 8 | public class IdWorker { 9 | protected long epoch = 1288834974657L; 10 | // protected long epoch = 1387886498127L; // 2013-12-24 20:01:38.127 11 | 12 | 13 | protected long workerIdBits = 10L; 14 | protected long maxWorkerId = -1L ^ (-1L << workerIdBits); 15 | protected long sequenceBits = 11L; 16 | 17 | protected long workerIdShift = sequenceBits; 18 | protected long timestampLeftShift = sequenceBits + workerIdBits; 19 | protected long sequenceMask = -1L ^ (-1L << sequenceBits); 20 | 21 | protected long lastMillis = -1L; 22 | 23 | protected final long workerId; 24 | protected long sequence = 0L; 25 | protected Logger logger = LoggerFactory.getLogger(IdWorker.class); 26 | 27 | public IdWorker(long workerId) { 28 | this.workerId = checkWorkerId(workerId); 29 | 30 | logger.debug("worker starting. timestamp left shift {}, worker id {}", timestampLeftShift, workerId); 31 | } 32 | 33 | public long getEpoch() { 34 | return epoch; 35 | } 36 | 37 | private long checkWorkerId(long workerId) { 38 | // sanity check for workerId 39 | if (workerId > maxWorkerId || workerId < 0) { 40 | int rand = new SecureRandom().nextInt((int) maxWorkerId + 1); 41 | logger.warn("worker Id can't be greater than {} or less than 0, use a random {}", maxWorkerId, rand); 42 | return rand; 43 | } 44 | 45 | return workerId; 46 | } 47 | 48 | public synchronized long nextId() { 49 | long timestamp = millisGen(); 50 | 51 | if (timestamp < lastMillis) { 52 | logger.error("clock is moving backwards. Rejecting requests until {}.", lastMillis); 53 | throw new InvalidSystemClock(String.format( 54 | "Clock moved backwards. Refusing to generate id for {} milliseconds", lastMillis - timestamp)); 55 | } 56 | 57 | if (lastMillis == timestamp) { 58 | sequence = (sequence + 1) & sequenceMask; 59 | if (sequence == 0) 60 | timestamp = tilNextMillis(lastMillis); 61 | } else { 62 | sequence = 0; 63 | } 64 | 65 | lastMillis = timestamp; 66 | long diff = timestamp - getEpoch(); 67 | return (diff << timestampLeftShift) | 68 | (workerId << workerIdShift) | 69 | sequence; 70 | } 71 | 72 | protected long tilNextMillis(long lastMillis) { 73 | long millis = millisGen(); 74 | while (millis <= lastMillis) 75 | millis = millisGen(); 76 | 77 | return millis; 78 | } 79 | 80 | protected long millisGen() { 81 | return System.currentTimeMillis(); 82 | } 83 | 84 | public long getLastMillis() { 85 | return lastMillis; 86 | } 87 | 88 | public long getWorkerId() { 89 | return workerId; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/InvalidSystemClock.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public class InvalidSystemClock extends RuntimeException { 4 | public InvalidSystemClock(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/RandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public interface RandomCodeStrategy { 4 | void init(); 5 | 6 | int prefix(); 7 | 8 | int next(); 9 | 10 | void release(); 11 | } 12 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/Sid.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | import org.n3r.idworker.strategy.DefaultWorkerIdStrategy; 4 | import org.n3r.idworker.utils.Utils; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | @Component 11 | public class Sid { 12 | private static WorkerIdStrategy workerIdStrategy; 13 | private static IdWorker idWorker; 14 | 15 | static { 16 | configure(DefaultWorkerIdStrategy.instance); 17 | } 18 | 19 | 20 | public static synchronized void configure(WorkerIdStrategy custom) { 21 | if (workerIdStrategy != null) workerIdStrategy.release(); 22 | workerIdStrategy = custom; 23 | idWorker = new IdWorker(workerIdStrategy.availableWorkerId()) { 24 | @Override 25 | public long getEpoch() { 26 | return Utils.midnightMillis(); 27 | } 28 | }; 29 | } 30 | 31 | /** 32 | * 一天最大毫秒86400000,最大占用27比特 33 | * 27+10+11=48位 最大值281474976710655(15字),YK0XXHZ827(10字) 34 | * 6位(YYMMDD)+15位,共21位 35 | * 36 | * @return 固定21位数字字符串 37 | */ 38 | 39 | public static String next() { 40 | long id = idWorker.nextId(); 41 | String yyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); 42 | return yyMMdd + String.format("%014d", id); 43 | } 44 | 45 | 46 | /** 47 | * 返回固定16位的字母数字混编的字符串。 48 | */ 49 | public String nextShort() { 50 | long id = idWorker.nextId(); 51 | String yyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); 52 | return yyMMdd + Utils.padLeft(Utils.encode(id), 10, '0'); 53 | } 54 | 55 | public static void main(String[] args) { 56 | String aa = new Sid().nextShort(); 57 | String bb = new Sid().next(); 58 | 59 | System.out.println(aa); 60 | System.out.println(bb); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/Test.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public class Test { 4 | 5 | public static void main(String[] args) { 6 | 7 | for (int i = 0 ; i < 1000 ; i ++) { 8 | // System.out.println(Sid.nextShort()); 9 | } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/WorkerIdStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker; 2 | 3 | public interface WorkerIdStrategy { 4 | void initialize(); 5 | 6 | long availableWorkerId(); 7 | 8 | void release(); 9 | } 10 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/strategy/DayPrefixRandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.strategy; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | public class DayPrefixRandomCodeStrategy extends DefaultRandomCodeStrategy { 7 | private final String dayFormat; 8 | private String lastDay; 9 | 10 | public DayPrefixRandomCodeStrategy(String dayFormat) { 11 | this.dayFormat = dayFormat; 12 | } 13 | 14 | @Override 15 | public void init() { 16 | String day = createDate(); 17 | if (day.equals(lastDay)) 18 | throw new RuntimeException("init failed for day unrolled"); 19 | 20 | lastDay = day; 21 | 22 | availableCodes.clear(); 23 | release(); 24 | 25 | prefixIndex = Integer.parseInt(lastDay); 26 | if (tryUsePrefix()) return; 27 | 28 | throw new RuntimeException("prefix is not available " + prefixIndex); 29 | } 30 | 31 | private String createDate() { 32 | return new SimpleDateFormat(dayFormat).format(new Date()); 33 | } 34 | 35 | @Override 36 | public int next() { 37 | if (!lastDay.equals(createDate())) init(); 38 | 39 | return super.next(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/strategy/DefaultRandomCodeStrategy.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.strategy; 2 | 3 | import org.n3r.idworker.Id; 4 | import org.n3r.idworker.RandomCodeStrategy; 5 | import org.n3r.idworker.utils.Utils; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.security.SecureRandom; 12 | import java.util.ArrayDeque; 13 | import java.util.BitSet; 14 | import java.util.Queue; 15 | 16 | public class DefaultRandomCodeStrategy implements RandomCodeStrategy { 17 | public static final int MAX_BITS = 1000000; 18 | 19 | Logger log = LoggerFactory.getLogger(DefaultRandomCodeStrategy.class); 20 | 21 | File idWorkerHome = Utils.createIdWorkerHome(); 22 | volatile FileLock fileLock; 23 | BitSet codesFilter; 24 | 25 | int prefixIndex = -1; 26 | File codePrefixIndex; 27 | 28 | int minRandomSize = 6; 29 | int maxRandomSize = 6; 30 | 31 | public DefaultRandomCodeStrategy() { 32 | destroyFileLockWhenShutdown(); 33 | } 34 | 35 | @Override 36 | public void init() { 37 | release(); 38 | 39 | while (++prefixIndex < 1000) { 40 | if (tryUsePrefix()) return; 41 | } 42 | 43 | throw new RuntimeException("all prefixes are used up, the world maybe ends!"); 44 | } 45 | 46 | public DefaultRandomCodeStrategy setMinRandomSize(int minRandomSize) { 47 | this.minRandomSize = minRandomSize; 48 | return this; 49 | } 50 | 51 | public DefaultRandomCodeStrategy setMaxRandomSize(int maxRandomSize) { 52 | this.maxRandomSize = maxRandomSize; 53 | return this; 54 | } 55 | 56 | protected boolean tryUsePrefix() { 57 | codePrefixIndex = new File(idWorkerHome, Id.getWorkerId() + ".code.prefix." + prefixIndex); 58 | 59 | if (!createPrefixIndexFile()) return false; 60 | if (!createFileLock()) return false; 61 | if (!createBloomFilter()) return false; 62 | 63 | log.info("get available prefix index file {}", codePrefixIndex); 64 | 65 | return true; 66 | } 67 | 68 | private boolean createFileLock() { 69 | if (fileLock != null) fileLock.destroy(); 70 | fileLock = new FileLock(codePrefixIndex); 71 | return fileLock.tryLock(); 72 | } 73 | 74 | private boolean createBloomFilter() { 75 | codesFilter = fileLock.readObject(); 76 | if (codesFilter == null) { 77 | log.info("create new bloom filter"); 78 | codesFilter = new BitSet(MAX_BITS); // 2^24 79 | } else { 80 | int size = codesFilter.cardinality(); 81 | if (size >= MAX_BITS) { 82 | log.warn("bloom filter with prefix file {} is already full", codePrefixIndex); 83 | return false; 84 | } 85 | log.info("recreate bloom filter with cardinality {}", size); 86 | } 87 | 88 | return true; 89 | } 90 | 91 | private void destroyFileLockWhenShutdown() { 92 | Runtime.getRuntime().addShutdownHook(new Thread() { 93 | @Override 94 | public void run() { 95 | release(); 96 | } 97 | }); 98 | } 99 | 100 | private boolean createPrefixIndexFile() { 101 | try { 102 | codePrefixIndex.createNewFile(); 103 | return codePrefixIndex.exists(); 104 | } catch (IOException e) { 105 | e.printStackTrace(); 106 | log.warn("create file {} error {}", codePrefixIndex, e.getMessage()); 107 | } 108 | return false; 109 | } 110 | 111 | @Override 112 | public int prefix() { 113 | return prefixIndex; 114 | } 115 | 116 | static final int CACHE_CODES_NUM = 1000; 117 | 118 | SecureRandom secureRandom = new SecureRandom(); 119 | Queue availableCodes = new ArrayDeque(CACHE_CODES_NUM); 120 | 121 | @Override 122 | public int next() { 123 | if (availableCodes.isEmpty()) generate(); 124 | 125 | return availableCodes.poll(); 126 | } 127 | 128 | @Override 129 | public synchronized void release() { 130 | if (fileLock != null) { 131 | fileLock.writeObject(codesFilter); 132 | fileLock.destroy(); 133 | fileLock = null; 134 | } 135 | } 136 | 137 | private void generate() { 138 | for (int i = 0; i < CACHE_CODES_NUM; ++i) 139 | availableCodes.add(generateOne()); 140 | 141 | fileLock.writeObject(codesFilter); 142 | } 143 | 144 | private int generateOne() { 145 | while (true) { 146 | int code = secureRandom.nextInt(max(maxRandomSize)); 147 | boolean existed = contains(code); 148 | 149 | code = !existed ? add(code) : tryFindAvailableCode(code); 150 | if (code >= 0) return code; 151 | 152 | init(); 153 | } 154 | } 155 | 156 | private int tryFindAvailableCode(int code) { 157 | int next = codesFilter.nextClearBit(code); 158 | if (next != -1 && next < max(maxRandomSize)) return add(next); 159 | 160 | next = codesFilter.previousClearBit(code); 161 | if (next != -1) return add(next); 162 | 163 | return -1; 164 | } 165 | 166 | private int add(int code) { 167 | codesFilter.set(code); 168 | return code; 169 | } 170 | 171 | private boolean contains(int code) { 172 | return codesFilter.get(code); 173 | } 174 | 175 | 176 | private int max(int size) { 177 | switch (size) { 178 | case 1: // fall through 179 | case 2: // fall through 180 | case 3: // fall through 181 | case 4: 182 | return 10000; 183 | case 5: 184 | return 100000; 185 | case 6: 186 | return 1000000; 187 | case 7: 188 | return 10000000; 189 | case 8: 190 | return 100000000; 191 | case 9: 192 | return 1000000000; 193 | default: 194 | return Integer.MAX_VALUE; 195 | } 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/strategy/FileLock.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.strategy; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.*; 8 | import java.nio.channels.Channels; 9 | import java.nio.channels.ClosedChannelException; 10 | import java.nio.channels.FileChannel; 11 | import java.nio.channels.OverlappingFileLockException; 12 | 13 | /** 14 | * A file lock a la flock/funlock 15 | *

16 | * The given path will be created and opened if it doesn't exist. 17 | */ 18 | public class FileLock { 19 | private final File file; 20 | private FileChannel channel; 21 | private java.nio.channels.FileLock flock = null; 22 | Logger logger = LoggerFactory.getLogger(FileLock.class); 23 | 24 | public FileLock(File file) { 25 | this.file = file; 26 | 27 | try { 28 | file.createNewFile(); // create the file if it doesn't exist 29 | channel = new RandomAccessFile(file, "rw").getChannel(); 30 | } catch (IOException e) { 31 | throw new RuntimeException(e); 32 | } 33 | } 34 | 35 | 36 | /** 37 | * Lock the file or throw an exception if the lock is already held 38 | */ 39 | public void lock() { 40 | try { 41 | synchronized (this) { 42 | logger.trace("Acquiring lock on {}", file.getAbsolutePath()); 43 | flock = channel.lock(); 44 | } 45 | } catch (IOException e) { 46 | throw new RuntimeException(e); 47 | } 48 | } 49 | 50 | /** 51 | * Try to lock the file and return true if the locking succeeds 52 | */ 53 | public boolean tryLock() { 54 | synchronized (this) { 55 | logger.trace("Acquiring lock on {}", file.getAbsolutePath()); 56 | try { 57 | // weirdly this method will return null if the lock is held by another 58 | // process, but will throw an exception if the lock is held by this process 59 | // so we have to handle both cases 60 | flock = channel.tryLock(); 61 | return flock != null; 62 | } catch (OverlappingFileLockException e) { 63 | return false; 64 | } catch (IOException e) { 65 | throw new RuntimeException(e); 66 | } 67 | } 68 | } 69 | 70 | /** 71 | * Unlock the lock if it is held 72 | */ 73 | public void unlock() { 74 | synchronized (this) { 75 | logger.trace("Releasing lock on {}", file.getAbsolutePath()); 76 | if (flock == null) return; 77 | try { 78 | flock.release(); 79 | } catch (ClosedChannelException e) { 80 | // Ignore 81 | } catch (IOException e) { 82 | throw new RuntimeException(e); 83 | } 84 | } 85 | } 86 | 87 | /** 88 | * Destroy this lock, closing the associated FileChannel 89 | */ 90 | public void destroy() { 91 | synchronized (this) { 92 | unlock(); 93 | if (!channel.isOpen()) return; 94 | 95 | try { 96 | channel.close(); 97 | } catch (IOException e) { 98 | throw new RuntimeException(e); 99 | } 100 | } 101 | } 102 | 103 | 104 | @SuppressWarnings("unchecked") 105 | public T readObject() { 106 | try { 107 | InputStream is = Channels.newInputStream(channel); 108 | ObjectInputStream objectReader = new ObjectInputStream(is); 109 | return (T) objectReader.readObject(); 110 | } catch (EOFException e) { 111 | } catch (Exception e) { 112 | throw new RuntimeException(e); 113 | } 114 | 115 | return null; 116 | } 117 | 118 | 119 | public synchronized boolean writeObject(Object object) { 120 | if (!channel.isOpen()) return false; 121 | 122 | try { 123 | channel.position(0); 124 | OutputStream out = Channels.newOutputStream(channel); 125 | ObjectOutputStream objectOutput = new ObjectOutputStream(out); 126 | objectOutput.writeObject(object); 127 | return true; 128 | } catch (Exception e) { 129 | throw new RuntimeException(e); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/utils/HttpReq.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.ByteArrayOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.io.UnsupportedEncodingException; 10 | import java.net.HttpURLConnection; 11 | import java.net.URL; 12 | import java.net.URLEncoder; 13 | 14 | public class HttpReq { 15 | private final String baseUrl; 16 | private String req; 17 | private StringBuilder params = new StringBuilder(); 18 | Logger logger = LoggerFactory.getLogger(HttpReq.class); 19 | 20 | public HttpReq(String baseUrl) { 21 | this.baseUrl = baseUrl; 22 | } 23 | 24 | public static HttpReq get(String baseUrl) { 25 | return new HttpReq(baseUrl); 26 | } 27 | 28 | public HttpReq req(String req) { 29 | this.req = req; 30 | return this; 31 | } 32 | 33 | public HttpReq param(String name, String value) { 34 | if (params.length() > 0) params.append('&'); 35 | try { 36 | params.append(name).append('=').append(URLEncoder.encode(value, "UTF-8")); 37 | } catch (UnsupportedEncodingException e) { 38 | throw new RuntimeException(e); 39 | } 40 | 41 | return this; 42 | } 43 | 44 | public String exec() { 45 | HttpURLConnection http = null; 46 | try { 47 | http = (HttpURLConnection) new URL(baseUrl 48 | + (req == null ? "" : req) 49 | + (params.length() > 0 ? ("?" + params) : "")).openConnection(); 50 | http.setRequestProperty("Accept-Charset", "UTF-8"); 51 | HttpURLConnection.setFollowRedirects(false); 52 | http.setConnectTimeout(5 * 1000); 53 | http.setReadTimeout(5 * 1000); 54 | http.connect(); 55 | 56 | int status = http.getResponseCode(); 57 | String charset = getCharset(http.getHeaderField("Content-Type")); 58 | 59 | if (status == 200) { 60 | return readResponseBody(http, charset); 61 | } else { 62 | logger.warn("non 200 respoonse :" + readErrorResponseBody(http, status, charset)); 63 | return null; 64 | } 65 | } catch (Exception e) { 66 | logger.error("exec error {}", e.getMessage()); 67 | return null; 68 | } finally { 69 | if (http != null) http.disconnect(); 70 | } 71 | 72 | } 73 | 74 | private static String readErrorResponseBody(HttpURLConnection http, int status, String charset) throws IOException { 75 | InputStream errorStream = http.getErrorStream(); 76 | if (errorStream != null) { 77 | String error = toString(charset, errorStream); 78 | return ("STATUS CODE =" + status + "\n\n" + error); 79 | } else { 80 | return ("STATUS CODE =" + status); 81 | } 82 | } 83 | 84 | private static String readResponseBody(HttpURLConnection http, String charset) throws IOException { 85 | InputStream inputStream = http.getInputStream(); 86 | 87 | return toString(charset, inputStream); 88 | } 89 | 90 | private static String toString(String charset, InputStream inputStream) throws IOException { 91 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 92 | byte[] buffer = new byte[1024]; 93 | 94 | int length; 95 | while ((length = inputStream.read(buffer)) != -1) { 96 | baos.write(buffer, 0, length); 97 | } 98 | 99 | return new String(baos.toByteArray(), charset); 100 | } 101 | 102 | private static String getCharset(String contentType) { 103 | if (contentType == null) return "UTF-8"; 104 | 105 | String charset = null; 106 | for (String param : contentType.replace(" ", "").split(";")) { 107 | if (param.startsWith("charset=")) { 108 | charset = param.split("=", 2)[1]; 109 | break; 110 | } 111 | } 112 | 113 | return charset == null ? "UTF-8" : charset; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/utils/IPv4Utils.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | /** 4 | * This utility provides methods to either convert an IPv4 address to its long format or a 32bit dotted format. 5 | * 6 | * @author Aion 7 | * Created on 22/11/12 8 | */ 9 | public class IPv4Utils { 10 | 11 | /** 12 | * Returns the long format of the provided IP address. 13 | * 14 | * @param ipAddress the IP address 15 | * @return the long format of ipAddress 16 | * @throws IllegalArgumentException if ipAddress is invalid 17 | */ 18 | public static long toLong(String ipAddress) { 19 | if (ipAddress == null || ipAddress.isEmpty()) { 20 | throw new IllegalArgumentException("ip address cannot be null or empty"); 21 | } 22 | String[] octets = ipAddress.split(java.util.regex.Pattern.quote(".")); 23 | if (octets.length != 4) { 24 | throw new IllegalArgumentException("invalid ip address"); 25 | } 26 | long ip = 0; 27 | for (int i = 3; i >= 0; i--) { 28 | long octet = Long.parseLong(octets[3 - i]); 29 | if (octet > 255 || octet < 0) { 30 | throw new IllegalArgumentException("invalid ip address"); 31 | } 32 | ip |= octet << (i * 8); 33 | } 34 | return ip; 35 | } 36 | 37 | /** 38 | * Returns the 32bit dotted format of the provided long ip. 39 | * 40 | * @param ip the long ip 41 | * @return the 32bit dotted format of ip 42 | * @throws IllegalArgumentException if ip is invalid 43 | */ 44 | public static String toString(long ip) { 45 | // if ip is bigger than 255.255.255.255 or smaller than 0.0.0.0 46 | if (ip > 4294967295l || ip < 0) { 47 | throw new IllegalArgumentException("invalid ip"); 48 | } 49 | StringBuilder ipAddress = new StringBuilder(); 50 | for (int i = 3; i >= 0; i--) { 51 | int shift = i * 8; 52 | ipAddress.append((ip & (0xff << shift)) >> shift); 53 | if (i > 0) { 54 | ipAddress.append("."); 55 | } 56 | } 57 | return ipAddress.toString(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/utils/Ip.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.net.Inet4Address; 8 | import java.net.InetAddress; 9 | import java.net.NetworkInterface; 10 | import java.net.SocketException; 11 | import java.util.Enumeration; 12 | 13 | public class Ip { 14 | static Logger logger = LoggerFactory.getLogger(Ip.class); 15 | 16 | public static String ip; 17 | public static long lip; 18 | 19 | static { 20 | try { 21 | InetAddress localHostLANAddress = getFirstNonLoopbackAddress(); 22 | ip = localHostLANAddress.getHostAddress(); 23 | 24 | byte[] address = localHostLANAddress.getAddress(); 25 | lip = ((address [0] & 0xFFL) << (3*8)) + 26 | ((address [1] & 0xFFL) << (2*8)) + 27 | ((address [2] & 0xFFL) << (1*8)) + 28 | (address [3] & 0xFFL); 29 | } catch (Exception e) { 30 | logger.error("get ipv4 failed ", e); 31 | } 32 | } 33 | 34 | private static InetAddress getFirstNonLoopbackAddress() throws SocketException { 35 | Enumeration en = NetworkInterface.getNetworkInterfaces(); 36 | while (en.hasMoreElements()) { 37 | NetworkInterface i = (NetworkInterface) en.nextElement(); 38 | for (Enumeration en2 = i.getInetAddresses(); en2.hasMoreElements(); ) { 39 | InetAddress addr = (InetAddress) en2.nextElement(); 40 | if (addr.isLoopbackAddress()) continue; 41 | 42 | if (addr instanceof Inet4Address) { 43 | return addr; 44 | } 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/utils/Props.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.*; 7 | import java.util.Properties; 8 | 9 | import static java.io.File.separator; 10 | import static org.n3r.idworker.utils.Serializes.closeQuietly; 11 | 12 | public class Props { 13 | static Logger log = LoggerFactory.getLogger(Props.class); 14 | 15 | public static Properties tryProperties(String propertiesFileName, String userHomeBasePath) { 16 | Properties properties = new Properties(); 17 | InputStream is = null; 18 | try { 19 | is = Props.tryResource(propertiesFileName, userHomeBasePath, Silent.ON); 20 | if (is != null) properties.load(is); 21 | } catch (IOException e) { 22 | log.error("load properties error: {}", e.getMessage()); 23 | } finally { 24 | closeQuietly(is); 25 | } 26 | 27 | return properties; 28 | } 29 | 30 | 31 | enum Silent {ON, OFF} 32 | 33 | public static InputStream tryResource(String propertiesFileName, String userHomeBasePath, Silent silent) { 34 | InputStream is = currentDirResource(new File(propertiesFileName)); 35 | if (is != null) return is; 36 | 37 | is = userHomeResource(propertiesFileName, userHomeBasePath); 38 | if (is != null) return is; 39 | 40 | is = classpathResource(propertiesFileName); 41 | if (is != null || silent == Silent.ON) return is; 42 | 43 | throw new RuntimeException("fail to find " + propertiesFileName + " in current dir or classpath"); 44 | } 45 | 46 | private static InputStream userHomeResource(String pathname, String appHome) { 47 | String filePath = System.getProperty("user.home") + separator + appHome; 48 | File dir = new File(filePath); 49 | if (!dir.exists()) return null; 50 | 51 | return currentDirResource(new File(dir, pathname)); 52 | } 53 | 54 | private static InputStream currentDirResource(File file) { 55 | if (!file.exists()) return null; 56 | 57 | try { 58 | return new FileInputStream(file); 59 | } catch (FileNotFoundException e) { 60 | // This should not happened 61 | log.error("read file {} error", file, e); 62 | return null; 63 | } 64 | } 65 | 66 | public static InputStream classpathResource(String resourceName) { 67 | return Props.class.getClassLoader().getResourceAsStream(resourceName); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/utils/Serializes.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import java.io.*; 4 | import java.nio.channels.FileChannel; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class Serializes { 9 | 10 | @SuppressWarnings("unchecked") 11 | public static List readObjects(File file) { 12 | ArrayList objects = new ArrayList(); 13 | ObjectInputStream objectReader = null; 14 | FileInputStream fis = null; 15 | try { 16 | fis = new FileInputStream(file); 17 | objectReader = new ObjectInputStream(fis); 18 | while (true) 19 | objects.add((T) objectReader.readObject()); 20 | 21 | } catch (EOFException e) { 22 | } catch (Exception e) { 23 | throw new RuntimeException(e); 24 | } finally { 25 | closeQuietly(objectReader); 26 | closeQuietly(fis); 27 | } 28 | 29 | return objects; 30 | } 31 | 32 | 33 | @SuppressWarnings("unchecked") 34 | public static T readObject(File file) { 35 | ObjectInputStream objectReader = null; 36 | FileInputStream fis = null; 37 | try { 38 | fis = new FileInputStream(file); 39 | objectReader = new ObjectInputStream(fis); 40 | return (T) objectReader.readObject(); 41 | 42 | } catch (EOFException e) { 43 | } catch (Exception e) { 44 | throw new RuntimeException(e); 45 | } finally { 46 | closeQuietly(objectReader); 47 | closeQuietly(fis); 48 | } 49 | 50 | return null; 51 | } 52 | 53 | public static void writeObject(File file, Object object) { 54 | ObjectOutputStream objectOutput = null; 55 | FileOutputStream fos = null; 56 | try { 57 | fos = new FileOutputStream(file); 58 | objectOutput = new ObjectOutputStream(fos); 59 | objectOutput.writeObject(object); 60 | } catch (Exception e) { 61 | throw new RuntimeException(e); 62 | } finally { 63 | closeQuietly(objectOutput); 64 | closeQuietly(fos); 65 | } 66 | } 67 | 68 | public static void writeObject(FileOutputStream fos, Object object) { 69 | FileChannel channel = fos.getChannel(); 70 | if (!channel.isOpen()) throw new RuntimeException("channel is closed"); 71 | 72 | try { 73 | channel.position(0); 74 | ObjectOutputStream objectOutput = new ObjectOutputStream(fos); 75 | objectOutput.writeObject(object); 76 | fos.flush(); 77 | } catch (Exception e) { 78 | throw new RuntimeException(e); 79 | } finally { 80 | } 81 | } 82 | 83 | public static void writeObjects(File file, Object... objects) { 84 | ObjectOutputStream objectOutput = null; 85 | FileOutputStream fos = null; 86 | try { 87 | fos = new FileOutputStream(file); 88 | objectOutput = new ObjectOutputStream(fos); 89 | 90 | for (Object object : objects) 91 | objectOutput.writeObject(object); 92 | } catch (Exception e) { 93 | throw new RuntimeException(e); 94 | } finally { 95 | closeQuietly(objectOutput); 96 | closeQuietly(fos); 97 | } 98 | 99 | } 100 | 101 | public static void closeQuietly(OutputStream os) { 102 | if (os != null) try { 103 | os.close(); 104 | } catch (IOException e) { 105 | // ignore 106 | } 107 | } 108 | 109 | 110 | public static void closeQuietly(InputStream is) { 111 | if (is != null) try { 112 | is.close(); 113 | } catch (IOException e) { 114 | // ignore 115 | } 116 | 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /foodie-common/src/main/java/org/n3r/idworker/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package org.n3r.idworker.utils; 2 | 3 | import java.io.*; 4 | import java.sql.Timestamp; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Calendar; 7 | 8 | public class Utils { 9 | 10 | public static final String DOT_IDWORKERS = ".idworkers"; 11 | 12 | public static ClassLoader getClassLoader() { 13 | ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); 14 | return contextClassLoader != null ? contextClassLoader : Utils.class.getClassLoader(); 15 | } 16 | 17 | 18 | public static InputStream classResourceToStream(String resourceName) { 19 | return getClassLoader().getResourceAsStream(resourceName); 20 | } 21 | 22 | 23 | public static String firstLine(String classResourceName) { 24 | InputStream inputStream = null; 25 | try { 26 | inputStream = classResourceToStream(classResourceName); 27 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); 28 | 29 | return bufferedReader.readLine(); 30 | } catch (IOException e) { 31 | return null; 32 | } finally { 33 | if (inputStream != null) try { 34 | inputStream.close(); 35 | } catch (IOException e) { 36 | // ignore 37 | } 38 | } 39 | } 40 | 41 | public static String checkNotEmpty(String param, String name) { 42 | if (param == null || param.isEmpty()) 43 | throw new IllegalArgumentException(name + " is empty"); 44 | 45 | return param; 46 | } 47 | 48 | 49 | public static long midnightMillis() { 50 | // today 51 | Calendar date = Calendar.getInstance(); 52 | // reset hour, minutes, seconds and millis 53 | date.set(Calendar.HOUR_OF_DAY, 0); 54 | date.set(Calendar.MINUTE, 0); 55 | date.set(Calendar.SECOND, 0); 56 | date.set(Calendar.MILLISECOND, 0); 57 | 58 | return date.getTimeInMillis(); 59 | } 60 | 61 | public static void main(String[] args) { 62 | // 2013-12-25 00:00:00.000 63 | System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Timestamp(midnightMillis()))); 64 | System.out.println(encode(281474976710655L)); 65 | } 66 | 67 | public static long decode(String s, String symbols) { 68 | final int B = symbols.length(); 69 | long num = 0; 70 | for (char ch : s.toCharArray()) { 71 | num *= B; 72 | num += symbols.indexOf(ch); 73 | } 74 | return num; 75 | } 76 | 77 | public static String encode(long num) { 78 | return encode(num, defaultRange); 79 | } 80 | 81 | public static String encode(long num, String symbols) { 82 | final int B = symbols.length(); 83 | StringBuilder sb = new StringBuilder(); 84 | while (num != 0) { 85 | sb.append(symbols.charAt((int) (num % B))); 86 | num /= B; 87 | } 88 | return sb.reverse().toString(); 89 | } 90 | 91 | // all un-clearly-recognized letters are skiped. 92 | static String defaultRange = "0123456789ABCDFGHKMNPRSTWXYZ"; 93 | 94 | public static String padLeft(String str, int size, char padChar) { 95 | if (str.length() >= size) return str; 96 | 97 | StringBuilder s = new StringBuilder(); 98 | for (int i = size - str.length(); i > 0; --i) { 99 | s.append(padChar); 100 | } 101 | s.append(str); 102 | 103 | return s.toString(); 104 | } 105 | 106 | public static File createIdWorkerHome() { 107 | String userHome = System.getProperty("user.home"); 108 | File idWorkerHome = new File(userHome + File.separator + DOT_IDWORKERS); 109 | idWorkerHome.mkdirs(); 110 | if (idWorkerHome.isDirectory()) return idWorkerHome; 111 | 112 | throw new RuntimeException("failed to create .idworkers at user home"); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /foodie-mapper/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie 7 | com.muxin 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | foodie-mapper 13 | 14 | 15 | 16 | 20 | 21 | 22 | com.muxin 23 | foodie-pojo 24 | 1.0-SNAPSHOT 25 | 26 | 27 | junit 28 | junit 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/AddressMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.UserAddress; 6 | 7 | public interface AddressMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/CarouselMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | import com.muxin.my.mapper.MyMapper; 4 | import com.muxin.pojo.Carousel; 5 | 6 | public interface CarouselMapper extends MyMapper { 7 | @Override 8 | Carousel selectByPrimaryKey(Object o); 9 | } 10 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/CategoryCustomMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | import com.muxin.pojo.vo.CategoryVO; 4 | import com.muxin.pojo.vo.NewItemsVO; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public interface CategoryCustomMapper { 11 | 12 | public List getSubCatList(Integer rootCatId); 13 | 14 | public List getSixNewItemsLazy(@Param("paramsMap") Map map); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/CategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.Category; 6 | 7 | public interface CategoryMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/ItemsCommentsMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.ItemsComments; 6 | 7 | public interface ItemsCommentsMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/ItemsCustomMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.pojo.vo.ItemCommentVO; 5 | import com.muxin.pojo.vo.SearchItemsVO; 6 | import com.muxin.pojo.vo.ShopcartVO; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public interface ItemsCustomMapper { 13 | 14 | public List queryItemComments(@Param("paramsMap") Map map); 15 | 16 | public List searchItems(@Param("paramsMap") Map map); 17 | 18 | public List searchItemsByThirdCat(@Param("paramsMap") Map map); 19 | 20 | public List queryItemsBySpecIds(@Param("paramsList") List specIdsList); 21 | 22 | public int decreaseItemSpecStock(@Param("specId") String specId, 23 | @Param("pendingCounts") int pendingCounts); 24 | } 25 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/ItemsImgMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.ItemsImg; 6 | 7 | public interface ItemsImgMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/ItemsMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | import com.muxin.my.mapper.MyMapper; 4 | import com.muxin.pojo.Items; 5 | 6 | public interface ItemsMapper extends MyMapper { 7 | } 8 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/ItemsParamMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.ItemParams; 6 | 7 | public interface ItemsParamMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/ItemsSpecMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.ItemsSpec; 6 | 7 | public interface ItemsSpecMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/OrderItemsMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.OrderItems; 6 | 7 | public interface OrderItemsMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/OrderStatusMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.OrderStatus; 6 | 7 | public interface OrderStatusMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/OrdersMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.Orders; 6 | 7 | public interface OrdersMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/StuMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.Stu; 6 | 7 | public interface StuMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/mapper/UsersMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.mapper; 2 | 3 | 4 | import com.muxin.my.mapper.MyMapper; 5 | import com.muxin.pojo.Users; 6 | 7 | public interface UsersMapper extends MyMapper { 8 | } 9 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/java/com/muxin/my/mapper/MyMapper.java: -------------------------------------------------------------------------------- 1 | package com.muxin.my.mapper; 2 | 3 | import tk.mybatis.mapper.common.Mapper; 4 | import tk.mybatis.mapper.common.MySqlMapper; 5 | 6 | /** 7 | * 继承自己的MyMapper 8 | */ 9 | public interface MyMapper extends Mapper, MySqlMapper { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/CarouselMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/CategoryMapperCustom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/ItemsCommentsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/ItemsCustomMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 25 | 26 | 61 | 62 | 63 | 64 | 65 | 66 | 100 | 101 | 102 | 129 | 130 | 131 | 132 | update 133 | items_spec 134 | set 135 | stock = stock - #{pendingCounts} 136 | where 137 | id = #{specId} 138 | and 139 | stock >= #{pendingCounts} 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/ItemsImgMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/ItemsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/ItemsParamMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/ItemsSpecMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/OrderItemsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/OrderStatusMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/OrdersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/StuMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/UsersMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /foodie-mapper/src/main/resources/mapper/addressMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /foodie-pojo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie 7 | com.muxin 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | foodie-pojo 13 | 14 | 15 | 16 | 17 | com.muxin 18 | foodie-common 19 | 1.0-SNAPSHOT 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/Carousel.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | public class Carousel { 7 | /** 8 | * 主键 9 | */ 10 | @Id 11 | private String id; 12 | 13 | /** 14 | * 图片 图片地址 15 | */ 16 | @Column(name = "image_url") 17 | private String imageUrl; 18 | 19 | /** 20 | * 背景色 21 | */ 22 | @Column(name = "background_color") 23 | private String backgroundColor; 24 | 25 | /** 26 | * 商品id 商品id 27 | */ 28 | @Column(name = "item_id") 29 | private String itemId; 30 | 31 | /** 32 | * 商品分类id 商品分类id 33 | */ 34 | @Column(name = "cat_id") 35 | private String catId; 36 | 37 | /** 38 | * 轮播图类型 轮播图类型,用于判断,可以根据商品id或者分类进行页面跳转,1:商品 2:分类 39 | */ 40 | private Integer type; 41 | 42 | /** 43 | * 轮播图展示顺序 44 | */ 45 | private Integer sort; 46 | 47 | /** 48 | * 是否展示 49 | */ 50 | @Column(name = "is_show") 51 | private Integer isShow; 52 | 53 | /** 54 | * 创建时间 创建时间 55 | */ 56 | @Column(name = "create_time") 57 | private Date createTime; 58 | 59 | /** 60 | * 更新时间 更新 61 | */ 62 | @Column(name = "update_time") 63 | private Date updateTime; 64 | 65 | /** 66 | * 获取主键 67 | * 68 | * @return id - 主键 69 | */ 70 | public String getId() { 71 | return id; 72 | } 73 | 74 | /** 75 | * 设置主键 76 | * 77 | * @param id 主键 78 | */ 79 | public void setId(String id) { 80 | this.id = id; 81 | } 82 | 83 | /** 84 | * 获取图片 图片地址 85 | * 86 | * @return image_url - 图片 图片地址 87 | */ 88 | public String getImageUrl() { 89 | return imageUrl; 90 | } 91 | 92 | /** 93 | * 设置图片 图片地址 94 | * 95 | * @param imageUrl 图片 图片地址 96 | */ 97 | public void setImageUrl(String imageUrl) { 98 | this.imageUrl = imageUrl; 99 | } 100 | 101 | /** 102 | * 获取背景色 103 | * 104 | * @return background_color - 背景色 105 | */ 106 | public String getBackgroundColor() { 107 | return backgroundColor; 108 | } 109 | 110 | /** 111 | * 设置背景色 112 | * 113 | * @param backgroundColor 背景色 114 | */ 115 | public void setBackgroundColor(String backgroundColor) { 116 | this.backgroundColor = backgroundColor; 117 | } 118 | 119 | /** 120 | * 获取商品id 商品id 121 | * 122 | * @return item_id - 商品id 商品id 123 | */ 124 | public String getItemId() { 125 | return itemId; 126 | } 127 | 128 | /** 129 | * 设置商品id 商品id 130 | * 131 | * @param itemId 商品id 商品id 132 | */ 133 | public void setItemId(String itemId) { 134 | this.itemId = itemId; 135 | } 136 | 137 | /** 138 | * 获取商品分类id 商品分类id 139 | * 140 | * @return cat_id - 商品分类id 商品分类id 141 | */ 142 | public String getCatId() { 143 | return catId; 144 | } 145 | 146 | /** 147 | * 设置商品分类id 商品分类id 148 | * 149 | * @param catId 商品分类id 商品分类id 150 | */ 151 | public void setCatId(String catId) { 152 | this.catId = catId; 153 | } 154 | 155 | /** 156 | * 获取轮播图类型 轮播图类型,用于判断,可以根据商品id或者分类进行页面跳转,1:商品 2:分类 157 | * 158 | * @return type - 轮播图类型 轮播图类型,用于判断,可以根据商品id或者分类进行页面跳转,1:商品 2:分类 159 | */ 160 | public Integer getType() { 161 | return type; 162 | } 163 | 164 | /** 165 | * 设置轮播图类型 轮播图类型,用于判断,可以根据商品id或者分类进行页面跳转,1:商品 2:分类 166 | * 167 | * @param type 轮播图类型 轮播图类型,用于判断,可以根据商品id或者分类进行页面跳转,1:商品 2:分类 168 | */ 169 | public void setType(Integer type) { 170 | this.type = type; 171 | } 172 | 173 | /** 174 | * 获取轮播图展示顺序 175 | * 176 | * @return sort - 轮播图展示顺序 177 | */ 178 | public Integer getSort() { 179 | return sort; 180 | } 181 | 182 | /** 183 | * 设置轮播图展示顺序 184 | * 185 | * @param sort 轮播图展示顺序 186 | */ 187 | public void setSort(Integer sort) { 188 | this.sort = sort; 189 | } 190 | 191 | /** 192 | * 获取是否展示 193 | * 194 | * @return is_show - 是否展示 195 | */ 196 | public Integer getIsShow() { 197 | return isShow; 198 | } 199 | 200 | /** 201 | * 设置是否展示 202 | * 203 | * @param isShow 是否展示 204 | */ 205 | public void setIsShow(Integer isShow) { 206 | this.isShow = isShow; 207 | } 208 | 209 | /** 210 | * 获取创建时间 创建时间 211 | * 212 | * @return create_time - 创建时间 创建时间 213 | */ 214 | public Date getCreateTime() { 215 | return createTime; 216 | } 217 | 218 | /** 219 | * 设置创建时间 创建时间 220 | * 221 | * @param createTime 创建时间 创建时间 222 | */ 223 | public void setCreateTime(Date createTime) { 224 | this.createTime = createTime; 225 | } 226 | 227 | /** 228 | * 获取更新时间 更新 229 | * 230 | * @return update_time - 更新时间 更新 231 | */ 232 | public Date getUpdateTime() { 233 | return updateTime; 234 | } 235 | 236 | /** 237 | * 设置更新时间 更新 238 | * 239 | * @param updateTime 更新时间 更新 240 | */ 241 | public void setUpdateTime(Date updateTime) { 242 | this.updateTime = updateTime; 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/Category.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | 5 | public class Category { 6 | /** 7 | * 主键 8 | */ 9 | @Id 10 | private Integer id; 11 | 12 | /** 13 | * 分类名称 14 | */ 15 | private String name; 16 | 17 | /** 18 | * 分类类型 19 | */ 20 | private Integer type; 21 | 22 | /** 23 | * 父id 24 | */ 25 | @Column(name = "father_id") 26 | private Integer fatherId; 27 | 28 | /** 29 | * 图标 30 | */ 31 | private String logo; 32 | 33 | /** 34 | * 口号 35 | */ 36 | private String slogan; 37 | 38 | /** 39 | * 分类图 40 | */ 41 | @Column(name = "cat_image") 42 | private String catImage; 43 | 44 | /** 45 | * 背景颜色 46 | */ 47 | @Column(name = "bg_color") 48 | private String bgColor; 49 | 50 | /** 51 | * 获取主键 52 | * 53 | * @return id - 主键 54 | */ 55 | public Integer getId() { 56 | return id; 57 | } 58 | 59 | /** 60 | * 设置主键 61 | * 62 | * @param id 主键 63 | */ 64 | public void setId(Integer id) { 65 | this.id = id; 66 | } 67 | 68 | /** 69 | * 获取分类名称 70 | * 71 | * @return name - 分类名称 72 | */ 73 | public String getName() { 74 | return name; 75 | } 76 | 77 | /** 78 | * 设置分类名称 79 | * 80 | * @param name 分类名称 81 | */ 82 | public void setName(String name) { 83 | this.name = name; 84 | } 85 | 86 | /** 87 | * 获取分类类型 88 | * 89 | * @return type - 分类类型 90 | */ 91 | public Integer getType() { 92 | return type; 93 | } 94 | 95 | /** 96 | * 设置分类类型 97 | * 98 | * @param type 分类类型 99 | */ 100 | public void setType(Integer type) { 101 | this.type = type; 102 | } 103 | 104 | /** 105 | * 获取父id 106 | * 107 | * @return father_id - 父id 108 | */ 109 | public Integer getFatherId() { 110 | return fatherId; 111 | } 112 | 113 | /** 114 | * 设置父id 115 | * 116 | * @param fatherId 父id 117 | */ 118 | public void setFatherId(Integer fatherId) { 119 | this.fatherId = fatherId; 120 | } 121 | 122 | /** 123 | * 获取图标 124 | * 125 | * @return logo - 图标 126 | */ 127 | public String getLogo() { 128 | return logo; 129 | } 130 | 131 | /** 132 | * 设置图标 133 | * 134 | * @param logo 图标 135 | */ 136 | public void setLogo(String logo) { 137 | this.logo = logo; 138 | } 139 | 140 | /** 141 | * 获取口号 142 | * 143 | * @return slogan - 口号 144 | */ 145 | public String getSlogan() { 146 | return slogan; 147 | } 148 | 149 | /** 150 | * 设置口号 151 | * 152 | * @param slogan 口号 153 | */ 154 | public void setSlogan(String slogan) { 155 | this.slogan = slogan; 156 | } 157 | 158 | /** 159 | * 获取分类图 160 | * 161 | * @return cat_image - 分类图 162 | */ 163 | public String getCatImage() { 164 | return catImage; 165 | } 166 | 167 | /** 168 | * 设置分类图 169 | * 170 | * @param catImage 分类图 171 | */ 172 | public void setCatImage(String catImage) { 173 | this.catImage = catImage; 174 | } 175 | 176 | /** 177 | * 获取背景颜色 178 | * 179 | * @return bg_color - 背景颜色 180 | */ 181 | public String getBgColor() { 182 | return bgColor; 183 | } 184 | 185 | /** 186 | * 设置背景颜色 187 | * 188 | * @param bgColor 背景颜色 189 | */ 190 | public void setBgColor(String bgColor) { 191 | this.bgColor = bgColor; 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/Items.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | public class Items { 7 | /** 8 | * 商品主键id 9 | */ 10 | @Id 11 | private String id; 12 | 13 | /** 14 | * 商品名称 商品名称 15 | */ 16 | @Column(name = "item_name") 17 | private String itemName; 18 | 19 | /** 20 | * 分类外键id 分类id 21 | */ 22 | @Column(name = "cat_id") 23 | private Integer catId; 24 | 25 | /** 26 | * 一级分类外键id 27 | */ 28 | @Column(name = "root_cat_id") 29 | private Integer rootCatId; 30 | 31 | /** 32 | * 累计销售 累计销售 33 | */ 34 | @Column(name = "sell_counts") 35 | private Integer sellCounts; 36 | 37 | /** 38 | * 上下架状态 上下架状态,1:上架 2:下架 39 | */ 40 | @Column(name = "on_off_status") 41 | private Integer onOffStatus; 42 | 43 | /** 44 | * 创建时间 45 | */ 46 | @Column(name = "created_time") 47 | private Date createdTime; 48 | 49 | /** 50 | * 更新时间 51 | */ 52 | @Column(name = "updated_time") 53 | private Date updatedTime; 54 | 55 | /** 56 | * 商品内容 商品内容 57 | */ 58 | private String content; 59 | 60 | /** 61 | * 获取商品主键id 62 | * 63 | * @return id - 商品主键id 64 | */ 65 | public String getId() { 66 | return id; 67 | } 68 | 69 | /** 70 | * 设置商品主键id 71 | * 72 | * @param id 商品主键id 73 | */ 74 | public void setId(String id) { 75 | this.id = id; 76 | } 77 | 78 | /** 79 | * 获取商品名称 商品名称 80 | * 81 | * @return item_name - 商品名称 商品名称 82 | */ 83 | public String getItemName() { 84 | return itemName; 85 | } 86 | 87 | /** 88 | * 设置商品名称 商品名称 89 | * 90 | * @param itemName 商品名称 商品名称 91 | */ 92 | public void setItemName(String itemName) { 93 | this.itemName = itemName; 94 | } 95 | 96 | /** 97 | * 获取分类外键id 分类id 98 | * 99 | * @return cat_id - 分类外键id 分类id 100 | */ 101 | public Integer getCatId() { 102 | return catId; 103 | } 104 | 105 | /** 106 | * 设置分类外键id 分类id 107 | * 108 | * @param catId 分类外键id 分类id 109 | */ 110 | public void setCatId(Integer catId) { 111 | this.catId = catId; 112 | } 113 | 114 | /** 115 | * 获取一级分类外键id 116 | * 117 | * @return root_cat_id - 一级分类外键id 118 | */ 119 | public Integer getRootCatId() { 120 | return rootCatId; 121 | } 122 | 123 | /** 124 | * 设置一级分类外键id 125 | * 126 | * @param rootCatId 一级分类外键id 127 | */ 128 | public void setRootCatId(Integer rootCatId) { 129 | this.rootCatId = rootCatId; 130 | } 131 | 132 | /** 133 | * 获取累计销售 累计销售 134 | * 135 | * @return sell_counts - 累计销售 累计销售 136 | */ 137 | public Integer getSellCounts() { 138 | return sellCounts; 139 | } 140 | 141 | /** 142 | * 设置累计销售 累计销售 143 | * 144 | * @param sellCounts 累计销售 累计销售 145 | */ 146 | public void setSellCounts(Integer sellCounts) { 147 | this.sellCounts = sellCounts; 148 | } 149 | 150 | /** 151 | * 获取上下架状态 上下架状态,1:上架 2:下架 152 | * 153 | * @return on_off_status - 上下架状态 上下架状态,1:上架 2:下架 154 | */ 155 | public Integer getOnOffStatus() { 156 | return onOffStatus; 157 | } 158 | 159 | /** 160 | * 设置上下架状态 上下架状态,1:上架 2:下架 161 | * 162 | * @param onOffStatus 上下架状态 上下架状态,1:上架 2:下架 163 | */ 164 | public void setOnOffStatus(Integer onOffStatus) { 165 | this.onOffStatus = onOffStatus; 166 | } 167 | 168 | /** 169 | * 获取创建时间 170 | * 171 | * @return created_time - 创建时间 172 | */ 173 | public Date getCreatedTime() { 174 | return createdTime; 175 | } 176 | 177 | /** 178 | * 设置创建时间 179 | * 180 | * @param createdTime 创建时间 181 | */ 182 | public void setCreatedTime(Date createdTime) { 183 | this.createdTime = createdTime; 184 | } 185 | 186 | /** 187 | * 获取更新时间 188 | * 189 | * @return updated_time - 更新时间 190 | */ 191 | public Date getUpdatedTime() { 192 | return updatedTime; 193 | } 194 | 195 | /** 196 | * 设置更新时间 197 | * 198 | * @param updatedTime 更新时间 199 | */ 200 | public void setUpdatedTime(Date updatedTime) { 201 | this.updatedTime = updatedTime; 202 | } 203 | 204 | /** 205 | * 获取商品内容 商品内容 206 | * 207 | * @return content - 商品内容 商品内容 208 | */ 209 | public String getContent() { 210 | return content; 211 | } 212 | 213 | /** 214 | * 设置商品内容 商品内容 215 | * 216 | * @param content 商品内容 商品内容 217 | */ 218 | public void setContent(String content) { 219 | this.content = content; 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/ItemsComments.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Table(name = "items_comments") 7 | public class ItemsComments { 8 | /** 9 | * id主键 10 | */ 11 | @Id 12 | private String id; 13 | 14 | /** 15 | * 用户id 用户名须脱敏 16 | */ 17 | @Column(name = "user_id") 18 | private String userId; 19 | 20 | /** 21 | * 商品id 22 | */ 23 | @Column(name = "item_id") 24 | private String itemId; 25 | 26 | /** 27 | * 商品名称 28 | */ 29 | @Column(name = "item_name") 30 | private String itemName; 31 | 32 | /** 33 | * 商品规格id 可为空 34 | */ 35 | @Column(name = "item_spec_id") 36 | private String itemSpecId; 37 | 38 | /** 39 | * 规格名称 可为空 40 | */ 41 | @Column(name = "spec_name") 42 | private String specName; 43 | 44 | /** 45 | * 评价等级 1:好评 2:中评 3:差评 46 | */ 47 | @Column(name = "comment_level") 48 | private Integer commentLevel; 49 | 50 | /** 51 | * 评价内容 52 | */ 53 | private String content; 54 | 55 | /** 56 | * 创建时间 57 | */ 58 | @Column(name = "created_time") 59 | private Date createdTime; 60 | 61 | /** 62 | * 更新时间 63 | */ 64 | @Column(name = "updated_time") 65 | private Date updatedTime; 66 | 67 | /** 68 | * 获取id主键 69 | * 70 | * @return id - id主键 71 | */ 72 | public String getId() { 73 | return id; 74 | } 75 | 76 | /** 77 | * 设置id主键 78 | * 79 | * @param id id主键 80 | */ 81 | public void setId(String id) { 82 | this.id = id; 83 | } 84 | 85 | /** 86 | * 获取用户id 用户名须脱敏 87 | * 88 | * @return user_id - 用户id 用户名须脱敏 89 | */ 90 | public String getUserId() { 91 | return userId; 92 | } 93 | 94 | /** 95 | * 设置用户id 用户名须脱敏 96 | * 97 | * @param userId 用户id 用户名须脱敏 98 | */ 99 | public void setUserId(String userId) { 100 | this.userId = userId; 101 | } 102 | 103 | /** 104 | * 获取商品id 105 | * 106 | * @return item_id - 商品id 107 | */ 108 | public String getItemId() { 109 | return itemId; 110 | } 111 | 112 | /** 113 | * 设置商品id 114 | * 115 | * @param itemId 商品id 116 | */ 117 | public void setItemId(String itemId) { 118 | this.itemId = itemId; 119 | } 120 | 121 | /** 122 | * 获取商品名称 123 | * 124 | * @return item_name - 商品名称 125 | */ 126 | public String getItemName() { 127 | return itemName; 128 | } 129 | 130 | /** 131 | * 设置商品名称 132 | * 133 | * @param itemName 商品名称 134 | */ 135 | public void setItemName(String itemName) { 136 | this.itemName = itemName; 137 | } 138 | 139 | /** 140 | * 获取商品规格id 可为空 141 | * 142 | * @return item_spec_id - 商品规格id 可为空 143 | */ 144 | public String getItemSpecId() { 145 | return itemSpecId; 146 | } 147 | 148 | /** 149 | * 设置商品规格id 可为空 150 | * 151 | * @param itemSpecId 商品规格id 可为空 152 | */ 153 | public void setItemSpecId(String itemSpecId) { 154 | this.itemSpecId = itemSpecId; 155 | } 156 | 157 | /** 158 | * 获取规格名称 可为空 159 | * 160 | * @return sepc_name - 规格名称 可为空 161 | */ 162 | public String getSpecName() { 163 | return specName; 164 | } 165 | 166 | /** 167 | * 设置规格名称 可为空 168 | * 169 | * @param specName 规格名称 可为空 170 | */ 171 | public void setSpecName(String specName) { 172 | this.specName = specName; 173 | } 174 | 175 | /** 176 | * 获取评价等级 1:好评 2:中评 3:差评 177 | * 178 | * @return comment_level - 评价等级 1:好评 2:中评 3:差评 179 | */ 180 | public Integer getCommentLevel() { 181 | return commentLevel; 182 | } 183 | 184 | /** 185 | * 设置评价等级 1:好评 2:中评 3:差评 186 | * 187 | * @param commentLevel 评价等级 1:好评 2:中评 3:差评 188 | */ 189 | public void setCommentLevel(Integer commentLevel) { 190 | this.commentLevel = commentLevel; 191 | } 192 | 193 | /** 194 | * 获取评价内容 195 | * 196 | * @return content - 评价内容 197 | */ 198 | public String getContent() { 199 | return content; 200 | } 201 | 202 | /** 203 | * 设置评价内容 204 | * 205 | * @param content 评价内容 206 | */ 207 | public void setContent(String content) { 208 | this.content = content; 209 | } 210 | 211 | /** 212 | * 获取创建时间 213 | * 214 | * @return created_time - 创建时间 215 | */ 216 | public Date getCreatedTime() { 217 | return createdTime; 218 | } 219 | 220 | /** 221 | * 设置创建时间 222 | * 223 | * @param createdTime 创建时间 224 | */ 225 | public void setCreatedTime(Date createdTime) { 226 | this.createdTime = createdTime; 227 | } 228 | 229 | /** 230 | * 获取更新时间 231 | * 232 | * @return updated_time - 更新时间 233 | */ 234 | public Date getUpdatedTime() { 235 | return updatedTime; 236 | } 237 | 238 | /** 239 | * 设置更新时间 240 | * 241 | * @param updatedTime 更新时间 242 | */ 243 | public void setUpdatedTime(Date updatedTime) { 244 | this.updatedTime = updatedTime; 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/ItemsImg.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Table(name = "items_img") 7 | public class ItemsImg { 8 | /** 9 | * 图片主键 10 | */ 11 | @Id 12 | private String id; 13 | 14 | /** 15 | * 商品外键id 商品外键id 16 | */ 17 | @Column(name = "item_id") 18 | private String itemId; 19 | 20 | /** 21 | * 图片地址 图片地址 22 | */ 23 | private String url; 24 | 25 | /** 26 | * 顺序 图片顺序,从小到大 27 | */ 28 | private Integer sort; 29 | 30 | /** 31 | * 是否主图 是否主图,1:是,0:否 32 | */ 33 | @Column(name = "is_main") 34 | private Integer isMain; 35 | 36 | /** 37 | * 创建时间 38 | */ 39 | @Column(name = "created_time") 40 | private Date createdTime; 41 | 42 | /** 43 | * 更新时间 44 | */ 45 | @Column(name = "updated_time") 46 | private Date updatedTime; 47 | 48 | /** 49 | * 获取图片主键 50 | * 51 | * @return id - 图片主键 52 | */ 53 | public String getId() { 54 | return id; 55 | } 56 | 57 | /** 58 | * 设置图片主键 59 | * 60 | * @param id 图片主键 61 | */ 62 | public void setId(String id) { 63 | this.id = id; 64 | } 65 | 66 | /** 67 | * 获取商品外键id 商品外键id 68 | * 69 | * @return item_id - 商品外键id 商品外键id 70 | */ 71 | public String getItemId() { 72 | return itemId; 73 | } 74 | 75 | /** 76 | * 设置商品外键id 商品外键id 77 | * 78 | * @param itemId 商品外键id 商品外键id 79 | */ 80 | public void setItemId(String itemId) { 81 | this.itemId = itemId; 82 | } 83 | 84 | /** 85 | * 获取图片地址 图片地址 86 | * 87 | * @return url - 图片地址 图片地址 88 | */ 89 | public String getUrl() { 90 | return url; 91 | } 92 | 93 | /** 94 | * 设置图片地址 图片地址 95 | * 96 | * @param url 图片地址 图片地址 97 | */ 98 | public void setUrl(String url) { 99 | this.url = url; 100 | } 101 | 102 | /** 103 | * 获取顺序 图片顺序,从小到大 104 | * 105 | * @return sort - 顺序 图片顺序,从小到大 106 | */ 107 | public Integer getSort() { 108 | return sort; 109 | } 110 | 111 | /** 112 | * 设置顺序 图片顺序,从小到大 113 | * 114 | * @param sort 顺序 图片顺序,从小到大 115 | */ 116 | public void setSort(Integer sort) { 117 | this.sort = sort; 118 | } 119 | 120 | /** 121 | * 获取是否主图 是否主图,1:是,0:否 122 | * 123 | * @return is_main - 是否主图 是否主图,1:是,0:否 124 | */ 125 | public Integer getIsMain() { 126 | return isMain; 127 | } 128 | 129 | /** 130 | * 设置是否主图 是否主图,1:是,0:否 131 | * 132 | * @param isMain 是否主图 是否主图,1:是,0:否 133 | */ 134 | public void setIsMain(Integer isMain) { 135 | this.isMain = isMain; 136 | } 137 | 138 | /** 139 | * 获取创建时间 140 | * 141 | * @return created_time - 创建时间 142 | */ 143 | public Date getCreatedTime() { 144 | return createdTime; 145 | } 146 | 147 | /** 148 | * 设置创建时间 149 | * 150 | * @param createdTime 创建时间 151 | */ 152 | public void setCreatedTime(Date createdTime) { 153 | this.createdTime = createdTime; 154 | } 155 | 156 | /** 157 | * 获取更新时间 158 | * 159 | * @return updated_time - 更新时间 160 | */ 161 | public Date getUpdatedTime() { 162 | return updatedTime; 163 | } 164 | 165 | /** 166 | * 设置更新时间 167 | * 168 | * @param updatedTime 更新时间 169 | */ 170 | public void setUpdatedTime(Date updatedTime) { 171 | this.updatedTime = updatedTime; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/ItemsSpec.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | import java.math.BigDecimal; 7 | import java.util.Date; 8 | 9 | @Table(name = "items_spec") 10 | public class ItemsSpec { 11 | /** 12 | * 商品规格id 13 | */ 14 | @Id 15 | private String id; 16 | 17 | /** 18 | * 商品外键id 19 | */ 20 | @Column(name = "item_id") 21 | private String itemId; 22 | 23 | /** 24 | * 规格名称 25 | */ 26 | private String name; 27 | 28 | /** 29 | * 库存 30 | */ 31 | private Integer stock; 32 | 33 | /** 34 | * 折扣力度 35 | */ 36 | private BigDecimal discounts; 37 | 38 | /** 39 | * 优惠价 40 | */ 41 | @Column(name = "price_discount") 42 | private Integer priceDiscount; 43 | 44 | /** 45 | * 原价 46 | */ 47 | @Column(name = "price_normal") 48 | private Integer priceNormal; 49 | 50 | /** 51 | * 创建时间 52 | */ 53 | @Column(name = "created_time") 54 | private Date createdTime; 55 | 56 | /** 57 | * 更新时间 58 | */ 59 | @Column(name = "updated_time") 60 | private Date updatedTime; 61 | 62 | /** 63 | * 获取商品规格id 64 | * 65 | * @return id - 商品规格id 66 | */ 67 | public String getId() { 68 | return id; 69 | } 70 | 71 | /** 72 | * 设置商品规格id 73 | * 74 | * @param id 商品规格id 75 | */ 76 | public void setId(String id) { 77 | this.id = id; 78 | } 79 | 80 | /** 81 | * 获取商品外键id 82 | * 83 | * @return item_id - 商品外键id 84 | */ 85 | public String getItemId() { 86 | return itemId; 87 | } 88 | 89 | /** 90 | * 设置商品外键id 91 | * 92 | * @param itemId 商品外键id 93 | */ 94 | public void setItemId(String itemId) { 95 | this.itemId = itemId; 96 | } 97 | 98 | /** 99 | * 获取规格名称 100 | * 101 | * @return name - 规格名称 102 | */ 103 | public String getName() { 104 | return name; 105 | } 106 | 107 | /** 108 | * 设置规格名称 109 | * 110 | * @param name 规格名称 111 | */ 112 | public void setName(String name) { 113 | this.name = name; 114 | } 115 | 116 | /** 117 | * 获取库存 118 | * 119 | * @return stock - 库存 120 | */ 121 | public Integer getStock() { 122 | return stock; 123 | } 124 | 125 | /** 126 | * 设置库存 127 | * 128 | * @param stock 库存 129 | */ 130 | public void setStock(Integer stock) { 131 | this.stock = stock; 132 | } 133 | 134 | /** 135 | * 获取折扣力度 136 | * 137 | * @return discounts - 折扣力度 138 | */ 139 | public BigDecimal getDiscounts() { 140 | return discounts; 141 | } 142 | 143 | /** 144 | * 设置折扣力度 145 | * 146 | * @param discounts 折扣力度 147 | */ 148 | public void setDiscounts(BigDecimal discounts) { 149 | this.discounts = discounts; 150 | } 151 | 152 | /** 153 | * 获取优惠价 154 | * 155 | * @return price_discount - 优惠价 156 | */ 157 | public Integer getPriceDiscount() { 158 | return priceDiscount; 159 | } 160 | 161 | /** 162 | * 设置优惠价 163 | * 164 | * @param priceDiscount 优惠价 165 | */ 166 | public void setPriceDiscount(Integer priceDiscount) { 167 | this.priceDiscount = priceDiscount; 168 | } 169 | 170 | /** 171 | * 获取原价 172 | * 173 | * @return price_normal - 原价 174 | */ 175 | public Integer getPriceNormal() { 176 | return priceNormal; 177 | } 178 | 179 | /** 180 | * 设置原价 181 | * 182 | * @param priceNormal 原价 183 | */ 184 | public void setPriceNormal(Integer priceNormal) { 185 | this.priceNormal = priceNormal; 186 | } 187 | 188 | /** 189 | * 获取创建时间 190 | * 191 | * @return created_time - 创建时间 192 | */ 193 | public Date getCreatedTime() { 194 | return createdTime; 195 | } 196 | 197 | /** 198 | * 设置创建时间 199 | * 200 | * @param createdTime 创建时间 201 | */ 202 | public void setCreatedTime(Date createdTime) { 203 | this.createdTime = createdTime; 204 | } 205 | 206 | /** 207 | * 获取更新时间 208 | * 209 | * @return updated_time - 更新时间 210 | */ 211 | public Date getUpdatedTime() { 212 | return updatedTime; 213 | } 214 | 215 | /** 216 | * 设置更新时间 217 | * 218 | * @param updatedTime 更新时间 219 | */ 220 | public void setUpdatedTime(Date updatedTime) { 221 | this.updatedTime = updatedTime; 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/OrderItems.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | 5 | @Table(name = "order_items") 6 | public class OrderItems { 7 | /** 8 | * 主键id 9 | */ 10 | @Id 11 | private String id; 12 | 13 | /** 14 | * 归属订单id 15 | */ 16 | @Column(name = "order_id") 17 | private String orderId; 18 | 19 | /** 20 | * 商品id 21 | */ 22 | @Column(name = "item_id") 23 | private String itemId; 24 | 25 | /** 26 | * 商品图片 27 | */ 28 | @Column(name = "item_img") 29 | private String itemImg; 30 | 31 | /** 32 | * 商品名称 33 | */ 34 | @Column(name = "item_name") 35 | private String itemName; 36 | 37 | /** 38 | * 规格id 39 | */ 40 | @Column(name = "item_spec_id") 41 | private String itemSpecId; 42 | 43 | /** 44 | * 规格名称 45 | */ 46 | @Column(name = "item_spec_name") 47 | private String itemSpecName; 48 | 49 | /** 50 | * 成交价格 51 | */ 52 | private Integer price; 53 | 54 | /** 55 | * 购买数量 56 | */ 57 | @Column(name = "buy_counts") 58 | private Integer buyCounts; 59 | 60 | /** 61 | * 获取主键id 62 | * 63 | * @return id - 主键id 64 | */ 65 | public String getId() { 66 | return id; 67 | } 68 | 69 | /** 70 | * 设置主键id 71 | * 72 | * @param id 主键id 73 | */ 74 | public void setId(String id) { 75 | this.id = id; 76 | } 77 | 78 | /** 79 | * 获取归属订单id 80 | * 81 | * @return order_id - 归属订单id 82 | */ 83 | public String getOrderId() { 84 | return orderId; 85 | } 86 | 87 | /** 88 | * 设置归属订单id 89 | * 90 | * @param orderId 归属订单id 91 | */ 92 | public void setOrderId(String orderId) { 93 | this.orderId = orderId; 94 | } 95 | 96 | /** 97 | * 获取商品id 98 | * 99 | * @return item_id - 商品id 100 | */ 101 | public String getItemId() { 102 | return itemId; 103 | } 104 | 105 | /** 106 | * 设置商品id 107 | * 108 | * @param itemId 商品id 109 | */ 110 | public void setItemId(String itemId) { 111 | this.itemId = itemId; 112 | } 113 | 114 | /** 115 | * 获取商品图片 116 | * 117 | * @return item_img - 商品图片 118 | */ 119 | public String getItemImg() { 120 | return itemImg; 121 | } 122 | 123 | /** 124 | * 设置商品图片 125 | * 126 | * @param itemImg 商品图片 127 | */ 128 | public void setItemImg(String itemImg) { 129 | this.itemImg = itemImg; 130 | } 131 | 132 | /** 133 | * 获取商品名称 134 | * 135 | * @return item_name - 商品名称 136 | */ 137 | public String getItemName() { 138 | return itemName; 139 | } 140 | 141 | /** 142 | * 设置商品名称 143 | * 144 | * @param itemName 商品名称 145 | */ 146 | public void setItemName(String itemName) { 147 | this.itemName = itemName; 148 | } 149 | 150 | /** 151 | * 获取规格id 152 | * 153 | * @return item_spec_id - 规格id 154 | */ 155 | public String getItemSpecId() { 156 | return itemSpecId; 157 | } 158 | 159 | /** 160 | * 设置规格id 161 | * 162 | * @param itemSpecId 规格id 163 | */ 164 | public void setItemSpecId(String itemSpecId) { 165 | this.itemSpecId = itemSpecId; 166 | } 167 | 168 | /** 169 | * 获取规格名称 170 | * 171 | * @return item_spec_name - 规格名称 172 | */ 173 | public String getItemSpecName() { 174 | return itemSpecName; 175 | } 176 | 177 | /** 178 | * 设置规格名称 179 | * 180 | * @param itemSpecName 规格名称 181 | */ 182 | public void setItemSpecName(String itemSpecName) { 183 | this.itemSpecName = itemSpecName; 184 | } 185 | 186 | /** 187 | * 获取成交价格 188 | * 189 | * @return price - 成交价格 190 | */ 191 | public Integer getPrice() { 192 | return price; 193 | } 194 | 195 | /** 196 | * 设置成交价格 197 | * 198 | * @param price 成交价格 199 | */ 200 | public void setPrice(Integer price) { 201 | this.price = price; 202 | } 203 | 204 | /** 205 | * 获取购买数量 206 | * 207 | * @return buy_counts - 购买数量 208 | */ 209 | public Integer getBuyCounts() { 210 | return buyCounts; 211 | } 212 | 213 | /** 214 | * 设置购买数量 215 | * 216 | * @param buyCounts 购买数量 217 | */ 218 | public void setBuyCounts(Integer buyCounts) { 219 | this.buyCounts = buyCounts; 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Table(name = "order_status") 7 | public class OrderStatus { 8 | /** 9 | * 订单ID;对应订单表的主键id 10 | */ 11 | @Id 12 | @Column(name = "order_id") 13 | private String orderId; 14 | 15 | /** 16 | * 订单状态 17 | */ 18 | @Column(name = "order_status") 19 | private Integer orderStatus; 20 | 21 | /** 22 | * 订单创建时间;对应[10:待付款]状态 23 | */ 24 | @Column(name = "created_time") 25 | private Date createdTime; 26 | 27 | /** 28 | * 支付成功时间;对应[20:已付款,待发货]状态 29 | */ 30 | @Column(name = "pay_time") 31 | private Date payTime; 32 | 33 | /** 34 | * 发货时间;对应[30:已发货,待收货]状态 35 | */ 36 | @Column(name = "deliver_time") 37 | private Date deliverTime; 38 | 39 | /** 40 | * 交易成功时间;对应[40:交易成功]状态 41 | */ 42 | @Column(name = "success_time") 43 | private Date successTime; 44 | 45 | /** 46 | * 交易关闭时间;对应[50:交易关闭]状态 47 | */ 48 | @Column(name = "close_time") 49 | private Date closeTime; 50 | 51 | /** 52 | * 留言时间;用户在交易成功后的留言时间 53 | */ 54 | @Column(name = "comment_time") 55 | private Date commentTime; 56 | 57 | /** 58 | * 获取订单ID;对应订单表的主键id 59 | * 60 | * @return order_id - 订单ID;对应订单表的主键id 61 | */ 62 | public String getOrderId() { 63 | return orderId; 64 | } 65 | 66 | /** 67 | * 设置订单ID;对应订单表的主键id 68 | * 69 | * @param orderId 订单ID;对应订单表的主键id 70 | */ 71 | public void setOrderId(String orderId) { 72 | this.orderId = orderId; 73 | } 74 | 75 | /** 76 | * 获取订单状态 77 | * 78 | * @return order_status - 订单状态 79 | */ 80 | public Integer getOrderStatus() { 81 | return orderStatus; 82 | } 83 | 84 | /** 85 | * 设置订单状态 86 | * 87 | * @param orderStatus 订单状态 88 | */ 89 | public void setOrderStatus(Integer orderStatus) { 90 | this.orderStatus = orderStatus; 91 | } 92 | 93 | /** 94 | * 获取订单创建时间;对应[10:待付款]状态 95 | * 96 | * @return created_time - 订单创建时间;对应[10:待付款]状态 97 | */ 98 | public Date getCreatedTime() { 99 | return createdTime; 100 | } 101 | 102 | /** 103 | * 设置订单创建时间;对应[10:待付款]状态 104 | * 105 | * @param createdTime 订单创建时间;对应[10:待付款]状态 106 | */ 107 | public void setCreatedTime(Date createdTime) { 108 | this.createdTime = createdTime; 109 | } 110 | 111 | /** 112 | * 获取支付成功时间;对应[20:已付款,待发货]状态 113 | * 114 | * @return pay_time - 支付成功时间;对应[20:已付款,待发货]状态 115 | */ 116 | public Date getPayTime() { 117 | return payTime; 118 | } 119 | 120 | /** 121 | * 设置支付成功时间;对应[20:已付款,待发货]状态 122 | * 123 | * @param payTime 支付成功时间;对应[20:已付款,待发货]状态 124 | */ 125 | public void setPayTime(Date payTime) { 126 | this.payTime = payTime; 127 | } 128 | 129 | /** 130 | * 获取发货时间;对应[30:已发货,待收货]状态 131 | * 132 | * @return deliver_time - 发货时间;对应[30:已发货,待收货]状态 133 | */ 134 | public Date getDeliverTime() { 135 | return deliverTime; 136 | } 137 | 138 | /** 139 | * 设置发货时间;对应[30:已发货,待收货]状态 140 | * 141 | * @param deliverTime 发货时间;对应[30:已发货,待收货]状态 142 | */ 143 | public void setDeliverTime(Date deliverTime) { 144 | this.deliverTime = deliverTime; 145 | } 146 | 147 | /** 148 | * 获取交易成功时间;对应[40:交易成功]状态 149 | * 150 | * @return success_time - 交易成功时间;对应[40:交易成功]状态 151 | */ 152 | public Date getSuccessTime() { 153 | return successTime; 154 | } 155 | 156 | /** 157 | * 设置交易成功时间;对应[40:交易成功]状态 158 | * 159 | * @param successTime 交易成功时间;对应[40:交易成功]状态 160 | */ 161 | public void setSuccessTime(Date successTime) { 162 | this.successTime = successTime; 163 | } 164 | 165 | /** 166 | * 获取交易关闭时间;对应[50:交易关闭]状态 167 | * 168 | * @return close_time - 交易关闭时间;对应[50:交易关闭]状态 169 | */ 170 | public Date getCloseTime() { 171 | return closeTime; 172 | } 173 | 174 | /** 175 | * 设置交易关闭时间;对应[50:交易关闭]状态 176 | * 177 | * @param closeTime 交易关闭时间;对应[50:交易关闭]状态 178 | */ 179 | public void setCloseTime(Date closeTime) { 180 | this.closeTime = closeTime; 181 | } 182 | 183 | /** 184 | * 获取留言时间;用户在交易成功后的留言时间 185 | * 186 | * @return comment_time - 留言时间;用户在交易成功后的留言时间 187 | */ 188 | public Date getCommentTime() { 189 | return commentTime; 190 | } 191 | 192 | /** 193 | * 设置留言时间;用户在交易成功后的留言时间 194 | * 195 | * @param commentTime 留言时间;用户在交易成功后的留言时间 196 | */ 197 | public void setCommentTime(Date commentTime) { 198 | this.commentTime = commentTime; 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/Stu.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.Id; 4 | 5 | public class Stu { 6 | @Id 7 | private Integer id; 8 | 9 | private String name; 10 | 11 | private Integer age; 12 | 13 | /** 14 | * @return id 15 | */ 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | /** 21 | * @param id 22 | */ 23 | public void setId(Integer id) { 24 | this.id = id; 25 | } 26 | 27 | /** 28 | * @return name 29 | */ 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | /** 35 | * @param name 36 | */ 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | /** 42 | * @return age 43 | */ 44 | public Integer getAge() { 45 | return age; 46 | } 47 | 48 | /** 49 | * @param age 50 | */ 51 | public void setAge(Integer age) { 52 | this.age = age; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/UserAddress.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Table(name = "user_address") 7 | public class UserAddress { 8 | /** 9 | * 地址主键id 10 | */ 11 | @Id 12 | private String id; 13 | 14 | /** 15 | * 关联用户id 16 | */ 17 | @Column(name = "user_id") 18 | private String userId; 19 | 20 | /** 21 | * 收件人姓名 22 | */ 23 | private String receiver; 24 | 25 | /** 26 | * 收件人手机号 27 | */ 28 | private String mobile; 29 | 30 | /** 31 | * 省份 32 | */ 33 | private String province; 34 | 35 | /** 36 | * 城市 37 | */ 38 | private String city; 39 | 40 | /** 41 | * 区县 42 | */ 43 | private String district; 44 | 45 | /** 46 | * 详细地址 47 | */ 48 | private String detail; 49 | 50 | /** 51 | * 扩展字段 52 | */ 53 | private String extand; 54 | 55 | /** 56 | * 是否默认地址 57 | */ 58 | @Column(name = "is_default") 59 | private Integer isDefault; 60 | 61 | /** 62 | * 创建时间 63 | */ 64 | @Column(name = "created_time") 65 | private Date createdTime; 66 | 67 | /** 68 | * 更新时间 69 | */ 70 | @Column(name = "updated_time") 71 | private Date updatedTime; 72 | 73 | /** 74 | * 获取地址主键id 75 | * 76 | * @return id - 地址主键id 77 | */ 78 | public String getId() { 79 | return id; 80 | } 81 | 82 | /** 83 | * 设置地址主键id 84 | * 85 | * @param id 地址主键id 86 | */ 87 | public void setId(String id) { 88 | this.id = id; 89 | } 90 | 91 | /** 92 | * 获取关联用户id 93 | * 94 | * @return user_id - 关联用户id 95 | */ 96 | public String getUserId() { 97 | return userId; 98 | } 99 | 100 | /** 101 | * 设置关联用户id 102 | * 103 | * @param userId 关联用户id 104 | */ 105 | public void setUserId(String userId) { 106 | this.userId = userId; 107 | } 108 | 109 | /** 110 | * 获取收件人姓名 111 | * 112 | * @return receiver - 收件人姓名 113 | */ 114 | public String getReceiver() { 115 | return receiver; 116 | } 117 | 118 | /** 119 | * 设置收件人姓名 120 | * 121 | * @param receiver 收件人姓名 122 | */ 123 | public void setReceiver(String receiver) { 124 | this.receiver = receiver; 125 | } 126 | 127 | /** 128 | * 获取收件人手机号 129 | * 130 | * @return mobile - 收件人手机号 131 | */ 132 | public String getMobile() { 133 | return mobile; 134 | } 135 | 136 | /** 137 | * 设置收件人手机号 138 | * 139 | * @param mobile 收件人手机号 140 | */ 141 | public void setMobile(String mobile) { 142 | this.mobile = mobile; 143 | } 144 | 145 | /** 146 | * 获取省份 147 | * 148 | * @return province - 省份 149 | */ 150 | public String getProvince() { 151 | return province; 152 | } 153 | 154 | /** 155 | * 设置省份 156 | * 157 | * @param province 省份 158 | */ 159 | public void setProvince(String province) { 160 | this.province = province; 161 | } 162 | 163 | /** 164 | * 获取城市 165 | * 166 | * @return city - 城市 167 | */ 168 | public String getCity() { 169 | return city; 170 | } 171 | 172 | /** 173 | * 设置城市 174 | * 175 | * @param city 城市 176 | */ 177 | public void setCity(String city) { 178 | this.city = city; 179 | } 180 | 181 | /** 182 | * 获取区县 183 | * 184 | * @return district - 区县 185 | */ 186 | public String getDistrict() { 187 | return district; 188 | } 189 | 190 | /** 191 | * 设置区县 192 | * 193 | * @param district 区县 194 | */ 195 | public void setDistrict(String district) { 196 | this.district = district; 197 | } 198 | 199 | /** 200 | * 获取详细地址 201 | * 202 | * @return detail - 详细地址 203 | */ 204 | public String getDetail() { 205 | return detail; 206 | } 207 | 208 | /** 209 | * 设置详细地址 210 | * 211 | * @param detail 详细地址 212 | */ 213 | public void setDetail(String detail) { 214 | this.detail = detail; 215 | } 216 | 217 | /** 218 | * 获取扩展字段 219 | * 220 | * @return extand - 扩展字段 221 | */ 222 | public String getExtand() { 223 | return extand; 224 | } 225 | 226 | /** 227 | * 设置扩展字段 228 | * 229 | * @param extand 扩展字段 230 | */ 231 | public void setExtand(String extand) { 232 | this.extand = extand; 233 | } 234 | 235 | /** 236 | * 获取是否默认地址 237 | * 238 | * @return is_default - 是否默认地址 239 | */ 240 | public Integer getIsDefault() { 241 | return isDefault; 242 | } 243 | 244 | /** 245 | * 设置是否默认地址 246 | * 247 | * @param isDefault 是否默认地址 248 | */ 249 | public void setIsDefault(Integer isDefault) { 250 | this.isDefault = isDefault; 251 | } 252 | 253 | /** 254 | * 获取创建时间 255 | * 256 | * @return created_time - 创建时间 257 | */ 258 | public Date getCreatedTime() { 259 | return createdTime; 260 | } 261 | 262 | /** 263 | * 设置创建时间 264 | * 265 | * @param createdTime 创建时间 266 | */ 267 | public void setCreatedTime(Date createdTime) { 268 | this.createdTime = createdTime; 269 | } 270 | 271 | /** 272 | * 获取更新时间 273 | * 274 | * @return updated_time - 更新时间 275 | */ 276 | public Date getUpdatedTime() { 277 | return updatedTime; 278 | } 279 | 280 | /** 281 | * 设置更新时间 282 | * 283 | * @param updatedTime 更新时间 284 | */ 285 | public void setUpdatedTime(Date updatedTime) { 286 | this.updatedTime = updatedTime; 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/Users.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | public class Users { 7 | /** 8 | * 主键id 用户id 9 | */ 10 | @Id 11 | private String id; 12 | 13 | /** 14 | * 用户名 用户名 15 | */ 16 | private String username; 17 | 18 | /** 19 | * 密码 密码 20 | */ 21 | private String password; 22 | 23 | /** 24 | * 昵称 昵称 25 | */ 26 | private String nickname; 27 | 28 | /** 29 | * 真实姓名 30 | */ 31 | private String realname; 32 | 33 | /** 34 | * 头像 35 | */ 36 | private String face; 37 | 38 | /** 39 | * 手机号 手机号 40 | */ 41 | private String mobile; 42 | 43 | /** 44 | * 邮箱地址 邮箱地址 45 | */ 46 | private String email; 47 | 48 | /** 49 | * 性别 性别 1:男 0:女 2:保密 50 | */ 51 | private Integer sex; 52 | 53 | /** 54 | * 生日 生日 55 | */ 56 | private Date birthday; 57 | 58 | /** 59 | * 创建时间 创建时间 60 | */ 61 | @Column(name = "created_time") 62 | private Date createdTime; 63 | 64 | /** 65 | * 更新时间 更新时间 66 | */ 67 | @Column(name = "updated_time") 68 | private Date updatedTime; 69 | 70 | /** 71 | * 获取主键id 用户id 72 | * 73 | * @return id - 主键id 用户id 74 | */ 75 | public String getId() { 76 | return id; 77 | } 78 | 79 | /** 80 | * 设置主键id 用户id 81 | * 82 | * @param id 主键id 用户id 83 | */ 84 | public void setId(String id) { 85 | this.id = id; 86 | } 87 | 88 | /** 89 | * 获取用户名 用户名 90 | * 91 | * @return username - 用户名 用户名 92 | */ 93 | public String getUsername() { 94 | return username; 95 | } 96 | 97 | /** 98 | * 设置用户名 用户名 99 | * 100 | * @param username 用户名 用户名 101 | */ 102 | public void setUsername(String username) { 103 | this.username = username; 104 | } 105 | 106 | /** 107 | * 获取密码 密码 108 | * 109 | * @return password - 密码 密码 110 | */ 111 | public String getPassword() { 112 | return password; 113 | } 114 | 115 | /** 116 | * 设置密码 密码 117 | * 118 | * @param password 密码 密码 119 | */ 120 | public void setPassword(String password) { 121 | this.password = password; 122 | } 123 | 124 | /** 125 | * 获取昵称 昵称 126 | * 127 | * @return nickname - 昵称 昵称 128 | */ 129 | public String getNickname() { 130 | return nickname; 131 | } 132 | 133 | /** 134 | * 设置昵称 昵称 135 | * 136 | * @param nickname 昵称 昵称 137 | */ 138 | public void setNickname(String nickname) { 139 | this.nickname = nickname; 140 | } 141 | 142 | /** 143 | * 获取真实姓名 144 | * 145 | * @return realname - 真实姓名 146 | */ 147 | public String getRealname() { 148 | return realname; 149 | } 150 | 151 | /** 152 | * 设置真实姓名 153 | * 154 | * @param realname 真实姓名 155 | */ 156 | public void setRealname(String realname) { 157 | this.realname = realname; 158 | } 159 | 160 | /** 161 | * 获取头像 162 | * 163 | * @return face - 头像 164 | */ 165 | public String getFace() { 166 | return face; 167 | } 168 | 169 | /** 170 | * 设置头像 171 | * 172 | * @param face 头像 173 | */ 174 | public void setFace(String face) { 175 | this.face = face; 176 | } 177 | 178 | /** 179 | * 获取手机号 手机号 180 | * 181 | * @return mobile - 手机号 手机号 182 | */ 183 | public String getMobile() { 184 | return mobile; 185 | } 186 | 187 | /** 188 | * 设置手机号 手机号 189 | * 190 | * @param mobile 手机号 手机号 191 | */ 192 | public void setMobile(String mobile) { 193 | this.mobile = mobile; 194 | } 195 | 196 | /** 197 | * 获取邮箱地址 邮箱地址 198 | * 199 | * @return email - 邮箱地址 邮箱地址 200 | */ 201 | public String getEmail() { 202 | return email; 203 | } 204 | 205 | /** 206 | * 设置邮箱地址 邮箱地址 207 | * 208 | * @param email 邮箱地址 邮箱地址 209 | */ 210 | public void setEmail(String email) { 211 | this.email = email; 212 | } 213 | 214 | /** 215 | * 获取性别 性别 1:男 0:女 2:保密 216 | * 217 | * @return sex - 性别 性别 1:男 0:女 2:保密 218 | */ 219 | public Integer getSex() { 220 | return sex; 221 | } 222 | 223 | /** 224 | * 设置性别 性别 1:男 0:女 2:保密 225 | * 226 | * @param sex 性别 性别 1:男 0:女 2:保密 227 | */ 228 | public void setSex(Integer sex) { 229 | this.sex = sex; 230 | } 231 | 232 | /** 233 | * 获取生日 生日 234 | * 235 | * @return birthday - 生日 生日 236 | */ 237 | public Date getBirthday() { 238 | return birthday; 239 | } 240 | 241 | /** 242 | * 设置生日 生日 243 | * 244 | * @param birthday 生日 生日 245 | */ 246 | public void setBirthday(Date birthday) { 247 | this.birthday = birthday; 248 | } 249 | 250 | /** 251 | * 获取创建时间 创建时间 252 | * 253 | * @return created_time - 创建时间 创建时间 254 | */ 255 | public Date getCreatedTime() { 256 | return createdTime; 257 | } 258 | 259 | /** 260 | * 设置创建时间 创建时间 261 | * 262 | * @param createdTime 创建时间 创建时间 263 | */ 264 | public void setCreatedTime(Date createdTime) { 265 | this.createdTime = createdTime; 266 | } 267 | 268 | /** 269 | * 获取更新时间 更新时间 270 | * 271 | * @return updated_time - 更新时间 更新时间 272 | */ 273 | public Date getUpdatedTime() { 274 | return updatedTime; 275 | } 276 | 277 | /** 278 | * 设置更新时间 更新时间 279 | * 280 | * @param updatedTime 更新时间 更新时间 281 | */ 282 | public void setUpdatedTime(Date updatedTime) { 283 | this.updatedTime = updatedTime; 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/bo/AddressBO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.bo; 2 | 3 | public class AddressBO { 4 | 5 | private String addressId; 6 | private String userId; 7 | private String receiver; 8 | private String mobile; 9 | private String province; 10 | private String city; 11 | private String district; 12 | private String detail; 13 | 14 | 15 | public String getAddressId() { 16 | return addressId; 17 | } 18 | 19 | public void setAddressId(String addressId) { 20 | this.addressId = addressId; 21 | } 22 | 23 | public String getUserId() { 24 | return userId; 25 | } 26 | 27 | public void setUserId(String userId) { 28 | this.userId = userId; 29 | } 30 | 31 | public String getReceiver() { 32 | return receiver; 33 | } 34 | 35 | public void setReceiver(String receiver) { 36 | this.receiver = receiver; 37 | } 38 | 39 | public String getMobile() { 40 | return mobile; 41 | } 42 | 43 | public void setMobile(String mobile) { 44 | this.mobile = mobile; 45 | } 46 | 47 | public String getProvince() { 48 | return province; 49 | } 50 | 51 | public void setProvince(String province) { 52 | this.province = province; 53 | } 54 | 55 | public String getCity() { 56 | return city; 57 | } 58 | 59 | public void setCity(String city) { 60 | this.city = city; 61 | } 62 | 63 | public String getDistrict() { 64 | return district; 65 | } 66 | 67 | public void setDistrict(String district) { 68 | this.district = district; 69 | } 70 | 71 | public String getDetail() { 72 | return detail; 73 | } 74 | 75 | public void setDetail(String detail) { 76 | this.detail = detail; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/bo/ShopcartBO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.bo; 2 | 3 | public class ShopcartBO { 4 | private String itemId; 5 | private String itemImgUrl; 6 | private String itemName; 7 | private String specId; 8 | private String specName; 9 | private Integer buyCounts; 10 | private String priceDiscount; 11 | private String priceNormal; 12 | 13 | public String getItemId() { 14 | return itemId; 15 | } 16 | 17 | public void setItemId(String itemId) { 18 | this.itemId = itemId; 19 | } 20 | 21 | public String getItemImgUrl() { 22 | return itemImgUrl; 23 | } 24 | 25 | public void setItemImgUrl(String itemImgUrl) { 26 | this.itemImgUrl = itemImgUrl; 27 | } 28 | 29 | public String getItemName() { 30 | return itemName; 31 | } 32 | 33 | public void setItemName(String itemName) { 34 | this.itemName = itemName; 35 | } 36 | 37 | public String getSpecId() { 38 | return specId; 39 | } 40 | 41 | public void setSpecId(String specId) { 42 | this.specId = specId; 43 | } 44 | 45 | public String getSpecName() { 46 | return specName; 47 | } 48 | 49 | public void setSpecName(String specName) { 50 | this.specName = specName; 51 | } 52 | 53 | public Integer getBuyCounts() { 54 | return buyCounts; 55 | } 56 | 57 | public void setBuyCounts(Integer buyCounts) { 58 | this.buyCounts = buyCounts; 59 | } 60 | 61 | public String getPriceDiscount() { 62 | return priceDiscount; 63 | } 64 | 65 | public void setPriceDiscount(String priceDiscount) { 66 | this.priceDiscount = priceDiscount; 67 | } 68 | 69 | public String getPriceNormal() { 70 | return priceNormal; 71 | } 72 | 73 | public void setPriceNormal(String priceNormal) { 74 | this.priceNormal = priceNormal; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "ShopcartBO{" + 80 | "itemId='" + itemId + '\'' + 81 | ", itemImgUrl='" + itemImgUrl + '\'' + 82 | ", itemName='" + itemName + '\'' + 83 | ", specId='" + specId + '\'' + 84 | ", specName='" + specName + '\'' + 85 | ", buyCounts=" + buyCounts + 86 | ", priceDiscount='" + priceDiscount + '\'' + 87 | ", priceNormal='" + priceNormal + '\'' + 88 | '}'; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/bo/SubmitOrderBO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.bo; 2 | 3 | /** 4 | * 用于创建订单的BO对象 5 | */ 6 | public class SubmitOrderBO { 7 | private String userId; 8 | private String itemSpecIds; 9 | private String addressId; 10 | private Integer payMethod; 11 | private String leftMsg; 12 | 13 | public String getUserId() { 14 | return userId; 15 | } 16 | 17 | public void setUserId(String userId) { 18 | this.userId = userId; 19 | } 20 | 21 | public String getItemSpecIds() { 22 | return itemSpecIds; 23 | } 24 | 25 | public void setItemSpecIds(String itemSpecIds) { 26 | this.itemSpecIds = itemSpecIds; 27 | } 28 | 29 | public String getAddressId() { 30 | return addressId; 31 | } 32 | 33 | public void setAddressId(String addressId) { 34 | this.addressId = addressId; 35 | } 36 | 37 | public Integer getPayMethod() { 38 | return payMethod; 39 | } 40 | 41 | public void setPayMethod(Integer payMethod) { 42 | this.payMethod = payMethod; 43 | } 44 | 45 | public String getLeftMsg() { 46 | return leftMsg; 47 | } 48 | 49 | public void setLeftMsg(String leftMsg) { 50 | this.leftMsg = leftMsg; 51 | } 52 | 53 | @Override 54 | public String toString() { 55 | return "SubmitOrderBO{" + 56 | "userId='" + userId + '\'' + 57 | ", itemSpecIds='" + itemSpecIds + '\'' + 58 | ", addressId='" + addressId + '\'' + 59 | ", payMethod=" + payMethod + 60 | ", leftMsg='" + leftMsg + '\'' + 61 | '}'; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/bo/UserBO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.bo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | 6 | /** 7 | * @program: foodie 8 | * @description: 9 | * @author: Mr.Wang 10 | * @create: 2019-28 18:57 11 | */ 12 | @ApiModel(value = "用户对象BO", description = "从客户端,由用户传入的数据封装在此entity中") 13 | public class UserBO { 14 | 15 | @ApiModelProperty(value="用户名", name="username", example = "muxin", required = true) 16 | private String username; 17 | @ApiModelProperty(value="密码", name="password", example = "123456", required = true) 18 | private String password; 19 | @ApiModelProperty(value="确认密码", name="confirmPassword", example = "123456", required = false) 20 | private String confirmPassword; 21 | 22 | public String getUsername() { 23 | return username; 24 | } 25 | 26 | public void setUsername(String username) { 27 | this.username = username; 28 | } 29 | 30 | public String getPassword() { 31 | return password; 32 | } 33 | 34 | public void setPassword(String password) { 35 | this.password = password; 36 | } 37 | 38 | public String getConfirmPassword() { 39 | return confirmPassword; 40 | } 41 | 42 | public void setConfirmPassword(String confirmPassword) { 43 | this.confirmPassword = confirmPassword; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/CategoryVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 二级分类VO 7 | */ 8 | public class CategoryVO { 9 | 10 | private Integer id; 11 | private String name; 12 | private String type; 13 | private Integer fatherId; 14 | 15 | // 三级分类vo list 16 | private List subCatList; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | 34 | public String getType() { 35 | return type; 36 | } 37 | 38 | public void setType(String type) { 39 | this.type = type; 40 | } 41 | 42 | public Integer getFatherId() { 43 | return fatherId; 44 | } 45 | 46 | public void setFatherId(Integer fatherId) { 47 | this.fatherId = fatherId; 48 | } 49 | 50 | public List getSubCatList() { 51 | return subCatList; 52 | } 53 | 54 | public void setSubCatList(List subCatList) { 55 | this.subCatList = subCatList; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/CommentLevelCountsVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 用于展示商品评价数量的vo 6 | * @author: Mr.Wang 7 | * @create: 2020-05 16:14 8 | */ 9 | public class CommentLevelCountsVO { 10 | 11 | public Integer totalCounts; 12 | public Integer goodCounts; 13 | public Integer normalCounts; 14 | public Integer badCounts; 15 | 16 | public Integer getTotalCounts() { 17 | return totalCounts; 18 | } 19 | 20 | public void setTotalCounts(Integer totalCounts) { 21 | this.totalCounts = totalCounts; 22 | } 23 | 24 | public Integer getGoodCounts() { 25 | return goodCounts; 26 | } 27 | 28 | public void setGoodCounts(Integer goodCounts) { 29 | this.goodCounts = goodCounts; 30 | } 31 | 32 | public Integer getNormalCounts() { 33 | return normalCounts; 34 | } 35 | 36 | public void setNormalCounts(Integer normalCounts) { 37 | this.normalCounts = normalCounts; 38 | } 39 | 40 | public Integer getBadCounts() { 41 | return badCounts; 42 | } 43 | 44 | public void setBadCounts(Integer badCounts) { 45 | this.badCounts = badCounts; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/ItemCommentVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * 用于展示商品评价的VO 7 | */ 8 | public class ItemCommentVO { 9 | 10 | private Integer commentLevel; 11 | private String content; 12 | private String specName; 13 | private Date createdTime; 14 | private String userFace; 15 | private String nickname; 16 | 17 | public Integer getCommentLevel() { 18 | return commentLevel; 19 | } 20 | 21 | public void setCommentLevel(Integer commentLevel) { 22 | this.commentLevel = commentLevel; 23 | } 24 | 25 | public String getContent() { 26 | return content; 27 | } 28 | 29 | public void setContent(String content) { 30 | this.content = content; 31 | } 32 | 33 | public String getSpecName() { 34 | return specName; 35 | } 36 | 37 | public void setSpecName(String specName) { 38 | this.specName = specName; 39 | } 40 | 41 | public Date getCreatedTime() { 42 | return createdTime; 43 | } 44 | 45 | public void setCreatedTime(Date createdTime) { 46 | this.createdTime = createdTime; 47 | } 48 | 49 | public String getUserFace() { 50 | return userFace; 51 | } 52 | 53 | public void setUserFace(String userFace) { 54 | this.userFace = userFace; 55 | } 56 | 57 | public String getNickname() { 58 | return nickname; 59 | } 60 | 61 | public void setNickname(String nickname) { 62 | this.nickname = nickname; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/ItemInfoVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | import com.muxin.pojo.ItemParams; 4 | import com.muxin.pojo.Items; 5 | import com.muxin.pojo.ItemsImg; 6 | import com.muxin.pojo.ItemsSpec; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @program: foodie 12 | * @description: 商品详情VO 13 | * @author: Mr.Wang 14 | * @create: 2020-04 12:04 15 | */ 16 | public class ItemInfoVO { 17 | 18 | private Items item; 19 | private List itemImgList; 20 | private List itemsSpecList; 21 | private ItemParams itemParams; 22 | 23 | public ItemParams getItemParams() { 24 | return itemParams; 25 | } 26 | 27 | public void setItemParams(ItemParams itemParams) { 28 | this.itemParams = itemParams; 29 | } 30 | 31 | public Items getItem() { 32 | return item; 33 | } 34 | 35 | public void setItem(Items item) { 36 | this.item = item; 37 | } 38 | 39 | public List getItemImgList() { 40 | return itemImgList; 41 | } 42 | 43 | public void setItemImgList(List itemImgList) { 44 | this.itemImgList = itemImgList; 45 | } 46 | 47 | public List getItemSpecList() { 48 | return itemsSpecList; 49 | } 50 | 51 | public void setItemSpecList(List itemSpecList) { 52 | this.itemsSpecList = itemSpecList; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/NewItemsVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 最新商品VO 7 | */ 8 | public class NewItemsVO { 9 | 10 | private Integer rootCatId; 11 | private String rootCatName; 12 | private String slogan; 13 | private String catImage; 14 | private String bgColor; 15 | 16 | private List simpleItemList; 17 | 18 | public Integer getRootCatId() { 19 | return rootCatId; 20 | } 21 | 22 | public void setRootCatId(Integer rootCatId) { 23 | this.rootCatId = rootCatId; 24 | } 25 | 26 | public String getRootCatName() { 27 | return rootCatName; 28 | } 29 | 30 | public void setRootCatName(String rootCatName) { 31 | this.rootCatName = rootCatName; 32 | } 33 | 34 | public String getSlogan() { 35 | return slogan; 36 | } 37 | 38 | public void setSlogan(String slogan) { 39 | this.slogan = slogan; 40 | } 41 | 42 | public String getCatImage() { 43 | return catImage; 44 | } 45 | 46 | public void setCatImage(String catImage) { 47 | this.catImage = catImage; 48 | } 49 | 50 | public String getBgColor() { 51 | return bgColor; 52 | } 53 | 54 | public void setBgColor(String bgColor) { 55 | this.bgColor = bgColor; 56 | } 57 | 58 | public List getSimpleItemList() { 59 | return simpleItemList; 60 | } 61 | 62 | public void setSimpleItemList(List simpleItemList) { 63 | this.simpleItemList = simpleItemList; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/SearchItemsVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | /** 4 | * 用于展示商品搜索列表结果的VO 5 | */ 6 | public class SearchItemsVO { 7 | 8 | private String itemId; 9 | private String itemName; 10 | private int sellCounts; 11 | private String imgUrl; 12 | private int price; 13 | 14 | public String getItemId() { 15 | return itemId; 16 | } 17 | 18 | public void setItemId(String itemId) { 19 | this.itemId = itemId; 20 | } 21 | 22 | public String getItemName() { 23 | return itemName; 24 | } 25 | 26 | public void setItemName(String itemName) { 27 | this.itemName = itemName; 28 | } 29 | 30 | public int getSellCounts() { 31 | return sellCounts; 32 | } 33 | 34 | public void setSellCounts(int sellCounts) { 35 | this.sellCounts = sellCounts; 36 | } 37 | 38 | public String getImgUrl() { 39 | return imgUrl; 40 | } 41 | 42 | public void setImgUrl(String imgUrl) { 43 | this.imgUrl = imgUrl; 44 | } 45 | 46 | public int getPrice() { 47 | return price; 48 | } 49 | 50 | public void setPrice(int price) { 51 | this.price = price; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/ShopcartVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | public class ShopcartVO { 4 | 5 | private String itemId; 6 | private String itemImgUrl; 7 | private String itemName; 8 | private String specId; 9 | private String specName; 10 | private String priceDiscount; 11 | private String priceNormal; 12 | 13 | public String getItemId() { 14 | return itemId; 15 | } 16 | 17 | public void setItemId(String itemId) { 18 | this.itemId = itemId; 19 | } 20 | 21 | public String getItemImgUrl() { 22 | return itemImgUrl; 23 | } 24 | 25 | public void setItemImgUrl(String itemImgUrl) { 26 | this.itemImgUrl = itemImgUrl; 27 | } 28 | 29 | public String getItemName() { 30 | return itemName; 31 | } 32 | 33 | public void setItemName(String itemName) { 34 | this.itemName = itemName; 35 | } 36 | 37 | public String getSpecId() { 38 | return specId; 39 | } 40 | 41 | public void setSpecId(String specId) { 42 | this.specId = specId; 43 | } 44 | 45 | public String getSpecName() { 46 | return specName; 47 | } 48 | 49 | public void setSpecName(String specName) { 50 | this.specName = specName; 51 | } 52 | 53 | public String getPriceDiscount() { 54 | return priceDiscount; 55 | } 56 | 57 | public void setPriceDiscount(String priceDiscount) { 58 | this.priceDiscount = priceDiscount; 59 | } 60 | 61 | public String getPriceNormal() { 62 | return priceNormal; 63 | } 64 | 65 | public void setPriceNormal(String priceNormal) { 66 | this.priceNormal = priceNormal; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/SimpleItemVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 6 个最新商品的简单数据类型 6 | * @author: Mr.Wang 7 | * @create: 2020-04 12:04 8 | */ 9 | public class SimpleItemVO { 10 | 11 | private String rootCatName; 12 | private String itemId; 13 | private String itemName; 14 | private String itemUrl; 15 | 16 | public String getRootCatName() { 17 | return rootCatName; 18 | } 19 | 20 | public void setRootCatName(String rootCatName) { 21 | this.rootCatName = rootCatName; 22 | } 23 | 24 | public String getItemId() { 25 | return itemId; 26 | } 27 | 28 | public void setItemId(String itemId) { 29 | this.itemId = itemId; 30 | } 31 | 32 | public String getItemName() { 33 | return itemName; 34 | } 35 | 36 | public void setItemName(String itemName) { 37 | this.itemName = itemName; 38 | } 39 | 40 | public String getItemUrl() { 41 | return itemUrl; 42 | } 43 | 44 | public void setItemUrl(String itemUrl) { 45 | this.itemUrl = itemUrl; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /foodie-pojo/src/main/java/com/muxin/pojo/vo/SubCategoryVO.java: -------------------------------------------------------------------------------- 1 | package com.muxin.pojo.vo; 2 | 3 | /** 4 | * @program: foodie 5 | * @description: 三级分类VO 6 | * @author: Mr.Wang 7 | * @create: 2020-02 16:05 8 | */ 9 | public class SubCategoryVO { 10 | private Integer subId; 11 | private String subName; 12 | private String subType; 13 | private Integer subFatherId; 14 | 15 | public Integer getSubId() { 16 | return subId; 17 | } 18 | 19 | public void setSubId(Integer subId) { 20 | this.subId = subId; 21 | } 22 | 23 | public String getSubName() { 24 | return subName; 25 | } 26 | 27 | public void setSubName(String subName) { 28 | this.subName = subName; 29 | } 30 | 31 | public String getSubType() { 32 | return subType; 33 | } 34 | 35 | public void setSubType(String subType) { 36 | this.subType = subType; 37 | } 38 | 39 | public Integer getSubFatherId() { 40 | return subFatherId; 41 | } 42 | 43 | public void setSubFatherId(Integer subFatherId) { 44 | this.subFatherId = subFatherId; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /foodie-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | foodie 7 | com.muxin 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | foodie-service 13 | 14 | 15 | 19 | 20 | 21 | 22 | com.muxin 23 | foodie-mapper 24 | 1.0-SNAPSHOT 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/AddressService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | import com.muxin.pojo.UserAddress; 4 | import com.muxin.pojo.bo.AddressBO; 5 | 6 | import java.util.List; 7 | 8 | public interface AddressService { 9 | 10 | /** 11 | * 根据用户id查询用户的收货地址列表 12 | * 13 | * @return 14 | */ 15 | public List queryAll(String userId); 16 | 17 | 18 | /** 19 | * 用户新增地址 20 | * 21 | * @param addressBO 22 | */ 23 | public void addNewUserAddress(AddressBO addressBO); 24 | 25 | /** 26 | * 用户修改地址 27 | * 28 | * @param addressBO 29 | */ 30 | public void updateUserAddress(AddressBO addressBO); 31 | 32 | 33 | /** 34 | * 根据用户id和地址id,删除对应的用户地址信息 35 | * 36 | * @param userId 37 | * @param addressId 38 | */ 39 | public void deleteUserAddress(String userId, String addressId); 40 | 41 | 42 | /** 43 | * 修改默认地址 44 | * 45 | * @param userId 46 | * @param addressId 47 | */ 48 | public void updateUserAddressToBeDefault(String userId, String addressId); 49 | 50 | /** 51 | * 根据用户Id和地址Id,查询具体的用户地址对象信息 52 | * 53 | * @param userId 54 | * @param addressId 55 | * @return 56 | */ 57 | public UserAddress queryUserAddress(String userId, String addressId); 58 | } 59 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/CarouselService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | import com.muxin.pojo.Carousel; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @program: foodie 9 | * @description: 10 | * @author: Mr.Wang 11 | * @create: 2020-01 20:51 12 | */ 13 | public interface CarouselService { 14 | 15 | /** 16 | * 查询所有轮播图列表 17 | * 18 | * @param isShow 19 | * @return 20 | */ 21 | public List queryAll(Integer isShow); 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | import com.muxin.pojo.Category; 4 | import com.muxin.pojo.vo.CategoryVO; 5 | import com.muxin.pojo.vo.NewItemsVO; 6 | 7 | import java.util.List; 8 | 9 | public interface CategoryService { 10 | 11 | /** 12 | * 查询所有一级分类 13 | * 14 | * @return 15 | */ 16 | public List queryAllRootLevelCat(); 17 | 18 | /** 19 | * 根据一级分类id查询子分类信息 20 | * 21 | * @param rootCatId 22 | * @return 23 | */ 24 | public List getSubCatList(Integer rootCatId); 25 | 26 | 27 | /** 28 | * 查询首页每个一级分类下的6条最新商品数据 29 | * 30 | * @param rootCatId 31 | * @return 32 | */ 33 | public List getSixNewItemsLazy(Integer rootCatId); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/ItemService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | import com.muxin.pojo.Items; 4 | import com.muxin.pojo.ItemsImg; 5 | import com.muxin.pojo.ItemParams; 6 | import com.muxin.pojo.ItemsSpec; 7 | import com.muxin.pojo.vo.CommentLevelCountsVO; 8 | import com.muxin.pojo.vo.ShopcartVO; 9 | import com.muxin.utils.PagedGridResult; 10 | 11 | import java.util.List; 12 | 13 | 14 | /** 15 | * @program: foodie 16 | * @description: 17 | * @author: Mr.Wang 18 | * @create: 2020-01 20:51 19 | */ 20 | public interface ItemService { 21 | 22 | /** 23 | * 根据商品id查询详情 24 | * 25 | * @param id 26 | * @return 27 | */ 28 | public Items queryItemById(String id); 29 | 30 | /** 31 | * 根据商品id查询商品图片列表 32 | * 33 | * @param itemId 34 | * @return 35 | */ 36 | public List queryItemImgList(String itemId); 37 | 38 | 39 | /** 40 | * 根据商品id查询商品规格 41 | * 42 | * @param itemId 43 | * @return 44 | */ 45 | public List queryItemSpecList(String itemId); 46 | 47 | 48 | /** 49 | * 根据商品id查询商品参数 50 | * 51 | * @param itemId 52 | * @return 53 | */ 54 | public ItemParams queryItemParam(String itemId); 55 | 56 | 57 | /** 58 | * 根据商品id查询商品的评价等级数量 59 | * 60 | * @param itemId 61 | */ 62 | public CommentLevelCountsVO queryCommentCounts(String itemId); 63 | 64 | /** 65 | * 根据商品id查询商品的评价(分页) 66 | * 67 | * @param itemId 68 | * @param level 69 | * @return 70 | */ 71 | public PagedGridResult queryPagedComment(String itemId, Integer level, 72 | Integer page, Integer pageSize); 73 | 74 | /** 75 | * 根据规格ids查询最新的购物车中商品数据(用于刷新渲染购物车中的商品数据) 76 | * 77 | * @param specIds 78 | * @return 79 | */ 80 | public List queryItemsBySpecIds(String specIds); 81 | 82 | /** 83 | * 根据商品规格id获取规格对象的具体信息 84 | * 85 | * @param specId 86 | * @return 87 | */ 88 | public ItemsSpec queryItemSpecById(String specId); 89 | 90 | 91 | public String queryItemMainImgById(String itemId); 92 | 93 | /** 94 | * 减少库存 95 | * 96 | * @param specId 97 | * @param buyCounts 98 | */ 99 | public void decreaseItemSpecStock(String specId, int buyCounts); 100 | } 101 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | import com.muxin.pojo.Carousel; 4 | import com.muxin.pojo.bo.SubmitOrderBO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @program: foodie 10 | * @description: 11 | * @author: Mr.Wang 12 | * @create: 2020-01 20:51 13 | */ 14 | public interface OrderService { 15 | 16 | /** 17 | * 用于创建订单相关信息 18 | * 19 | * @param submitOrderBO 20 | * @return 21 | */ 22 | public String createOrder(SubmitOrderBO submitOrderBO); 23 | } 24 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/TestTransService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | public interface TestTransService { 4 | public void testPropagationTrans(); 5 | } 6 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service; 2 | 3 | import com.muxin.pojo.bo.UserBO; 4 | import com.muxin.pojo.Users; 5 | 6 | /** 7 | * @program: foodie 8 | * @description: 9 | * @author: Mr.Wang 10 | * @create: 2019-07 18:27 11 | */ 12 | public interface UserService { 13 | 14 | /** 15 | * 判断用户名是否存在 16 | */ 17 | public boolean queryUsernameIsExist(String username); 18 | 19 | /** 20 | * 创建用户 21 | * 22 | * @param userBO 23 | * @return 24 | */ 25 | public Users createUser(UserBO userBO); 26 | 27 | /** 28 | * 检索用户名和密码是否匹配,用于登录 29 | * 30 | * @param username 31 | * @param password 32 | * @return 33 | */ 34 | public Users queryUserForLogin(String username, String password); 35 | } 36 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/impl/AddressServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service.impl; 2 | 3 | import com.muxin.enums.YesOrNo; 4 | import com.muxin.mapper.AddressMapper; 5 | import com.muxin.pojo.UserAddress; 6 | import com.muxin.pojo.bo.AddressBO; 7 | import com.muxin.service.AddressService; 8 | import org.n3r.idworker.Sid; 9 | import org.springframework.beans.BeanUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Propagation; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | import java.util.Date; 16 | import java.util.List; 17 | 18 | @Service 19 | public class AddressServiceImpl implements AddressService { 20 | 21 | @Autowired 22 | private AddressMapper addressMapper; 23 | 24 | @Autowired 25 | private Sid sid; 26 | 27 | @Transactional(propagation = Propagation.SUPPORTS) 28 | @Override 29 | public List queryAll(String userId) { 30 | UserAddress ua = new UserAddress(); 31 | ua.setUserId(userId); 32 | 33 | return addressMapper.select(ua); 34 | } 35 | 36 | @Transactional(propagation = Propagation.REQUIRED) 37 | @Override 38 | public void addNewUserAddress(AddressBO addressBO) { 39 | 40 | // 1. 判断当前用户是否存在地址,如果没有,则新增为'默认地址' 41 | Integer isDefault = 0; 42 | List addressList = this.queryAll(addressBO.getUserId()); 43 | if(addressList == null || addressList.isEmpty() || addressList.size() == 0) { 44 | isDefault = 1; 45 | } 46 | 47 | String addressId = sid.nextShort(); 48 | 49 | // 2. 保存到数据库 50 | UserAddress newAddress = new UserAddress(); 51 | BeanUtils.copyProperties(addressBO, newAddress); 52 | 53 | newAddress.setId(addressId); 54 | newAddress.setIsDefault(isDefault); 55 | newAddress.setCreatedTime(new Date()); 56 | newAddress.setUpdatedTime(new Date()); 57 | 58 | addressMapper.insert(newAddress); 59 | } 60 | 61 | @Transactional(propagation = Propagation.SUPPORTS) 62 | @Override 63 | public void updateUserAddress(AddressBO addressBO) { 64 | String addressId = addressBO.getAddressId(); 65 | 66 | UserAddress pendingAddress = new UserAddress(); 67 | BeanUtils.copyProperties(addressBO, pendingAddress); 68 | 69 | pendingAddress.setId(addressId); 70 | pendingAddress.setUpdatedTime(new Date()); 71 | 72 | addressMapper.updateByPrimaryKeySelective(pendingAddress); 73 | } 74 | 75 | @Transactional(propagation = Propagation.REQUIRED) 76 | @Override 77 | public void deleteUserAddress(String userId, String addressId) { 78 | UserAddress address = new UserAddress(); 79 | address.setId(addressId); 80 | address.setUserId(userId); 81 | 82 | addressMapper.delete(address); 83 | } 84 | 85 | @Transactional(propagation = Propagation.REQUIRED) 86 | @Override 87 | public void updateUserAddressToBeDefault(String userId, String addressId) { 88 | 89 | // 1. 查找默认地址,设置为不默认 90 | UserAddress queryAddress = new UserAddress(); 91 | queryAddress.setUserId(userId); 92 | queryAddress.setIsDefault(YesOrNo.YES.type); 93 | List list = addressMapper.select(queryAddress); 94 | for (UserAddress ua : list) { 95 | ua.setIsDefault(YesOrNo.NO.type); 96 | addressMapper.updateByPrimaryKeySelective(ua); 97 | } 98 | 99 | // 2. 根据地址id修改为默认的地址 100 | UserAddress defaultAddress = new UserAddress(); 101 | defaultAddress.setId(addressId); 102 | defaultAddress.setUserId(userId); 103 | defaultAddress.setIsDefault(YesOrNo.YES.type); 104 | addressMapper.updateByPrimaryKeySelective(defaultAddress); 105 | } 106 | 107 | @Transactional(propagation = Propagation.SUPPORTS) 108 | @Override 109 | public UserAddress queryUserAddress(String userId, String addressId) { 110 | 111 | UserAddress singleAddress = new UserAddress(); 112 | singleAddress.setId(addressId); 113 | singleAddress.setUserId(userId); 114 | 115 | return addressMapper.selectOne(singleAddress); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/impl/CarouselServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service.impl; 2 | 3 | import com.muxin.mapper.CarouselMapper; 4 | import com.muxin.pojo.Carousel; 5 | import com.muxin.service.CarouselService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Propagation; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import tk.mybatis.mapper.entity.Example; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @program: foodie 16 | * @description: 17 | * @author: Mr.Wang 18 | * @create: 2020-01 22:47 19 | */ 20 | @Service 21 | public class CarouselServiceImpl implements CarouselService { 22 | 23 | @Autowired 24 | private CarouselMapper carouselMapper; 25 | 26 | @Transactional(propagation = Propagation.SUPPORTS) 27 | @Override 28 | public List queryAll(Integer isShow) { 29 | Example example = new Example(Carousel.class); 30 | example.orderBy("sort").desc(); 31 | Example.Criteria criteria = example.createCriteria(); 32 | criteria.andEqualTo("isShow", isShow); 33 | 34 | List result = carouselMapper.selectByExample(example); 35 | 36 | return result; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service.impl; 2 | 3 | import com.muxin.enums.ProductCategory; 4 | import com.muxin.mapper.CategoryMapper; 5 | import com.muxin.mapper.CategoryCustomMapper; 6 | import com.muxin.pojo.Category; 7 | import com.muxin.pojo.vo.CategoryVO; 8 | import com.muxin.pojo.vo.NewItemsVO; 9 | import com.muxin.service.CategoryService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Propagation; 13 | import org.springframework.transaction.annotation.Transactional; 14 | import tk.mybatis.mapper.entity.Example; 15 | 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | /** 21 | * @program: foodie 22 | * @description: 23 | * @author: Mr.Wang 24 | * @create: 2020-02 13:50 25 | */ 26 | @Service 27 | public class CategoryServiceImpl implements CategoryService { 28 | 29 | @Autowired 30 | private CategoryMapper categoryMapper; 31 | 32 | @Autowired 33 | private CategoryCustomMapper categoryCustomMapper; 34 | 35 | 36 | @Transactional(propagation = Propagation.SUPPORTS) 37 | @Override 38 | public List queryAllRootLevelCat() { 39 | Example example = new Example(Category.class); 40 | Example.Criteria criteria = example.createCriteria(); 41 | criteria.andEqualTo("type", ProductCategory.firstLevel.type); 42 | 43 | List result = categoryMapper.selectByExample(example); 44 | 45 | return result; 46 | } 47 | 48 | @Transactional(propagation = Propagation.SUPPORTS) 49 | @Override 50 | public List getSubCatList(Integer rootCatId) { 51 | return categoryCustomMapper.getSubCatList(rootCatId); 52 | } 53 | 54 | @Transactional(propagation = Propagation.SUPPORTS) 55 | @Override 56 | public List getSixNewItemsLazy(Integer rootCatId) { 57 | 58 | Map map = new HashMap<>(); 59 | map.put("rootCatId", rootCatId); 60 | 61 | 62 | return categoryCustomMapper.getSixNewItemsLazy(map); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service.impl; 2 | 3 | import com.muxin.enums.OrderStatusEnum; 4 | import com.muxin.enums.YesOrNo; 5 | import com.muxin.mapper.OrderItemsMapper; 6 | import com.muxin.mapper.OrderStatusMapper; 7 | import com.muxin.mapper.OrdersMapper; 8 | import com.muxin.pojo.*; 9 | import com.muxin.pojo.bo.SubmitOrderBO; 10 | import com.muxin.service.AddressService; 11 | import com.muxin.service.ItemService; 12 | import com.muxin.service.OrderService; 13 | import org.n3r.idworker.Sid; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | import org.springframework.transaction.annotation.Propagation; 17 | import org.springframework.transaction.annotation.Transactional; 18 | 19 | import java.util.Date; 20 | 21 | @Service 22 | public class OrderServiceImpl implements OrderService { 23 | 24 | @Autowired 25 | private OrdersMapper ordersMapper; 26 | 27 | @Autowired 28 | private OrderItemsMapper orderItemsMapper; 29 | 30 | @Autowired 31 | private OrderStatusMapper orderStatusMapper; 32 | 33 | @Autowired 34 | private AddressService addressService; 35 | 36 | @Autowired 37 | private ItemService itemService; 38 | 39 | @Autowired 40 | private Sid sid; 41 | 42 | @Transactional(propagation = Propagation.REQUIRED) 43 | @Override 44 | public String createOrder(SubmitOrderBO submitOrderBO) { 45 | String userId = submitOrderBO.getUserId(); 46 | String addressId = submitOrderBO.getAddressId(); 47 | String itemSpecIds = submitOrderBO.getItemSpecIds(); 48 | Integer payMethod = submitOrderBO.getPayMethod(); 49 | String leftMsg = submitOrderBO.getLeftMsg(); 50 | // 包邮费用设置为0 51 | Integer postAmount = 0; 52 | 53 | String orderId = sid.nextShort(); 54 | 55 | UserAddress address = addressService.queryUserAddress(userId, addressId); 56 | 57 | // 1. 新订单数据保存 58 | Orders newOrder = new Orders(); 59 | newOrder.setId(orderId); 60 | newOrder.setUserId(userId); 61 | 62 | newOrder.setReceiverName(address.getReceiver()); 63 | newOrder.setReceiverMobile(address.getMobile()); 64 | newOrder.setReceiverAddress(address.getProvince() + " " + 65 | address.getCity() + " " + 66 | address.getDistrict() + " " + 67 | address.getDetail()); 68 | 69 | // newOrder.setTotalAmount(); 70 | // newOrder.setRealPayAmount(); 71 | newOrder.setPostAmount(postAmount); 72 | 73 | newOrder.setPayMethod(payMethod); 74 | newOrder.setLeftMsg(leftMsg); 75 | 76 | newOrder.setIsComment(YesOrNo.NO.type); 77 | newOrder.setIsDelete(YesOrNo.NO.type); 78 | newOrder.setCreatedTime(new Date()); 79 | newOrder.setUpdatedTime(new Date()); 80 | 81 | // 2. 循环根据itemSpecIds保存订单商品信息表 82 | String itemSpecIdArr[] = itemSpecIds.split(","); 83 | Integer totalAmount = 0; // 商品原价累计 84 | Integer realPayAmount = 0; // 优惠后实际支付价格累计 85 | for (String itemSpecId : itemSpecIdArr) { 86 | 87 | // TODO 整合redis后,商品购买的数量重新从redis的购物车中获取 88 | int buyCounts = 1; 89 | 90 | // 2.1 根据规格id,查询规格的具体信息,主要获取价格 91 | ItemsSpec itemSpec = itemService.queryItemSpecById(itemSpecId); 92 | totalAmount += itemSpec.getPriceNormal() * buyCounts; 93 | realPayAmount += itemSpec.getPriceDiscount() * buyCounts; 94 | 95 | // 2.2 根据规格id,获得商品信息以及商品图片 96 | String itemId = itemSpec.getItemId(); 97 | Items item = itemService.queryItemById(itemId); 98 | String imgUrl = itemService.queryItemMainImgById(itemId); 99 | 100 | // 2.3 循环保存订单数据到数据库 101 | String subOrderId = sid.nextShort(); 102 | OrderItems subOrderItem = new OrderItems(); 103 | subOrderItem.setId(subOrderId); 104 | subOrderItem.setOrderId(orderId); 105 | subOrderItem.setItemId(itemId); 106 | subOrderItem.setItemName(item.getItemName()); 107 | subOrderItem.setItemImg(imgUrl); 108 | subOrderItem.setBuyCounts(buyCounts); 109 | subOrderItem.setItemSpecId(itemSpecId); 110 | subOrderItem.setItemSpecName(itemSpec.getName()); 111 | subOrderItem.setPrice(itemSpec.getPriceDiscount()); 112 | orderItemsMapper.insert(subOrderItem); 113 | 114 | // 2.4 在用户提交订单以后,规格表中扣除库存 115 | itemService.decreaseItemSpecStock(itemSpecId, buyCounts); 116 | 117 | } 118 | 119 | newOrder.setTotalAmount(totalAmount); 120 | newOrder.setRealPayAmount(realPayAmount); 121 | ordersMapper.insert(newOrder); 122 | 123 | // 3. 保存订单状态表 124 | OrderStatus waitPayOrderStatus = new OrderStatus(); 125 | waitPayOrderStatus.setOrderId(orderId); 126 | waitPayOrderStatus.setOrderStatus(OrderStatusEnum.WAIT_PAY.type); 127 | waitPayOrderStatus.setCreatedTime(new Date()); 128 | orderStatusMapper.insert(waitPayOrderStatus); 129 | 130 | return orderId; 131 | 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /foodie-service/src/main/java/com/muxin/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.muxin.service.impl; 2 | 3 | import com.muxin.enums.Sex; 4 | import com.muxin.pojo.bo.UserBO; 5 | import com.muxin.mapper.UsersMapper; 6 | import com.muxin.pojo.Users; 7 | import com.muxin.service.UserService; 8 | import com.muxin.utils.DateUtil; 9 | import com.muxin.utils.MD5Utils; 10 | import org.n3r.idworker.Sid; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.transaction.annotation.Propagation; 14 | import org.springframework.transaction.annotation.Transactional; 15 | import tk.mybatis.mapper.entity.Example; 16 | 17 | import java.util.Date; 18 | 19 | /** 20 | * @program: foodie 21 | * @description: 22 | * @author: Mr.Wang 23 | * @create: 2019-23 19:57 24 | */ 25 | @Service 26 | public class UserServiceImpl implements UserService { 27 | 28 | @Autowired 29 | public UsersMapper usersMapper; 30 | 31 | @Autowired 32 | private Sid sid; 33 | 34 | private static final String USER_FACE = "https://www.google.com/imgres?imgurl=http%3A%2F%2Fpic.616pic.com%2Fys_bnew_img%2F00%2F06%2F27%2FTWk2P5YJ5k.jpg&imgrefurl=http%3A%2F%2F616pic.com%2Fsucai%2Fz7ri3e251.html&docid=1YZPM1bINDX5SM&tbnid=4lLfk3D9CudG2M%3A&vet=10ahUKEwiOhJ_OyNjmAhUTNaYKHe6eDdAQMwhGKAAwAA..i&w=713&h=714&bih=765&biw=1440&q=%E9%BB%98%E8%AE%A4%E5%A4%B4%E5%83%8F&ved=0ahUKEwiOhJ_OyNjmAhUTNaYKHe6eDdAQMwhGKAAwAA&iact=mrc&uact=8"; 35 | 36 | @Transactional(propagation = Propagation.SUPPORTS) 37 | @Override 38 | public boolean queryUsernameIsExist(String username) { 39 | 40 | Example userExample = new Example(Users.class); 41 | Example.Criteria userCriteria = userExample.createCriteria(); 42 | 43 | userCriteria.andEqualTo("username", username); 44 | 45 | Users result = usersMapper.selectOneByExample(userExample); 46 | 47 | return result == null ? false : true; 48 | } 49 | 50 | 51 | @Transactional(propagation = Propagation.REQUIRED) 52 | @Override 53 | public Users createUser(UserBO userBO) { 54 | 55 | // try { 56 | // Thread.sleep(3500); 57 | // } catch (InterruptedException e) { 58 | // e.printStackTrace(); 59 | // } 60 | 61 | String userId = sid.nextShort(); 62 | 63 | Users user = new Users(); 64 | user.setId(userId); 65 | user.setUsername(userBO.getUsername()); 66 | try { 67 | user.setPassword(MD5Utils.getMD5Str(userBO.getPassword())); 68 | } catch (Exception e) { 69 | e.printStackTrace(); 70 | } 71 | // 默认用户昵称同用户名 72 | user.setNickname(userBO.getUsername()); 73 | // 默认头像 74 | user.setFace(USER_FACE); 75 | // 设置默认生日 76 | user.setBirthday(DateUtil.stringToDate("1900-01-01")); 77 | // 默认性别为保密 78 | user.setSex(Sex.secret.type); 79 | 80 | user.setCreatedTime(new Date()); 81 | user.setUpdatedTime(new Date()); 82 | 83 | 84 | usersMapper.insert(user); 85 | 86 | return user; 87 | } 88 | 89 | @Transactional(propagation = Propagation.SUPPORTS) 90 | @Override 91 | public Users queryUserForLogin(String username, String password) { 92 | 93 | // try { 94 | // Thread.sleep(2500); 95 | // } catch (InterruptedException e) { 96 | // e.printStackTrace(); 97 | // } 98 | 99 | Example userExample = new Example(Users.class); 100 | Example.Criteria userCriteria = userExample.createCriteria(); 101 | 102 | userCriteria.andEqualTo("username", username); 103 | userCriteria.andEqualTo("password", password); 104 | 105 | Users result = usersMapper.selectOneByExample(userExample); 106 | return result; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.muxin 8 | foodie 9 | 1.0-SNAPSHOT 10 | 11 | 12 | foodie-common 13 | foodie-pojo 14 | foodie-mapper 15 | foodie-service 16 | foodie-api 17 | 18 | 19 | 25 | 26 | 27 | pom 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-parent 32 | 2.1.5.RELEASE 33 | 34 | 35 | 36 | 37 | 38 | 39 | UTF-8 40 | UTF-8 41 | 1.8 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter 49 | 50 | 51 | spring-boot-starter-logging 52 | org.springframework.boot 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-web 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-aop 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-configuration-processor 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | mysql 81 | mysql-connector-java 82 | 8.0.11 83 | 84 | 85 | 86 | org.mybatis.spring.boot 87 | mybatis-spring-boot-starter 88 | 2.1.0 89 | 90 | 91 | 92 | 93 | tk.mybatis 94 | mapper-spring-boot-starter 95 | 2.1.5 96 | 97 | 98 | 99 | 100 | com.github.pagehelper 101 | pagehelper-spring-boot-starter 102 | 1.2.12 103 | 104 | 105 | 106 | 107 | commons-codec 108 | commons-codec 109 | 1.11 110 | 111 | 112 | org.apache.commons 113 | commons-lang3 114 | 3.4 115 | 116 | 117 | org.apache.commons 118 | commons-io 119 | 1.3.2 120 | 121 | 122 | 123 | 124 | io.springfox 125 | springfox-swagger2 126 | 2.4.0 127 | 128 | 129 | io.springfox 130 | springfox-swagger-ui 131 | 2.4.0 132 | 133 | 134 | com.github.xiaoymin 135 | swagger-bootstrap-ui 136 | 1.6 137 | 138 | 139 | 140 | 141 | org.slf4j 142 | slf4j-api 143 | 1.7.21 144 | 145 | 146 | org.slf4j 147 | slf4j-log4j12 148 | 1.7.21 149 | 150 | 151 | 152 | 153 | 154 | --------------------------------------------------------------------------------