├── src └── main │ ├── webapp │ ├── index.jsp │ └── WEB-INF │ │ ├── web.xml │ │ └── dispatcher-servlet.xml │ ├── resources │ ├── mmall.properties │ ├── datasource.properties │ ├── applicationContext.xml │ ├── logback.xml │ ├── applicationContext-datasource.xml │ ├── mappers │ │ ├── CartMapper.xml │ │ ├── CategoryMapper.xml │ │ ├── PayInfoMapper.xml │ │ ├── OrderItemMapper.xml │ │ ├── ProductMapper.xml │ │ ├── UserMapper.xml │ │ ├── ShippingMapper.xml │ │ └── OrderMapper.xml │ └── generatorConfig.xml │ └── java │ └── com │ └── mmall │ ├── dao │ ├── CartMapper.java │ ├── OrderMapper.java │ ├── PayInfoMapper.java │ ├── ProductMapper.java │ ├── ShippingMapper.java │ ├── OrderItemMapper.java │ ├── CategoryMapper.java │ └── UserMapper.java │ ├── common │ ├── Const.java │ ├── ResponseCode.java │ ├── TokenCache.java │ └── ServerResponse.java │ ├── service │ ├── ProductService.java │ ├── CategoryService.java │ ├── UserService.java │ └── impl │ │ ├── ProductServiceImpl.java │ │ ├── CategoryServiceImpl.java │ │ └── UserServiceImpl.java │ ├── util │ ├── BigDecimalUtil.java │ ├── PropertiesUtil.java │ ├── DateTimeUtil.java │ ├── MD5Util.java │ └── FTPUtil.java │ ├── controller │ ├── backend │ │ ├── UserManagerController.java │ │ ├── ProductManageController.java │ │ └── CategoryManageController.java │ └── portal │ │ └── UserController.java │ └── pojo │ ├── Cart.java │ ├── Category.java │ ├── PayInfo.java │ ├── User.java │ ├── OrderItem.java │ ├── Product.java │ ├── Order.java │ └── Shipping.java ├── lib └── mysql-connector-java-5.1.13-bin.jar ├── README.md ├── .gitignore ├── pom.xml └── sqlScript └── mmall.sql /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/mysql-connector-java-5.1.13-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5zhu/ssm/HEAD/lib/mysql-connector-java-5.1.13-bin.jar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SSM Demo 2 |   3 | ## 技术选型 4 | -  Spring MVC 5 | -  MyBatis 6 | - logback 7 | - guava 8 | - pagehelper 9 | - jedis 10 |   11 | -------------------------------------------------------------------------------- /src/main/resources/mmall.properties: -------------------------------------------------------------------------------- 1 | 2 | ftp.server.ip=你的FTP服务器ip地址 3 | ftp.user=mmallftp 4 | ftp.pass=ftppassword 5 | ftp.server.http.prefix=http://img.happymmall.com/ 6 | 7 | 8 | alipay.callback.url=http://www.happymmall.com/order/alipay_callback.do 9 | 10 | password.salt = sdafaqj23ou89ZXcj@#$@#$#@KJdjklj;D../dSF., 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | #package 4 | *.war 5 | *.ear 6 | 7 | *.orig 8 | 9 | target/ 10 | 11 | .settings/ 12 | .project 13 | .classpatch 14 | 15 | .idea/ 16 | /idea/ 17 | *.ipr 18 | *.iml 19 | *.iws 20 | 21 | # temp file 22 | *.log 23 | *.cache 24 | *.diff 25 | *.patch 26 | *.tmp 27 | 28 | .DS_Store 29 | Thumbs.db 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/CartMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Cart; 4 | 5 | public interface CartMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(Cart record); 9 | 10 | int insertSelective(Cart record); 11 | 12 | Cart selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(Cart record); 15 | 16 | int updateByPrimaryKey(Cart record); 17 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/Const.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | public class Const { 4 | 5 | public static final String CURRENT_USER = "currentUser"; 6 | 7 | public static final String USERNAME = "username"; 8 | 9 | public static final String EMAIL = "email"; 10 | 11 | //角色 12 | public interface Role{ 13 | int ROLE_CUSTOMER = 0; //普通用户 14 | int ROLE_ADMIN = 1; //管理员 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Order; 4 | 5 | public interface OrderMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(Order record); 9 | 10 | int insertSelective(Order record); 11 | 12 | Order selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(Order record); 15 | 16 | int updateByPrimaryKey(Order record); 17 | } -------------------------------------------------------------------------------- /src/main/resources/datasource.properties: -------------------------------------------------------------------------------- 1 | db.driverLocation=lib/mysql-connector-java-5.1.13-bin.jar 2 | db.driverClassName=com.mysql.jdbc.Driver 3 | db.url=jdbc:mysql://127.0.0.1:3306/mmall?characterEncoding=utf-8 4 | db.username=root 5 | db.password=123456 6 | 7 | 8 | db.initialSize = 20 9 | db.maxActive = 50 10 | db.maxIdle = 20 11 | db.minIdle = 10 12 | db.maxWait = 10 13 | db.defaultAutoCommit = true 14 | db.minEvictableIdleTimeMillis = 3600000 15 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/PayInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.PayInfo; 4 | 5 | public interface PayInfoMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(PayInfo record); 9 | 10 | int insertSelective(PayInfo record); 11 | 12 | PayInfo selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(PayInfo record); 15 | 16 | int updateByPrimaryKey(PayInfo record); 17 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Product; 4 | 5 | public interface ProductMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(Product record); 9 | 10 | int insertSelective(Product record); 11 | 12 | Product selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(Product record); 15 | 16 | int updateByPrimaryKey(Product record); 17 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/ShippingMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Shipping; 4 | 5 | public interface ShippingMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(Shipping record); 9 | 10 | int insertSelective(Shipping record); 11 | 12 | Shipping selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(Shipping record); 15 | 16 | int updateByPrimaryKey(Shipping record); 17 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/OrderItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.OrderItem; 4 | 5 | public interface OrderItemMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(OrderItem record); 9 | 10 | int insertSelective(OrderItem record); 11 | 12 | OrderItem selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(OrderItem record); 15 | 16 | int updateByPrimaryKey(OrderItem record); 17 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.pojo.Product; 5 | 6 | /** 7 | * 商品service接口 8 | */ 9 | public interface ProductService { 10 | 11 | /** 12 | * 新增或更新产品 13 | * @param product 14 | * @return 15 | */ 16 | ServerResponse saveOrUpdateProduct(Product product); 17 | 18 | /** 19 | * 更新产品销售状态 20 | * @param productId 21 | * @return 22 | */ 23 | ServerResponse setSaleStatus(Integer productId, Integer status); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | public enum ResponseCode { 4 | 5 | SUCCESS(0, "SUCCESS"), 6 | ERROR(1, "ERROR"), 7 | NEED_LOGIN(10, "NEED_LOGIN"), 8 | ILLEGAL_ARGUMENT(2, "ILLEGAL_ARGUMENT"); 9 | 10 | private final int code; 11 | 12 | private final String desc; 13 | 14 | ResponseCode(int code, String desc) { 15 | this.code = code; 16 | this.desc = desc; 17 | } 18 | 19 | 20 | public int getCode() { 21 | return code; 22 | } 23 | 24 | public String getDesc() { 25 | return desc; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/CategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.pojo.Category; 5 | 6 | import java.util.List; 7 | 8 | public interface CategoryMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(Category record); 12 | 13 | int insertSelective(Category record); 14 | 15 | Category selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(Category record); 18 | 19 | int updateByPrimaryKey(Category record); 20 | 21 | List selectCategoryChildrenByParentId(Integer parent_id); 22 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.pojo.Category; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * CategoryService接口 11 | */ 12 | public interface CategoryService { 13 | 14 | /** 15 | * 添加category 16 | * @param categoryName 17 | * @param parentId 18 | * @return 19 | */ 20 | ServerResponse addCategory(String categoryName, Integer parentId); 21 | 22 | /** 23 | * 更新category 的名称 24 | * @param categoryId 25 | * @param categoryName 26 | * @return 27 | */ 28 | ServerResponse updateCategory(Integer categoryId, String categoryName); 29 | 30 | 31 | /** 32 | * 查询子节点,不递归 33 | * @param categoryId 34 | * @return 35 | */ 36 | ServerResponse> getChildrenParallelCategory(Integer categoryId); 37 | 38 | /** 39 | * 递归查询子节点 40 | * @param categoryId 41 | * @return 42 | */ 43 | ServerResponse getCategoryAndChildrenById(Integer categoryId); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.User; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface UserMapper { 7 | int deleteByPrimaryKey(Integer id); 8 | 9 | int insert(User record); 10 | 11 | int insertSelective(User record); 12 | 13 | User selectByPrimaryKey(Integer id); 14 | 15 | int updateByPrimaryKeySelective(User record); 16 | 17 | int updateByPrimaryKey(User record); 18 | 19 | int checkUsername(String username); 20 | 21 | User selectLogin(@Param("username") String username, @Param("password") String password); 22 | 23 | int checkEmail(String email); 24 | 25 | String selectQuestionByUsername(String username); 26 | 27 | int checkAnswer(@Param("username") String username, 28 | @Param("question") String question, 29 | @Param("answer") String answer); 30 | 31 | int updatePasswordByUsername(@Param("username") String username, @Param("md5Password")String md5Password); 32 | 33 | int checkPassword(@Param(value = "password") String password, @Param(value = "userId") Integer userId); 34 | 35 | int checkEmailByUserId(@Param("email") String email, @Param("userId") Integer id); 36 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/BigDecimalUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * Created by gegf 7 | */ 8 | public class BigDecimalUtil { 9 | 10 | private BigDecimalUtil(){ 11 | 12 | } 13 | 14 | 15 | public static BigDecimal add(double v1,double v2){ 16 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 17 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 18 | return b1.add(b2); 19 | } 20 | 21 | public static BigDecimal sub(double v1,double v2){ 22 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 23 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 24 | return b1.subtract(b2); 25 | } 26 | 27 | 28 | public static BigDecimal mul(double v1,double v2){ 29 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 30 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 31 | return b1.multiply(b2); 32 | } 33 | 34 | public static BigDecimal div(double v1,double v2){ 35 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 36 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 37 | return b1.divide(b2,2,BigDecimal.ROUND_HALF_UP);//四舍五入,保留2位小数 38 | 39 | //除不尽的情况 40 | } 41 | 42 | 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/PropertiesUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.util.Properties; 10 | 11 | /** 12 | * Created by gegf 13 | */ 14 | public class PropertiesUtil { 15 | 16 | private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class); 17 | 18 | private static Properties props; 19 | 20 | static { 21 | String fileName = "mmall.properties"; 22 | props = new Properties(); 23 | try { 24 | props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName),"UTF-8")); 25 | } catch (IOException e) { 26 | logger.error("配置文件读取异常",e); 27 | } 28 | } 29 | 30 | public static String getProperty(String key){ 31 | String value = props.getProperty(key.trim()); 32 | if(StringUtils.isBlank(value)){ 33 | return null; 34 | } 35 | return value.trim(); 36 | } 37 | 38 | public static String getProperty(String key,String defaultValue){ 39 | 40 | String value = props.getProperty(key.trim()); 41 | if(StringUtils.isBlank(value)){ 42 | value = defaultValue; 43 | } 44 | return value.trim(); 45 | } 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/TokenCache.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | import com.google.common.cache.CacheBuilder; 4 | import com.google.common.cache.CacheLoader; 5 | import com.google.common.cache.LoadingCache; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.concurrent.TimeUnit; 10 | 11 | public class TokenCache { 12 | 13 | private static Logger logger = LoggerFactory.getLogger(TokenCache.class); 14 | 15 | public static final String TOKEN_PREFIX = "token_"; 16 | 17 | private static LoadingCache localCache = CacheBuilder 18 | .newBuilder() 19 | .initialCapacity(1000) 20 | .maximumSize(10000).expireAfterAccess(12, TimeUnit.HOURS) 21 | .build(new CacheLoader() { 22 | @Override 23 | public String load(String s) throws Exception { 24 | return "null"; 25 | } 26 | }); 27 | 28 | public static void setKey(String key, String value){ 29 | localCache.put(key, value); 30 | } 31 | 32 | public static String getKey(String key){ 33 | String value = null; 34 | try { 35 | value = localCache.get(key); 36 | if ("null".equals(value)) { 37 | return null; 38 | } 39 | return value; 40 | }catch (Exception e){ 41 | logger.error("localCache get error", e); 42 | } 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/UserManagerController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.pojo.User; 6 | import com.mmall.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import javax.servlet.http.HttpSession; 14 | 15 | @Controller 16 | @RequestMapping("/manager/user") 17 | public class UserManagerController { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | /** 23 | * 管理员登陆 24 | * @param username 25 | * @param password 26 | * @param session 27 | * @return 28 | */ 29 | @ResponseBody 30 | @RequestMapping(value = "login.do", method = RequestMethod.POST) 31 | public ServerResponse login(String username, String password, HttpSession session){ 32 | ServerResponse response = userService.login(username, password); 33 | if(response.isSuccess()){ 34 | User user = response.getData(); 35 | if (user.getRole() == Const.Role.ROLE_ADMIN){ 36 | session.setAttribute(Const.CURRENT_USER, user); 37 | return response; 38 | }else{ 39 | return ServerResponse.createByErrorMessage("不是管理员,无法登陆"); 40 | } 41 | 42 | } 43 | return response; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Archetype Created Web Application 8 | 9 | 10 | characterEncodingFilter 11 | org.springframework.web.filter.CharacterEncodingFilter 12 | 13 | encoding 14 | UTF-8 15 | 16 | 17 | forceEncoding 18 | true 19 | 20 | 21 | 22 | characterEncodingFilter 23 | /* 24 | 25 | 26 | 27 | 28 | org.springframework.web.context.request.RequestContextListener 29 | 30 | 31 | 32 | org.springframework.web.context.ContextLoaderListener 33 | 34 | 35 | contextConfigLocation 36 | 37 | classpath:applicationContext.xml 38 | 39 | 40 | 41 | 42 | dispatcher 43 | org.springframework.web.servlet.DispatcherServlet 44 | 1 45 | 46 | 47 | 48 | 49 | 50 | dispatcher 51 | *.do 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/DateTimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.joda.time.DateTime; 5 | import org.joda.time.format.DateTimeFormat; 6 | import org.joda.time.format.DateTimeFormatter; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by gegf 12 | */ 13 | public class DateTimeUtil { 14 | 15 | //joda-time 16 | 17 | //str->Date 18 | //Date->str 19 | public static final String STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss"; 20 | 21 | 22 | 23 | public static Date strToDate(String dateTimeStr,String formatStr){ 24 | DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(formatStr); 25 | DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); 26 | return dateTime.toDate(); 27 | } 28 | 29 | public static String dateToStr(Date date,String formatStr){ 30 | if(date == null){ 31 | return StringUtils.EMPTY; 32 | } 33 | DateTime dateTime = new DateTime(date); 34 | return dateTime.toString(formatStr); 35 | } 36 | 37 | public static Date strToDate(String dateTimeStr){ 38 | DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(STANDARD_FORMAT); 39 | DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); 40 | return dateTime.toDate(); 41 | } 42 | 43 | public static String dateToStr(Date date){ 44 | if(date == null){ 45 | return StringUtils.EMPTY; 46 | } 47 | DateTime dateTime = new DateTime(date); 48 | return dateTime.toString(STANDARD_FORMAT); 49 | } 50 | 51 | 52 | 53 | 54 | public static void main(String[] args) { 55 | System.out.println(DateTimeUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")); 56 | System.out.println(DateTimeUtil.strToDate("2010-01-01 11:11:11","yyyy-MM-dd HH:mm:ss")); 57 | 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.springframework.util.StringUtils; 4 | 5 | import java.security.MessageDigest; 6 | 7 | /** 8 | * Created by gegf 9 | */ 10 | public class MD5Util { 11 | 12 | private static String byteArrayToHexString(byte b[]) { 13 | StringBuffer resultSb = new StringBuffer(); 14 | for (int i = 0; i < b.length; i++) 15 | resultSb.append(byteToHexString(b[i])); 16 | 17 | return resultSb.toString(); 18 | } 19 | 20 | private static String byteToHexString(byte b) { 21 | int n = b; 22 | if (n < 0) 23 | n += 256; 24 | int d1 = n / 16; 25 | int d2 = n % 16; 26 | return hexDigits[d1] + hexDigits[d2]; 27 | } 28 | 29 | /** 30 | * 返回大写MD5 31 | * 32 | * @param origin 33 | * @param charsetname 34 | * @return 35 | */ 36 | private static String MD5Encode(String origin, String charsetname) { 37 | String resultString = null; 38 | try { 39 | resultString = new String(origin); 40 | MessageDigest md = MessageDigest.getInstance("MD5"); 41 | if (charsetname == null || "".equals(charsetname)) 42 | resultString = byteArrayToHexString(md.digest(resultString.getBytes())); 43 | else 44 | resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); 45 | } catch (Exception exception) { 46 | } 47 | return resultString.toUpperCase(); 48 | } 49 | 50 | public static String MD5EncodeUtf8(String origin) { 51 | origin = origin + PropertiesUtil.getProperty("password.salt", ""); 52 | return MD5Encode(origin, "utf-8"); 53 | } 54 | 55 | 56 | private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", 57 | "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.pojo.User; 5 | 6 | /** 7 | * Created by gegf 8 | */ 9 | public interface UserService { 10 | 11 | /** 12 | * 用户登录接口 13 | * @param username 14 | * @param password 15 | * @return 16 | */ 17 | public ServerResponse login(String username, String password); 18 | 19 | /** 20 | * 注册 21 | * @param user 22 | * @return 23 | */ 24 | public ServerResponse register(User user); 25 | 26 | /** 27 | * 校验参数 28 | * @param str 29 | * @param type 30 | * @return 31 | */ 32 | public ServerResponse checkValid(String str, String type); 33 | 34 | /** 35 | * 获取问题 36 | * @param username 37 | * @return 38 | */ 39 | public ServerResponse selectQuestion(String username); 40 | 41 | /** 42 | * 验证问题答案 43 | * @param username 44 | * @param question 45 | * @param answer 46 | * @return 47 | */ 48 | public ServerResponse checkAnswer(String username, String question, String answer); 49 | 50 | /** 51 | * 忘记密码-重置 52 | * @param username 53 | * @param passwordNew 54 | * @param forgetToken 55 | * @return 56 | */ 57 | ServerResponse forgetResetPassword(String username, String passwordNew, String forgetToken); 58 | 59 | /** 60 | * 登录用户重置密码 61 | * @param passwordOld 62 | * @param passwordNew 63 | * @param user 64 | * @return 65 | */ 66 | ServerResponse resetPassword(String passwordOld, String passwordNew, User user); 67 | 68 | /** 69 | * 修改用户信息 70 | * @param user 71 | * @return 72 | */ 73 | ServerResponse updateUserInformation(User user); 74 | 75 | /** 76 | * 获取用户信息 77 | * @param id 78 | * @return 79 | */ 80 | ServerResponse getInformation(Integer id); 81 | 82 | ServerResponse checkAdminRole(User user); 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Cart.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class Cart { 6 | private Integer id; 7 | 8 | private Integer userId; 9 | 10 | private Integer productId; 11 | 12 | private Integer quantity; 13 | 14 | private Integer checked; 15 | 16 | private Date createTime; 17 | 18 | private Date updateTime; 19 | 20 | public Cart(Integer id, Integer userId, Integer productId, Integer quantity, Integer checked, Date createTime, Date updateTime) { 21 | this.id = id; 22 | this.userId = userId; 23 | this.productId = productId; 24 | this.quantity = quantity; 25 | this.checked = checked; 26 | this.createTime = createTime; 27 | this.updateTime = updateTime; 28 | } 29 | 30 | public Cart() { 31 | super(); 32 | } 33 | 34 | public Integer getId() { 35 | return id; 36 | } 37 | 38 | public void setId(Integer id) { 39 | this.id = id; 40 | } 41 | 42 | public Integer getUserId() { 43 | return userId; 44 | } 45 | 46 | public void setUserId(Integer userId) { 47 | this.userId = userId; 48 | } 49 | 50 | public Integer getProductId() { 51 | return productId; 52 | } 53 | 54 | public void setProductId(Integer productId) { 55 | this.productId = productId; 56 | } 57 | 58 | public Integer getQuantity() { 59 | return quantity; 60 | } 61 | 62 | public void setQuantity(Integer quantity) { 63 | this.quantity = quantity; 64 | } 65 | 66 | public Integer getChecked() { 67 | return checked; 68 | } 69 | 70 | public void setChecked(Integer checked) { 71 | this.checked = checked; 72 | } 73 | 74 | public Date getCreateTime() { 75 | return createTime; 76 | } 77 | 78 | public void setCreateTime(Date createTime) { 79 | this.createTime = createTime; 80 | } 81 | 82 | public Date getUpdateTime() { 83 | return updateTime; 84 | } 85 | 86 | public void setUpdateTime(Date updateTime) { 87 | this.updateTime = updateTime; 88 | } 89 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | text/plain;charset=UTF-8 19 | text/html;charset=UTF-8 20 | 21 | 22 | 23 | 24 | 25 | 26 | application/json;charset=UTF-8 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | import com.mmall.common.ResponseCode; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.controller.backend.ProductManageController; 6 | import com.mmall.dao.ProductMapper; 7 | import com.mmall.pojo.Product; 8 | import com.mmall.service.ProductService; 9 | import org.apache.commons.lang.StringUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | @Service("productService") 14 | public class ProductServiceImpl implements ProductService { 15 | 16 | @Autowired 17 | private ProductMapper productMapper; 18 | 19 | @Override 20 | public ServerResponse saveOrUpdateProduct(Product product) { 21 | if(product != null){ 22 | if(StringUtils.isNotBlank(product.getSubImages())){ 23 | String[] subImageArray = product.getSubImages().split(","); 24 | if(subImageArray.length > 0){ 25 | product.setMainImage(subImageArray[0]); 26 | } 27 | } 28 | 29 | if(product.getId() != null){ 30 | int rowCount = productMapper.updateByPrimaryKey(product); 31 | if(rowCount > 0){ 32 | return ServerResponse.createBySuccessMessage("更新产品成功"); 33 | } 34 | return ServerResponse.createByErrorMessage("更新产品失败"); 35 | } 36 | }else{ 37 | int rowCount = productMapper.insert(product); 38 | if(rowCount > 0){ 39 | return ServerResponse.createBySuccessMessage("新增产品成功"); 40 | } 41 | return ServerResponse.createByErrorMessage("新增产品失败"); 42 | } 43 | return ServerResponse.createByErrorMessage("参数错误"); 44 | } 45 | 46 | @Override 47 | public ServerResponse setSaleStatus(Integer productId, Integer status) { 48 | if(productId ==null || status == null){ 49 | return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), 50 | ResponseCode.ILLEGAL_ARGUMENT.getDesc()); 51 | } 52 | Product product = new Product(); 53 | product.setId(productId); 54 | product.setStatus(status); 55 | int rowCount = productMapper.updateByPrimaryKey(product); 56 | if(rowCount > 0){ 57 | return ServerResponse.createBySuccessMessage("更新销售状态成功"); 58 | } 59 | return ServerResponse.createByErrorMessage("更新销售状态失败"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Category.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | import java.util.Objects; 5 | 6 | public class Category { 7 | private Integer id; 8 | 9 | private Integer parentId; 10 | 11 | private String name; 12 | 13 | private Boolean status; 14 | 15 | private Integer sortOrder; 16 | 17 | private Date createTime; 18 | 19 | private Date updateTime; 20 | 21 | public Category(Integer id, Integer parentId, String name, Boolean status, Integer sortOrder, Date createTime, Date updateTime) { 22 | this.id = id; 23 | this.parentId = parentId; 24 | this.name = name; 25 | this.status = status; 26 | this.sortOrder = sortOrder; 27 | this.createTime = createTime; 28 | this.updateTime = updateTime; 29 | } 30 | 31 | public Category() { 32 | super(); 33 | } 34 | 35 | public Integer getId() { 36 | return id; 37 | } 38 | 39 | public void setId(Integer id) { 40 | this.id = id; 41 | } 42 | 43 | public Integer getParentId() { 44 | return parentId; 45 | } 46 | 47 | public void setParentId(Integer parentId) { 48 | this.parentId = parentId; 49 | } 50 | 51 | public String getName() { 52 | return name; 53 | } 54 | 55 | public void setName(String name) { 56 | this.name = name == null ? null : name.trim(); 57 | } 58 | 59 | public Boolean getStatus() { 60 | return status; 61 | } 62 | 63 | public void setStatus(Boolean status) { 64 | this.status = status; 65 | } 66 | 67 | public Integer getSortOrder() { 68 | return sortOrder; 69 | } 70 | 71 | public void setSortOrder(Integer sortOrder) { 72 | this.sortOrder = sortOrder; 73 | } 74 | 75 | public Date getCreateTime() { 76 | return createTime; 77 | } 78 | 79 | public void setCreateTime(Date createTime) { 80 | this.createTime = createTime; 81 | } 82 | 83 | public Date getUpdateTime() { 84 | return updateTime; 85 | } 86 | 87 | public void setUpdateTime(Date updateTime) { 88 | this.updateTime = updateTime; 89 | } 90 | 91 | @Override 92 | public boolean equals(Object o) { 93 | if (this == o) return true; 94 | if (o == null || getClass() != o.getClass()) return false; 95 | Category category = (Category) o; 96 | return Objects.equals(id, category.id); 97 | } 98 | 99 | @Override 100 | public int hashCode() { 101 | 102 | return Objects.hash(id); 103 | } 104 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/PayInfo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class PayInfo { 6 | private Integer id; 7 | 8 | private Integer userId; 9 | 10 | private Long orderNo; 11 | 12 | private Integer payPlatform; 13 | 14 | private String platformNumber; 15 | 16 | private String platformStatus; 17 | 18 | private Date createTime; 19 | 20 | private Date updateTime; 21 | 22 | public PayInfo(Integer id, Integer userId, Long orderNo, Integer payPlatform, String platformNumber, String platformStatus, Date createTime, Date updateTime) { 23 | this.id = id; 24 | this.userId = userId; 25 | this.orderNo = orderNo; 26 | this.payPlatform = payPlatform; 27 | this.platformNumber = platformNumber; 28 | this.platformStatus = platformStatus; 29 | this.createTime = createTime; 30 | this.updateTime = updateTime; 31 | } 32 | 33 | public PayInfo() { 34 | super(); 35 | } 36 | 37 | public Integer getId() { 38 | return id; 39 | } 40 | 41 | public void setId(Integer id) { 42 | this.id = id; 43 | } 44 | 45 | public Integer getUserId() { 46 | return userId; 47 | } 48 | 49 | public void setUserId(Integer userId) { 50 | this.userId = userId; 51 | } 52 | 53 | public Long getOrderNo() { 54 | return orderNo; 55 | } 56 | 57 | public void setOrderNo(Long orderNo) { 58 | this.orderNo = orderNo; 59 | } 60 | 61 | public Integer getPayPlatform() { 62 | return payPlatform; 63 | } 64 | 65 | public void setPayPlatform(Integer payPlatform) { 66 | this.payPlatform = payPlatform; 67 | } 68 | 69 | public String getPlatformNumber() { 70 | return platformNumber; 71 | } 72 | 73 | public void setPlatformNumber(String platformNumber) { 74 | this.platformNumber = platformNumber == null ? null : platformNumber.trim(); 75 | } 76 | 77 | public String getPlatformStatus() { 78 | return platformStatus; 79 | } 80 | 81 | public void setPlatformStatus(String platformStatus) { 82 | this.platformStatus = platformStatus == null ? null : platformStatus.trim(); 83 | } 84 | 85 | public Date getCreateTime() { 86 | return createTime; 87 | } 88 | 89 | public void setCreateTime(Date createTime) { 90 | this.createTime = createTime; 91 | } 92 | 93 | public Date getUpdateTime() { 94 | return updateTime; 95 | } 96 | 97 | public void setUpdateTime(Date updateTime) { 98 | this.updateTime = updateTime; 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/ProductManageController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ResponseCode; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.pojo.Product; 7 | import com.mmall.pojo.User; 8 | import com.mmall.service.ProductService; 9 | import com.mmall.service.UserService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import javax.servlet.http.HttpSession; 18 | 19 | /** 20 | *Create by gegf 21 | */ 22 | 23 | @Controller 24 | @RequestMapping("/manage/product") 25 | public class ProductManageController { 26 | 27 | @Autowired 28 | private UserService userService; 29 | 30 | @Autowired 31 | private ProductService productService; 32 | 33 | public ServerResponse manageProductDetail(Integer productId){ 34 | if(productId == null){ 35 | return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), 36 | ResponseCode.ILLEGAL_ARGUMENT.getDesc()); 37 | } 38 | return null; 39 | } 40 | 41 | @ResponseBody 42 | @RequestMapping(value = "/product", method = RequestMethod.POST) 43 | public ServerResponse productSave(HttpSession session, Product product){ 44 | User user = (User)session.getAttribute(Const.CURRENT_USER); 45 | if(user == null){ 46 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), 47 | ResponseCode.NEED_LOGIN.getDesc()); 48 | } 49 | if(userService.checkAdminRole(user).isSuccess()){ 50 | return productService.saveOrUpdateProduct(product); 51 | }else { 52 | return ServerResponse.createByErrorMessage("无权限操作"); 53 | } 54 | } 55 | 56 | @ResponseBody 57 | @RequestMapping(value = "set_salt_status.do") 58 | public ServerResponse setSaleStatus(HttpSession session, Product product, Integer status){ 59 | User user = (User)session.getAttribute(Const.CURRENT_USER); 60 | if(user == null){ 61 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), 62 | ResponseCode.NEED_LOGIN.getDesc()); 63 | } 64 | if(userService.checkAdminRole(user).isSuccess()){ 65 | return productService.setSaleStatus(product.getId(), status); 66 | }else { 67 | return ServerResponse.createByErrorMessage("无权限操作"); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/ServerResponse.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnore; 4 | import org.codehaus.jackson.map.annotate.JsonSerialize; 5 | 6 | import java.io.Serializable; 7 | 8 | @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)//null的key会消失 9 | public class ServerResponse implements Serializable { 10 | 11 | private int status; 12 | 13 | private String msg; 14 | 15 | private T data; 16 | 17 | public ServerResponse(){} 18 | 19 | public ServerResponse(int status) { 20 | this.status = status; 21 | } 22 | 23 | public ServerResponse(int status, String msg) { 24 | this.status = status; 25 | this.msg = msg; 26 | } 27 | 28 | public ServerResponse(int status, T data) { 29 | this.status = status; 30 | this.data = data; 31 | } 32 | 33 | public ServerResponse(int status, String msg, T data) { 34 | this.status = status; 35 | this.msg = msg; 36 | this.data = data; 37 | } 38 | 39 | @JsonIgnore 40 | public boolean isSuccess(){ 41 | return this.status == ResponseCode.SUCCESS.getCode(); 42 | } 43 | 44 | public int getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(int status) { 49 | this.status = status; 50 | } 51 | 52 | public String getMsg() { 53 | return msg; 54 | } 55 | 56 | public void setMsg(String msg) { 57 | this.msg = msg; 58 | } 59 | 60 | public T getData() { 61 | return data; 62 | } 63 | 64 | public void setData(T data) { 65 | this.data = data; 66 | } 67 | 68 | public static ServerResponse createBySuccess(){ 69 | return new ServerResponse<>(ResponseCode.SUCCESS.getCode()); 70 | } 71 | 72 | public static ServerResponse createBySuccessMessage(String msg){ 73 | return new ServerResponse<>(ResponseCode.SUCCESS.getCode(), msg); 74 | } 75 | 76 | public static ServerResponse createBySuccess(T data){ 77 | return new ServerResponse<>(ResponseCode.SUCCESS.getCode(), data); 78 | } 79 | 80 | public static ServerResponse createBySuccess(String msg, T data){ 81 | return new ServerResponse<>(ResponseCode.SUCCESS.getCode(), msg, data); 82 | } 83 | 84 | public static ServerResponse createByError(){ 85 | return new ServerResponse<>(ResponseCode.ERROR.getCode(), ResponseCode.ERROR.getDesc()); 86 | } 87 | 88 | public static ServerResponse createByErrorMessage(String msg){ 89 | return new ServerResponse<>(ResponseCode.ERROR.getCode(), msg); 90 | } 91 | 92 | public static ServerResponse createByErrorCodeMessage(int errorCode, String msg){ 93 | return new ServerResponse<>(errorCode, msg); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/User.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class User { 6 | private Integer id; 7 | 8 | private String username; 9 | 10 | private String password; 11 | 12 | private String email; 13 | 14 | private String phone; 15 | 16 | private String question; 17 | 18 | private String answer; 19 | 20 | private Integer role; 21 | 22 | private Date createTime; 23 | 24 | private Date updateTime; 25 | 26 | public User(Integer id, String username, String password, String email, String phone, String question, String answer, Integer role, Date createTime, Date updateTime) { 27 | this.id = id; 28 | this.username = username; 29 | this.password = password; 30 | this.email = email; 31 | this.phone = phone; 32 | this.question = question; 33 | this.answer = answer; 34 | this.role = role; 35 | this.createTime = createTime; 36 | this.updateTime = updateTime; 37 | } 38 | 39 | public User() { 40 | super(); 41 | } 42 | 43 | public Integer getId() { 44 | return id; 45 | } 46 | 47 | public void setId(Integer id) { 48 | this.id = id; 49 | } 50 | 51 | public String getUsername() { 52 | return username; 53 | } 54 | 55 | public void setUsername(String username) { 56 | this.username = username == null ? null : username.trim(); 57 | } 58 | 59 | public String getPassword() { 60 | return password; 61 | } 62 | 63 | public void setPassword(String password) { 64 | this.password = password == null ? null : password.trim(); 65 | } 66 | 67 | public String getEmail() { 68 | return email; 69 | } 70 | 71 | public void setEmail(String email) { 72 | this.email = email == null ? null : email.trim(); 73 | } 74 | 75 | public String getPhone() { 76 | return phone; 77 | } 78 | 79 | public void setPhone(String phone) { 80 | this.phone = phone == null ? null : phone.trim(); 81 | } 82 | 83 | public String getQuestion() { 84 | return question; 85 | } 86 | 87 | public void setQuestion(String question) { 88 | this.question = question == null ? null : question.trim(); 89 | } 90 | 91 | public String getAnswer() { 92 | return answer; 93 | } 94 | 95 | public void setAnswer(String answer) { 96 | this.answer = answer == null ? null : answer.trim(); 97 | } 98 | 99 | public Integer getRole() { 100 | return role; 101 | } 102 | 103 | public void setRole(Integer role) { 104 | this.role = role; 105 | } 106 | 107 | public Date getCreateTime() { 108 | return createTime; 109 | } 110 | 111 | public void setCreateTime(Date createTime) { 112 | this.createTime = createTime; 113 | } 114 | 115 | public Date getUpdateTime() { 116 | return updateTime; 117 | } 118 | 119 | public void setUpdateTime(Date updateTime) { 120 | this.updateTime = updateTime; 121 | } 122 | } -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UTF-8 5 | 6 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 7 | 8 | 9 | DEBUG 10 | 11 | 12 | 13 | 14 | 15 | c:/apache-tomcat-7.0.73/logs/mmall.log 16 | 17 | c:/apache-tomcat-7.0.73/logs/mmall.log.%d{yyyy-MM-dd}.gz 18 | true 19 | 10 20 | 21 | 22 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 23 | 24 | 25 | 26 | 27 | 28 | 29 | c:/apache-tomcat-7.0.73/logs/error.log 30 | 31 | c:/apache-tomcat-7.0.73/logs/error.log.%d{yyyy-MM-dd}.gz 32 | 33 | true 34 | 10 35 | 36 | 37 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 38 | 39 | 40 | ERROR 41 | ACCEPT 42 | DENY 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 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class OrderItem { 7 | private Integer id; 8 | 9 | private Integer userId; 10 | 11 | private Long orderNo; 12 | 13 | private Integer productId; 14 | 15 | private String productName; 16 | 17 | private String productImage; 18 | 19 | private BigDecimal currentUnitPrice; 20 | 21 | private Integer quantity; 22 | 23 | private BigDecimal totalPrice; 24 | 25 | private Date createTime; 26 | 27 | private Date updateTime; 28 | 29 | public OrderItem(Integer id, Integer userId, Long orderNo, Integer productId, String productName, String productImage, BigDecimal currentUnitPrice, Integer quantity, BigDecimal totalPrice, Date createTime, Date updateTime) { 30 | this.id = id; 31 | this.userId = userId; 32 | this.orderNo = orderNo; 33 | this.productId = productId; 34 | this.productName = productName; 35 | this.productImage = productImage; 36 | this.currentUnitPrice = currentUnitPrice; 37 | this.quantity = quantity; 38 | this.totalPrice = totalPrice; 39 | this.createTime = createTime; 40 | this.updateTime = updateTime; 41 | } 42 | 43 | public OrderItem() { 44 | super(); 45 | } 46 | 47 | public Integer getId() { 48 | return id; 49 | } 50 | 51 | public void setId(Integer id) { 52 | this.id = id; 53 | } 54 | 55 | public Integer getUserId() { 56 | return userId; 57 | } 58 | 59 | public void setUserId(Integer userId) { 60 | this.userId = userId; 61 | } 62 | 63 | public Long getOrderNo() { 64 | return orderNo; 65 | } 66 | 67 | public void setOrderNo(Long orderNo) { 68 | this.orderNo = orderNo; 69 | } 70 | 71 | public Integer getProductId() { 72 | return productId; 73 | } 74 | 75 | public void setProductId(Integer productId) { 76 | this.productId = productId; 77 | } 78 | 79 | public String getProductName() { 80 | return productName; 81 | } 82 | 83 | public void setProductName(String productName) { 84 | this.productName = productName == null ? null : productName.trim(); 85 | } 86 | 87 | public String getProductImage() { 88 | return productImage; 89 | } 90 | 91 | public void setProductImage(String productImage) { 92 | this.productImage = productImage == null ? null : productImage.trim(); 93 | } 94 | 95 | public BigDecimal getCurrentUnitPrice() { 96 | return currentUnitPrice; 97 | } 98 | 99 | public void setCurrentUnitPrice(BigDecimal currentUnitPrice) { 100 | this.currentUnitPrice = currentUnitPrice; 101 | } 102 | 103 | public Integer getQuantity() { 104 | return quantity; 105 | } 106 | 107 | public void setQuantity(Integer quantity) { 108 | this.quantity = quantity; 109 | } 110 | 111 | public BigDecimal getTotalPrice() { 112 | return totalPrice; 113 | } 114 | 115 | public void setTotalPrice(BigDecimal totalPrice) { 116 | this.totalPrice = totalPrice; 117 | } 118 | 119 | public Date getCreateTime() { 120 | return createTime; 121 | } 122 | 123 | public void setCreateTime(Date createTime) { 124 | this.createTime = createTime; 125 | } 126 | 127 | public Date getUpdateTime() { 128 | return updateTime; 129 | } 130 | 131 | public void setUpdateTime(Date updateTime) { 132 | this.updateTime = updateTime; 133 | } 134 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.google.common.collect.Sets; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.dao.CategoryMapper; 7 | import com.mmall.pojo.Category; 8 | import com.mmall.service.CategoryService; 9 | import org.apache.commons.collections.CollectionUtils; 10 | import org.apache.commons.lang.StringUtils; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Service; 15 | 16 | import java.util.List; 17 | import java.util.Set; 18 | 19 | @Service("categoryService") 20 | public class CategoryServiceImpl implements CategoryService { 21 | 22 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 23 | 24 | @Autowired 25 | private CategoryMapper categoryMapper; 26 | 27 | @Override 28 | public ServerResponse addCategory(String categoryName, Integer parentId) { 29 | if(parentId == null || StringUtils.isBlank(categoryName)){ 30 | return ServerResponse.createByErrorMessage("参数有误"); 31 | } 32 | Category category = new Category(); 33 | category.setName(categoryName); 34 | category.setParentId(parentId); 35 | category.setStatus(true); 36 | 37 | int rowCount = categoryMapper.insert(category); 38 | if(rowCount > 0){ 39 | return ServerResponse.createBySuccessMessage("添加商品类别成功"); 40 | } 41 | return ServerResponse.createByErrorMessage("添加商品类别失败"); 42 | } 43 | 44 | @Override 45 | public ServerResponse updateCategory(Integer categoryId, String categoryName) { 46 | if(categoryId == null || StringUtils.isBlank(categoryName)){ 47 | return ServerResponse.createByErrorMessage("参数有误"); 48 | } 49 | Category category = new Category(); 50 | category.setId(categoryId); 51 | category.setName(categoryName); 52 | 53 | int rowCount = categoryMapper.updateByPrimaryKeySelective(category); 54 | if(rowCount > 0){ 55 | return ServerResponse.createBySuccessMessage("更新商品类别成功"); 56 | } 57 | return ServerResponse.createByErrorMessage("更新商品类别失败"); 58 | } 59 | 60 | @Override 61 | public ServerResponse> getChildrenParallelCategory(Integer categoryId) { 62 | List categoryList = categoryMapper.selectCategoryChildrenByParentId(categoryId); 63 | if(CollectionUtils.isEmpty(categoryList)){ 64 | logger.info("未找到当前分类的子分类"); 65 | } 66 | return ServerResponse.createBySuccess(categoryList); 67 | } 68 | 69 | @Override 70 | public ServerResponse getCategoryAndChildrenById(Integer categoryId) { 71 | Set categorySet = Sets.newHashSet(); 72 | findChildCategory(categorySet, categoryId); 73 | 74 | List categoryList = Lists.newArrayList(); 75 | if(categoryId != null){ 76 | categorySet.stream().forEach(c -> categoryList.add(c.getId())); 77 | } 78 | return ServerResponse.createBySuccess(categoryList); 79 | } 80 | 81 | private Set findChildCategory(Set categorySet, Integer categoryId) { 82 | Category category = categoryMapper.selectByPrimaryKey(categoryId); 83 | if (category != null) { 84 | categorySet.add(category); 85 | } 86 | List categoryList = categoryMapper.selectCategoryChildrenByParentId(categoryId); 87 | for (Category item : categoryList) { 88 | findChildCategory(categorySet, item.getId()); 89 | } 90 | return categorySet; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Product.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class Product { 7 | private Integer id; 8 | 9 | private Integer categoryId; 10 | 11 | private String name; 12 | 13 | private String subtitle; 14 | 15 | private String mainImage; 16 | 17 | private String subImages; 18 | 19 | private String detail; 20 | 21 | private BigDecimal price; 22 | 23 | private Integer stock; 24 | 25 | private Integer status; 26 | 27 | private Date createTime; 28 | 29 | private Date updateTime; 30 | 31 | public Product(Integer id, Integer categoryId, String name, String subtitle, String mainImage, String subImages, String detail, BigDecimal price, Integer stock, Integer status, Date createTime, Date updateTime) { 32 | this.id = id; 33 | this.categoryId = categoryId; 34 | this.name = name; 35 | this.subtitle = subtitle; 36 | this.mainImage = mainImage; 37 | this.subImages = subImages; 38 | this.detail = detail; 39 | this.price = price; 40 | this.stock = stock; 41 | this.status = status; 42 | this.createTime = createTime; 43 | this.updateTime = updateTime; 44 | } 45 | 46 | public Product() { 47 | super(); 48 | } 49 | 50 | public Integer getId() { 51 | return id; 52 | } 53 | 54 | public void setId(Integer id) { 55 | this.id = id; 56 | } 57 | 58 | public Integer getCategoryId() { 59 | return categoryId; 60 | } 61 | 62 | public void setCategoryId(Integer categoryId) { 63 | this.categoryId = categoryId; 64 | } 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | public void setName(String name) { 71 | this.name = name == null ? null : name.trim(); 72 | } 73 | 74 | public String getSubtitle() { 75 | return subtitle; 76 | } 77 | 78 | public void setSubtitle(String subtitle) { 79 | this.subtitle = subtitle == null ? null : subtitle.trim(); 80 | } 81 | 82 | public String getMainImage() { 83 | return mainImage; 84 | } 85 | 86 | public void setMainImage(String mainImage) { 87 | this.mainImage = mainImage == null ? null : mainImage.trim(); 88 | } 89 | 90 | public String getSubImages() { 91 | return subImages; 92 | } 93 | 94 | public void setSubImages(String subImages) { 95 | this.subImages = subImages == null ? null : subImages.trim(); 96 | } 97 | 98 | public String getDetail() { 99 | return detail; 100 | } 101 | 102 | public void setDetail(String detail) { 103 | this.detail = detail == null ? null : detail.trim(); 104 | } 105 | 106 | public BigDecimal getPrice() { 107 | return price; 108 | } 109 | 110 | public void setPrice(BigDecimal price) { 111 | this.price = price; 112 | } 113 | 114 | public Integer getStock() { 115 | return stock; 116 | } 117 | 118 | public void setStock(Integer stock) { 119 | this.stock = stock; 120 | } 121 | 122 | public Integer getStatus() { 123 | return status; 124 | } 125 | 126 | public void setStatus(Integer status) { 127 | this.status = status; 128 | } 129 | 130 | public Date getCreateTime() { 131 | return createTime; 132 | } 133 | 134 | public void setCreateTime(Date createTime) { 135 | this.createTime = createTime; 136 | } 137 | 138 | public Date getUpdateTime() { 139 | return updateTime; 140 | } 141 | 142 | public void setUpdateTime(Date updateTime) { 143 | this.updateTime = updateTime; 144 | } 145 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/FTPUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.apache.commons.net.ftp.FTPClient; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.File; 8 | import java.io.FileInputStream; 9 | import java.io.IOException; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by gegf 14 | */ 15 | public class FTPUtil { 16 | 17 | private static final Logger logger = LoggerFactory.getLogger(FTPUtil.class); 18 | 19 | private static String ftpIp = PropertiesUtil.getProperty("ftp.server.ip"); 20 | private static String ftpUser = PropertiesUtil.getProperty("ftp.user"); 21 | private static String ftpPass = PropertiesUtil.getProperty("ftp.pass"); 22 | 23 | public FTPUtil(String ip,int port,String user,String pwd){ 24 | this.ip = ip; 25 | this.port = port; 26 | this.user = user; 27 | this.pwd = pwd; 28 | } 29 | public static boolean uploadFile(List fileList) throws IOException { 30 | FTPUtil ftpUtil = new FTPUtil(ftpIp,21,ftpUser,ftpPass); 31 | logger.info("开始连接ftp服务器"); 32 | boolean result = ftpUtil.uploadFile("img",fileList); 33 | logger.info("开始连接ftp服务器,结束上传,上传结果:{}"); 34 | return result; 35 | } 36 | 37 | 38 | private boolean uploadFile(String remotePath,List fileList) throws IOException { 39 | boolean uploaded = true; 40 | FileInputStream fis = null; 41 | //连接FTP服务器 42 | if(connectServer(this.ip,this.port,this.user,this.pwd)){ 43 | try { 44 | ftpClient.changeWorkingDirectory(remotePath); 45 | ftpClient.setBufferSize(1024); 46 | ftpClient.setControlEncoding("UTF-8"); 47 | ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); 48 | ftpClient.enterLocalPassiveMode(); 49 | for(File fileItem : fileList){ 50 | fis = new FileInputStream(fileItem); 51 | ftpClient.storeFile(fileItem.getName(),fis); 52 | } 53 | 54 | } catch (IOException e) { 55 | logger.error("上传文件异常",e); 56 | uploaded = false; 57 | e.printStackTrace(); 58 | } finally { 59 | fis.close(); 60 | ftpClient.disconnect(); 61 | } 62 | } 63 | return uploaded; 64 | } 65 | 66 | 67 | 68 | private boolean connectServer(String ip,int port,String user,String pwd){ 69 | 70 | boolean isSuccess = false; 71 | ftpClient = new FTPClient(); 72 | try { 73 | ftpClient.connect(ip); 74 | isSuccess = ftpClient.login(user,pwd); 75 | } catch (IOException e) { 76 | logger.error("连接FTP服务器异常",e); 77 | } 78 | return isSuccess; 79 | } 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | private String ip; 92 | private int port; 93 | private String user; 94 | private String pwd; 95 | private FTPClient ftpClient; 96 | 97 | public String getIp() { 98 | return ip; 99 | } 100 | 101 | public void setIp(String ip) { 102 | this.ip = ip; 103 | } 104 | 105 | public int getPort() { 106 | return port; 107 | } 108 | 109 | public void setPort(int port) { 110 | this.port = port; 111 | } 112 | 113 | public String getUser() { 114 | return user; 115 | } 116 | 117 | public void setUser(String user) { 118 | this.user = user; 119 | } 120 | 121 | public String getPwd() { 122 | return pwd; 123 | } 124 | 125 | public void setPwd(String pwd) { 126 | this.pwd = pwd; 127 | } 128 | 129 | public FTPClient getFtpClient() { 130 | return ftpClient; 131 | } 132 | 133 | public void setFtpClient(FTPClient ftpClient) { 134 | this.ftpClient = ftpClient; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Order.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class Order { 7 | private Integer id; 8 | 9 | private Long orderNo; 10 | 11 | private Integer userId; 12 | 13 | private Integer shippingId; 14 | 15 | private BigDecimal payment; 16 | 17 | private Integer paymentType; 18 | 19 | private Integer postage; 20 | 21 | private Integer status; 22 | 23 | private Date paymentTime; 24 | 25 | private Date sendTime; 26 | 27 | private Date endTime; 28 | 29 | private Date closeTime; 30 | 31 | private Date createTime; 32 | 33 | private Date updateTime; 34 | 35 | public Order(Integer id, Long orderNo, Integer userId, Integer shippingId, BigDecimal payment, Integer paymentType, Integer postage, Integer status, Date paymentTime, Date sendTime, Date endTime, Date closeTime, Date createTime, Date updateTime) { 36 | this.id = id; 37 | this.orderNo = orderNo; 38 | this.userId = userId; 39 | this.shippingId = shippingId; 40 | this.payment = payment; 41 | this.paymentType = paymentType; 42 | this.postage = postage; 43 | this.status = status; 44 | this.paymentTime = paymentTime; 45 | this.sendTime = sendTime; 46 | this.endTime = endTime; 47 | this.closeTime = closeTime; 48 | this.createTime = createTime; 49 | this.updateTime = updateTime; 50 | } 51 | 52 | public Order() { 53 | super(); 54 | } 55 | 56 | public Integer getId() { 57 | return id; 58 | } 59 | 60 | public void setId(Integer id) { 61 | this.id = id; 62 | } 63 | 64 | public Long getOrderNo() { 65 | return orderNo; 66 | } 67 | 68 | public void setOrderNo(Long orderNo) { 69 | this.orderNo = orderNo; 70 | } 71 | 72 | public Integer getUserId() { 73 | return userId; 74 | } 75 | 76 | public void setUserId(Integer userId) { 77 | this.userId = userId; 78 | } 79 | 80 | public Integer getShippingId() { 81 | return shippingId; 82 | } 83 | 84 | public void setShippingId(Integer shippingId) { 85 | this.shippingId = shippingId; 86 | } 87 | 88 | public BigDecimal getPayment() { 89 | return payment; 90 | } 91 | 92 | public void setPayment(BigDecimal payment) { 93 | this.payment = payment; 94 | } 95 | 96 | public Integer getPaymentType() { 97 | return paymentType; 98 | } 99 | 100 | public void setPaymentType(Integer paymentType) { 101 | this.paymentType = paymentType; 102 | } 103 | 104 | public Integer getPostage() { 105 | return postage; 106 | } 107 | 108 | public void setPostage(Integer postage) { 109 | this.postage = postage; 110 | } 111 | 112 | public Integer getStatus() { 113 | return status; 114 | } 115 | 116 | public void setStatus(Integer status) { 117 | this.status = status; 118 | } 119 | 120 | public Date getPaymentTime() { 121 | return paymentTime; 122 | } 123 | 124 | public void setPaymentTime(Date paymentTime) { 125 | this.paymentTime = paymentTime; 126 | } 127 | 128 | public Date getSendTime() { 129 | return sendTime; 130 | } 131 | 132 | public void setSendTime(Date sendTime) { 133 | this.sendTime = sendTime; 134 | } 135 | 136 | public Date getEndTime() { 137 | return endTime; 138 | } 139 | 140 | public void setEndTime(Date endTime) { 141 | this.endTime = endTime; 142 | } 143 | 144 | public Date getCloseTime() { 145 | return closeTime; 146 | } 147 | 148 | public void setCloseTime(Date closeTime) { 149 | this.closeTime = closeTime; 150 | } 151 | 152 | public Date getCreateTime() { 153 | return createTime; 154 | } 155 | 156 | public void setCreateTime(Date createTime) { 157 | this.createTime = createTime; 158 | } 159 | 160 | public Date getUpdateTime() { 161 | return updateTime; 162 | } 163 | 164 | public void setUpdateTime(Date updateTime) { 165 | this.updateTime = updateTime; 166 | } 167 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Shipping.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class Shipping { 6 | private Integer id; 7 | 8 | private Integer userId; 9 | 10 | private String receiverName; 11 | 12 | private String receiverPhone; 13 | 14 | private String receiverMobile; 15 | 16 | private String receiverProvince; 17 | 18 | private String receiverCity; 19 | 20 | private String receiverDistrict; 21 | 22 | private String receiverAddress; 23 | 24 | private String receiverZip; 25 | 26 | private Date createTime; 27 | 28 | private Date updateTime; 29 | 30 | public Shipping(Integer id, Integer userId, String receiverName, String receiverPhone, String receiverMobile, String receiverProvince, String receiverCity, String receiverDistrict, String receiverAddress, String receiverZip, Date createTime, Date updateTime) { 31 | this.id = id; 32 | this.userId = userId; 33 | this.receiverName = receiverName; 34 | this.receiverPhone = receiverPhone; 35 | this.receiverMobile = receiverMobile; 36 | this.receiverProvince = receiverProvince; 37 | this.receiverCity = receiverCity; 38 | this.receiverDistrict = receiverDistrict; 39 | this.receiverAddress = receiverAddress; 40 | this.receiverZip = receiverZip; 41 | this.createTime = createTime; 42 | this.updateTime = updateTime; 43 | } 44 | 45 | public Shipping() { 46 | super(); 47 | } 48 | 49 | public Integer getId() { 50 | return id; 51 | } 52 | 53 | public void setId(Integer id) { 54 | this.id = id; 55 | } 56 | 57 | public Integer getUserId() { 58 | return userId; 59 | } 60 | 61 | public void setUserId(Integer userId) { 62 | this.userId = userId; 63 | } 64 | 65 | public String getReceiverName() { 66 | return receiverName; 67 | } 68 | 69 | public void setReceiverName(String receiverName) { 70 | this.receiverName = receiverName == null ? null : receiverName.trim(); 71 | } 72 | 73 | public String getReceiverPhone() { 74 | return receiverPhone; 75 | } 76 | 77 | public void setReceiverPhone(String receiverPhone) { 78 | this.receiverPhone = receiverPhone == null ? null : receiverPhone.trim(); 79 | } 80 | 81 | public String getReceiverMobile() { 82 | return receiverMobile; 83 | } 84 | 85 | public void setReceiverMobile(String receiverMobile) { 86 | this.receiverMobile = receiverMobile == null ? null : receiverMobile.trim(); 87 | } 88 | 89 | public String getReceiverProvince() { 90 | return receiverProvince; 91 | } 92 | 93 | public void setReceiverProvince(String receiverProvince) { 94 | this.receiverProvince = receiverProvince == null ? null : receiverProvince.trim(); 95 | } 96 | 97 | public String getReceiverCity() { 98 | return receiverCity; 99 | } 100 | 101 | public void setReceiverCity(String receiverCity) { 102 | this.receiverCity = receiverCity == null ? null : receiverCity.trim(); 103 | } 104 | 105 | public String getReceiverDistrict() { 106 | return receiverDistrict; 107 | } 108 | 109 | public void setReceiverDistrict(String receiverDistrict) { 110 | this.receiverDistrict = receiverDistrict == null ? null : receiverDistrict.trim(); 111 | } 112 | 113 | public String getReceiverAddress() { 114 | return receiverAddress; 115 | } 116 | 117 | public void setReceiverAddress(String receiverAddress) { 118 | this.receiverAddress = receiverAddress == null ? null : receiverAddress.trim(); 119 | } 120 | 121 | public String getReceiverZip() { 122 | return receiverZip; 123 | } 124 | 125 | public void setReceiverZip(String receiverZip) { 126 | this.receiverZip = receiverZip == null ? null : receiverZip.trim(); 127 | } 128 | 129 | public Date getCreateTime() { 130 | return createTime; 131 | } 132 | 133 | public void setCreateTime(Date createTime) { 134 | this.createTime = createTime; 135 | } 136 | 137 | public Date getUpdateTime() { 138 | return updateTime; 139 | } 140 | 141 | public void setUpdateTime(Date updateTime) { 142 | this.updateTime = updateTime; 143 | } 144 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/CategoryManageController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ResponseCode; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.pojo.Category; 7 | import com.mmall.pojo.User; 8 | import com.mmall.service.CategoryService; 9 | import com.mmall.service.UserService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import javax.servlet.http.HttpSession; 18 | import java.util.List; 19 | 20 | /** 21 | * 分类管理Controller 22 | */ 23 | @Controller 24 | @RequestMapping("/manager/category") 25 | public class CategoryManageController { 26 | 27 | @Autowired 28 | private UserService userService; 29 | 30 | @Autowired 31 | private CategoryService categoryService; 32 | 33 | /** 34 | * 添加category 35 | * @param session 36 | * @param categoryName 37 | * @param parentId 38 | * @return 39 | */ 40 | @ResponseBody 41 | @RequestMapping(value = "add_category.do", method = RequestMethod.POST) 42 | public ServerResponse addCategory(HttpSession session, String categoryName, 43 | @RequestParam(value = "parentId", defaultValue = "0") int parentId){ 44 | User user = (User)session.getAttribute(Const.CURRENT_USER); 45 | if(user == null){ 46 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户未登录"); 47 | } 48 | if(userService.checkAdminRole(user).isSuccess()){ 49 | return categoryService.addCategory(categoryName, parentId); 50 | }else{ 51 | return ServerResponse.createByErrorMessage("无权限操作,需要有管理员权限"); 52 | } 53 | } 54 | 55 | @ResponseBody 56 | @RequestMapping(value = "set_category.do", method = RequestMethod.POST) 57 | public ServerResponse setCategory(HttpSession session, Integer categoryId, String categoryName){ 58 | User user = (User)session.getAttribute(Const.CURRENT_USER); 59 | if(user == null){ 60 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户未登录"); 61 | } 62 | if(userService.checkAdminRole(user).isSuccess()){ 63 | return categoryService.updateCategory(categoryId, categoryName); 64 | }else{ 65 | return ServerResponse.createByErrorMessage("无权限操作,需要有管理员权限"); 66 | } 67 | } 68 | 69 | @ResponseBody 70 | @RequestMapping(value = "get_category.do", method = RequestMethod.GET) 71 | public ServerResponse> getChildrenParallelCategory(HttpSession session, 72 | @RequestParam(value = "categoryId",defaultValue = "0") Integer categoryId){ 73 | User user = (User) session.getAttribute(Const.CURRENT_USER); 74 | if(user == null){ 75 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户未登录"); 76 | } 77 | if(userService.checkAdminRole(user).isSuccess()){ 78 | //查询子节点的信息,并且不递归 79 | return categoryService.getChildrenParallelCategory(categoryId); 80 | }else{ 81 | return ServerResponse.createByErrorMessage("无操作权限,需要管理员权限"); 82 | } 83 | } 84 | 85 | @ResponseBody 86 | @RequestMapping(value = "get_deepcategory.do", method = RequestMethod.GET) 87 | public ServerResponse> getDeepChildrenParallelCategory(HttpSession session, 88 | @RequestParam(value = "categoryId",defaultValue = "0") Integer categoryId){ 89 | User user = (User) session.getAttribute(Const.CURRENT_USER); 90 | if(user == null){ 91 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户未登录"); 92 | } 93 | if(userService.checkAdminRole(user).isSuccess()){ 94 | //查询子节点的信息,递归 95 | return categoryService.getCategoryAndChildrenById(categoryId); 96 | }else{ 97 | return ServerResponse.createByErrorMessage("无操作权限,需要管理员权限"); 98 | } 99 | } 100 | 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext-datasource.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | classpath:datasource.properties 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | dialect=mysql 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/main/resources/mappers/CartMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, user_id, product_id, quantity, checked, create_time, update_time 17 | 18 | 24 | 25 | delete from mmall_cart 26 | where id = #{id,jdbcType=INTEGER} 27 | 28 | 29 | insert into mmall_cart (id, user_id, product_id, 30 | quantity, checked, create_time, 31 | update_time) 32 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, 33 | #{quantity,jdbcType=INTEGER}, #{checked,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 34 | #{updateTime,jdbcType=TIMESTAMP}) 35 | 36 | 37 | insert into mmall_cart 38 | 39 | 40 | id, 41 | 42 | 43 | user_id, 44 | 45 | 46 | product_id, 47 | 48 | 49 | quantity, 50 | 51 | 52 | checked, 53 | 54 | 55 | create_time, 56 | 57 | 58 | update_time, 59 | 60 | 61 | 62 | 63 | #{id,jdbcType=INTEGER}, 64 | 65 | 66 | #{userId,jdbcType=INTEGER}, 67 | 68 | 69 | #{productId,jdbcType=INTEGER}, 70 | 71 | 72 | #{quantity,jdbcType=INTEGER}, 73 | 74 | 75 | #{checked,jdbcType=INTEGER}, 76 | 77 | 78 | #{createTime,jdbcType=TIMESTAMP}, 79 | 80 | 81 | #{updateTime,jdbcType=TIMESTAMP}, 82 | 83 | 84 | 85 | 86 | update mmall_cart 87 | 88 | 89 | user_id = #{userId,jdbcType=INTEGER}, 90 | 91 | 92 | product_id = #{productId,jdbcType=INTEGER}, 93 | 94 | 95 | quantity = #{quantity,jdbcType=INTEGER}, 96 | 97 | 98 | checked = #{checked,jdbcType=INTEGER}, 99 | 100 | 101 | create_time = #{createTime,jdbcType=TIMESTAMP}, 102 | 103 | 104 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 105 | 106 | 107 | where id = #{id,jdbcType=INTEGER} 108 | 109 | 110 | update mmall_cart 111 | set user_id = #{userId,jdbcType=INTEGER}, 112 | product_id = #{productId,jdbcType=INTEGER}, 113 | quantity = #{quantity,jdbcType=INTEGER}, 114 | checked = #{checked,jdbcType=INTEGER}, 115 | create_time = #{createTime,jdbcType=TIMESTAMP}, 116 | update_time = #{updateTime,jdbcType=TIMESTAMP} 117 | where id = #{id,jdbcType=INTEGER} 118 | 119 | -------------------------------------------------------------------------------- /src/main/resources/mappers/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, parent_id, name, status, sort_order, create_time, update_time 17 | 18 | 24 | 25 | delete from mmall_category 26 | where id = #{id,jdbcType=INTEGER} 27 | 28 | 29 | insert into mmall_category (id, parent_id, name, 30 | status, sort_order, create_time, 31 | update_time) 32 | values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 33 | #{status,jdbcType=BIT}, #{sortOrder,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 34 | #{updateTime,jdbcType=TIMESTAMP}) 35 | 36 | 37 | insert into mmall_category 38 | 39 | 40 | id, 41 | 42 | 43 | parent_id, 44 | 45 | 46 | name, 47 | 48 | 49 | status, 50 | 51 | 52 | sort_order, 53 | 54 | 55 | create_time, 56 | 57 | 58 | update_time, 59 | 60 | 61 | 62 | 63 | #{id,jdbcType=INTEGER}, 64 | 65 | 66 | #{parentId,jdbcType=INTEGER}, 67 | 68 | 69 | #{name,jdbcType=VARCHAR}, 70 | 71 | 72 | #{status,jdbcType=BIT}, 73 | 74 | 75 | #{sortOrder,jdbcType=INTEGER}, 76 | 77 | 78 | #{createTime,jdbcType=TIMESTAMP}, 79 | 80 | 81 | #{updateTime,jdbcType=TIMESTAMP}, 82 | 83 | 84 | 85 | 86 | update mmall_category 87 | 88 | 89 | parent_id = #{parentId,jdbcType=INTEGER}, 90 | 91 | 92 | name = #{name,jdbcType=VARCHAR}, 93 | 94 | 95 | status = #{status,jdbcType=BIT}, 96 | 97 | 98 | sort_order = #{sortOrder,jdbcType=INTEGER}, 99 | 100 | 101 | create_time = #{createTime,jdbcType=TIMESTAMP}, 102 | 103 | 104 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 105 | 106 | 107 | where id = #{id,jdbcType=INTEGER} 108 | 109 | 110 | update mmall_category 111 | set parent_id = #{parentId,jdbcType=INTEGER}, 112 | name = #{name,jdbcType=VARCHAR}, 113 | status = #{status,jdbcType=BIT}, 114 | sort_order = #{sortOrder,jdbcType=INTEGER}, 115 | create_time = #{createTime,jdbcType=TIMESTAMP}, 116 | update_time = #{updateTime,jdbcType=TIMESTAMP} 117 | where id = #{id,jdbcType=INTEGER} 118 | 119 | 120 | 126 | -------------------------------------------------------------------------------- /src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | 80 | 81 | 82 |
83 |
84 | 85 | 86 | 87 |
88 |
-------------------------------------------------------------------------------- /src/main/resources/mappers/PayInfoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id, user_id, order_no, pay_platform, platform_number, platform_status, create_time, 18 | update_time 19 | 20 | 26 | 27 | delete from mmall_pay_info 28 | where id = #{id,jdbcType=INTEGER} 29 | 30 | 31 | insert into mmall_pay_info (id, user_id, order_no, 32 | pay_platform, platform_number, platform_status, 33 | create_time, update_time) 34 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, 35 | #{payPlatform,jdbcType=INTEGER}, #{platformNumber,jdbcType=VARCHAR}, #{platformStatus,jdbcType=VARCHAR}, 36 | #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}) 37 | 38 | 39 | insert into mmall_pay_info 40 | 41 | 42 | id, 43 | 44 | 45 | user_id, 46 | 47 | 48 | order_no, 49 | 50 | 51 | pay_platform, 52 | 53 | 54 | platform_number, 55 | 56 | 57 | platform_status, 58 | 59 | 60 | create_time, 61 | 62 | 63 | update_time, 64 | 65 | 66 | 67 | 68 | #{id,jdbcType=INTEGER}, 69 | 70 | 71 | #{userId,jdbcType=INTEGER}, 72 | 73 | 74 | #{orderNo,jdbcType=BIGINT}, 75 | 76 | 77 | #{payPlatform,jdbcType=INTEGER}, 78 | 79 | 80 | #{platformNumber,jdbcType=VARCHAR}, 81 | 82 | 83 | #{platformStatus,jdbcType=VARCHAR}, 84 | 85 | 86 | #{createTime,jdbcType=TIMESTAMP}, 87 | 88 | 89 | #{updateTime,jdbcType=TIMESTAMP}, 90 | 91 | 92 | 93 | 94 | update mmall_pay_info 95 | 96 | 97 | user_id = #{userId,jdbcType=INTEGER}, 98 | 99 | 100 | order_no = #{orderNo,jdbcType=BIGINT}, 101 | 102 | 103 | pay_platform = #{payPlatform,jdbcType=INTEGER}, 104 | 105 | 106 | platform_number = #{platformNumber,jdbcType=VARCHAR}, 107 | 108 | 109 | platform_status = #{platformStatus,jdbcType=VARCHAR}, 110 | 111 | 112 | create_time = #{createTime,jdbcType=TIMESTAMP}, 113 | 114 | 115 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 116 | 117 | 118 | where id = #{id,jdbcType=INTEGER} 119 | 120 | 121 | update mmall_pay_info 122 | set user_id = #{userId,jdbcType=INTEGER}, 123 | order_no = #{orderNo,jdbcType=BIGINT}, 124 | pay_platform = #{payPlatform,jdbcType=INTEGER}, 125 | platform_number = #{platformNumber,jdbcType=VARCHAR}, 126 | platform_status = #{platformStatus,jdbcType=VARCHAR}, 127 | create_time = #{createTime,jdbcType=TIMESTAMP}, 128 | update_time = #{updateTime,jdbcType=TIMESTAMP} 129 | where id = #{id,jdbcType=INTEGER} 130 | 131 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/portal/UserController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.portal; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ResponseCode; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.pojo.User; 7 | import com.mmall.service.UserService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import javax.servlet.http.HttpSession; 15 | 16 | /** 17 | * Created by gegf 18 | */ 19 | @Controller 20 | @RequestMapping("/user/") 21 | public class UserController { 22 | 23 | @Autowired 24 | private UserService userService; 25 | 26 | /** 27 | * 登录 28 | * @param username 29 | * @param password 30 | * @param session 31 | * @return 32 | */ 33 | @ResponseBody 34 | @RequestMapping(value = "login.do", method = RequestMethod.POST) 35 | public ServerResponse login(String username, String password, HttpSession session){ 36 | ServerResponse response = userService.login(username, password); 37 | if(response.isSuccess()){ 38 | session.setAttribute(Const.CURRENT_USER, response.getData()); 39 | } 40 | return response; 41 | } 42 | 43 | /** 44 | * 登出 45 | * @param session 46 | * @return 47 | */ 48 | @ResponseBody 49 | @RequestMapping(value = "logout.do", method = RequestMethod.GET) 50 | public ServerResponse logout(HttpSession session){ 51 | session.removeAttribute(Const.CURRENT_USER); 52 | return ServerResponse.createBySuccess(); 53 | } 54 | 55 | /** 56 | * 注册 57 | * @param user 58 | * @return 59 | */ 60 | @ResponseBody 61 | @RequestMapping(value = "register.do", method = RequestMethod.POST) 62 | public ServerResponse register(User user){ 63 | return userService.register(user); 64 | } 65 | 66 | /** 67 | * 注册校验接口 68 | * @param str 69 | * @param type 70 | * @return 71 | */ 72 | @ResponseBody 73 | @RequestMapping(value = "checkValid.do", method = RequestMethod.GET) 74 | public ServerResponse checkValid(String str, String type){ 75 | return userService.checkValid(str, type); 76 | } 77 | 78 | /** 79 | * 获取Session中的用户信息 80 | * @param session 81 | * @return 82 | */ 83 | @ResponseBody 84 | @RequestMapping(value = "get_user_info.do", method = RequestMethod.GET) 85 | public ServerResponse getUserInfo(HttpSession session){ 86 | User user = (User)session.getAttribute(Const.CURRENT_USER); 87 | if(user != null){ 88 | ServerResponse.createBySuccess(user); 89 | } 90 | return ServerResponse.createByErrorMessage("用户未登录,无法获取用户信息"); 91 | } 92 | 93 | /** 94 | * 忘记密码,获取问题 95 | * @param username 96 | * @return 97 | */ 98 | @ResponseBody 99 | @RequestMapping(value = "forget_get_question.do", method = RequestMethod.GET) 100 | public ServerResponse forgetGetQuestion(String username){ 101 | return userService.selectQuestion(username); 102 | } 103 | 104 | /** 105 | * 检查问题答案 106 | * @param username 107 | * @param question 108 | * @param answer 109 | * @return 110 | */ 111 | @ResponseBody 112 | @RequestMapping(value = "forget_check_answer.do", method = RequestMethod.GET) 113 | public ServerResponse checkAnswer(String username, String question, String answer){ 114 | return userService.checkAnswer(username, question, answer); 115 | } 116 | 117 | @ResponseBody 118 | @RequestMapping(value = "forget_reset_password.do", method = RequestMethod.GET) 119 | public ServerResponse forgetResetPassword(String username, String passwordNew, String forgetToken){ 120 | return userService.forgetResetPassword(username, passwordNew, forgetToken); 121 | } 122 | 123 | @ResponseBody 124 | @RequestMapping(value = "reset_password.do", method = RequestMethod.GET) 125 | public ServerResponse resetPassword(HttpSession session, String passwordOld, String passwordNew){ 126 | User user = (User)session.getAttribute(Const.CURRENT_USER); 127 | if(user == null){ 128 | return ServerResponse.createByErrorMessage("用户未登录"); 129 | } 130 | return userService.resetPassword(passwordOld, passwordNew, user); 131 | } 132 | 133 | @ResponseBody 134 | @RequestMapping(value = "update_information.do", method = RequestMethod.GET) 135 | public ServerResponse update_information(HttpSession session, User user){ 136 | User currentUser = (User) session.getAttribute(Const.CURRENT_USER); 137 | if(currentUser == null){ 138 | return ServerResponse.createByErrorMessage("用户未登录"); 139 | } 140 | user.setId(currentUser.getId()); 141 | ServerResponse response = userService.updateUserInformation(user); 142 | if(response.isSuccess()){ 143 | session.setAttribute(Const.CURRENT_USER, user); 144 | } 145 | return response; 146 | } 147 | 148 | @RequestMapping(value = "get_information.do",method = RequestMethod.POST) 149 | @ResponseBody 150 | public ServerResponse get_information(HttpSession session){ 151 | User currentUser = (User)session.getAttribute(Const.CURRENT_USER); 152 | if(currentUser == null){ 153 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"未登录,需要强制登录status=10"); 154 | } 155 | return userService.getInformation(currentUser.getId()); 156 | } 157 | 158 | 159 | } 160 | -------------------------------------------------------------------------------- /src/main/resources/mappers/OrderItemMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | id, user_id, order_no, product_id, product_name, product_image, current_unit_price, 21 | quantity, total_price, create_time, update_time 22 | 23 | 29 | 30 | delete from mmall_order_item 31 | where id = #{id,jdbcType=INTEGER} 32 | 33 | 34 | insert into mmall_order_item (id, user_id, order_no, 35 | product_id, product_name, product_image, 36 | current_unit_price, quantity, total_price, 37 | create_time, update_time) 38 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, 39 | #{productId,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{productImage,jdbcType=VARCHAR}, 40 | #{currentUnitPrice,jdbcType=DECIMAL}, #{quantity,jdbcType=INTEGER}, #{totalPrice,jdbcType=DECIMAL}, 41 | #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}) 42 | 43 | 44 | insert into mmall_order_item 45 | 46 | 47 | id, 48 | 49 | 50 | user_id, 51 | 52 | 53 | order_no, 54 | 55 | 56 | product_id, 57 | 58 | 59 | product_name, 60 | 61 | 62 | product_image, 63 | 64 | 65 | current_unit_price, 66 | 67 | 68 | quantity, 69 | 70 | 71 | total_price, 72 | 73 | 74 | create_time, 75 | 76 | 77 | update_time, 78 | 79 | 80 | 81 | 82 | #{id,jdbcType=INTEGER}, 83 | 84 | 85 | #{userId,jdbcType=INTEGER}, 86 | 87 | 88 | #{orderNo,jdbcType=BIGINT}, 89 | 90 | 91 | #{productId,jdbcType=INTEGER}, 92 | 93 | 94 | #{productName,jdbcType=VARCHAR}, 95 | 96 | 97 | #{productImage,jdbcType=VARCHAR}, 98 | 99 | 100 | #{currentUnitPrice,jdbcType=DECIMAL}, 101 | 102 | 103 | #{quantity,jdbcType=INTEGER}, 104 | 105 | 106 | #{totalPrice,jdbcType=DECIMAL}, 107 | 108 | 109 | #{createTime,jdbcType=TIMESTAMP}, 110 | 111 | 112 | #{updateTime,jdbcType=TIMESTAMP}, 113 | 114 | 115 | 116 | 117 | update mmall_order_item 118 | 119 | 120 | user_id = #{userId,jdbcType=INTEGER}, 121 | 122 | 123 | order_no = #{orderNo,jdbcType=BIGINT}, 124 | 125 | 126 | product_id = #{productId,jdbcType=INTEGER}, 127 | 128 | 129 | product_name = #{productName,jdbcType=VARCHAR}, 130 | 131 | 132 | product_image = #{productImage,jdbcType=VARCHAR}, 133 | 134 | 135 | current_unit_price = #{currentUnitPrice,jdbcType=DECIMAL}, 136 | 137 | 138 | quantity = #{quantity,jdbcType=INTEGER}, 139 | 140 | 141 | total_price = #{totalPrice,jdbcType=DECIMAL}, 142 | 143 | 144 | create_time = #{createTime,jdbcType=TIMESTAMP}, 145 | 146 | 147 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 148 | 149 | 150 | where id = #{id,jdbcType=INTEGER} 151 | 152 | 153 | update mmall_order_item 154 | set user_id = #{userId,jdbcType=INTEGER}, 155 | order_no = #{orderNo,jdbcType=BIGINT}, 156 | product_id = #{productId,jdbcType=INTEGER}, 157 | product_name = #{productName,jdbcType=VARCHAR}, 158 | product_image = #{productImage,jdbcType=VARCHAR}, 159 | current_unit_price = #{currentUnitPrice,jdbcType=DECIMAL}, 160 | quantity = #{quantity,jdbcType=INTEGER}, 161 | total_price = #{totalPrice,jdbcType=DECIMAL}, 162 | create_time = #{createTime,jdbcType=TIMESTAMP}, 163 | update_time = #{updateTime,jdbcType=TIMESTAMP} 164 | where id = #{id,jdbcType=INTEGER} 165 | 166 | -------------------------------------------------------------------------------- /src/main/resources/mappers/ProductMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id, category_id, name, subtitle, main_image, sub_images, detail, price, stock, status, 22 | create_time, update_time 23 | 24 | 30 | 31 | delete from mmall_product 32 | where id = #{id,jdbcType=INTEGER} 33 | 34 | 35 | insert into mmall_product (id, category_id, name, 36 | subtitle, main_image, sub_images, 37 | detail, price, stock, 38 | status, create_time, update_time 39 | ) 40 | values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 41 | #{subtitle,jdbcType=VARCHAR}, #{mainImage,jdbcType=VARCHAR}, #{subImages,jdbcType=VARCHAR}, 42 | #{detail,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{stock,jdbcType=INTEGER}, 43 | #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} 44 | ) 45 | 46 | 47 | insert into mmall_product 48 | 49 | 50 | id, 51 | 52 | 53 | category_id, 54 | 55 | 56 | name, 57 | 58 | 59 | subtitle, 60 | 61 | 62 | main_image, 63 | 64 | 65 | sub_images, 66 | 67 | 68 | detail, 69 | 70 | 71 | price, 72 | 73 | 74 | stock, 75 | 76 | 77 | status, 78 | 79 | 80 | create_time, 81 | 82 | 83 | update_time, 84 | 85 | 86 | 87 | 88 | #{id,jdbcType=INTEGER}, 89 | 90 | 91 | #{categoryId,jdbcType=INTEGER}, 92 | 93 | 94 | #{name,jdbcType=VARCHAR}, 95 | 96 | 97 | #{subtitle,jdbcType=VARCHAR}, 98 | 99 | 100 | #{mainImage,jdbcType=VARCHAR}, 101 | 102 | 103 | #{subImages,jdbcType=VARCHAR}, 104 | 105 | 106 | #{detail,jdbcType=VARCHAR}, 107 | 108 | 109 | #{price,jdbcType=DECIMAL}, 110 | 111 | 112 | #{stock,jdbcType=INTEGER}, 113 | 114 | 115 | #{status,jdbcType=INTEGER}, 116 | 117 | 118 | #{createTime,jdbcType=TIMESTAMP}, 119 | 120 | 121 | #{updateTime,jdbcType=TIMESTAMP}, 122 | 123 | 124 | 125 | 126 | update mmall_product 127 | 128 | 129 | category_id = #{categoryId,jdbcType=INTEGER}, 130 | 131 | 132 | name = #{name,jdbcType=VARCHAR}, 133 | 134 | 135 | subtitle = #{subtitle,jdbcType=VARCHAR}, 136 | 137 | 138 | main_image = #{mainImage,jdbcType=VARCHAR}, 139 | 140 | 141 | sub_images = #{subImages,jdbcType=VARCHAR}, 142 | 143 | 144 | detail = #{detail,jdbcType=VARCHAR}, 145 | 146 | 147 | price = #{price,jdbcType=DECIMAL}, 148 | 149 | 150 | stock = #{stock,jdbcType=INTEGER}, 151 | 152 | 153 | status = #{status,jdbcType=INTEGER}, 154 | 155 | 156 | create_time = #{createTime,jdbcType=TIMESTAMP}, 157 | 158 | 159 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 160 | 161 | 162 | where id = #{id,jdbcType=INTEGER} 163 | 164 | 165 | update mmall_product 166 | set category_id = #{categoryId,jdbcType=INTEGER}, 167 | name = #{name,jdbcType=VARCHAR}, 168 | subtitle = #{subtitle,jdbcType=VARCHAR}, 169 | main_image = #{mainImage,jdbcType=VARCHAR}, 170 | sub_images = #{subImages,jdbcType=VARCHAR}, 171 | detail = #{detail,jdbcType=VARCHAR}, 172 | price = #{price,jdbcType=DECIMAL}, 173 | stock = #{stock,jdbcType=INTEGER}, 174 | status = #{status,jdbcType=INTEGER}, 175 | create_time = #{createTime,jdbcType=TIMESTAMP}, 176 | update_time = #{updateTime,jdbcType=TIMESTAMP} 177 | where id = #{id,jdbcType=INTEGER} 178 | 179 | -------------------------------------------------------------------------------- /src/main/resources/mappers/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id, username, password, email, phone, question, answer, role, create_time, update_time 20 | 21 | 27 | 28 | delete from mmall_user 29 | where id = #{id,jdbcType=INTEGER} 30 | 31 | 32 | insert into mmall_user (id, username, password, 33 | email, phone, question, 34 | answer, role, create_time, 35 | update_time) 36 | values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 37 | #{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{question,jdbcType=VARCHAR}, 38 | #{answer,jdbcType=VARCHAR}, #{role,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 39 | #{updateTime,jdbcType=TIMESTAMP}) 40 | 41 | 42 | insert into mmall_user 43 | 44 | 45 | id, 46 | 47 | 48 | username, 49 | 50 | 51 | password, 52 | 53 | 54 | email, 55 | 56 | 57 | phone, 58 | 59 | 60 | question, 61 | 62 | 63 | answer, 64 | 65 | 66 | role, 67 | 68 | 69 | create_time, 70 | 71 | 72 | update_time, 73 | 74 | 75 | 76 | 77 | #{id,jdbcType=INTEGER}, 78 | 79 | 80 | #{username,jdbcType=VARCHAR}, 81 | 82 | 83 | #{password,jdbcType=VARCHAR}, 84 | 85 | 86 | #{email,jdbcType=VARCHAR}, 87 | 88 | 89 | #{phone,jdbcType=VARCHAR}, 90 | 91 | 92 | #{question,jdbcType=VARCHAR}, 93 | 94 | 95 | #{answer,jdbcType=VARCHAR}, 96 | 97 | 98 | #{role,jdbcType=INTEGER}, 99 | 100 | 101 | #{createTime,jdbcType=TIMESTAMP}, 102 | 103 | 104 | #{updateTime,jdbcType=TIMESTAMP}, 105 | 106 | 107 | 108 | 109 | update mmall_user 110 | 111 | 112 | username = #{username,jdbcType=VARCHAR}, 113 | 114 | 115 | password = #{password,jdbcType=VARCHAR}, 116 | 117 | 118 | email = #{email,jdbcType=VARCHAR}, 119 | 120 | 121 | phone = #{phone,jdbcType=VARCHAR}, 122 | 123 | 124 | question = #{question,jdbcType=VARCHAR}, 125 | 126 | 127 | answer = #{answer,jdbcType=VARCHAR}, 128 | 129 | 130 | role = #{role,jdbcType=INTEGER}, 131 | 132 | 133 | create_time = #{createTime,jdbcType=TIMESTAMP}, 134 | 135 | 136 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 137 | 138 | 139 | where id = #{id,jdbcType=INTEGER} 140 | 141 | 142 | update mmall_user 143 | set username = #{username,jdbcType=VARCHAR}, 144 | password = #{password,jdbcType=VARCHAR}, 145 | email = #{email,jdbcType=VARCHAR}, 146 | phone = #{phone,jdbcType=VARCHAR}, 147 | question = #{question,jdbcType=VARCHAR}, 148 | answer = #{answer,jdbcType=VARCHAR}, 149 | role = #{role,jdbcType=INTEGER}, 150 | create_time = #{createTime,jdbcType=TIMESTAMP}, 151 | update_time = #{updateTime,jdbcType=TIMESTAMP} 152 | where id = #{id,jdbcType=INTEGER} 153 | 154 | 155 | 159 | 160 | 167 | 168 | 172 | 173 | 177 | 178 | 179 | 183 | 184 | 185 | update mmall_user set password =#{md5Password}, update_time=now() where username=#{username} 186 | 187 | 188 | 189 | 195 | 196 | 200 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.common.TokenCache; 6 | import com.mmall.dao.UserMapper; 7 | import com.mmall.pojo.User; 8 | import com.mmall.service.UserService; 9 | import com.mmall.util.MD5Util; 10 | import org.apache.commons.lang.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.UUID; 15 | 16 | /** 17 | * Created by gegf 18 | */ 19 | @Service("userService") 20 | public class UserServiceImpl implements UserService { 21 | 22 | @Autowired 23 | private UserMapper userMapper; 24 | 25 | @Override 26 | public ServerResponse login(String username, String password) { 27 | int resultCount = userMapper.checkUsername(username); 28 | if(resultCount == 0){ 29 | return ServerResponse.createByErrorMessage("用户名不存在"); 30 | } 31 | String md5Password = MD5Util.MD5EncodeUtf8(password); 32 | 33 | User user = userMapper.selectLogin(username, md5Password); 34 | if(user == null){ 35 | return ServerResponse.createByErrorMessage("密码错误"); 36 | } 37 | user.setPassword(StringUtils.EMPTY); 38 | return ServerResponse.createBySuccess("登录成功", user); 39 | } 40 | 41 | @Override 42 | public ServerResponse register(User user) { 43 | 44 | ServerResponse validResponse = checkValid(user.getUsername(), Const.USERNAME); 45 | if(!validResponse.isSuccess()){ 46 | return validResponse; 47 | } 48 | validResponse = checkValid(user.getEmail(), Const.EMAIL); 49 | if(!validResponse.isSuccess()){ 50 | return validResponse; 51 | } 52 | //默认把角色设为普通用户 53 | user.setRole(Const.Role.ROLE_CUSTOMER); 54 | //MD5加密 55 | user.setPassword(MD5Util.MD5EncodeUtf8(user.getPassword())); 56 | int resultCount = userMapper.insert(user); 57 | if (resultCount == 0){ 58 | return ServerResponse.createByErrorMessage("注册失败"); 59 | } 60 | return ServerResponse.createBySuccessMessage("注册成功"); 61 | } 62 | 63 | @Override 64 | public ServerResponse checkValid(String str, String type) { 65 | if(StringUtils.isNotBlank(str)){ 66 | if(Const.USERNAME.equals(type)){ 67 | int resultCount = userMapper.checkUsername(str); 68 | if(resultCount > 0){ 69 | return ServerResponse.createByErrorMessage("用户名已存在"); 70 | } 71 | }else if(Const.EMAIL.equals(type)){ 72 | int resultCount = userMapper.checkEmail(str); 73 | if(resultCount > 0){ 74 | return ServerResponse.createByErrorMessage("邮箱已存在"); 75 | } 76 | } 77 | }else{ 78 | return ServerResponse.createByErrorMessage("参数错误"); 79 | } 80 | return ServerResponse.createBySuccessMessage("校验成功"); 81 | } 82 | 83 | @Override 84 | public ServerResponse selectQuestion(String username) { 85 | ServerResponse validResponse = checkValid(username, Const.USERNAME); 86 | if(validResponse.isSuccess()){ 87 | return ServerResponse.createByErrorMessage("用户不存在"); 88 | } 89 | String question = userMapper.selectQuestionByUsername(username); 90 | if(StringUtils.isNotBlank(question)){ 91 | return ServerResponse.createBySuccess(question); 92 | } 93 | return ServerResponse.createByErrorMessage("找回密码的问题为空"); 94 | } 95 | 96 | @Override 97 | public ServerResponse checkAnswer(String username, String question, String answer) { 98 | int resultCount = userMapper.checkAnswer(username, question, answer); 99 | if (resultCount > 0){ 100 | String forgetToken = UUID.randomUUID().toString(); 101 | TokenCache.setKey("token_"+username, forgetToken); 102 | return ServerResponse.createBySuccess(forgetToken); 103 | } 104 | return ServerResponse.createBySuccessMessage("答案错误"); 105 | } 106 | 107 | @Override 108 | public ServerResponse forgetResetPassword(String username, String passwordNew, String forgetToken) { 109 | if(StringUtils.isBlank(forgetToken)){ 110 | return ServerResponse.createByErrorMessage("参数错误"); 111 | } 112 | ServerResponse validResponse = checkValid(username, Const.USERNAME); 113 | if(validResponse.isSuccess()){ 114 | return ServerResponse.createByErrorMessage("用户不存在"); 115 | } 116 | String token = TokenCache.getKey(TokenCache.TOKEN_PREFIX+username); 117 | if(StringUtils.isBlank(token)){ 118 | return ServerResponse.createByErrorMessage("Token无效或过期"); 119 | } 120 | if(StringUtils.equals(forgetToken, token)){ 121 | String md5Password = MD5Util.MD5EncodeUtf8(passwordNew); 122 | int rowCount = userMapper.updatePasswordByUsername(username, md5Password); 123 | if(rowCount > 0){ 124 | return ServerResponse.createBySuccess("修改密码成功"); 125 | } 126 | }else { 127 | return ServerResponse.createByErrorMessage("token错误,请重新获取token"); 128 | } 129 | 130 | return ServerResponse.createByErrorMessage("修改密码失败"); 131 | } 132 | 133 | @Override 134 | public ServerResponse resetPassword(String passwordOld, String passwordNew, User user) { 135 | //防止横向越权,要校验用户旧密码 136 | int count = userMapper.checkPassword(MD5Util.MD5EncodeUtf8(passwordOld), user.getId()); 137 | if(count == 0){ 138 | return ServerResponse.createByErrorMessage("旧密码错误"); 139 | } 140 | user.setPassword(MD5Util.MD5EncodeUtf8(passwordNew)); 141 | int updateCount = userMapper.updateByPrimaryKeySelective(user); //选择性更新 142 | if (updateCount > 0){ 143 | return ServerResponse.createBySuccessMessage("密码更新成功"); 144 | } 145 | return ServerResponse.createByErrorMessage("密码更新失败"); 146 | } 147 | 148 | @Override 149 | public ServerResponse updateUserInformation(User user) { 150 | //username不更新 151 | int count = userMapper.checkEmailByUserId(user.getEmail(), user.getId()); 152 | 153 | if(count > 0){ 154 | return ServerResponse.createByErrorMessage("邮箱已存在"); 155 | } 156 | User updateUser = new User(); 157 | updateUser.setId(user.getId()); 158 | updateUser.setEmail(user.getEmail()); 159 | updateUser.setPhone(user.getPhone()); 160 | updateUser.setQuestion(user.getQuestion()); 161 | updateUser.setAnswer(user.getAnswer()); 162 | 163 | int updateCount = userMapper.updateByPrimaryKeySelective(updateUser); 164 | if(updateCount > 0){ 165 | return ServerResponse.createBySuccessMessage("更新个人信息成功"); 166 | } 167 | return ServerResponse.createByErrorMessage("更新个人信息失败"); 168 | } 169 | 170 | @Override 171 | public ServerResponse getInformation(Integer userId) { 172 | User user = userMapper.selectByPrimaryKey(userId); 173 | if(user == null){ 174 | return ServerResponse.createByErrorMessage("找不到当前用户"); 175 | } 176 | user.setPassword(org.apache.commons.lang3.StringUtils.EMPTY); 177 | return ServerResponse.createBySuccess(user); 178 | } 179 | 180 | @Override 181 | public ServerResponse checkAdminRole(User user) { 182 | if(user != null && user.getRole().intValue() == Const.Role.ROLE_ADMIN){ 183 | ServerResponse.createBySuccess(); 184 | } 185 | return ServerResponse.createByError(); 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /src/main/resources/mappers/ShippingMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id, user_id, receiver_name, receiver_phone, receiver_mobile, receiver_province, receiver_city, 22 | receiver_district, receiver_address, receiver_zip, create_time, update_time 23 | 24 | 30 | 31 | delete from mmall_shipping 32 | where id = #{id,jdbcType=INTEGER} 33 | 34 | 35 | insert into mmall_shipping (id, user_id, receiver_name, 36 | receiver_phone, receiver_mobile, receiver_province, 37 | receiver_city, receiver_district, receiver_address, 38 | receiver_zip, create_time, update_time 39 | ) 40 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR}, 41 | #{receiverPhone,jdbcType=VARCHAR}, #{receiverMobile,jdbcType=VARCHAR}, #{receiverProvince,jdbcType=VARCHAR}, 42 | #{receiverCity,jdbcType=VARCHAR}, #{receiverDistrict,jdbcType=VARCHAR}, #{receiverAddress,jdbcType=VARCHAR}, 43 | #{receiverZip,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} 44 | ) 45 | 46 | 47 | insert into mmall_shipping 48 | 49 | 50 | id, 51 | 52 | 53 | user_id, 54 | 55 | 56 | receiver_name, 57 | 58 | 59 | receiver_phone, 60 | 61 | 62 | receiver_mobile, 63 | 64 | 65 | receiver_province, 66 | 67 | 68 | receiver_city, 69 | 70 | 71 | receiver_district, 72 | 73 | 74 | receiver_address, 75 | 76 | 77 | receiver_zip, 78 | 79 | 80 | create_time, 81 | 82 | 83 | update_time, 84 | 85 | 86 | 87 | 88 | #{id,jdbcType=INTEGER}, 89 | 90 | 91 | #{userId,jdbcType=INTEGER}, 92 | 93 | 94 | #{receiverName,jdbcType=VARCHAR}, 95 | 96 | 97 | #{receiverPhone,jdbcType=VARCHAR}, 98 | 99 | 100 | #{receiverMobile,jdbcType=VARCHAR}, 101 | 102 | 103 | #{receiverProvince,jdbcType=VARCHAR}, 104 | 105 | 106 | #{receiverCity,jdbcType=VARCHAR}, 107 | 108 | 109 | #{receiverDistrict,jdbcType=VARCHAR}, 110 | 111 | 112 | #{receiverAddress,jdbcType=VARCHAR}, 113 | 114 | 115 | #{receiverZip,jdbcType=VARCHAR}, 116 | 117 | 118 | #{createTime,jdbcType=TIMESTAMP}, 119 | 120 | 121 | #{updateTime,jdbcType=TIMESTAMP}, 122 | 123 | 124 | 125 | 126 | update mmall_shipping 127 | 128 | 129 | user_id = #{userId,jdbcType=INTEGER}, 130 | 131 | 132 | receiver_name = #{receiverName,jdbcType=VARCHAR}, 133 | 134 | 135 | receiver_phone = #{receiverPhone,jdbcType=VARCHAR}, 136 | 137 | 138 | receiver_mobile = #{receiverMobile,jdbcType=VARCHAR}, 139 | 140 | 141 | receiver_province = #{receiverProvince,jdbcType=VARCHAR}, 142 | 143 | 144 | receiver_city = #{receiverCity,jdbcType=VARCHAR}, 145 | 146 | 147 | receiver_district = #{receiverDistrict,jdbcType=VARCHAR}, 148 | 149 | 150 | receiver_address = #{receiverAddress,jdbcType=VARCHAR}, 151 | 152 | 153 | receiver_zip = #{receiverZip,jdbcType=VARCHAR}, 154 | 155 | 156 | create_time = #{createTime,jdbcType=TIMESTAMP}, 157 | 158 | 159 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 160 | 161 | 162 | where id = #{id,jdbcType=INTEGER} 163 | 164 | 165 | update mmall_shipping 166 | set user_id = #{userId,jdbcType=INTEGER}, 167 | receiver_name = #{receiverName,jdbcType=VARCHAR}, 168 | receiver_phone = #{receiverPhone,jdbcType=VARCHAR}, 169 | receiver_mobile = #{receiverMobile,jdbcType=VARCHAR}, 170 | receiver_province = #{receiverProvince,jdbcType=VARCHAR}, 171 | receiver_city = #{receiverCity,jdbcType=VARCHAR}, 172 | receiver_district = #{receiverDistrict,jdbcType=VARCHAR}, 173 | receiver_address = #{receiverAddress,jdbcType=VARCHAR}, 174 | receiver_zip = #{receiverZip,jdbcType=VARCHAR}, 175 | create_time = #{createTime,jdbcType=TIMESTAMP}, 176 | update_time = #{updateTime,jdbcType=TIMESTAMP} 177 | where id = #{id,jdbcType=INTEGER} 178 | 179 | -------------------------------------------------------------------------------- /src/main/resources/mappers/OrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | id, order_no, user_id, shipping_id, payment, payment_type, postage, status, payment_time, 24 | send_time, end_time, close_time, create_time, update_time 25 | 26 | 32 | 33 | delete from mmall_order 34 | where id = #{id,jdbcType=INTEGER} 35 | 36 | 37 | insert into mmall_order (id, order_no, user_id, 38 | shipping_id, payment, payment_type, 39 | postage, status, payment_time, 40 | send_time, end_time, close_time, 41 | create_time, update_time) 42 | values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, #{userId,jdbcType=INTEGER}, 43 | #{shippingId,jdbcType=INTEGER}, #{payment,jdbcType=DECIMAL}, #{paymentType,jdbcType=INTEGER}, 44 | #{postage,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{paymentTime,jdbcType=TIMESTAMP}, 45 | #{sendTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{closeTime,jdbcType=TIMESTAMP}, 46 | #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}) 47 | 48 | 49 | insert into mmall_order 50 | 51 | 52 | id, 53 | 54 | 55 | order_no, 56 | 57 | 58 | user_id, 59 | 60 | 61 | shipping_id, 62 | 63 | 64 | payment, 65 | 66 | 67 | payment_type, 68 | 69 | 70 | postage, 71 | 72 | 73 | status, 74 | 75 | 76 | payment_time, 77 | 78 | 79 | send_time, 80 | 81 | 82 | end_time, 83 | 84 | 85 | close_time, 86 | 87 | 88 | create_time, 89 | 90 | 91 | update_time, 92 | 93 | 94 | 95 | 96 | #{id,jdbcType=INTEGER}, 97 | 98 | 99 | #{orderNo,jdbcType=BIGINT}, 100 | 101 | 102 | #{userId,jdbcType=INTEGER}, 103 | 104 | 105 | #{shippingId,jdbcType=INTEGER}, 106 | 107 | 108 | #{payment,jdbcType=DECIMAL}, 109 | 110 | 111 | #{paymentType,jdbcType=INTEGER}, 112 | 113 | 114 | #{postage,jdbcType=INTEGER}, 115 | 116 | 117 | #{status,jdbcType=INTEGER}, 118 | 119 | 120 | #{paymentTime,jdbcType=TIMESTAMP}, 121 | 122 | 123 | #{sendTime,jdbcType=TIMESTAMP}, 124 | 125 | 126 | #{endTime,jdbcType=TIMESTAMP}, 127 | 128 | 129 | #{closeTime,jdbcType=TIMESTAMP}, 130 | 131 | 132 | #{createTime,jdbcType=TIMESTAMP}, 133 | 134 | 135 | #{updateTime,jdbcType=TIMESTAMP}, 136 | 137 | 138 | 139 | 140 | update mmall_order 141 | 142 | 143 | order_no = #{orderNo,jdbcType=BIGINT}, 144 | 145 | 146 | user_id = #{userId,jdbcType=INTEGER}, 147 | 148 | 149 | shipping_id = #{shippingId,jdbcType=INTEGER}, 150 | 151 | 152 | payment = #{payment,jdbcType=DECIMAL}, 153 | 154 | 155 | payment_type = #{paymentType,jdbcType=INTEGER}, 156 | 157 | 158 | postage = #{postage,jdbcType=INTEGER}, 159 | 160 | 161 | status = #{status,jdbcType=INTEGER}, 162 | 163 | 164 | payment_time = #{paymentTime,jdbcType=TIMESTAMP}, 165 | 166 | 167 | send_time = #{sendTime,jdbcType=TIMESTAMP}, 168 | 169 | 170 | end_time = #{endTime,jdbcType=TIMESTAMP}, 171 | 172 | 173 | close_time = #{closeTime,jdbcType=TIMESTAMP}, 174 | 175 | 176 | create_time = #{createTime,jdbcType=TIMESTAMP}, 177 | 178 | 179 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 180 | 181 | 182 | where id = #{id,jdbcType=INTEGER} 183 | 184 | 185 | update mmall_order 186 | set order_no = #{orderNo,jdbcType=BIGINT}, 187 | user_id = #{userId,jdbcType=INTEGER}, 188 | shipping_id = #{shippingId,jdbcType=INTEGER}, 189 | payment = #{payment,jdbcType=DECIMAL}, 190 | payment_type = #{paymentType,jdbcType=INTEGER}, 191 | postage = #{postage,jdbcType=INTEGER}, 192 | status = #{status,jdbcType=INTEGER}, 193 | payment_time = #{paymentTime,jdbcType=TIMESTAMP}, 194 | send_time = #{sendTime,jdbcType=TIMESTAMP}, 195 | end_time = #{endTime,jdbcType=TIMESTAMP}, 196 | close_time = #{closeTime,jdbcType=TIMESTAMP}, 197 | create_time = #{createTime,jdbcType=TIMESTAMP}, 198 | update_time = #{updateTime,jdbcType=TIMESTAMP} 199 | where id = #{id,jdbcType=INTEGER} 200 | 201 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com 5 | mmail 6 | war 7 | 1.0-SNAPSHOT 8 | mmail Maven Webapp 9 | http://maven.apache.org 10 | 11 | 12 | UTF-8 13 | UTF-8 14 | UTF-8 15 | 16 | 4.0.0.RELEASE 17 | 3.4.1 18 | 1.3.0 19 | 20 | 21 | 22 | 23 | 24 | org.apache.tomcat 25 | tomcat-servlet-api 26 | 7.0.64 27 | 28 | 29 | 30 | org.springframework 31 | spring-webmvc 32 | ${org.springframework.version} 33 | 34 | 35 | 36 | org.springframework 37 | spring-oxm 38 | ${org.springframework.version} 39 | 40 | 41 | 42 | org.springframework 43 | spring-jdbc 44 | ${org.springframework.version} 45 | 46 | 47 | 48 | org.springframework 49 | spring-tx 50 | ${org.springframework.version} 51 | 52 | 53 | 54 | org.springframework 55 | spring-test 56 | ${org.springframework.version} 57 | 58 | 59 | 60 | 61 | org.aspectj 62 | aspectjweaver 63 | 1.7.3 64 | 65 | 66 | 67 | org.mybatis 68 | mybatis-spring 69 | ${org.mybatis.spring.version} 70 | 71 | 72 | org.mybatis 73 | mybatis 74 | ${org.mybatis.version} 75 | 76 | 77 | 78 | org.aspectj 79 | aspectjrt 80 | 1.6.11 81 | 82 | 83 | 84 | org.codehaus.jackson 85 | jackson-mapper-asl 86 | 1.9.12 87 | 88 | 89 | 90 | commons-dbcp 91 | commons-dbcp 92 | 1.4 93 | 94 | 95 | 96 | 97 | 98 | ch.qos.logback 99 | logback-classic 100 | 1.1.2 101 | compile 102 | 103 | 104 | ch.qos.logback 105 | logback-core 106 | 1.1.2 107 | compile 108 | 109 | 110 | 111 | mysql 112 | mysql-connector-java 113 | 5.1.6 114 | 115 | 116 | 117 | com.google.guava 118 | guava 119 | 20.0 120 | 121 | 122 | 123 | 124 | org.apache.commons 125 | commons-lang3 126 | 3.5 127 | 128 | 129 | 130 | 131 | commons-collections 132 | commons-collections 133 | 3.2.1 134 | 135 | 136 | 137 | 138 | junit 139 | junit 140 | 4.12 141 | 142 | 143 | 144 | 145 | joda-time 146 | joda-time 147 | 2.3 148 | 149 | 150 | 151 | 152 | 153 | org.hashids 154 | hashids 155 | 1.0.1 156 | 157 | 158 | 159 | 160 | 161 | commons-net 162 | commons-net 163 | 3.1 164 | 165 | 166 | 167 | 168 | 169 | 170 | commons-fileupload 171 | commons-fileupload 172 | 1.2.2 173 | 174 | 175 | 176 | commons-io 177 | commons-io 178 | 2.0.1 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | com.github.pagehelper 188 | pagehelper 189 | 4.1.0 190 | 191 | 192 | 193 | com.github.miemiedev 194 | mybatis-paginator 195 | 1.2.17 196 | 197 | 198 | 199 | com.github.jsqlparser 200 | jsqlparser 201 | 0.9.4 202 | 203 | 204 | 205 | 206 | 207 | commons-codec 208 | commons-codec 209 | 1.10 210 | 211 | 212 | commons-configuration 213 | commons-configuration 214 | 1.10 215 | 216 | 217 | commons-lang 218 | commons-lang 219 | 2.6 220 | 221 | 222 | commons-logging 223 | commons-logging 224 | 1.1.1 225 | 226 | 227 | com.google.zxing 228 | core 229 | 2.1 230 | 231 | 232 | com.google.code.gson 233 | gson 234 | 2.3.1 235 | 236 | 237 | org.hamcrest 238 | hamcrest-core 239 | 1.3 240 | 241 | 242 | 243 | redis.clients 244 | jedis 245 | 2.9.0 246 | 247 | 248 | 249 | 250 | 251 | mmail 252 | 253 | 254 | org.mybatis.generator 255 | mybatis-generator-maven-plugin 256 | 1.3.2 257 | 258 | true 259 | true 260 | 261 | 262 | 263 | 264 | 265 | org.apache.maven.plugins 266 | maven-compiler-plugin 267 | 268 | 1.7 269 | 1.7 270 | UTF-8 271 | 272 | ${project.basedir}/src/main/webapp/WEB-INF/lib 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | -------------------------------------------------------------------------------- /sqlScript/mmall.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 182.92.82.103 5 | Source Server Type : MySQL 6 | Source Server Version : 50173 7 | Source Host : 182.92.82.103 8 | Source Database : mmall 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50173 12 | File Encoding : utf-8 13 | 14 | Date: 04/13/2017 22:04:18 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `mmall_cart` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `mmall_cart`; 24 | CREATE TABLE `mmall_cart` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT, 26 | `user_id` int(11) NOT NULL, 27 | `product_id` int(11) DEFAULT NULL COMMENT '商品id', 28 | `quantity` int(11) DEFAULT NULL COMMENT '数量', 29 | `checked` int(11) DEFAULT NULL COMMENT '是否选择,1=已勾选,0=未勾选', 30 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', 31 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 32 | PRIMARY KEY (`id`), 33 | KEY `user_id_index` (`user_id`) USING BTREE 34 | ) ENGINE=InnoDB AUTO_INCREMENT=146 DEFAULT CHARSET=utf8; 35 | 36 | -- ---------------------------- 37 | -- Records of `mmall_cart` 38 | -- ---------------------------- 39 | BEGIN; 40 | INSERT INTO `mmall_cart` VALUES ('126', '21', '26', '1', '1', '2017-04-13 21:27:06', '2017-04-13 21:27:06'); 41 | COMMIT; 42 | 43 | -- ---------------------------- 44 | -- Table structure for `mmall_category` 45 | -- ---------------------------- 46 | DROP TABLE IF EXISTS `mmall_category`; 47 | CREATE TABLE `mmall_category` ( 48 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '类别Id', 49 | `parent_id` int(11) DEFAULT NULL COMMENT '父类别id当id=0时说明是根节点,一级类别', 50 | `name` varchar(50) DEFAULT NULL COMMENT '类别名称', 51 | `status` tinyint(1) DEFAULT '1' COMMENT '类别状态1-正常,2-已废弃', 52 | `sort_order` int(4) DEFAULT NULL COMMENT '排序编号,同类展示顺序,数值相等则自然排序', 53 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', 54 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 55 | PRIMARY KEY (`id`) 56 | ) ENGINE=InnoDB AUTO_INCREMENT=100032 DEFAULT CHARSET=utf8; 57 | 58 | -- ---------------------------- 59 | -- Records of `mmall_category` 60 | -- ---------------------------- 61 | BEGIN; 62 | INSERT INTO `mmall_category` VALUES ('100001', '0', '家用电器', '1', null, '2017-03-25 16:46:00', '2017-03-25 16:46:00'), ('100002', '0', '数码3C', '1', null, '2017-03-25 16:46:21', '2017-03-25 16:46:21'), ('100003', '0', '服装箱包', '1', null, '2017-03-25 16:49:53', '2017-03-25 16:49:53'), ('100004', '0', '食品生鲜', '1', null, '2017-03-25 16:50:19', '2017-03-25 16:50:19'), ('100005', '0', '酒水饮料', '1', null, '2017-03-25 16:50:29', '2017-03-25 16:50:29'), ('100006', '100001', '冰箱', '1', null, '2017-03-25 16:52:15', '2017-03-25 16:52:15'), ('100007', '100001', '电视', '1', null, '2017-03-25 16:52:26', '2017-03-25 16:52:26'), ('100008', '100001', '洗衣机', '1', null, '2017-03-25 16:52:39', '2017-03-25 16:52:39'), ('100009', '100001', '空调', '1', null, '2017-03-25 16:52:45', '2017-03-25 16:52:45'), ('100010', '100001', '电热水器', '1', null, '2017-03-25 16:52:54', '2017-03-25 16:52:54'), ('100011', '100002', '电脑', '1', null, '2017-03-25 16:53:18', '2017-03-25 16:53:18'), ('100012', '100002', '手机', '1', null, '2017-03-25 16:53:27', '2017-03-25 16:53:27'), ('100013', '100002', '平板电脑', '1', null, '2017-03-25 16:53:35', '2017-03-25 16:53:35'), ('100014', '100002', '数码相机', '1', null, '2017-03-25 16:53:56', '2017-03-25 16:53:56'), ('100015', '100002', '3C配件', '1', null, '2017-03-25 16:54:07', '2017-03-25 16:54:07'), ('100016', '100003', '女装', '1', null, '2017-03-25 16:54:44', '2017-03-25 16:54:44'), ('100017', '100003', '帽子', '1', null, '2017-03-25 16:54:51', '2017-03-25 16:54:51'), ('100018', '100003', '旅行箱', '1', null, '2017-03-25 16:55:02', '2017-03-25 16:55:02'), ('100019', '100003', '手提包', '1', null, '2017-03-25 16:55:09', '2017-03-25 16:55:09'), ('100020', '100003', '保暖内衣', '1', null, '2017-03-25 16:55:18', '2017-03-25 16:55:18'), ('100021', '100004', '零食', '1', null, '2017-03-25 16:55:30', '2017-03-25 16:55:30'), ('100022', '100004', '生鲜', '1', null, '2017-03-25 16:55:37', '2017-03-25 16:55:37'), ('100023', '100004', '半成品菜', '1', null, '2017-03-25 16:55:47', '2017-03-25 16:55:47'), ('100024', '100004', '速冻食品', '1', null, '2017-03-25 16:55:56', '2017-03-25 16:55:56'), ('100025', '100004', '进口食品', '1', null, '2017-03-25 16:56:06', '2017-03-25 16:56:06'), ('100026', '100005', '白酒', '1', null, '2017-03-25 16:56:22', '2017-03-25 16:56:22'), ('100027', '100005', '红酒', '1', null, '2017-03-25 16:56:30', '2017-03-25 16:56:30'), ('100028', '100005', '饮料', '1', null, '2017-03-25 16:56:37', '2017-03-25 16:56:37'), ('100029', '100005', '调制鸡尾酒', '1', null, '2017-03-25 16:56:45', '2017-03-25 16:56:45'), ('100030', '100005', '进口洋酒', '1', null, '2017-03-25 16:57:05', '2017-03-25 16:57:05'); 63 | COMMIT; 64 | 65 | -- ---------------------------- 66 | -- Table structure for `mmall_order` 67 | -- ---------------------------- 68 | DROP TABLE IF EXISTS `mmall_order`; 69 | CREATE TABLE `mmall_order` ( 70 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '订单id', 71 | `order_no` bigint(20) DEFAULT NULL COMMENT '订单号', 72 | `user_id` int(11) DEFAULT NULL COMMENT '用户id', 73 | `shipping_id` int(11) DEFAULT NULL, 74 | `payment` decimal(20,2) DEFAULT NULL COMMENT '实际付款金额,单位是元,保留两位小数', 75 | `payment_type` int(4) DEFAULT NULL COMMENT '支付类型,1-在线支付', 76 | `postage` int(10) DEFAULT NULL COMMENT '运费,单位是元', 77 | `status` int(10) DEFAULT NULL COMMENT '订单状态:0-已取消-10-未付款,20-已付款,40-已发货,50-交易成功,60-交易关闭', 78 | `payment_time` datetime DEFAULT NULL COMMENT '支付时间', 79 | `send_time` datetime DEFAULT NULL COMMENT '发货时间', 80 | `end_time` datetime DEFAULT NULL COMMENT '交易完成时间', 81 | `close_time` datetime DEFAULT NULL COMMENT '交易关闭时间', 82 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', 83 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 84 | PRIMARY KEY (`id`), 85 | UNIQUE KEY `order_no_index` (`order_no`) USING BTREE 86 | ) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8; 87 | 88 | -- ---------------------------- 89 | -- Records of `mmall_order` 90 | -- ---------------------------- 91 | BEGIN; 92 | INSERT INTO `mmall_order` VALUES ('103', '1491753014256', '1', '25', '13998.00', '1', '0', '10', null, null, null, null, '2017-04-09 23:50:14', '2017-04-09 23:50:14'), ('104', '1491830695216', '1', '26', '13998.00', '1', '0', '10', null, null, null, null, '2017-04-10 21:24:55', '2017-04-10 21:24:55'), ('105', '1492089528889', '1', '29', '3299.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:18:48', '2017-04-13 21:18:48'), ('106', '1492090946105', '1', '29', '27894.00', '1', '0', '20', '2017-04-13 21:42:40', null, null, null, '2017-04-13 21:42:26', '2017-04-13 21:42:41'), ('107', '1492091003128', '1', '29', '8597.00', '1', '0', '20', '2017-04-13 21:43:38', null, null, null, '2017-04-13 21:43:23', '2017-04-13 21:43:38'), ('108', '1492091051313', '1', '29', '1999.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:11', '2017-04-13 21:44:11'), ('109', '1492091061513', '1', '29', '6598.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:21', '2017-04-13 21:44:21'), ('110', '1492091069563', '1', '29', '3299.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:29', '2017-04-13 21:44:29'), ('111', '1492091076073', '1', '29', '4299.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:36', '2017-04-13 21:44:36'), ('112', '1492091083720', '1', '29', '3299.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:43', '2017-04-13 21:44:43'), ('113', '1492091089794', '1', '29', '6999.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:49', '2017-04-13 21:44:49'), ('114', '1492091096400', '1', '29', '6598.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:44:56', '2017-04-13 21:44:56'), ('115', '1492091102371', '1', '29', '3299.00', '1', '0', '10', null, null, null, null, '2017-04-13 21:45:02', '2017-04-13 21:45:02'), ('116', '1492091110004', '1', '29', '8598.00', '1', '0', '40', '2017-04-13 21:55:16', '2017-04-13 21:55:31', null, null, '2017-04-13 21:45:09', '2017-04-13 21:55:31'), ('117', '1492091141269', '1', '29', '22894.00', '1', '0', '20', '2017-04-13 21:46:06', null, null, null, '2017-04-13 21:45:41', '2017-04-13 21:46:07'); 93 | COMMIT; 94 | 95 | -- ---------------------------- 96 | -- Table structure for `mmall_order_item` 97 | -- ---------------------------- 98 | DROP TABLE IF EXISTS `mmall_order_item`; 99 | CREATE TABLE `mmall_order_item` ( 100 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '订单子表id', 101 | `user_id` int(11) DEFAULT NULL, 102 | `order_no` bigint(20) DEFAULT NULL, 103 | `product_id` int(11) DEFAULT NULL COMMENT '商品id', 104 | `product_name` varchar(100) DEFAULT NULL COMMENT '商品名称', 105 | `product_image` varchar(500) DEFAULT NULL COMMENT '商品图片地址', 106 | `current_unit_price` decimal(20,2) DEFAULT NULL COMMENT '生成订单时的商品单价,单位是元,保留两位小数', 107 | `quantity` int(10) DEFAULT NULL COMMENT '商品数量', 108 | `total_price` decimal(20,2) DEFAULT NULL COMMENT '商品总价,单位是元,保留两位小数', 109 | `create_time` datetime DEFAULT NULL, 110 | `update_time` datetime DEFAULT NULL, 111 | PRIMARY KEY (`id`), 112 | KEY `order_no_index` (`order_no`) USING BTREE, 113 | KEY `order_no_user_id_index` (`user_id`,`order_no`) USING BTREE 114 | ) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8; 115 | 116 | -- ---------------------------- 117 | -- Records of `mmall_order_item` 118 | -- ---------------------------- 119 | BEGIN; 120 | INSERT INTO `mmall_order_item` VALUES ('113', '1', '1491753014256', '26', 'Apple iPhone 7 Plus (A1661) 128G 玫瑰金色 移动联通电信4G手机', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg', '6999.00', '2', '13998.00', '2017-04-09 23:50:14', '2017-04-09 23:50:14'), ('114', '1', '1491830695216', '26', 'Apple iPhone 7 Plus (A1661) 128G 玫瑰金色 移动联通电信4G手机', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg', '6999.00', '2', '13998.00', '2017-04-10 21:24:55', '2017-04-10 21:24:55'), ('115', '1', '1492089528889', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '1', '3299.00', '2017-04-13 21:18:48', '2017-04-13 21:18:48'), ('116', '1', '1492090946105', '29', 'Haier/海尔HJ100-1HU1 10公斤滚筒洗衣机全自动带烘干家用大容量 洗烘一体', '173335a4-5dce-4afd-9f18-a10623724c4e.jpeg', '4299.00', '2', '8598.00', '2017-04-13 21:42:26', '2017-04-13 21:42:26'), ('117', '1', '1492090946105', '28', '4+64G送手环/Huawei/华为 nova 手机P9/P10plus青春', '0093f5d3-bdb4-4fb0-bec5-5465dfd26363.jpeg', '1999.00', '1', '1999.00', '2017-04-13 21:42:26', '2017-04-13 21:42:26'), ('118', '1', '1492090946105', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '1', '3299.00', '2017-04-13 21:42:26', '2017-04-13 21:42:26'), ('119', '1', '1492090946105', '26', 'Apple iPhone 7 Plus (A1661) 128G 玫瑰金色 移动联通电信4G手机', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg', '6999.00', '2', '13998.00', '2017-04-13 21:42:26', '2017-04-13 21:42:26'), ('120', '1', '1492091003128', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '2', '6598.00', '2017-04-13 21:43:23', '2017-04-13 21:43:23'), ('121', '1', '1492091003128', '28', '4+64G送手环/Huawei/华为 nova 手机P9/P10plus青春', '0093f5d3-bdb4-4fb0-bec5-5465dfd26363.jpeg', '1999.00', '1', '1999.00', '2017-04-13 21:43:23', '2017-04-13 21:43:23'), ('122', '1', '1492091051313', '28', '4+64G送手环/Huawei/华为 nova 手机P9/P10plus青春', '0093f5d3-bdb4-4fb0-bec5-5465dfd26363.jpeg', '1999.00', '1', '1999.00', '2017-04-13 21:44:11', '2017-04-13 21:44:11'), ('123', '1', '1492091061513', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '2', '6598.00', '2017-04-13 21:44:21', '2017-04-13 21:44:21'), ('124', '1', '1492091069563', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '1', '3299.00', '2017-04-13 21:44:29', '2017-04-13 21:44:29'), ('125', '1', '1492091076073', '29', 'Haier/海尔HJ100-1HU1 10公斤滚筒洗衣机全自动带烘干家用大容量 洗烘一体', '173335a4-5dce-4afd-9f18-a10623724c4e.jpeg', '4299.00', '1', '4299.00', '2017-04-13 21:44:36', '2017-04-13 21:44:36'), ('126', '1', '1492091083720', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '1', '3299.00', '2017-04-13 21:44:43', '2017-04-13 21:44:43'), ('127', '1', '1492091089794', '26', 'Apple iPhone 7 Plus (A1661) 128G 玫瑰金色 移动联通电信4G手机', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg', '6999.00', '1', '6999.00', '2017-04-13 21:44:49', '2017-04-13 21:44:49'), ('128', '1', '1492091096400', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '2', '6598.00', '2017-04-13 21:44:56', '2017-04-13 21:44:56'), ('129', '1', '1492091102371', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '1', '3299.00', '2017-04-13 21:45:02', '2017-04-13 21:45:02'), ('130', '1', '1492091110004', '29', 'Haier/海尔HJ100-1HU1 10公斤滚筒洗衣机全自动带烘干家用大容量 洗烘一体', '173335a4-5dce-4afd-9f18-a10623724c4e.jpeg', '4299.00', '2', '8598.00', '2017-04-13 21:45:09', '2017-04-13 21:45:09'), ('131', '1', '1492091141269', '26', 'Apple iPhone 7 Plus (A1661) 128G 玫瑰金色 移动联通电信4G手机', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg', '6999.00', '1', '6999.00', '2017-04-13 21:45:41', '2017-04-13 21:45:41'), ('132', '1', '1492091141269', '27', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', '3299.00', '1', '3299.00', '2017-04-13 21:45:41', '2017-04-13 21:45:41'), ('133', '1', '1492091141269', '29', 'Haier/海尔HJ100-1HU1 10公斤滚筒洗衣机全自动带烘干家用大容量 洗烘一体', '173335a4-5dce-4afd-9f18-a10623724c4e.jpeg', '4299.00', '2', '8598.00', '2017-04-13 21:45:41', '2017-04-13 21:45:41'), ('134', '1', '1492091141269', '28', '4+64G送手环/Huawei/华为 nova 手机P9/P10plus青春', '0093f5d3-bdb4-4fb0-bec5-5465dfd26363.jpeg', '1999.00', '2', '3998.00', '2017-04-13 21:45:41', '2017-04-13 21:45:41'); 121 | COMMIT; 122 | 123 | -- ---------------------------- 124 | -- Table structure for `mmall_pay_info` 125 | -- ---------------------------- 126 | DROP TABLE IF EXISTS `mmall_pay_info`; 127 | CREATE TABLE `mmall_pay_info` ( 128 | `id` int(11) NOT NULL AUTO_INCREMENT, 129 | `user_id` int(11) DEFAULT NULL COMMENT '用户id', 130 | `order_no` bigint(20) DEFAULT NULL COMMENT '订单号', 131 | `pay_platform` int(10) DEFAULT NULL COMMENT '支付平台:1-支付宝,2-微信', 132 | `platform_number` varchar(200) DEFAULT NULL COMMENT '支付宝支付流水号', 133 | `platform_status` varchar(20) DEFAULT NULL COMMENT '支付宝支付状态', 134 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', 135 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 136 | PRIMARY KEY (`id`) 137 | ) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8; 138 | 139 | -- ---------------------------- 140 | -- Records of `mmall_pay_info` 141 | -- ---------------------------- 142 | BEGIN; 143 | INSERT INTO `mmall_pay_info` VALUES ('53', '1', '1492090946105', '1', '2017041321001004300200116250', 'WAIT_BUYER_PAY', '2017-04-13 21:42:33', '2017-04-13 21:42:33'), ('54', '1', '1492090946105', '1', '2017041321001004300200116250', 'TRADE_SUCCESS', '2017-04-13 21:42:41', '2017-04-13 21:42:41'), ('55', '1', '1492091003128', '1', '2017041321001004300200116251', 'WAIT_BUYER_PAY', '2017-04-13 21:43:31', '2017-04-13 21:43:31'), ('56', '1', '1492091003128', '1', '2017041321001004300200116251', 'TRADE_SUCCESS', '2017-04-13 21:43:38', '2017-04-13 21:43:38'), ('57', '1', '1492091141269', '1', '2017041321001004300200116252', 'WAIT_BUYER_PAY', '2017-04-13 21:45:59', '2017-04-13 21:45:59'), ('58', '1', '1492091141269', '1', '2017041321001004300200116252', 'TRADE_SUCCESS', '2017-04-13 21:46:07', '2017-04-13 21:46:07'), ('59', '1', '1492091110004', '1', '2017041321001004300200116396', 'WAIT_BUYER_PAY', '2017-04-13 21:55:08', '2017-04-13 21:55:08'), ('60', '1', '1492091110004', '1', '2017041321001004300200116396', 'TRADE_SUCCESS', '2017-04-13 21:55:17', '2017-04-13 21:55:17'); 144 | COMMIT; 145 | 146 | -- ---------------------------- 147 | -- Table structure for `mmall_product` 148 | -- ---------------------------- 149 | DROP TABLE IF EXISTS `mmall_product`; 150 | CREATE TABLE `mmall_product` ( 151 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商品id', 152 | `category_id` int(11) NOT NULL COMMENT '分类id,对应mmall_category表的主键', 153 | `name` varchar(100) NOT NULL COMMENT '商品名称', 154 | `subtitle` varchar(200) DEFAULT NULL COMMENT '商品副标题', 155 | `main_image` varchar(500) DEFAULT NULL COMMENT '产品主图,url相对地址', 156 | `sub_images` text COMMENT '图片地址,json格式,扩展用', 157 | `detail` text COMMENT '商品详情', 158 | `price` decimal(20,2) NOT NULL COMMENT '价格,单位-元保留两位小数', 159 | `stock` int(11) NOT NULL COMMENT '库存数量', 160 | `status` int(6) DEFAULT '1' COMMENT '商品状态.1-在售 2-下架 3-删除', 161 | `create_time` datetime DEFAULT NULL COMMENT '创建时间', 162 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 163 | PRIMARY KEY (`id`) 164 | ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8; 165 | 166 | -- ---------------------------- 167 | -- Records of `mmall_product` 168 | -- ---------------------------- 169 | BEGIN; 170 | INSERT INTO `mmall_product` VALUES ('26', '100002', 'Apple iPhone 7 Plus (A1661) 128G 玫瑰金色 移动联通电信4G手机', 'iPhone 7,现更以红色呈现。', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg', '241997c4-9e62-4824-b7f0-7425c3c28917.jpeg,b6c56eb0-1748-49a9-98dc-bcc4b9788a54.jpeg,92f17532-1527-4563-aa1d-ed01baa0f7b2.jpeg,3adbe4f7-e374-4533-aa79-cc4a98c529bf.jpeg', '

