├── .gitattributes ├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── shopping │ └── mall │ ├── SpringBootMybatisMallApplication.java │ ├── Swagger.java │ ├── conf │ ├── WebMallInterceptor.java │ └── WebMvcConfig.java │ ├── controller │ ├── AlipayController.java │ ├── EvaluationController.java │ ├── ProductsController.java │ ├── ShoppingCarController.java │ ├── ShoppingRecordController.java │ ├── UserDetailController.java │ └── UserMainController.java │ ├── core │ ├── AbstractService.java │ ├── CommonException.java │ ├── Mapper.java │ ├── Service.java │ └── ServiceException.java │ ├── domain │ ├── Evaluation.java │ ├── PayDTO.java │ ├── Products.java │ ├── ShoppingCar.java │ ├── ShoppingRecord.java │ ├── UserDetail.java │ ├── UserDto.java │ └── UserMain.java │ ├── mapper │ ├── EvaluationMapper.java │ ├── ProductsMapper.java │ ├── ShoppingCarMapper.java │ ├── ShoppingRecordMapper.java │ ├── UserDetailMapper.java │ └── UserMainMapper.java │ └── service │ ├── EvaluationService.java │ ├── ProductsService.java │ ├── ShoppingCarService.java │ ├── ShoppingRecordService.java │ ├── UserDetailService.java │ ├── UserMainService.java │ └── imp │ ├── EvaluationServiceImpl.java │ ├── ProductsServiceImpl.java │ ├── ShoppingCarServiceImpl.java │ ├── ShoppingRecordServiceImpl.java │ ├── UserDetailServiceImpl.java │ └── UserMainServiceImpl.java └── resources ├── META-INF └── resources │ └── WEB-INF │ └── views │ ├── amend_info.jsp │ ├── control.jsp │ ├── include │ ├── foot.jsp │ └── header.jsp │ ├── login.jsp │ ├── main.jsp │ ├── product_detail.jsp │ ├── register.jsp │ ├── search.jsp │ ├── shopping_car.jsp │ ├── shopping_handle.jsp │ └── shopping_record.jsp ├── application-default.yml ├── banner.txt ├── db └── shopping.sql ├── mapper ├── EvaluationMapper.xml ├── ProductsMapper.xml ├── ShoppingCarMapper.xml ├── ShoppingRecordMapper.xml ├── UserDetailMapper.xml └── UserMainMapper.xml └── static ├── css ├── bootstrap-theme.css ├── bootstrap-theme.css.map ├── bootstrap-theme.min.css ├── bootstrap.css ├── bootstrap.css.map ├── bootstrap.min.css └── style.css ├── img ├── 37.jpg ├── 39.jpg ├── 40.jpg ├── 41.jpg ├── 42.jpg ├── 43.jpg ├── 44.jpg ├── 45.jpg ├── 46.jpg ├── 47.jpg ├── 48.jpg ├── 49.jpg ├── 50.jpg ├── 51.jpg ├── 52.jpg ├── 53.jpg └── 54.jpg └── js ├── ajaxfileupload.js ├── bootstrap.js ├── bootstrap.min.js ├── html5shiv.min.js ├── jquery.min.js ├── layer.js ├── mobile ├── layer.js └── need │ └── layer.css ├── npm.js ├── respond.min.js └── skin ├── default ├── icon-ext.png ├── icon.png ├── layer.css ├── loading-0.gif ├── loading-1.gif └── loading-2.gif ├── family └── style.css └── lists └── style.css /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=java 2 | *.css linguist-language=java 3 | *.html linguist-language=java 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Maven # 2 | target/ 3 | 4 | # IDEA # 5 | .idea/ 6 | *.iml 7 | 8 | # Eclipse # 9 | .settings/ 10 | .classpath 11 | .project 12 | 13 | # jrebel # 14 | src/main/resources/rebel.xml 15 | /src/main/resources/rebel.xml 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpringBoot-Mybatis-Mall 2 | spring-boot整合mybatis的校园电商项目 3 | 4 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | springboot-mybatis-mall 8 | springboot-mybatis-mall 9 | 1.0.0-SNAPSHOT 10 | 11 | 12 | org.springframework.boot 13 | spring-boot-starter-parent 14 | 1.5.6.RELEASE 15 | 16 | 17 | 18 | 1.8 19 | com.shopping.mall.SpringBootMybatisMallApplication 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-tomcat 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-jdbc 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | 41 | 42 | 43 | com.alibaba 44 | fastjson 45 | 1.2.44 46 | 47 | 48 | 49 | mysql 50 | mysql-connector-java 51 | 52 | 53 | 54 | org.mybatis.spring.boot 55 | mybatis-spring-boot-starter 56 | 1.3.1 57 | 58 | 59 | tk.mybatis 60 | mapper-spring-boot-starter 61 | 1.1.4 62 | 63 | 64 | com.github.pagehelper 65 | pagehelper-spring-boot-starter 66 | 1.2.3 67 | 68 | jdbc连接池补充<--> 69 | 70 | com.zaxxer 71 | HikariCP 72 | 73 | swagger<--> 74 | 75 | io.springfox 76 | springfox-swagger2 77 | 2.7.0 78 | 79 | 80 | io.springfox 81 | springfox-swagger-ui 82 | 2.7.0 83 | 84 | 85 | javax.servlet 86 | jstl 87 | 88 | 89 | 90 | org.springframework.boot 91 | spring-boot-starter-tomcat 92 | provided 93 | 94 | 95 | org.apache.tomcat.embed 96 | tomcat-embed-jasper 97 | 98 | 99 | 100 | org.springframework.boot 101 | spring-boot-starter-actuator 102 | 1.5.12.RELEASE 103 | 104 | 105 | 106 | com.alipay.sdk 107 | alipay-sdk-java 108 | 3.0.0 109 | 110 | 111 | 112 | 113 | 114 | 115 | org.springframework.boot 116 | spring-boot-maven-plugin 117 | 1.4.2.RELEASE 118 | 119 | 120 | org.springframework 121 | springloaded 122 | 1.2.5.RELEASE 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/SpringBootMybatisMallApplication.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @MapperScan(basePackages = "com.shopping.mall.mapper") 9 | public class SpringBootMybatisMallApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringBootMybatisMallApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/Swagger.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall; 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.spi.DocumentationType; 10 | import springfox.documentation.spring.web.plugins.Docket; 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 12 | 13 | 14 | @Configuration 15 | @EnableSwagger2 16 | public class Swagger { 17 | @Bean 18 | public Docket createResApi() { 19 | return new Docket(DocumentationType.SWAGGER_2) 20 | .apiInfo(apiInfo()) 21 | .select() 22 | .apis(RequestHandlerSelectors.basePackage("com.shopping.mall")) 23 | .paths(PathSelectors.any()) 24 | .build(); 25 | } 26 | 27 | private ApiInfo apiInfo() { 28 | return new ApiInfoBuilder() 29 | .title("校园商城项目API列表") 30 | .description("作者:陈钦锋") 31 | .build(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/conf/WebMallInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.conf; 2 | 3 | import com.shopping.mall.domain.UserMain; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.servlet.HandlerInterceptor; 8 | import org.springframework.web.servlet.ModelAndView; 9 | 10 | import javax.servlet.annotation.WebFilter; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | 15 | @Component 16 | @WebFilter(filterName = "mallFilter") 17 | public class WebMallInterceptor implements HandlerInterceptor { 18 | 19 | private Logger logger = LoggerFactory.getLogger(WebMallInterceptor.class); 20 | private static final String CURRENT_USER = "currentUser"; 21 | 22 | //在请求处理之前进行调用(Controller方法调用之前 23 | @Override 24 | public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { 25 | logger.info("拦截器启用"); 26 | HttpSession session = httpServletRequest.getSession(); 27 | if (session.getAttribute(CURRENT_USER) == null || "".equals(session.getAttribute(CURRENT_USER))) { 28 | return false; 29 | } else { 30 | UserMain userMain = (UserMain) session.getAttribute(CURRENT_USER); 31 | return userMain.getRole() == 1; 32 | } 33 | } 34 | 35 | //请求处理之后进行调用,但是在视图被渲染之前(Controller方法调用之后) 36 | @Override 37 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { 38 | logger.info("postHandle被调用"); 39 | } 40 | 41 | //在整个请求结束之后被调用,也就是在DispatcherServlet 渲染了对应的视图之后执行(主要是用于进行资源清理工作) 42 | @Override 43 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 44 | logger.info("afterCompletion被调用"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/conf/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.conf; 2 | 3 | import com.alibaba.fastjson.serializer.SerializerFeature; 4 | import com.alibaba.fastjson.support.config.FastJsonConfig; 5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.converter.HttpMessageConverter; 8 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 9 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 10 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 12 | 13 | import java.nio.charset.Charset; 14 | import java.util.List; 15 | 16 | @Configuration 17 | public class WebMvcConfig extends WebMvcConfigurerAdapter { 18 | 19 | @Override 20 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 21 | //静态资源映射 22 | registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); 23 | } 24 | 25 | @Override 26 | public void addViewControllers(ViewControllerRegistry registry) { 27 | //页面与api之间的关联 28 | registry.addViewController("/").setViewName("main"); 29 | registry.addViewController("/register").setViewName("register"); 30 | registry.addViewController("/amend_info").setViewName("amend_info"); 31 | registry.addViewController("/login").setViewName("login"); 32 | registry.addViewController("/main").setViewName("main"); 33 | registry.addViewController("/control").setViewName("control"); 34 | registry.addViewController("/product_detail").setViewName("product_detail"); 35 | registry.addViewController("/search").setViewName("search"); 36 | registry.addViewController("/shopping_car").setViewName("shopping_car"); 37 | registry.addViewController("/shopping_record").setViewName("shopping_record"); 38 | registry.addViewController("/shopping_handle").setViewName("shopping_handle"); 39 | } 40 | 41 | //使用阿里 FastJson 作为JSON MessageConverter 42 | @Override 43 | public void configureMessageConverters(List> converters) { 44 | FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); 45 | FastJsonConfig config = new FastJsonConfig(); 46 | //保留空的字段 47 | config.setSerializerFeatures(SerializerFeature.WriteMapNullValue, 48 | //String null -> "" 49 | SerializerFeature.WriteNullStringAsEmpty, 50 | //Number null -> 0 51 | SerializerFeature.WriteNullNumberAsZero); 52 | converter.setFastJsonConfig(config); 53 | converter.setDefaultCharset(Charset.forName("UTF-8")); 54 | converters.add(converter); 55 | } 56 | 57 | //增加拦截器 58 | @Override 59 | public void addInterceptors(InterceptorRegistry registry) { 60 | registry.addInterceptor(new WebMallInterceptor()) 61 | .addPathPatterns("/control**"); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/AlipayController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alipay.api.AlipayApiException; 5 | import com.alipay.api.AlipayClient; 6 | import com.alipay.api.DefaultAlipayClient; 7 | import com.alipay.api.domain.AlipayTradePagePayModel; 8 | import com.alipay.api.request.AlipayTradePagePayRequest; 9 | import com.shopping.mall.domain.PayDTO; 10 | import com.shopping.mall.domain.Products; 11 | import com.shopping.mall.domain.ShoppingRecord; 12 | import com.shopping.mall.service.ProductsService; 13 | import com.shopping.mall.service.ShoppingRecordService; 14 | import io.swagger.annotations.ApiOperation; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | import javax.servlet.http.HttpServletResponse; 23 | import java.io.IOException; 24 | import java.io.UnsupportedEncodingException; 25 | import java.math.BigDecimal; 26 | import java.util.*; 27 | 28 | 29 | @Controller 30 | @RequestMapping("/pay/alipay") 31 | public class AlipayController { 32 | 33 | private static String APP_ID = "2016091400513177"; 34 | private static String APP_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC6AF0sFpWtP/YpiIVSfckpSCkvaj4aK0HW3kgIJbTWoqeuFIxGxXqem5qZ1xwHnzAEdL8lmYaJmI4faMUXQi4FiCs1yoRs43HxKgVFEV7NSwc2911e148zlSh4OLvmk3BxS4kU2uohvyhbWBFgnNERwgXwbrvEbV6KctDbJR7ZPwG6zBDRcnN54ukliu4a51MZevDP5E6+whaYhVYMuuX2nVZrrJsJzduB8jjkiNn2/FIgudn6pI9AOkmqoXCc2kSc6Hf2OxjcdXwmwdEhkT0BS/Shv2qkPKLRAqZGoCABKPAX8FeI8OziI1LGOa0aMTnvRmjh+v0+lv1yRc4lu6GjAgMBAAECggEBAI0el5JKtFcVDzQl01lp/ASpLi4+Qk3igfp+/VHJIfIyyFvIVUGgtM6/qkWMMkUKHwlSdnAVkkC1ESd9ewORf49M59PRCjX/PsTFp+fmLPI/OYMXnKzHiWuOgHzuNonTVV1v/Npo2XivKvRa1hxh/jGl7pGjwixe+nq6cAHEoSobWUMde9HEDjqrddDSRPslxnLOivHOlsgnhG+N4vMGdX3XwzCIHAcmL/xRCsfLsV5XTZB0saETFPyjukOlsZ0IbWWDlr/KI4BqJ4mQtl2bbSVynzOhceVsPPIpCTJH0jqaxcsQonQlsmp4fEEwHCMiM/fqmn1fpUmTDP0wnvxwDpECgYEA9cJhKQWg1O85RlqHQ7K/51w3NCieJjWf/OLEXz/0JgHvGwk7qDdz5fJgW/0PWstX2RFBhhnlpYGF9/fwSKsTiJusjYOZ+iKihLLLfxcGZG9+BhSH+YPSIjF16AQCTBR2SFpLZ+/JOEznahl266l53LGTRWQ21gLIbfvR1Fp8PTkCgYEAwcCFejFw5jCd1+IVm/kwatsdo56XRTGUvqR9NklrhT7hOlkhkiQyRMC3qbFTPLvYD8Oa74I3GD9x1OQH0Itl0P7i6sZ747nh6w03jCaiP03HNv7E4SDWZz0tUuQsAw/x1KmZUCOrkQQeRoDSRtj6LRNyspg2pysKoreJmpJbMbsCgYBp8mNqiOeeBId/gfWAROYgOov962jKdiHDposbuPlrDThkQmW6jjVjs0rBPWZKMRFtHdhOlImBAUac8QFggogIQ3xvAYX25MmFRYMfBfEWiU4eFunLsn17ijEXVesbm1KmvG53n1Ly94xoHBQ9YjGL5+3iY2KUflyjtYTu9BdNWQKBgBwCOsl5UDrWmFrXAgy0Lz2jQ1ud13xXOIt+t+MbJgHzHxgSPnoj5Whu+536VnAXL5rHyiQJjPFiapA+DqslG6jkz+TkoJBBFNmn5XnLM/U2xy+6ELgCyTvPajfraDlhGrKFefZN0cV69O14Pe2j/DZ78z7CJlRwMm9nXOsNcUV1AoGBAMdgArU/N2MFmyneN/JmWrEXp58c6whCqzVRMGIeTPY26eoOJThy+2GmuLNhNBqEkw001k+ylGvAcVhXSInChcikI3A5lnoGowLHjyWIgcJeQszmjwQKQHcfIHXzmb5KqFL2cZ5+niyEW4zVFx50Q3mGUjhsVx7yAs6toXnAWXfR"; 35 | private static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAugBdLBaVrT/2KYiFUn3JKUgpL2o+GitB1t5ICCW01qKnrhSMRsV6npuamdccB58wBHS/JZmGiZiOH2jFF0IuBYgrNcqEbONx8SoFRRFezUsHNvddXtePM5UoeDi75pNwcUuJFNrqIb8oW1gRYJzREcIF8G67xG1einLQ2yUe2T8BuswQ0XJzeeLpJYruGudTGXrwz+ROvsIWmIVWDLrl9p1Wa6ybCc3bgfI45IjZ9vxSILnZ+qSPQDpJqqFwnNpEnOh39jsY3HV8JsHRIZE9AUv0ob9qpDyi0QKmRqAgASjwF/BXiPDs4iNSxjmtGjE570Zo4fr9Ppb9ckXOJbuhowIDAQAB"; 36 | 37 | private static Logger logger = LoggerFactory.getLogger(AlipayController.class); 38 | 39 | @Autowired 40 | private ProductsService productsService; 41 | @Autowired 42 | private ShoppingRecordService shoppingRecordService; 43 | 44 | /** 45 | * 支付请求 46 | */ 47 | @ApiOperation("支付宝支付") 48 | @GetMapping 49 | public void app(@RequestParam String jsonData, HttpServletResponse httpResponse) throws AlipayApiException, IOException { 50 | PayDTO payDTO = JSON.parseObject(jsonData, PayDTO.class); 51 | List productsIds = payDTO.getProductsIds(); 52 | List productsCounts = payDTO.getProductsCounts(); 53 | Integer totalPrice = 0; 54 | StringBuilder name = new StringBuilder(); 55 | for (int i = 0; i < productsIds.size(); i++) { 56 | Products product = productsService.findById(productsIds.get(i)); 57 | totalPrice += product.getPrice() * productsCounts.get(i); 58 | name.append(product.getName()).append("*").append(productsCounts.get(i)).append(";"); 59 | } 60 | BigDecimal price = new BigDecimal(totalPrice); 61 | Double result = price.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); 62 | //初始化客户端 只需要实例化一次(线程安全) 63 | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipaydev.com/gateway.do" 64 | , APP_ID, APP_PRIVATE_KEY, "json", "UTF-8", ALIPAY_PUBLIC_KEY, "RSA2"); 65 | AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest(); 66 | AlipayTradePagePayModel model = new AlipayTradePagePayModel(); 67 | model.setBody("校园购物平台价格清单"); 68 | model.setSubject(name.toString()); 69 | model.setOutTradeNo(UUID.randomUUID().toString()); 70 | model.setPassbackParams(JSON.toJSONString(payDTO)); 71 | model.setTimeoutExpress("30m"); 72 | model.setTotalAmount(result.toString()); 73 | model.setProductCode("FAST_INSTANT_TRADE_PAY"); 74 | alipayRequest.setBizModel(model); 75 | alipayRequest.setReturnUrl("http://39.104.86.85:8086/shopping_record"); 76 | alipayRequest.setNotifyUrl("http://39.104.86.85:8086/pay/alipay/notify"); 77 | String form = alipayClient.pageExecute(alipayRequest).getBody(); //调用SDK生成表单 78 | httpResponse.setContentType("text/html;charset=utf-8"); 79 | httpResponse.getWriter().write(form);//直接将完整的表单html输出到页面 80 | httpResponse.getWriter().flush(); 81 | } 82 | 83 | @ApiOperation("通知") 84 | @PostMapping("/notify") 85 | public void notify(HttpServletRequest request) throws UnsupportedEncodingException { 86 | //获取支付宝POST过来反馈信息 87 | Map params = new HashMap(); 88 | Map requestParams = request.getParameterMap(); 89 | for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext(); ) { 90 | String name = (String) iter.next(); 91 | String[] values = (String[]) requestParams.get(name); 92 | String valueStr = ""; 93 | for (int i = 0; i < values.length; i++) { 94 | valueStr = (i == values.length - 1) ? valueStr + values[i] 95 | : valueStr + values[i] + ","; 96 | } 97 | //乱码解决,这段代码在出现乱码时使用。 98 | valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8"); 99 | params.put(name, valueStr); 100 | } 101 | String jsonData = params.get("passback_params"); 102 | PayDTO payDTO = JSON.parseObject(jsonData, PayDTO.class); 103 | List productsIds = payDTO.getProductsIds(); 104 | List productsCounts = payDTO.getProductsCounts(); 105 | for (int i = 0; i < productsIds.size(); i++) { 106 | ShoppingRecord shoppingRecord = new ShoppingRecord(); 107 | shoppingRecord.setUserId(payDTO.getUserId()); 108 | shoppingRecord.setProductId(productsIds.get(i)); 109 | shoppingRecord.setCounts(productsCounts.get(i)); 110 | shoppingRecordService.addShoppingRecord(shoppingRecord); 111 | } 112 | // try { 113 | // boolean flag = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, "UTF-8", "RSA2"); 114 | // if (flag) { 115 | // 116 | // logger.info("付款成功"); 117 | // } 118 | // } catch (AlipayApiException e) { 119 | // logger.info("错误日志", e); 120 | // } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/EvaluationController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | import com.shopping.mall.core.CommonException; 4 | import com.shopping.mall.domain.Evaluation; 5 | import com.shopping.mall.service.EvaluationService; 6 | import io.swagger.annotations.ApiOperation; 7 | import io.swagger.annotations.ApiParam; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.*; 14 | 15 | 16 | @Controller 17 | @RequestMapping(value = "/mall/evaluation") 18 | public class EvaluationController { 19 | 20 | private EvaluationService evaluationService; 21 | 22 | public EvaluationController(EvaluationService evaluationService) { 23 | this.evaluationService = evaluationService; 24 | } 25 | 26 | @ApiOperation("添加评价信息") 27 | @PutMapping 28 | public ResponseEntity addEvaluation(@ApiParam(value = "评价信息", required = true) 29 | @RequestBody Evaluation evaluation) { 30 | 31 | return Optional.ofNullable(evaluationService.addEvaluation(evaluation)) 32 | .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED)) 33 | .orElseThrow(() -> new CommonException("error.evaluation.create")); 34 | } 35 | 36 | @ApiOperation("根据产品编号获取评价信息") 37 | @GetMapping(value = "/query_evaluations/{productId}") 38 | public ResponseEntity> getShoppingEvaluations(@ApiParam(value = "评价信息", required = true) 39 | @PathVariable int productId) { 40 | return Optional.ofNullable(evaluationService.getProductEvaluation(productId)) 41 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 42 | .orElseThrow(() -> new CommonException("error.query_evaluations")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/ProductsController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | import com.shopping.mall.core.CommonException; 4 | import com.shopping.mall.domain.Products; 5 | import com.shopping.mall.service.ProductsService; 6 | import io.swagger.annotations.ApiOperation; 7 | import io.swagger.annotations.ApiParam; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | import org.springframework.web.multipart.MultipartFile; 15 | import tk.mybatis.mapper.entity.Condition; 16 | 17 | import javax.servlet.http.HttpSession; 18 | import java.io.File; 19 | import java.nio.file.Files; 20 | import java.nio.file.Path; 21 | import java.nio.file.Paths; 22 | import java.util.List; 23 | import java.util.Optional; 24 | 25 | @Controller 26 | @RequestMapping(value = "/mall/product") 27 | public class ProductsController { 28 | 29 | private ProductsService productsService; 30 | 31 | private static final String WIN = "win"; 32 | 33 | public ProductsController(ProductsService productsService) { 34 | this.productsService = productsService; 35 | } 36 | 37 | private Logger logger = LoggerFactory.getLogger(ProductsController.class); 38 | 39 | @ApiOperation("获取所有产品") 40 | @GetMapping(value = "/query_products") 41 | public ResponseEntity> queryAllProducts() { 42 | return Optional.ofNullable(productsService.queryAll()) 43 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 44 | .orElseThrow(() -> new CommonException("error.queryAllProducts")); 45 | } 46 | 47 | @ApiOperation("根据id删除产品") 48 | @DeleteMapping(value = "/{id}") 49 | public ResponseEntity deleteProduct(@ApiParam(value = "商品id", required = true) 50 | @PathVariable int id) { 51 | return Optional.ofNullable(productsService.deleteProduct(id)) 52 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 53 | .orElseThrow(() -> new CommonException("error.deleteProduct")); 54 | } 55 | 56 | @ApiOperation("添加产品") 57 | @PutMapping 58 | public ResponseEntity addProduct(@ApiParam(value = "产品信息", required = true) 59 | @RequestBody Products product) { 60 | return Optional.ofNullable(productsService.addProduct(product)) 61 | .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED)) 62 | .orElseThrow(() -> new CommonException("error.addProduct")); 63 | } 64 | 65 | @ApiOperation("根据id查询产品详情") 66 | @GetMapping(value = "/{id}") 67 | public ResponseEntity queryProduct(@ApiParam(value = "产品信息", required = true) 68 | @PathVariable int id, 69 | HttpSession httpSession) { 70 | Products product = productsService.findById(id); 71 | httpSession.setAttribute("productDetail", product); 72 | return Optional.ofNullable(product) 73 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 74 | .orElseThrow(() -> new CommonException("error.queryProduct")); 75 | } 76 | 77 | @ApiOperation("保存关键字到session") 78 | @GetMapping(value = "/search") 79 | public ResponseEntity searchPre(@ApiParam(value = "查询关键字", required = true) 80 | @RequestParam String searchKeyWord, 81 | HttpSession httpSession) { 82 | httpSession.setAttribute("searchKeyWord", searchKeyWord); 83 | return Optional.of(true) 84 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 85 | .orElseThrow(() -> new CommonException("error.searchPre")); 86 | } 87 | 88 | @ApiOperation("根据关键字查询产品详情") 89 | @GetMapping(value = "/search_by_key_word") 90 | public ResponseEntity> searchProduct(@ApiParam(value = "查询关键字", required = true) 91 | @RequestParam String searchKeyWord) { 92 | Condition condition = new Condition(Products.class); 93 | condition.createCriteria().andCondition("name like ", searchKeyWord).orCondition("key_word like ", searchKeyWord); 94 | return Optional.ofNullable(productsService.findByCondition(condition)) 95 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 96 | .orElseThrow(() -> new CommonException("error.searchProduct")); 97 | } 98 | 99 | @ApiOperation("上传商品图片") 100 | @PostMapping(value = "/upload") 101 | public ResponseEntity uploadFile(@ApiParam(value = "图片", required = true) 102 | @RequestParam MultipartFile productImgUpload, 103 | @ApiParam(value = "名称", required = true) 104 | @RequestParam String name) { 105 | try { 106 | if (productImgUpload != null && !productImgUpload.isEmpty()) { 107 | String sep = File.separator; 108 | String filePath = (Thread.currentThread().getContextClassLoader().getResource("").getPath() + "static" + sep + "img" + sep).substring(1); 109 | int id = productsService.findBy("name", name).getId(); 110 | String fileName = String.valueOf(id) + ".jpg"; 111 | byte[] bytes = productImgUpload.getBytes(); 112 | String os = System.getProperty("os.name"); 113 | if (!os.toLowerCase().startsWith(WIN)) { 114 | String sepa = java.io.File.separator; 115 | filePath = sepa + filePath; 116 | } 117 | Path path = Paths.get(filePath + fileName); 118 | //创建文件 119 | if (!Files.exists(path)) { 120 | Files.createFile(path); 121 | } 122 | Files.write(path, bytes); 123 | } 124 | } catch (Exception e) { 125 | logger.info("Exception", e); 126 | } 127 | return Optional.of(true) 128 | .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED)) 129 | .orElseThrow(() -> new CommonException("error.uploadFile")); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/ShoppingCarController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | import com.shopping.mall.core.CommonException; 4 | import com.shopping.mall.domain.ShoppingCar; 5 | import com.shopping.mall.service.ShoppingCarService; 6 | import io.swagger.annotations.ApiOperation; 7 | import io.swagger.annotations.ApiParam; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.*; 12 | import tk.mybatis.mapper.entity.Condition; 13 | 14 | import java.util.List; 15 | import java.util.Optional; 16 | 17 | @Controller 18 | @RequestMapping(value = "/mall/shopping_car") 19 | public class ShoppingCarController { 20 | 21 | 22 | private ShoppingCarService shoppingCarService; 23 | 24 | public ShoppingCarController(ShoppingCarService shoppingCarService) { 25 | this.shoppingCarService = shoppingCarService; 26 | } 27 | 28 | @ApiOperation("添加购物车") 29 | @PutMapping 30 | public ResponseEntity addShoppingCar(@ApiParam(value = "购物车信息", required = true) 31 | @RequestBody ShoppingCar shoppingCar) { 32 | return Optional.ofNullable(shoppingCarService.addShoppingCar(shoppingCar)) 33 | .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED)) 34 | .orElseThrow(() -> new CommonException("error.addShoppingCar")); 35 | } 36 | 37 | @ApiOperation("根据用户id查询购物车") 38 | @GetMapping(value = "/query_shopping_cars/{userId}") 39 | public ResponseEntity> getShoppingCars(@ApiParam(value = "用户id", required = true) 40 | @PathVariable int userId) { 41 | Condition condition = new Condition(ShoppingCar.class); 42 | condition.createCriteria().andCondition("user_id = ", userId); 43 | List shoppingCarList = shoppingCarService.findByCondition(condition); 44 | return Optional.ofNullable(shoppingCarList) 45 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 46 | .orElseThrow(() -> new CommonException("error.getShoppingCars")); 47 | } 48 | 49 | @ApiOperation("根据用户id和产品id删除购物车") 50 | @DeleteMapping(value = "/{userId}/{productId}") 51 | public ResponseEntity deleteShoppingCar(@ApiParam(value = "用户id", required = true) 52 | @PathVariable int userId, 53 | @ApiParam(value = "产品id", required = true) 54 | @PathVariable int productId) { 55 | return Optional.ofNullable(shoppingCarService.deleteShoppingCar(userId, productId)) 56 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 57 | .orElseThrow(() -> new CommonException("error.deleteShoppingCar")); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/ShoppingRecordController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | 4 | import com.shopping.mall.core.CommonException; 5 | import com.shopping.mall.domain.ShoppingCar; 6 | import com.shopping.mall.domain.ShoppingRecord; 7 | import com.shopping.mall.service.ShoppingRecordService; 8 | import io.swagger.annotations.ApiOperation; 9 | import io.swagger.annotations.ApiParam; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | import tk.mybatis.mapper.entity.Condition; 15 | 16 | import java.util.*; 17 | 18 | 19 | @Controller 20 | @RequestMapping(value = "/mall/shopping_record") 21 | public class ShoppingRecordController { 22 | 23 | private ShoppingRecordService shoppingRecordService; 24 | 25 | public ShoppingRecordController(ShoppingRecordService shoppingRecordService) { 26 | this.shoppingRecordService = shoppingRecordService; 27 | } 28 | 29 | @ApiOperation("添加购物记录") 30 | @PutMapping 31 | public ResponseEntity addShoppingRecord(@ApiParam(value = "购物记录信息", required = true) 32 | @RequestBody ShoppingRecord shoppingRecord) { 33 | return Optional.ofNullable(shoppingRecordService.addShoppingRecord(shoppingRecord)) 34 | .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED)) 35 | .orElseThrow(() -> new CommonException("error.addShoppingRecord")); 36 | } 37 | 38 | @ApiOperation("修改购物记录") 39 | @PostMapping 40 | public ResponseEntity changeShoppingRecord(@ApiParam(value = "购物记录信息", required = true) 41 | @RequestBody ShoppingRecord shoppingRecord) { 42 | return Optional.ofNullable(shoppingRecordService.changeShoppingRecord(shoppingRecord)) 43 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 44 | .orElseThrow(() -> new CommonException("error.changeShoppingRecord")); 45 | } 46 | 47 | @ApiOperation("根据用户id获取购物记录") 48 | @GetMapping(value = "/query_by_user_id/{userId}") 49 | public ResponseEntity> getShoppingRecords(@ApiParam(value = "用户id", required = true) 50 | @PathVariable int userId) { 51 | return Optional.ofNullable(shoppingRecordService.findByUserId(userId)) 52 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 53 | .orElseThrow(() -> new CommonException("error.getShoppingRecords")); 54 | } 55 | 56 | @ApiOperation("根据订单状态获取购物记录") 57 | @GetMapping(value = "/query_by_order_status/{orderStatus}") 58 | public ResponseEntity> getShoppingRecordsByOrderStatus(@ApiParam(value = "订单状态", required = true) 59 | @PathVariable int orderStatus) { 60 | Condition condition = new Condition(ShoppingCar.class); 61 | condition.createCriteria().andCondition("order_status", orderStatus); 62 | return Optional.ofNullable(shoppingRecordService.findByCondition(condition)) 63 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 64 | .orElseThrow(() -> new CommonException("error.getShoppingRecordsByOrderStatus")); 65 | } 66 | 67 | @ApiOperation("获取所有购物记录") 68 | @GetMapping 69 | public ResponseEntity> getAllShoppingRecords() { 70 | return Optional.ofNullable(shoppingRecordService.findAll()) 71 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 72 | .orElseThrow(() -> new CommonException("error.getAllShoppingRecords")); 73 | } 74 | 75 | @ApiOperation("根据用户id和产品id查询用户是否有记录") 76 | @GetMapping(value = "/query_user_product_record/{userId}/{productId}") 77 | public ResponseEntity getUserProductRecord(@ApiParam(value = "用户id", required = true) 78 | @PathVariable int userId, 79 | @ApiParam(value = "产品id", required = true) 80 | @PathVariable int productId) { 81 | return Optional.of(shoppingRecordService.getUserProductRecord(userId, productId)) 82 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 83 | .orElseThrow(() -> new CommonException("error.getUserProductRecord")); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/UserDetailController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.shopping.mall.core.CommonException; 6 | import com.shopping.mall.domain.UserDetail; 7 | import com.shopping.mall.service.UserDetailService; 8 | import io.swagger.annotations.ApiOperation; 9 | import io.swagger.annotations.ApiParam; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | @Controller 19 | @RequestMapping("/mall/user_detail") 20 | public class UserDetailController { 21 | 22 | private UserDetailService userDetailService; 23 | 24 | public UserDetailController(UserDetailService userDetailService) { 25 | this.userDetailService = userDetailService; 26 | } 27 | 28 | @ApiOperation("添加用户详情") 29 | @PutMapping 30 | public ResponseEntity add(@ApiParam(value = "用户详情", required = true) 31 | @RequestBody UserDetail userDetail) { 32 | return Optional.ofNullable(userDetailService.add(userDetail)) 33 | .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED)) 34 | .orElseThrow(() -> new CommonException("error.add")); 35 | } 36 | 37 | @ApiOperation("删除用户详情") 38 | @DeleteMapping(value = "/{id}") 39 | public ResponseEntity delete(@ApiParam(value = "用户详情", required = true) 40 | @PathVariable Integer id) { 41 | return Optional.ofNullable(userDetailService.delete(id)) 42 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 43 | .orElseThrow(() -> new CommonException("error.delete")); 44 | } 45 | 46 | @ApiOperation("更新用户详情") 47 | @PostMapping 48 | public ResponseEntity update(@ApiParam(value = "用户详情", required = true) 49 | @RequestBody UserDetail userDetail) { 50 | return Optional.ofNullable(userDetailService.updateUserDetail(userDetail)) 51 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 52 | .orElseThrow(() -> new CommonException("error.update")); 53 | } 54 | 55 | @ApiOperation("根据id获取用户详情") 56 | @GetMapping("/{id}") 57 | public ResponseEntity queryDetail(@ApiParam(value = "用户详情", required = true) 58 | @PathVariable Integer id) { 59 | return Optional.ofNullable(userDetailService.findById(id)) 60 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 61 | .orElseThrow(() -> new CommonException("error.queryDetail")); 62 | } 63 | 64 | @ApiOperation("分页获取所有用户详情") 65 | @GetMapping 66 | public ResponseEntity list(@ApiParam(value = "页数") 67 | @RequestParam(defaultValue = "0") Integer page, 68 | @ApiParam(value = "页数大小") 69 | @RequestParam(defaultValue = "0") Integer size) { 70 | PageHelper.startPage(page, size); 71 | List list = userDetailService.findAll(); 72 | PageInfo pageInfo = new PageInfo(list); 73 | return Optional.of(pageInfo) 74 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 75 | .orElseThrow(() -> new CommonException("error.queryDetail")); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/controller/UserMainController.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.controller; 2 | 3 | import com.shopping.mall.core.CommonException; 4 | import com.shopping.mall.domain.UserDetail; 5 | import com.shopping.mall.domain.UserDto; 6 | import com.shopping.mall.domain.UserMain; 7 | import com.shopping.mall.service.UserDetailService; 8 | import com.shopping.mall.service.UserMainService; 9 | import io.swagger.annotations.ApiOperation; 10 | import io.swagger.annotations.ApiParam; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import javax.servlet.http.HttpSession; 17 | import java.util.*; 18 | 19 | @Controller 20 | @RequestMapping("/mall/user_main") 21 | public class UserMainController { 22 | 23 | private UserMainService userService; 24 | private UserDetailService userDetailService; 25 | 26 | public UserMainController(UserMainService userService, 27 | UserDetailService userDetailService) { 28 | this.userService = userService; 29 | this.userDetailService = userDetailService; 30 | } 31 | 32 | @ApiOperation("用户登陆") 33 | @PostMapping(value = "/do_login") 34 | public ResponseEntity doLogin(@ApiParam(value = "用户登陆信息", required = true) 35 | @RequestBody UserMain userMain, HttpSession httpSession) { 36 | return Optional.ofNullable(userService.doLogin(userMain, httpSession)) 37 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 38 | .orElseThrow(() -> new CommonException("error.doLogin")); 39 | } 40 | 41 | @ApiOperation("用户注册") 42 | @PutMapping(value = "/do_register") 43 | public ResponseEntity doRegister(@ApiParam(value = "用户注册信息", required = true) 44 | @RequestBody UserDto userDto) { 45 | return Optional.ofNullable(userService.doRegister(userDto)) 46 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 47 | .orElseThrow(() -> new CommonException("error.doRegister")); 48 | } 49 | 50 | @ApiOperation("用户信息更新") 51 | @PostMapping 52 | public ResponseEntity doUpdate(@ApiParam(value = "用户更新信息", required = true) 53 | @RequestBody UserDto userDto) { 54 | return Optional.ofNullable(userService.doUpdate(userDto)) 55 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 56 | .orElseThrow(() -> new CommonException("error.doUpdate")); 57 | } 58 | 59 | @ApiOperation("获取所有用户") 60 | @GetMapping 61 | public ResponseEntity> getAllUser() { 62 | return Optional.ofNullable(userService.findAll()) 63 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 64 | .orElseThrow(() -> new CommonException("error.getAllUser")); 65 | } 66 | 67 | @ApiOperation("根据用户id删除用户") 68 | @DeleteMapping(value = "/{id}") 69 | public ResponseEntity deleteUser(@ApiParam(value = "用户id", required = true) 70 | @PathVariable int id) { 71 | //todo 关联删除用户的所有东西 72 | return Optional.of(userService.deleteById(id) == 1) 73 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 74 | .orElseThrow(() -> new CommonException("error.deleteUser")); 75 | } 76 | 77 | @ApiOperation("根据用户id查询地址和手机号") 78 | @GetMapping(value = "/query_user_address_and_phone_number/{id}") 79 | public ResponseEntity> getUserAddressAndPhoneNumber(@ApiParam(value = "用户id", required = true) 80 | @PathVariable int id) { 81 | String address = userDetailService.findById(id).getAddress(); 82 | String phoneNumber = userDetailService.findById(id).getPhoneNumber(); 83 | Map resultMap = new HashMap<>(); 84 | resultMap.put("address", address); 85 | resultMap.put("phoneNumber", phoneNumber); 86 | return Optional.of(resultMap) 87 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 88 | .orElseThrow(() -> new CommonException("error.getUserAddressAndPhoneNumber")); 89 | } 90 | 91 | @ApiOperation("注销登陆") 92 | @PostMapping(value = "do_logout") 93 | public ResponseEntity doLogout(HttpSession httpSession) { 94 | httpSession.setAttribute("currentUser", ""); 95 | return Optional.of("redirect:login") 96 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 97 | .orElseThrow(() -> new CommonException("error.doLogout")); 98 | } 99 | 100 | @ApiOperation("根据用户id获取用户信息") 101 | @GetMapping(value = "{id}") 102 | public ResponseEntity getUserById(@ApiParam(value = "用户id", required = true) 103 | @PathVariable int id) { 104 | return Optional.ofNullable(userService.findById(id)) 105 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 106 | .orElseThrow(() -> new CommonException("error.getUserById")); 107 | } 108 | 109 | @ApiOperation("根据用户id获取用户详细信息") 110 | @GetMapping(value = "{id}/detail") 111 | public ResponseEntity getUserDetailById(@ApiParam(value = "用户id", required = true) 112 | @PathVariable int id) { 113 | return Optional.ofNullable(userDetailService.findById(id)) 114 | .map(result -> new ResponseEntity<>(result, HttpStatus.OK)) 115 | .orElseThrow(() -> new CommonException("error.getUserDetailById")); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/core/AbstractService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.core; 2 | 3 | 4 | import org.apache.ibatis.exceptions.TooManyResultsException; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import tk.mybatis.mapper.entity.Condition; 7 | 8 | import java.lang.reflect.Field; 9 | import java.lang.reflect.ParameterizedType; 10 | import java.util.List; 11 | 12 | public abstract class AbstractService implements Service { 13 | 14 | @Autowired 15 | protected Mapper mapper; 16 | 17 | private Class modelClass; // 当前泛型真实类型的Class 18 | 19 | public AbstractService() { 20 | ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass(); 21 | modelClass = (Class) pt.getActualTypeArguments()[0]; 22 | } 23 | 24 | @Override 25 | public void save(T model) { 26 | mapper.insertSelective(model); 27 | } 28 | 29 | @Override 30 | public void save(List models) { 31 | mapper.insertList(models); 32 | } 33 | 34 | @Override 35 | public int deleteById(Integer id) { 36 | return mapper.deleteByPrimaryKey(id); 37 | } 38 | 39 | @Override 40 | public int deleteByCondition(Condition condition) { 41 | return mapper.deleteByCondition(condition); 42 | } 43 | 44 | 45 | @Override 46 | public void deleteByIds(String ids) { 47 | mapper.deleteByIds(ids); 48 | } 49 | 50 | @Override 51 | public void update(T model) { 52 | mapper.updateByPrimaryKeySelective(model); 53 | } 54 | 55 | @Override 56 | public T findById(Integer id) { 57 | return mapper.selectByPrimaryKey(id); 58 | } 59 | 60 | @Override 61 | public T findBy(String fieldName, Object value) throws TooManyResultsException { 62 | try { 63 | T model = modelClass.newInstance(); 64 | Field field = modelClass.getDeclaredField(fieldName); 65 | field.setAccessible(true); 66 | field.set(model, value); 67 | return mapper.selectOne(model); 68 | } catch (ReflectiveOperationException e) { 69 | throw new ServiceException(); 70 | } 71 | } 72 | 73 | @Override 74 | public List findByIds(String ids) { 75 | return mapper.selectByIds(ids); 76 | } 77 | 78 | @Override 79 | public List findByCondition(Condition condition) { 80 | return mapper.selectByCondition(condition); 81 | } 82 | 83 | @Override 84 | public List findAll() { 85 | return mapper.selectAll(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/core/CommonException.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.core; 2 | 3 | public class CommonException extends RuntimeException { 4 | 5 | private final transient Object[] parameters; 6 | 7 | public CommonException(String message, Object... parameters) { 8 | 9 | super(message); 10 | this.parameters = parameters; 11 | } 12 | 13 | public CommonException(Throwable cause, Object... parameters) { 14 | super(cause); 15 | this.parameters = parameters; 16 | } 17 | 18 | public Object[] getParameters() { 19 | return parameters; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/core/Mapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.core; 2 | 3 | import org.springframework.stereotype.Component; 4 | import tk.mybatis.mapper.common.BaseMapper; 5 | import tk.mybatis.mapper.common.ConditionMapper; 6 | import tk.mybatis.mapper.common.IdsMapper; 7 | import tk.mybatis.mapper.common.special.InsertListMapper; 8 | 9 | @Component 10 | public interface Mapper extends BaseMapper, 11 | ConditionMapper, 12 | IdsMapper, 13 | InsertListMapper { 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/core/Service.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.core; 2 | 3 | import org.apache.ibatis.exceptions.TooManyResultsException; 4 | import tk.mybatis.mapper.entity.Condition; 5 | 6 | import java.util.List; 7 | 8 | public interface Service { 9 | 10 | /** 11 | * 保存持久化 12 | * 13 | * @param model model 14 | */ 15 | void save(T model); 16 | 17 | /** 18 | * 批量持久化 19 | * 20 | * @param models models 21 | */ 22 | void save(List models); 23 | 24 | /** 25 | * 通过主鍵刪除 26 | * 27 | * @param id id 28 | * @return int 29 | */ 30 | int deleteById(Integer id); 31 | 32 | /** 33 | * 通过条件删除 34 | * 35 | * @param condition condition 36 | * @return int 37 | */ 38 | int deleteByCondition(Condition condition); 39 | 40 | /** 41 | * 批量删除 42 | * 43 | * @param ids eg:ids -> "1,2,3,4" 44 | */ 45 | void deleteByIds(String ids); 46 | 47 | /** 48 | * 更新 49 | * 50 | * @param model model 51 | */ 52 | void update(T model); 53 | 54 | /** 55 | * 通过ID查找 56 | * 57 | * @param id id 58 | * @return T 59 | */ 60 | T findById(Integer id); 61 | 62 | /** 63 | * 通过Model中某个成员变量名称(非数据表中column的名称)查找,value需符合unique约束 64 | * 65 | * @param fieldName fieldName 66 | * @param value value 67 | * @return T 68 | * @throws TooManyResultsException TooManyResultsException 69 | */ 70 | T findBy(String fieldName, Object value) throws TooManyResultsException; 71 | 72 | /** 73 | * 通过多个ID查找 74 | * 75 | * @param ids eg:ids -> "1,2,3,4" 76 | * @return List 77 | */ 78 | List findByIds(String ids); 79 | 80 | /** 81 | * 根据条件查找 82 | * 83 | * @param condition condition 84 | * @return List 85 | */ 86 | List findByCondition(Condition condition); 87 | 88 | /** 89 | * /获取所有 90 | * 91 | * @return List 92 | */ 93 | List findAll(); 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/core/ServiceException.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.core; 2 | 3 | 4 | public class ServiceException extends RuntimeException { 5 | 6 | public ServiceException() { 7 | } 8 | 9 | public ServiceException(String message) { 10 | super(message); 11 | } 12 | 13 | public ServiceException(String message, Throwable cause) { 14 | super(message, cause); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/Evaluation.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Id; 5 | import java.io.Serializable; 6 | 7 | public class Evaluation implements Serializable { 8 | 9 | @Id 10 | @Column(name = "user_id") 11 | private Integer userId; 12 | 13 | @Column(name = "product_id") 14 | private Integer productId; 15 | 16 | private String time; 17 | 18 | private String content; 19 | 20 | public Integer getUserId() { 21 | return userId; 22 | } 23 | 24 | public void setUserId(Integer userId) { 25 | this.userId = userId; 26 | } 27 | 28 | public Integer getProductId() { 29 | return productId; 30 | } 31 | 32 | public void setProductId(Integer productId) { 33 | this.productId = productId; 34 | } 35 | 36 | public String getTime() { 37 | return time; 38 | } 39 | 40 | public void setTime(String time) { 41 | this.time = time; 42 | } 43 | 44 | public String getContent() { 45 | return content; 46 | } 47 | 48 | public void setContent(String content) { 49 | this.content = content; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "Evaluation{" + 55 | "userId=" + userId + 56 | ", productId=" + productId + 57 | ", time='" + time + '\'' + 58 | ", content='" + content + '\'' + 59 | '}'; 60 | } 61 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/PayDTO.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import java.util.List; 4 | 5 | public class PayDTO { 6 | 7 | private List productsIds; 8 | 9 | private List productsCounts; 10 | 11 | private Integer userId; 12 | 13 | public List getProductsIds() { 14 | return productsIds; 15 | } 16 | 17 | public void setProductsIds(List productsIds) { 18 | this.productsIds = productsIds; 19 | } 20 | 21 | public List getProductsCounts() { 22 | return productsCounts; 23 | } 24 | 25 | public void setProductsCounts(List productsCounts) { 26 | this.productsCounts = productsCounts; 27 | } 28 | 29 | public Integer getUserId() { 30 | return userId; 31 | } 32 | 33 | public void setUserId(Integer userId) { 34 | this.userId = userId; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/Products.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.GenerationType; 6 | import javax.persistence.Id; 7 | import java.io.Serializable; 8 | 9 | public class Products implements Serializable { 10 | 11 | @Id 12 | @GeneratedValue(strategy = GenerationType.IDENTITY) 13 | private Integer id; 14 | 15 | private String name; 16 | 17 | private String description; 18 | 19 | @Column(name = "key_word") 20 | private String keyWord; 21 | 22 | private Integer price; 23 | 24 | private Integer counts; 25 | 26 | private String type; 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public String getDescription() { 45 | return description; 46 | } 47 | 48 | public void setDescription(String description) { 49 | this.description = description; 50 | } 51 | 52 | public String getKeyWord() { 53 | return keyWord; 54 | } 55 | 56 | public void setKeyWord(String keyWord) { 57 | this.keyWord = keyWord; 58 | } 59 | 60 | public Integer getPrice() { 61 | return price; 62 | } 63 | 64 | public void setPrice(Integer price) { 65 | this.price = price; 66 | } 67 | 68 | public Integer getCounts() { 69 | return counts; 70 | } 71 | 72 | public void setCounts(Integer counts) { 73 | this.counts = counts; 74 | } 75 | 76 | public String getType() { 77 | return type; 78 | } 79 | 80 | public void setType(String type) { 81 | this.type = type; 82 | } 83 | 84 | @Override 85 | public String toString() { 86 | return "Products{" + 87 | "id=" + id + 88 | ", name='" + name + '\'' + 89 | ", description='" + description + '\'' + 90 | ", keyWord='" + keyWord + '\'' + 91 | ", price=" + price + 92 | ", counts=" + counts + 93 | ", type=" + type + 94 | '}'; 95 | } 96 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/ShoppingCar.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Id; 5 | import javax.persistence.Table; 6 | import java.io.Serializable; 7 | 8 | @Table(name = "shopping_car") 9 | public class ShoppingCar implements Serializable { 10 | 11 | @Id 12 | @Column(name = "user_id") 13 | private Integer userId; 14 | 15 | @Column(name = "product_id") 16 | private Integer productId; 17 | 18 | @Column(name = "product_price") 19 | private Integer productPrice; 20 | 21 | private Integer counts; 22 | 23 | public Integer getUserId() { 24 | return userId; 25 | } 26 | 27 | public void setUserId(Integer userId) { 28 | this.userId = userId; 29 | } 30 | 31 | public Integer getProductId() { 32 | return productId; 33 | } 34 | 35 | public void setProductId(Integer productId) { 36 | this.productId = productId; 37 | } 38 | 39 | public Integer getProductPrice() { 40 | return productPrice; 41 | } 42 | 43 | public void setProductPrice(Integer productPrice) { 44 | this.productPrice = productPrice; 45 | } 46 | 47 | public Integer getCounts() { 48 | return counts; 49 | } 50 | 51 | public void setCounts(Integer counts) { 52 | this.counts = counts; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return "ShoppingCar{" + 58 | "userId=" + userId + 59 | ", productId=" + productId + 60 | ", productPrice=" + productPrice + 61 | ", counts=" + counts + 62 | '}'; 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/ShoppingRecord.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | @Table(name = "shopping_record") 7 | public class ShoppingRecord implements Serializable { 8 | 9 | @Id 10 | @GeneratedValue(strategy = GenerationType.IDENTITY) 11 | private Integer id; 12 | 13 | @Column(name = "user_id") 14 | private Integer userId; 15 | 16 | @Column(name = "product_id") 17 | private Integer productId; 18 | 19 | private String time; 20 | 21 | @Column(name = "order_status") 22 | private Integer orderStatus; 23 | 24 | @Column(name = "product_price") 25 | private Integer productPrice; 26 | 27 | private Integer counts; 28 | 29 | public Integer getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Integer id) { 34 | this.id = id; 35 | } 36 | 37 | public Integer getUserId() { 38 | return userId; 39 | } 40 | 41 | public void setUserId(Integer userId) { 42 | this.userId = userId; 43 | } 44 | 45 | public Integer getProductId() { 46 | return productId; 47 | } 48 | 49 | public void setProductId(Integer productId) { 50 | this.productId = productId; 51 | } 52 | 53 | public String getTime() { 54 | return time; 55 | } 56 | 57 | public void setTime(String time) { 58 | this.time = time; 59 | } 60 | 61 | public Integer getOrderStatus() { 62 | return orderStatus; 63 | } 64 | 65 | public void setOrderStatus(Integer orderStatus) { 66 | this.orderStatus = orderStatus; 67 | } 68 | 69 | public Integer getProductPrice() { 70 | return productPrice; 71 | } 72 | 73 | public void setProductPrice(Integer productPrice) { 74 | this.productPrice = productPrice; 75 | } 76 | 77 | public Integer getCounts() { 78 | return counts; 79 | } 80 | 81 | public void setCounts(Integer counts) { 82 | this.counts = counts; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "ShoppingRecord{" + 88 | "id=" + id + 89 | ", userId=" + userId + 90 | ", productId=" + productId + 91 | ", time='" + time + '\'' + 92 | ", orderStatus=" + orderStatus + 93 | ", productPrice=" + productPrice + 94 | ", counts=" + counts + 95 | '}'; 96 | } 97 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/UserDetail.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | @Table(name = "user_detail") 7 | public class UserDetail implements Serializable { 8 | 9 | @Id 10 | @GeneratedValue(strategy = GenerationType.IDENTITY) 11 | private Integer id; 12 | 13 | private String password; 14 | 15 | @Column(name = "phone_number") 16 | private String phoneNumber; 17 | 18 | private Integer sex; 19 | 20 | private String birthday; 21 | 22 | @Column(name = "post_number") 23 | private String postNumber; 24 | 25 | private String address; 26 | 27 | @Column(name = "register_time") 28 | private String registerTime; 29 | 30 | public Integer getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Integer id) { 35 | this.id = id; 36 | } 37 | 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | public void setPassword(String password) { 43 | this.password = password; 44 | } 45 | 46 | public String getPhoneNumber() { 47 | return phoneNumber; 48 | } 49 | 50 | public void setPhoneNumber(String phoneNumber) { 51 | this.phoneNumber = phoneNumber; 52 | } 53 | 54 | public Integer getSex() { 55 | return sex; 56 | } 57 | 58 | public void setSex(Integer sex) { 59 | this.sex = sex; 60 | } 61 | 62 | public String getBirthday() { 63 | return birthday; 64 | } 65 | 66 | public void setBirthday(String birthday) { 67 | this.birthday = birthday; 68 | } 69 | 70 | public String getPostNumber() { 71 | return postNumber; 72 | } 73 | 74 | public void setPostNumber(String postNumber) { 75 | this.postNumber = postNumber; 76 | } 77 | 78 | public String getAddress() { 79 | return address; 80 | } 81 | 82 | public void setAddress(String address) { 83 | this.address = address; 84 | } 85 | 86 | public String getRegisterTime() { 87 | return registerTime; 88 | } 89 | 90 | public void setRegisterTime(String registerTime) { 91 | this.registerTime = registerTime; 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | return "UserDetail{" + 97 | "id=" + id + 98 | ", password='" + password + '\'' + 99 | ", phoneNumber='" + phoneNumber + '\'' + 100 | ", sex=" + sex + 101 | ", birthday='" + birthday + '\'' + 102 | ", postNumber='" + postNumber + '\'' + 103 | ", address='" + address + '\'' + 104 | ", registerTime='" + registerTime + '\'' + 105 | '}'; 106 | } 107 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/UserDto.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | public class UserDto implements Serializable { 6 | 7 | private String userName; 8 | 9 | private String email; 10 | 11 | private String nickName; 12 | 13 | private String password; 14 | 15 | private String phoneNumber; 16 | 17 | private int sex; 18 | 19 | private String birthday; 20 | 21 | private String postNumber; 22 | 23 | private String address; 24 | 25 | public String getUserName() { 26 | return userName; 27 | } 28 | 29 | public void setUserName(String userName) { 30 | this.userName = userName; 31 | } 32 | 33 | public String getEmail() { 34 | return email; 35 | } 36 | 37 | public void setEmail(String email) { 38 | this.email = email; 39 | } 40 | 41 | public String getNickName() { 42 | return nickName; 43 | } 44 | 45 | public void setNickName(String nickName) { 46 | this.nickName = nickName; 47 | } 48 | 49 | public String getPassword() { 50 | return password; 51 | } 52 | 53 | public void setPassword(String password) { 54 | this.password = password; 55 | } 56 | 57 | public String getPhoneNumber() { 58 | return phoneNumber; 59 | } 60 | 61 | public void setPhoneNumber(String phoneNumber) { 62 | this.phoneNumber = phoneNumber; 63 | } 64 | 65 | public int getSex() { 66 | return sex; 67 | } 68 | 69 | public void setSex(int sex) { 70 | this.sex = sex; 71 | } 72 | 73 | public String getBirthday() { 74 | return birthday; 75 | } 76 | 77 | public void setBirthday(String birthday) { 78 | this.birthday = birthday; 79 | } 80 | 81 | public String getPostNumber() { 82 | return postNumber; 83 | } 84 | 85 | public void setPostNumber(String postNumber) { 86 | this.postNumber = postNumber; 87 | } 88 | 89 | public String getAddress() { 90 | return address; 91 | } 92 | 93 | public void setAddress(String address) { 94 | this.address = address; 95 | } 96 | 97 | @Override 98 | public String toString() { 99 | return "UserDto{" + 100 | "userName='" + userName + '\'' + 101 | ", email='" + email + '\'' + 102 | ", nickName='" + nickName + '\'' + 103 | ", password='" + password + '\'' + 104 | ", phoneNumber='" + phoneNumber + '\'' + 105 | ", sex=" + sex + 106 | ", birthday='" + birthday + '\'' + 107 | ", postNumber='" + postNumber + '\'' + 108 | ", address='" + address + '\'' + 109 | '}'; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/domain/UserMain.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.domain; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | @Table(name = "user_main") 7 | public class UserMain implements Serializable { 8 | 9 | @Id 10 | @GeneratedValue(strategy = GenerationType.IDENTITY) 11 | private Integer id; 12 | 13 | private String name; 14 | 15 | private String email; 16 | 17 | @Column(name = "nick_name") 18 | private String nickName; 19 | 20 | private Integer role; 21 | 22 | @Transient 23 | private String password; 24 | 25 | @Transient 26 | private String userNameOrEmail; 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public String getEmail() { 45 | return email; 46 | } 47 | 48 | public void setEmail(String email) { 49 | this.email = email; 50 | } 51 | 52 | public String getNickName() { 53 | return nickName; 54 | } 55 | 56 | public void setNickName(String nickName) { 57 | this.nickName = nickName; 58 | } 59 | 60 | public Integer getRole() { 61 | return role; 62 | } 63 | 64 | public void setRole(Integer role) { 65 | this.role = role; 66 | } 67 | 68 | public String getPassword() { 69 | return password; 70 | } 71 | 72 | public void setPassword(String password) { 73 | this.password = password; 74 | } 75 | 76 | public String getUserNameOrEmail() { 77 | return userNameOrEmail; 78 | } 79 | 80 | public void setUserNameOrEmail(String userNameOrEmail) { 81 | this.userNameOrEmail = userNameOrEmail; 82 | } 83 | 84 | @Override 85 | public String toString() { 86 | return "UserMain{" + 87 | "id=" + id + 88 | ", name='" + name + '\'' + 89 | ", email='" + email + '\'' + 90 | ", nickName='" + nickName + '\'' + 91 | ", role=" + role + 92 | ", password='" + password + '\'' + 93 | ", userNameOrEmail='" + userNameOrEmail + '\'' + 94 | '}'; 95 | } 96 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/mapper/EvaluationMapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.mapper; 2 | 3 | import com.shopping.mall.core.Mapper; 4 | import com.shopping.mall.domain.Evaluation; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.apache.ibatis.annotations.Select; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.List; 10 | 11 | @Component 12 | public interface EvaluationMapper extends Mapper { 13 | 14 | @Select("SELECT * from evaluation where product_id = #{productId}") 15 | List getProductEvaluation(@Param("productId") int productId); 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/mapper/ProductsMapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.mapper; 2 | 3 | 4 | import com.shopping.mall.core.Mapper; 5 | import com.shopping.mall.domain.Products; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | 11 | @Component 12 | public interface ProductsMapper extends Mapper { 13 | 14 | List queryAll(); 15 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/mapper/ShoppingCarMapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.mapper; 2 | 3 | 4 | import com.shopping.mall.core.Mapper; 5 | import com.shopping.mall.domain.ShoppingCar; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public interface ShoppingCarMapper extends Mapper { 10 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/mapper/ShoppingRecordMapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.mapper; 2 | 3 | 4 | import com.shopping.mall.core.Mapper; 5 | import com.shopping.mall.domain.ShoppingRecord; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.List; 11 | 12 | @Component 13 | public interface ShoppingRecordMapper extends Mapper { 14 | 15 | @Select("SELECT count(*) from shopping_record where user_id=#{userId} and product_id=#{productId}") 16 | Integer getUserProductRecord(@Param("userId") int userId, @Param("productId") int productId); 17 | 18 | @Select("SELECT * from shopping_record where user_id = #{userId}") 19 | List findByUserId(int userId); 20 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/mapper/UserDetailMapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.mapper; 2 | 3 | 4 | import com.shopping.mall.core.Mapper; 5 | import com.shopping.mall.domain.UserDetail; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public interface UserDetailMapper extends Mapper { 10 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/mapper/UserMainMapper.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.mapper; 2 | 3 | 4 | import com.shopping.mall.core.Mapper; 5 | import com.shopping.mall.domain.UserMain; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public interface UserMainMapper extends Mapper { 10 | } -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/EvaluationService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service; 2 | 3 | 4 | import com.shopping.mall.core.Service; 5 | import com.shopping.mall.domain.Evaluation; 6 | 7 | import java.util.List; 8 | 9 | 10 | public interface EvaluationService extends Service { 11 | 12 | /** 13 | * 根据productId获取评价 14 | * 15 | * @param productId productId 16 | * @return List 17 | */ 18 | List getProductEvaluation(int productId); 19 | 20 | /** 21 | * 添加评价信息 22 | * 23 | * @param evaluation evaluation 24 | * @return 成功true 25 | */ 26 | Boolean addEvaluation(Evaluation evaluation); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/ProductsService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service; 2 | 3 | 4 | import com.shopping.mall.core.Service; 5 | import com.shopping.mall.domain.Products; 6 | 7 | import java.util.List; 8 | 9 | 10 | public interface ProductsService extends Service { 11 | 12 | /** 13 | * 根据id删除商品 14 | * 15 | * @param id id 16 | * @return 成功true 17 | */ 18 | Boolean deleteProduct(int id); 19 | 20 | /** 21 | * 添加产品 22 | * 23 | * @param products products 24 | * @return products 25 | */ 26 | Products addProduct(Products products); 27 | 28 | /** 29 | * 查找所有商品 30 | * 31 | * @return List 32 | */ 33 | List queryAll(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/ShoppingCarService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service; 2 | 3 | 4 | import com.shopping.mall.core.Service; 5 | import com.shopping.mall.domain.ShoppingCar; 6 | 7 | 8 | public interface ShoppingCarService extends Service { 9 | 10 | /** 11 | * 添加购物车 12 | * 13 | * @param shoppingCar shoppingCar 14 | * @return ShoppingCar 15 | */ 16 | ShoppingCar addShoppingCar(ShoppingCar shoppingCar); 17 | 18 | /** 19 | * 根据用户id和产品id删除购物车 20 | * 21 | * @param userId userId 22 | * @param productId productId 23 | * @return 成功true 24 | */ 25 | Boolean deleteShoppingCar(int userId, int productId); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/ShoppingRecordService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service; 2 | 3 | 4 | import com.shopping.mall.core.Service; 5 | import com.shopping.mall.domain.ShoppingRecord; 6 | 7 | import java.util.List; 8 | 9 | public interface ShoppingRecordService extends Service { 10 | 11 | /** 12 | * 获取用户产品记录是否存在 13 | * 14 | * @param userId userId 15 | * @param productId productId 16 | * @return 成功true 17 | */ 18 | boolean getUserProductRecord(int userId, int productId); 19 | 20 | /** 21 | * 根据用户id查找购物记录 22 | * 23 | * @param userId userId 24 | * @return List 25 | */ 26 | List findByUserId(int userId); 27 | 28 | /** 29 | * 添加购物记录 30 | * 31 | * @param shoppingRecord shoppingRecord 32 | * @return 成功返回true 33 | */ 34 | Boolean addShoppingRecord(ShoppingRecord shoppingRecord); 35 | 36 | /** 37 | * 修改购物记录 38 | * 39 | * @param shoppingRecord shoppingRecord 40 | * @return 成功返回true 41 | */ 42 | Boolean changeShoppingRecord(ShoppingRecord shoppingRecord); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/UserDetailService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service; 2 | 3 | 4 | import com.shopping.mall.core.Service; 5 | import com.shopping.mall.domain.UserDetail; 6 | 7 | 8 | public interface UserDetailService extends Service { 9 | 10 | /** 11 | * 添加用户详情 12 | * 13 | * @param userDetail userDetail 14 | * @return UserDetail 15 | */ 16 | UserDetail add(UserDetail userDetail); 17 | 18 | /** 19 | * 根据id删除用户详情 20 | * 21 | * @param id id 22 | * @return 成功true 23 | */ 24 | Boolean delete(Integer id); 25 | 26 | /** 27 | * 更新用户详情 28 | * 29 | * @param userDetail userDetail 30 | * @return UserDetail 31 | */ 32 | UserDetail updateUserDetail(UserDetail userDetail); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/UserMainService.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service; 2 | 3 | 4 | import com.shopping.mall.core.Service; 5 | import com.shopping.mall.domain.UserDto; 6 | import com.shopping.mall.domain.UserMain; 7 | 8 | import javax.servlet.http.HttpSession; 9 | 10 | public interface UserMainService extends Service { 11 | 12 | /** 13 | * 用户登陆 14 | * 15 | * @param userMain userMain 16 | * @param session session 17 | * @return String 18 | */ 19 | String doLogin(UserMain userMain, HttpSession session); 20 | 21 | /** 22 | * 用户注册 23 | * 24 | * @param userDto userDto 25 | * @return String 26 | */ 27 | String doRegister(UserDto userDto); 28 | 29 | /** 30 | * 用户更新 31 | * 32 | * @param userDto userDto 33 | * @return 成功true 34 | */ 35 | Boolean doUpdate(UserDto userDto); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/imp/EvaluationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service.imp; 2 | 3 | 4 | import com.shopping.mall.core.AbstractService; 5 | import com.shopping.mall.core.CommonException; 6 | import com.shopping.mall.domain.Evaluation; 7 | import com.shopping.mall.mapper.EvaluationMapper; 8 | import com.shopping.mall.service.EvaluationService; 9 | import com.shopping.mall.service.ShoppingRecordService; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.text.SimpleDateFormat; 14 | import java.util.Date; 15 | import java.util.List; 16 | 17 | 18 | @Service 19 | @Transactional(rollbackFor = CommonException.class) 20 | public class EvaluationServiceImpl extends AbstractService implements EvaluationService { 21 | 22 | private EvaluationMapper evaluationMapper; 23 | 24 | private ShoppingRecordService shoppingRecordService; 25 | 26 | public EvaluationServiceImpl(EvaluationMapper evaluationMapper, 27 | ShoppingRecordService shoppingRecordService) { 28 | this.evaluationMapper = evaluationMapper; 29 | this.shoppingRecordService = shoppingRecordService; 30 | } 31 | 32 | @Override 33 | public List getProductEvaluation(int productId) { 34 | return evaluationMapper.getProductEvaluation(productId); 35 | } 36 | 37 | @Override 38 | public Boolean addEvaluation(Evaluation evaluation) { 39 | Boolean flag; 40 | if (shoppingRecordService.getUserProductRecord(evaluation.getUserId(), evaluation.getProductId())) { 41 | Date date = new Date(); 42 | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); 43 | evaluation.setTime(sf.format(date)); 44 | try { 45 | save(evaluation); 46 | } catch (Exception e) { 47 | throw new CommonException("error.addEvaluation"); 48 | } 49 | flag = true; 50 | } else { 51 | flag = false; 52 | } 53 | return flag; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/imp/ProductsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service.imp; 2 | 3 | import com.shopping.mall.core.AbstractService; 4 | import com.shopping.mall.core.CommonException; 5 | import com.shopping.mall.domain.Products; 6 | import com.shopping.mall.mapper.ProductsMapper; 7 | import com.shopping.mall.service.ProductsService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.util.List; 13 | 14 | 15 | @Service 16 | @Transactional(rollbackFor = CommonException.class) 17 | public class ProductsServiceImpl extends AbstractService implements ProductsService { 18 | 19 | @Autowired 20 | private ProductsMapper productsMapper; 21 | 22 | @Override 23 | public Boolean deleteProduct(int id) { 24 | if (deleteById(id) == 1) { 25 | return true; 26 | } else { 27 | throw new CommonException("error.deleteProduct"); 28 | } 29 | } 30 | 31 | @Override 32 | public Products addProduct(Products products) { 33 | try { 34 | save(products); 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | throw new CommonException("error.addProduct"); 38 | } 39 | return products; 40 | } 41 | 42 | @Override 43 | public List queryAll() { 44 | return productsMapper.queryAll(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/imp/ShoppingCarServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service.imp; 2 | 3 | import com.shopping.mall.core.AbstractService; 4 | import com.shopping.mall.core.CommonException; 5 | import com.shopping.mall.domain.ShoppingCar; 6 | import com.shopping.mall.service.ProductsService; 7 | import com.shopping.mall.service.ShoppingCarService; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import tk.mybatis.mapper.entity.Condition; 11 | 12 | import java.util.List; 13 | 14 | 15 | @Service 16 | @Transactional(rollbackFor = CommonException.class) 17 | public class ShoppingCarServiceImpl extends AbstractService implements ShoppingCarService { 18 | 19 | private ProductsService productsService; 20 | 21 | public ShoppingCarServiceImpl(ProductsService productsService) { 22 | this.productsService = productsService; 23 | } 24 | 25 | @Override 26 | public ShoppingCar addShoppingCar(ShoppingCar shoppingCar) { 27 | try { 28 | Condition condition = new Condition(ShoppingCar.class); 29 | condition.createCriteria().andCondition("user_id = ", shoppingCar.getUserId()).andCondition("product_id = ", shoppingCar.getProductId()); 30 | List shoppingCars = findByCondition(condition); 31 | if (shoppingCars != null && !shoppingCars.isEmpty()) { 32 | ShoppingCar oldShoppingCar = shoppingCars.get(0); 33 | shoppingCar.setCounts(shoppingCar.getCounts() + shoppingCar.getCounts()); 34 | shoppingCar.setProductPrice(productsService.findById(shoppingCar.getProductId()).getPrice() * shoppingCar.getCounts()); 35 | update(oldShoppingCar); 36 | } else { 37 | shoppingCar.setProductPrice(productsService.findById(shoppingCar.getProductId()).getPrice() * shoppingCar.getCounts()); 38 | save(shoppingCar); 39 | } 40 | return shoppingCar; 41 | } catch (Exception e) { 42 | throw new CommonException("error.addShoppingCar"); 43 | } 44 | } 45 | 46 | @Override 47 | public Boolean deleteShoppingCar(int userId, int productId) { 48 | Condition condition = new Condition(ShoppingCar.class); 49 | condition.createCriteria().andCondition("user_id = ", userId).andCondition("product_id = ", productId); 50 | if (deleteByCondition(condition) == 1) { 51 | return true; 52 | } else { 53 | throw new CommonException("error.deleteShoppingCar"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/imp/ShoppingRecordServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service.imp; 2 | 3 | import com.shopping.mall.core.AbstractService; 4 | import com.shopping.mall.core.CommonException; 5 | import com.shopping.mall.domain.Products; 6 | import com.shopping.mall.domain.ShoppingCar; 7 | import com.shopping.mall.domain.ShoppingRecord; 8 | import com.shopping.mall.mapper.ShoppingRecordMapper; 9 | import com.shopping.mall.service.ProductsService; 10 | import com.shopping.mall.service.ShoppingRecordService; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import tk.mybatis.mapper.entity.Condition; 14 | 15 | import java.text.SimpleDateFormat; 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | 20 | @Service 21 | @Transactional(rollbackFor = CommonException.class) 22 | public class ShoppingRecordServiceImpl extends AbstractService implements ShoppingRecordService { 23 | 24 | private ShoppingRecordMapper shoppingRecordMapper; 25 | 26 | private ProductsService productsService; 27 | 28 | public ShoppingRecordServiceImpl(ShoppingRecordMapper shoppingRecordMapper, 29 | ProductsService productsService) { 30 | this.shoppingRecordMapper = shoppingRecordMapper; 31 | this.productsService = productsService; 32 | } 33 | 34 | @Override 35 | public boolean getUserProductRecord(int userId, int productId) { 36 | return shoppingRecordMapper.getUserProductRecord(userId, productId) != 0; 37 | } 38 | 39 | @Override 40 | public List findByUserId(int userId) { 41 | return shoppingRecordMapper.findByUserId(userId); 42 | } 43 | 44 | @Override 45 | public Boolean addShoppingRecord(ShoppingRecord shoppingRecord) { 46 | try { 47 | Products product = productsService.findById(shoppingRecord.getProductId()); 48 | if (shoppingRecord.getCounts() <= product.getCounts()) { 49 | shoppingRecord.setProductPrice(product.getPrice() * shoppingRecord.getCounts()); 50 | shoppingRecord.setOrderStatus(0); 51 | Date date = new Date(); 52 | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); 53 | shoppingRecord.setTime(sf.format(date)); 54 | product.setCounts(product.getCounts() - shoppingRecord.getCounts()); 55 | productsService.update(product); 56 | save(shoppingRecord); 57 | return true; 58 | } else { 59 | return false; 60 | } 61 | } catch (Exception e) { 62 | throw new CommonException("error.addShoppingRecord"); 63 | } 64 | 65 | } 66 | 67 | @Override 68 | public Boolean changeShoppingRecord(ShoppingRecord shoppingRecord) { 69 | try { 70 | Condition condition = new Condition(ShoppingCar.class); 71 | condition.createCriteria().andCondition("user_id = ", shoppingRecord.getUserId()). 72 | andCondition("product_id = ", shoppingRecord.getProductId()).andCondition("time = ", shoppingRecord.getTime()); 73 | ShoppingRecord oldShoppingRecord = findByCondition(condition).get(0); 74 | oldShoppingRecord.setOrderStatus(shoppingRecord.getOrderStatus()); 75 | update(oldShoppingRecord); 76 | return true; 77 | } catch (Exception e) { 78 | throw new CommonException("error.changeShoppingRecord"); 79 | } 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/imp/UserDetailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service.imp; 2 | 3 | import com.shopping.mall.core.AbstractService; 4 | import com.shopping.mall.core.CommonException; 5 | import com.shopping.mall.domain.UserDetail; 6 | import com.shopping.mall.service.UserDetailService; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | 11 | 12 | @Service 13 | @Transactional(rollbackFor = CommonException.class) 14 | public class UserDetailServiceImpl extends AbstractService implements UserDetailService { 15 | 16 | @Override 17 | public UserDetail add(UserDetail userDetail) { 18 | try { 19 | save(userDetail); 20 | return userDetail; 21 | } catch (Exception e) { 22 | throw new CommonException("error.add"); 23 | } 24 | } 25 | 26 | @Override 27 | public Boolean delete(Integer id) { 28 | try { 29 | return deleteById(id) == 1; 30 | } catch (Exception e) { 31 | throw new CommonException("error.delete"); 32 | } 33 | } 34 | 35 | @Override 36 | public UserDetail updateUserDetail(UserDetail userDetail) { 37 | try { 38 | update(userDetail); 39 | return userDetail; 40 | } catch (Exception e) { 41 | throw new CommonException("error.updateUserDetail"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/shopping/mall/service/imp/UserMainServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shopping.mall.service.imp; 2 | 3 | 4 | import com.shopping.mall.core.AbstractService; 5 | import com.shopping.mall.core.CommonException; 6 | import com.shopping.mall.domain.ShoppingCar; 7 | import com.shopping.mall.domain.UserDetail; 8 | import com.shopping.mall.domain.UserDto; 9 | import com.shopping.mall.domain.UserMain; 10 | import com.shopping.mall.service.UserDetailService; 11 | import com.shopping.mall.service.UserMainService; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.transaction.annotation.Transactional; 14 | import tk.mybatis.mapper.entity.Condition; 15 | 16 | import javax.servlet.http.HttpSession; 17 | import java.text.SimpleDateFormat; 18 | import java.util.Date; 19 | 20 | 21 | @Service 22 | @Transactional(rollbackFor = CommonException.class) 23 | public class UserMainServiceImpl extends AbstractService implements UserMainService { 24 | 25 | private UserDetailService userDetailService; 26 | 27 | public UserMainServiceImpl(UserDetailService userDetailService) { 28 | this.userDetailService = userDetailService; 29 | } 30 | 31 | @Override 32 | public String doLogin(UserMain userMain, HttpSession session) { 33 | Condition condition = new Condition(ShoppingCar.class); 34 | condition.createCriteria().andCondition(" name = '" + userMain.getUserNameOrEmail() + "' or email = '" + userMain.getUserNameOrEmail() + "'"); 35 | UserMain user = findByCondition(condition).get(0); 36 | if (user == null) { 37 | return "unexist"; 38 | } else { 39 | UserDetail userDetail = userDetailService.findById(user.getId()); 40 | if (userDetail.getPassword().equals(userMain.getPassword())) { 41 | session.setAttribute("currentUser", user); 42 | return "success"; 43 | } else { 44 | return "wrong"; 45 | } 46 | } 47 | } 48 | 49 | @Override 50 | public String doRegister(UserDto userDto) { 51 | try { 52 | UserMain user = findBy("name", userDto.getUserName()); 53 | if (user != null) { 54 | return "nameExist"; 55 | } else { 56 | user = findBy("email", userDto.getEmail()); 57 | if (user != null) { 58 | return "emailExist"; 59 | } else { 60 | UserMain user1 = new UserMain(); 61 | user1.setName(userDto.getUserName()); 62 | user1.setEmail(userDto.getEmail()); 63 | user1.setNickName(userDto.getNickName()); 64 | user1.setRole(0); 65 | save(user1); 66 | user1 = findBy("name", userDto.getUserName()); 67 | UserDetail userDetail = new UserDetail(); 68 | userDetail.setId(user1.getId()); 69 | userDetail.setAddress(userDto.getAddress()); 70 | userDetail.setBirthday(userDto.getBirthday()); 71 | userDetail.setPassword(userDto.getPassword()); 72 | userDetail.setPhoneNumber(userDto.getPhoneNumber()); 73 | userDetail.setSex(userDto.getSex()); 74 | userDetail.setPostNumber(userDto.getPostNumber()); 75 | Date date = new Date(); 76 | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 77 | userDetail.setRegisterTime(sf.format(date)); 78 | userDetailService.save(userDetail); 79 | return "success"; 80 | } 81 | } 82 | } catch (Exception e) { 83 | throw new CommonException("error.doRegister"); 84 | } 85 | } 86 | 87 | @Override 88 | public Boolean doUpdate(UserDto userDto) { 89 | try { 90 | UserMain user = findBy("name", userDto.getUserName()); 91 | user.setEmail(userDto.getEmail()); 92 | user.setNickName(userDto.getNickName()); 93 | update(user); 94 | UserDetail userDetail = userDetailService.findById(user.getId()); 95 | userDetail.setAddress(userDto.getAddress()); 96 | userDetail.setBirthday(userDto.getBirthday()); 97 | userDetail.setPassword(userDto.getPassword()); 98 | userDetail.setPhoneNumber(userDto.getPhoneNumber()); 99 | userDetail.setSex(userDto.getSex()); 100 | userDetail.setPostNumber(userDto.getPostNumber()); 101 | userDetailService.update(userDetail); 102 | return true; 103 | } catch (Exception e) { 104 | throw new CommonException("error.doRegister"); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/amend_info.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |

修改个人信息

30 |
31 |
32 | 33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 |
46 |
47 | 48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 | 60 |
61 | 62 |
63 |
64 |
65 | 66 |
67 | 70 | 73 |
74 |
75 |
76 | 77 |
78 | 79 |
80 |
81 |
82 | 83 |
84 | 85 |
86 |
87 |
88 | 89 |
90 | 91 |
92 |
93 |
94 |
95 | 96 |
97 |
98 |
99 |
100 |
101 |
102 | 103 | 104 | 105 | 219 | 220 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/control.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
32 | 33 | 41 | 42 |
43 |
44 |
45 |

用户信息

46 |
47 | 48 |
49 |
50 | 51 |
52 |
53 |

商品信息

54 |
55 |
56 |
57 |
58 | 59 |
60 |
61 |

添加商品

62 |
63 |
64 | 65 |
66 |
67 | 68 |
69 | 70 |
71 |
72 |
73 | 74 |
75 | 77 |
78 |
79 |
80 | 81 |
82 | 83 |
84 |
85 |
86 | 87 |
88 | 89 |
90 |
91 |
92 | 93 |
94 | 95 |
96 |
97 |
98 | 99 |
100 | 109 |
110 |
111 |
112 | 113 |
114 | 115 |

上传的图片大小应为280*160大小