\"10000.jpg\"

\"20000.jpg\"

\"30000.jpg\"

\"40000.jpg\"

\"50000.jpg\"

\"60000.jpg\"


\"TB24p51hgFkpuFjSspnXXb4qFXa-1776456424.jpg\"


\"shouhou.jpg\"

\"999.jpg\"

', '6999.00', '9991', '1', null, '2017-04-13 21:45:41'), ('27', '100006', 'Midea/美的 BCD-535WKZM(E)冰箱双开门对开门风冷无霜智能电家用', '送品牌烤箱,五一大促', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg', 'ac3e571d-13ce-4fad-89e8-c92c2eccf536.jpeg,4bb02f1c-62d5-48cc-b358-97b05af5740d.jpeg,36bdb49c-72ae-4185-9297-78829b54b566.jpeg', '

\"miaoshu.jpg\"

\"miaoshu2.jpg\"\"miaoshu3.jpg\"\"miaoshu4.jpg\"

', '3299.00', '8876', '1', '2017-04-13 18:51:54', '2017-04-13 21:45:41'), ('28', '100012', '4+64G送手环/Huawei/华为 nova 手机P9/P10plus青春', 'NOVA青春版1999元', '0093f5d3-bdb4-4fb0-bec5-5465dfd26363.jpeg', '0093f5d3-bdb4-4fb0-bec5-5465dfd26363.jpeg,13da2172-4445-4eb5-a13f-c5d4ede8458c.jpeg,58d5d4b7-58d4-4948-81b6-2bae4f79bf02.jpeg', '

\"11TB2fKK3cl0kpuFjSsziXXa.oVXa_!!1777180618.jpg\"\"22TB2YP3AkEhnpuFjSZFpXXcpuXXa_!!1777180618.jpg\"\"33TB2Yyshk.hnpuFjSZFpXXcpuXXa_!!1777180618.jpg\"\"TB2diyziB8kpuFjSspeXXc7IpXa_!!1777180618.jpg\"

', '1999.00', '9994', '1', '2017-04-13 18:57:18', '2017-04-13 21:45:41'), ('29', '100008', 'Haier/海尔HJ100-1HU1 10公斤滚筒洗衣机全自动带烘干家用大容量 洗烘一体', '门店机型 德邦送货', '173335a4-5dce-4afd-9f18-a10623724c4e.jpeg', '173335a4-5dce-4afd-9f18-a10623724c4e.jpeg,42b1b8bc-27c7-4ee1-80ab-753d216a1d49.jpeg,2f1b3de1-1eb1-4c18-8ca2-518934931bec.jpeg', '

\"1TB2WLZrcIaK.eBjSspjXXXL.XXa_!!2114960396.jpg\"\"2TB2zhOFbZCO.eBjSZFzXXaRiVXa_!!2114960396.jpg\"\"3TB27mCtb7WM.eBjSZFhXXbdWpXa_!!2114960396.jpg\"