116 |
117 | <%----%> 118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | 128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | 138 | 139 | 140 | 141 | 317 | 318 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/include/foot.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 20 | 21 | 22 | 23 |
24 |
25 | 本项目采用了SpringBoot+SpringMVC+Mybatis开发框架,前端使用了Bootstrap开发框架 26 |
27 | 数据库使用了MySQL 28 |
29 | 本项目作者为陈钦锋,如果对此有任何疑问或者建议,请联系管理员 30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/include/header.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 校园购物平台 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 78 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |

登录

31 |
32 |
33 | 34 |
35 |
36 | 37 |
38 | 39 |
40 |
41 |
42 | 43 |
44 | 45 |
46 |
47 |
48 |
49 | 50 |
51 |
52 |
53 |
54 |
55 |
56 | 57 | 58 | 59 | 60 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/main.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 | 30 | 42 | 43 |
44 |
45 |

欢迎来到校园购物平台

46 |

校园购物平台是一个非常优秀的购物网站,你可以在这里买到物美价廉的东西

47 |
48 | 49 |
50 |
51 | 52 |
53 |
54 | 55 |
56 |
57 | 58 |
59 |
60 | 61 |
62 |
63 | 64 |
65 |
66 | 67 |
68 |
69 | 70 | 71 |
72 |
73 | 74 |
75 |
76 |
77 | 78 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/register.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |

注册

30 |
31 |
32 | 33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 |
46 |
47 | 48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 | 60 |
61 | 62 |
63 |
64 |
65 | 66 |
67 | 70 | 73 |
74 |
75 |
76 | 77 |
78 | 79 |
80 |
81 |
82 | 83 |
84 | 85 |
86 |
87 |
88 | 89 |
90 | 91 |
92 |
93 |
94 |
95 | 96 |
97 |
98 |
99 |
100 |
101 |
102 | 103 | 104 | 105 | 176 | 177 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/search.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 搜索结果 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 |
32 |
33 | 34 |
35 | 36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 121 | 122 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/views/shopping_car.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %> 2 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 校园购物平台 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 |
32 |

欢迎来到购物车

33 |

查看您的购物清单

34 |
35 |
36 |
37 | 38 |
39 | 40 |
41 |
42 |
43 | 46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 | 298 | 299 | -------------------------------------------------------------------------------- /src/main/resources/application-default.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: springboot-mybatis-mall 4 | profiles: 5 | active: dev 6 | mvc: 7 | view: 8 | # 页面默认前缀目录 9 | prefix: /WEB-INF/views/ 10 | # 响应页面默认后缀 11 | suffix: .jsp 12 | freemarker: 13 | cache: false 14 | request-context-attribute: request 15 | checkTemplateLocation: false 16 | http: 17 | multipart: 18 | max-file-size: 200MB 19 | max-request-size: 2500MB 20 | datasource: 21 | url: jdbc:mysql://127.0.0.1:13306/shopping?useUnicode=true&characterEncoding=utf-8&useSSL=false 22 | username: root 23 | password: root 24 | driver-class-name: com.mysql.jdbc.Driver 25 | type: com.zaxxer.hikari.HikariDataSource 26 | server: 27 | port: 8086 28 | #日志级别 29 | logging: 30 | level.com.shopping.mall: DEBUG 31 | mybatis: 32 | mapperLocations: classpath*:mapper/*.xml 33 | type-aliases-package: com.shopping.mall 34 | configuration: 35 | mapUnderscoreToCamelCase: true 36 | use-generated-keys: true 37 | default-fetch-size: 100 38 | default-statement-timeout: 30 39 | check-config-location: true 40 | mapper: 41 | mappers: com.shopping.mall.core.Mapper 42 | not-empty: false 43 | identity: MYSQL 44 | pagehelper: 45 | helperDialect: mysql 46 | reasonable: true 47 | supportMethodsArguments: true 48 | params: count=countSql 49 | management: 50 | security: 51 | enabled: false 52 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ${AnsiColor.BLUE} 2 | /$$$$$$ /$$ /$$ /$$ /$$ 3 | /$$__ $$| $$ |__/ | $$| $$ 4 | | $$ \__/| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$/$$$$ /$$$$$$ | $$| $$ 5 | | $$$$$$ | $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$| $$| $$__ $$ /$$__ $$ | $$_ $$_ $$ |____ $$| $$| $$ 6 | \____ $$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$| $$| $$ \ $$| $$ \ $$ | $$ \ $$ \ $$ /$$$$$$$| $$| $$ 7 | /$$ \ $$| $$ | $$| $$ | $$| $$ | $$| $$ | $$| $$| $$ | $$| $$ | $$ | $$ | $$ | $$ /$$__ $$| $$| $$ 8 | | $$$$$$/| $$ | $$| $$$$$$/| $$$$$$$/| $$$$$$$/| $$| $$ | $$| $$$$$$$ | $$ | $$ | $$| $$$$$$$| $$| $$ 9 | \______/ |__/ |__/ \______/ | $$____/ | $$____/ |__/|__/ |__/ \____ $$ |__/ |__/ |__/ \_______/|__/|__/ 10 | | $$ | $$ /$$ \ $$ 11 | | $$ | $$ | $$$$$$/ 12 | |__/ |__/ \______/ 13 | -------------------------------------------------------------------------------- /src/main/resources/db/shopping.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : IDEA 5 | Source Server Version : 50717 6 | Source Host : localhost:3306 7 | Source Database : shopping 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50717 11 | File Encoding : 65001 12 | 13 | Date: 2018-02-07 11:57:43 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for evaluation 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `evaluation`; 22 | CREATE TABLE `evaluation` ( 23 | `user_id` int(11) NOT NULL, 24 | `product_id` int(11) NOT NULL, 25 | `time` varchar(20) NOT NULL, 26 | `content` varchar(1000) NOT NULL, 27 | PRIMARY KEY (`user_id`,`time`,`product_id`), 28 | KEY `evaluation_ibfk_2` (`product_id`), 29 | CONSTRAINT `evaluation_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user_main` (`id`), 30 | CONSTRAINT `evaluation_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) 31 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of evaluation 35 | -- ---------------------------- 36 | 37 | -- ---------------------------- 38 | -- Table structure for products 39 | -- ---------------------------- 40 | DROP TABLE IF EXISTS `products`; 41 | CREATE TABLE `products` ( 42 | `id` int(11) NOT NULL AUTO_INCREMENT, 43 | `name` varchar(50) NOT NULL, 44 | `description` varchar(1000) NOT NULL, 45 | `key_word` varchar(1000) NOT NULL, 46 | `price` int(11) NOT NULL, 47 | `counts` int(11) NOT NULL, 48 | `type` varchar(11) NOT NULL, 49 | PRIMARY KEY (`id`), 50 | UNIQUE KEY `name` (`name`) 51 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 52 | 53 | -- ---------------------------- 54 | -- Records of products 55 | -- ---------------------------- 56 | 57 | -- ---------------------------- 58 | -- Table structure for shopping_car 59 | -- ---------------------------- 60 | DROP TABLE IF EXISTS `shopping_car`; 61 | CREATE TABLE `shopping_car` ( 62 | `user_id` int(11) NOT NULL, 63 | `product_id` int(11) NOT NULL, 64 | `product_price` int(11) NOT NULL, 65 | `counts` int(11) NOT NULL, 66 | PRIMARY KEY (`user_id`,`product_id`), 67 | KEY `shopping_car_ibfk_2` (`product_id`), 68 | CONSTRAINT `shopping_car_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user_main` (`id`), 69 | CONSTRAINT `shopping_car_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) 70 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 71 | 72 | -- ---------------------------- 73 | -- Records of shopping_car 74 | -- ---------------------------- 75 | 76 | -- ---------------------------- 77 | -- Table structure for shopping_record 78 | -- ---------------------------- 79 | DROP TABLE IF EXISTS `shopping_record`; 80 | CREATE TABLE `shopping_record` ( 81 | `user_id` int(11) NOT NULL, 82 | `product_id` int(11) NOT NULL, 83 | `time` varchar(20) NOT NULL, 84 | `order_status` int(11) NOT NULL, 85 | `product_price` int(11) NOT NULL, 86 | `counts` int(11) NOT NULL, 87 | PRIMARY KEY (`user_id`,`product_id`,`time`), 88 | KEY `shopping_record_ibfk_2` (`product_id`), 89 | CONSTRAINT `shopping_record_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user_main` (`id`), 90 | CONSTRAINT `shopping_record_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) 91 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 92 | 93 | -- ---------------------------- 94 | -- Records of shopping_record 95 | -- ---------------------------- 96 | 97 | -- ---------------------------- 98 | -- Table structure for user_detail 99 | -- ---------------------------- 100 | DROP TABLE IF EXISTS `user_detail`; 101 | CREATE TABLE `user_detail` ( 102 | `id` int(11) NOT NULL AUTO_INCREMENT, 103 | `password` varchar(20) NOT NULL, 104 | `phone_number` varchar(20) NOT NULL, 105 | `sex` int(11) NOT NULL, 106 | `birthday` varchar(20) NOT NULL, 107 | `post_number` varchar(10) NOT NULL, 108 | `address` varchar(50) NOT NULL, 109 | `register_time` varchar(20) NOT NULL, 110 | PRIMARY KEY (`id`), 111 | CONSTRAINT `user_detail_ibfk_1` FOREIGN KEY (`id`) REFERENCES `user_main` (`id`) 112 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 113 | 114 | -- ---------------------------- 115 | -- Records of user_detail 116 | -- ---------------------------- 117 | 118 | -- ---------------------------- 119 | -- Table structure for user_main 120 | -- ---------------------------- 121 | DROP TABLE IF EXISTS `user_main`; 122 | CREATE TABLE `user_main` ( 123 | `id` int(11) NOT NULL AUTO_INCREMENT, 124 | `name` varchar(30) NOT NULL, 125 | `email` varchar(50) NOT NULL, 126 | `nick_name` varchar(30) NOT NULL, 127 | `role` int(11) NOT NULL, 128 | PRIMARY KEY (`id`), 129 | UNIQUE KEY `name` (`name`), 130 | UNIQUE KEY `email` (`email`) 131 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 132 | 133 | -- ---------------------------- 134 | -- Records of user_main 135 | -- ---------------------------- 136 | -------------------------------------------------------------------------------- /src/main/resources/mapper/EvaluationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ProductsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ShoppingCarMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ShoppingRecordMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserDetailMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserMainMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/static/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | font-family: "Microsoft YaHei"; 4 | } 5 | div:hover { 6 | text-decoration: none; 7 | } 8 | .table th, .table td { 9 | text-align: center; 10 | vertical-align: middle!important; 11 | } 12 | 13 | .navbar-fixed-top { 14 | border: 0; 15 | } 16 | .sidebar { 17 | display: none; 18 | } 19 | @media (min-width: 768px) { 20 | .sidebar { 21 | position: fixed; 22 | top: 51px; 23 | bottom: 0; 24 | left: 0; 25 | z-index: 1000; 26 | display: block; 27 | padding: 20px; 28 | overflow-x: hidden; 29 | overflow-y: auto; 30 | background-color: #f5f5f5; 31 | border-right: 1px solid #eee; 32 | } 33 | } 34 | 35 | .nav-sidebar { 36 | margin-right: -21px; 37 | margin-bottom: 20px; 38 | margin-left: -20px; 39 | } 40 | .nav-sidebar > li > a { 41 | padding-right: 20px; 42 | padding-left: 20px; 43 | } 44 | .nav-sidebar > .active > a, 45 | .nav-sidebar > .active > a:hover, 46 | .nav-sidebar > .active > a:focus { 47 | color: #fff; 48 | background-color: #428bca; 49 | } 50 | 51 | .main { 52 | padding: 20px; 53 | } 54 | @media (min-width: 768px) { 55 | .main { 56 | padding-right: 40px; 57 | padding-left: 40px; 58 | } 59 | } 60 | 61 | 62 | 63 | .sidebar-1 { 64 | height: 100%; 65 | } 66 | .big { 67 | width: 280px; 68 | height: 160px; 69 | overflow: hidden; 70 | position: relative; 71 | text-align: center; 72 | cursor: pointer; 73 | } 74 | .big img { 75 | display:block; 76 | position: relative; 77 | } 78 | .bigimg img { 79 | opacity:1; 80 | -moz-transform:scale(1, 1); 81 | -webkit-transform:scale(1, 1); 82 | -o-transform:scale(1, 1); 83 | -ms-transform:scale(1, 1); 84 | transform:scale(1, 1); 85 | -webkit-transition: all 0.4s ease-in; 86 | -moz-transition: all 0.4s ease-in; 87 | -o-transition: all 0.4s ease-in; 88 | -ms-transition: all 0.4s ease-in; 89 | transition: all 0.4s ease-in; 90 | } 91 | .bigimg:hover img { 92 | opacity:1; 93 | -moz-transform:scale(1.2, 1.2); 94 | -webkit-transform:scale(1.2, 1.2); 95 | -o-transform:scale(1.2, 1.2); 96 | -ms-transform:scale(1.2, 1.2); 97 | transform:scale(1.2, 1.2); 98 | } 99 | .boxes { 100 | width:280px; 101 | height:245px; 102 | background-color:#f5f5f5; 103 | border:none; 104 | overflow:hidden; 105 | z-index:10 106 | } 107 | .foot-style { 108 | text-align: center; 109 | font-size: 14px; 110 | } 111 | .margin-t { 112 | margin-top: 30px; 113 | } 114 | .pd-10 { 115 | padding-top: 30px; 116 | } 117 | 118 | .center { 119 | text-align: center; 120 | } 121 | .margin-l { 122 | margin-left: 8%; 123 | } 124 | .big-button { 125 | margin-left: 10px; 126 | } 127 | .detail-img { 128 | width: 100%; 129 | } 130 | .detail-x { 131 | font-size: 18px; 132 | } 133 | .pd-5 { 134 | padding-top: 30px; 135 | } 136 | .pointer:hover { 137 | cursor: pointer; 138 | } 139 | .confirm-margin { 140 | margin-top: 10px; 141 | } 142 | .bigHead { 143 | padding-top: 10px; 144 | } 145 | .product-name { 146 | text-align: center; 147 | font-size: 20px; 148 | padding-top: 10px; 149 | } 150 | .product-price { 151 | text-align: center; 152 | color: #b92c28; 153 | font-size: 24px; 154 | padding-bottom: 5px; 155 | } 156 | .delete-button { 157 | margin-left: 36px; 158 | } 159 | 160 | .search-padding{ 161 | padding-left: 5%; 162 | padding-right: 5%; 163 | padding-top:15px; 164 | padding-bottom:15px; 165 | } 166 | 167 | .list-group-item-diy{ 168 | color: #555555; 169 | text-align: center; 170 | } 171 | .list-group-item-diy a,.list-group-item-diy a:hover,.list-group-item-diy a:visited{ 172 | color: #555555; 173 | } 174 | 175 | .division { 176 | padding-top: 15px; 177 | padding-bottom: 15px; 178 | } 179 | 180 | .evaluationTable td{ 181 | text-align: left; 182 | } 183 | 184 | .evaluationButton { 185 | padding-top: 10px; 186 | } -------------------------------------------------------------------------------- /src/main/resources/static/img/37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/37.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/39.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/40.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/41.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/42.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/43.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/44.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/44.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/45.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/45.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/46.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/46.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/47.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/47.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/48.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/48.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/49.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/49.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/50.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/51.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/51.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/52.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/52.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/53.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/53.jpg -------------------------------------------------------------------------------- /src/main/resources/static/img/54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dinghuang/springboot-mybatis-mall/d4505c71ae97ca9a94ef64b0bbce4203c3725f04/src/main/resources/static/img/54.jpg -------------------------------------------------------------------------------- /src/main/resources/static/js/ajaxfileupload.js: -------------------------------------------------------------------------------- 1 | // JavaScript Document 2 | jQuery.extend({ 3 | 4 | createUploadIframe: function(id, uri) 5 | { 6 | //create frame 7 | var frameId = 'jUploadFrame' + id; 8 | 9 | if(window.ActiveXObject) { 10 | var io = document.createElement('