', '4299.00', '9993', '1', '2017-04-13 19:07:47', '2017-04-13 21:45:41'); 171 | COMMIT; 172 | 173 | -- ---------------------------- 174 | -- Table structure for `mmall_shipping` 175 | -- ---------------------------- 176 | DROP TABLE IF EXISTS `mmall_shipping`; 177 | CREATE TABLE `mmall_shipping` ( 178 | `id` int(11) NOT NULL AUTO_INCREMENT, 179 | `user_id` int(11) DEFAULT NULL COMMENT '用户id', 180 | `receiver_name` varchar(20) DEFAULT NULL COMMENT '收货姓名', 181 | `receiver_phone` varchar(20) DEFAULT NULL COMMENT '收货固定电话', 182 | `receiver_mobile` varchar(20) DEFAULT NULL COMMENT '收货移动电话', 183 | `receiver_province` varchar(20) DEFAULT NULL COMMENT '省份', 184 | `receiver_city` varchar(20) DEFAULT NULL COMMENT '城市', 185 | `receiver_district` varchar(20) DEFAULT NULL COMMENT '区/县', 186 | `receiver_address` varchar(200) DEFAULT NULL COMMENT '详细地址', 187 | `receiver_zip` varchar(6) DEFAULT NULL COMMENT '邮编', 188 | `create_time` datetime DEFAULT NULL, 189 | `update_time` datetime DEFAULT NULL, 190 | PRIMARY KEY (`id`) 191 | ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8; 192 | 193 | -- ---------------------------- 194 | -- Records of `mmall_shipping` 195 | -- ---------------------------- 196 | BEGIN; 197 | INSERT INTO `mmall_shipping` VALUES ('4', '13', 'geely', '010', '18688888888', '北京', '北京市', '海淀区', '中关村', '100000', '2017-01-22 14:26:25', '2017-01-22 14:26:25'), ('7', '17', 'Rosen', '13800138000', '13800138000', '北京', '北京', null, '中关村', '100000', '2017-03-29 12:11:01', '2017-03-29 12:11:01'), ('29', '1', '吉利', '13800138000', '13800138000', '北京', '北京', '海淀区', '海淀区中关村', '100000', '2017-04-09 18:33:32', '2017-04-09 18:33:32'); 198 | COMMIT; 199 | 200 | -- ---------------------------- 201 | -- Table structure for `mmall_user` 202 | -- ---------------------------- 203 | DROP TABLE IF EXISTS `mmall_user`; 204 | CREATE TABLE `mmall_user` ( 205 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户表id', 206 | `username` varchar(50) NOT NULL COMMENT '用户名', 207 | `password` varchar(50) NOT NULL COMMENT '用户密码,MD5加密', 208 | `email` varchar(50) DEFAULT NULL, 209 | `phone` varchar(20) DEFAULT NULL, 210 | `question` varchar(100) DEFAULT NULL COMMENT '找回密码问题', 211 | `answer` varchar(100) DEFAULT NULL COMMENT '找回密码答案', 212 | `role` int(4) NOT NULL COMMENT '角色0-管理员,1-普通用户', 213 | `create_time` datetime NOT NULL COMMENT '创建时间', 214 | `update_time` datetime NOT NULL COMMENT '最后一次更新时间', 215 | PRIMARY KEY (`id`), 216 | UNIQUE KEY `user_name_unique` (`username`) USING BTREE 217 | ) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8; 218 | 219 | -- ---------------------------- 220 | -- Records of `mmall_user` 221 | -- ---------------------------- 222 | BEGIN; 223 | INSERT INTO `mmall_user` VALUES ('1', 'admin', '427338237BD929443EC5D48E24FD2B1A', 'admin@happymmall.com', '13800138000', '问题', '答案', '1', '2016-11-06 16:56:45', '2017-04-04 19:27:36'), ('13', 'geely', '08E9A6EA287E70E7E3F7C982BF7923AC', 'geely@happymmall.com', '13800138000', '问题', '答案', '0', '2016-11-19 22:19:25', '2016-11-19 22:19:25'), ('17', 'rosen', '095AC193FE2212EEC7A93E8FEFF11902', 'rosen1@happymmall.com', '13800138000', '问题', '答案', '0', '2017-03-17 10:51:33', '2017-04-09 23:13:26'), ('21', 'soonerbetter', 'DE6D76FE7C40D5A1A8F04213F2BEFBEE', 'test06@happymmall.com', '13800138000', '105204', '105204', '0', '2017-04-13 21:26:22', '2017-04-13 21:26:22'); 224 | COMMIT; 225 | 226 | SET FOREIGN_KEY_CHECKS = 1; 227 | --------------------------------------------------------------------------------