diff --git a/doc/mmallFormatter.xml b/doc/mmallFormatter.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5b7e94f464bede77452990437a15d15bdd45ec1 --- /dev/null +++ b/doc/mmallFormatter.xml @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index e4f8393d9c0a79348949ba7d63f245051763b9c0..1bd29b1d232da5297c684dd7dee3112646b3071a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,21 +1,288 @@ - 4.0.0 - com - mmall - war - 1.0-SNAPSHOT - mmall Maven Webapp - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - - mmall - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + com + mmall + war + 1.0-SNAPSHOT + mmall Maven Webapp + http://maven.apache.org + + + UTF-8 + UTF-8 + UTF-8 + + 3.2.5.RELEASE + 3.4.1 + 1.3.0 + + + + + + org.apache.tomcat + tomcat-servlet-api + 7.0.64 + + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + + org.springframework + spring-tx + ${org.springframework.version} + + + + org.springframework + spring-test + ${org.springframework.version} + + + + + org.aspectj + aspectjweaver + 1.7.3 + + + + org.mybatis + mybatis-spring + ${org.mybatis.spring.version} + + + org.mybatis + mybatis + ${org.mybatis.version} + + + + org.aspectj + aspectjrt + 1.6.11 + + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.12 + + + + commons-dbcp + commons-dbcp + 1.4 + + + + + + + + ch.qos.logback + logback-classic + 1.1.2 + compile + + + ch.qos.logback + logback-core + 1.1.2 + compile + + + + mysql + mysql-connector-java + 5.1.6 + + + + com.google.guava + guava + 20.0 + + + + + org.apache.commons + commons-lang3 + 3.5 + + + + commons-beanutils + commons-beanutils + 1.9.2 + + + + commons-collections + commons-collections + 3.2.1 + + + + + junit + junit + 4.12 + + + + + joda-time + joda-time + 2.3 + + + + + + org.hashids + hashids + 1.0.1 + + + + + + commons-net + commons-net + 3.1 + + + + + + + commons-fileupload + commons-fileupload + 1.2.2 + + + + commons-io + commons-io + 2.0.1 + + + + + + + + + com.github.pagehelper + pagehelper + 4.1.0 + + + + com.github.miemiedev + mybatis-paginator + 1.2.17 + + + + com.github.jsqlparser + jsqlparser + 0.9.4 + + + + + + commons-codec + commons-codec + 1.10 + + + commons-configuration + commons-configuration + 1.10 + + + commons-lang + commons-lang + 2.6 + + + commons-logging + commons-logging + 1.1.1 + + + com.google.zxing + core + 2.1 + + + com.google.code.gson + gson + 2.3.1 + + + org.hamcrest + hamcrest-core + 1.3 + + + + redis.clients + jedis + 2.9.0 + + + + + + mmall + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.2 + + true + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + UTF-8 + + ${project.basedir}/src/main/webapp/WEB-INF/lib + + + + + + + + diff --git a/src/main/java/com/mmall/common/Const.java b/src/main/java/com/mmall/common/Const.java new file mode 100644 index 0000000000000000000000000000000000000000..566e08be29e25cb15aea29993f2a7102393e5d13 --- /dev/null +++ b/src/main/java/com/mmall/common/Const.java @@ -0,0 +1,18 @@ +package com.mmall.common; + +/** + * Created by qujian on 2017/6/3. + */ +public class Const { + + public static final String CURRENT_USER = "CURRENT_USER"; + + public static final String EMAIL = "email"; + + public static final String USERNAME = "username"; + public interface Role{ + int ROLE_CUSTOMER = 0; //普通用户 + int ROLE_ADMIN = 1; //管理员 + } + +} diff --git a/src/main/java/com/mmall/common/ResponseCode.java b/src/main/java/com/mmall/common/ResponseCode.java new file mode 100644 index 0000000000000000000000000000000000000000..703b709ea05aa289abb226ab3c6c96552663c94c --- /dev/null +++ b/src/main/java/com/mmall/common/ResponseCode.java @@ -0,0 +1,30 @@ +package com.mmall.common; + +/** + * Created by qujian on 2017/6/3. +*/ + +public enum ResponseCode { + + SUCCESS(0,"SUCCESS"), + ERROR(1,"ERROR"), + NEED_LOGIN(10,"NEED_LOGIN"), + ILLEGAL_ARGUMENT(2,"ILLEGAL_ARGUMENT"); + + private final int code; + + private final String desc; + + ResponseCode(int code, String desc) { + this.code = code; + this.desc = desc; + } + + public int getCode() { + return code; + } + + public String getDesc() { + return desc; + } +} diff --git a/src/main/java/com/mmall/common/ServerResponse.java b/src/main/java/com/mmall/common/ServerResponse.java new file mode 100644 index 0000000000000000000000000000000000000000..9e1a1381b40a38461e8481b0f299124ac659a069 --- /dev/null +++ b/src/main/java/com/mmall/common/ServerResponse.java @@ -0,0 +1,86 @@ +package com.mmall.common; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import java.io.Serializable; + +/** + * Created by qujian on 2017/6/3. +*/ + +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) //Json序列化的时候忽略空的字段 +public class ServerResponse implements Serializable{ + + private int status; + private String mag; + private T data; + + private ServerResponse(int status) { + this.status = status; + } + + private ServerResponse(int status, String mag) { + this.status = status; + this.mag = mag; + } + + private ServerResponse(int status, String mag, T data) { + this.status = status; + this.mag = mag; + this.data = data; + } + + private ServerResponse(int status, T data) { + this.status = status; + this.data = data; + } + + @JsonIgnore //这个注解表示在json序列化的时候不显示 + public boolean isSuccess(){ + return this.status == ResponseCode.SUCCESS.getCode(); + } + + public int getStatus() { + return status; + } + + public String getMag() { + return mag; + } + + public T getData() { + return data; + } + + public static ServerResponse createBySuccess(){ + return new ServerResponse(ResponseCode.SUCCESS.getCode()); + } + + public static ServerResponse createBySuccessMessage(String msg){ + return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg); + } + + public static ServerResponse createBySuccess(T data){ + return new ServerResponse(ResponseCode.SUCCESS.getCode(),data); + } + + public static ServerResponse createBySuccess(String msg,T data){ + return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg,data); + } + + + public static ServerResponse createByError(){ + return new ServerResponse(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDesc()); + } + + + public static ServerResponse createByErrorMessage(String errorMessage){ + return new ServerResponse(ResponseCode.ERROR.getCode(),errorMessage); + } + + public static ServerResponse createByErrorCodeMessage(int errorCode,String errorMessage){ + return new ServerResponse(errorCode,errorMessage); + } + +} diff --git a/src/main/java/com/mmall/common/TokenCache.java b/src/main/java/com/mmall/common/TokenCache.java new file mode 100644 index 0000000000000000000000000000000000000000..2a836507c69dabe4fde2a83e7edb02652d3859c0 --- /dev/null +++ b/src/main/java/com/mmall/common/TokenCache.java @@ -0,0 +1,56 @@ +package com.mmall.common; + +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; + +/** + * Created by qujian on 2017/6/9. + */ +public class TokenCache { + + private static Logger logger = LoggerFactory + .getLogger(TokenCache.class); + + public static final String TOKEN_PREFIX = "token_"; + + + /** + * 静态内存块 + *initialCapacity:设置缓存的初始化容量 + * maximumSize:缓存的最大容量超过这个容量的时候,guava的cache会使用LRU算法(最少使用算法)来移除缓存项 + * expireAfterAccess:设置有效期 + */ + private static LoadingCache localcache = CacheBuilder.newBuilder() + .initialCapacity(1000).maximumSize(10000).expireAfterAccess(12, TimeUnit.HOURS) + .build(new CacheLoader() { + //默认的数据加载实现,当调用get取值的时候,如果key没有对应的值,就调用这个方法进行加载 + @Override + public String load(String s) throws Exception { + return "null"; + } + }); + + public static void setKey(String key,String value){ + localcache.put(key,value); + } + + public static String getKey(String key){ + String value = null; + try { + value = localcache.get(key); + if("null".equals(value)){ + return null; + } + return value; + } catch (Exception e) { + logger.error("localCache get error", e); + } + return null; + } +} diff --git a/src/main/java/com/mmall/controller/backend/UserManageController.java b/src/main/java/com/mmall/controller/backend/UserManageController.java new file mode 100644 index 0000000000000000000000000000000000000000..0ea81a1ab7d0b32318f8d3b2492c8874eb276b57 --- /dev/null +++ b/src/main/java/com/mmall/controller/backend/UserManageController.java @@ -0,0 +1,44 @@ +package com.mmall.controller.backend; + +import com.mmall.common.Const; +import com.mmall.common.ServerResponse; +import com.mmall.pojo.User; +import com.mmall.service.IUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpSession; + +/** + * Created by qujian on 2017/6/13. + */ +@Controller +@RequestMapping(value = "/manage/user/") +public class UserManageController { + + @Autowired + private IUserService iUserService; + + @ResponseBody + @RequestMapping(value = "login.do", method = RequestMethod.POST) + public ServerResponse login(@RequestParam("username") String username, + @RequestParam("password") String password, + @RequestParam("session") HttpSession session) { + ServerResponse response = iUserService.login(username,password); + if(response.isSuccess()){ + User user = response.getData(); + if(user.getRole() == Const.Role.ROLE_ADMIN){ + //说明登录的是管理员 + session.setAttribute(Const.CURRENT_USER,user); + return response; + }else{ + return ServerResponse.createByErrorMessage("不是管理员,无法登陆"); + } + } + return response; + } +} diff --git a/src/main/java/com/mmall/controller/protal/userController.java b/src/main/java/com/mmall/controller/protal/userController.java new file mode 100644 index 0000000000000000000000000000000000000000..39d3a002d4da76058d5d463969024d663ff0a27c --- /dev/null +++ b/src/main/java/com/mmall/controller/protal/userController.java @@ -0,0 +1,200 @@ +package com.mmall.controller.protal; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.mmall.common.Const; +import com.mmall.common.ResponseCode; +import com.mmall.common.ServerResponse; +import com.mmall.pojo.User; +import com.mmall.service.IUserService; + +/** + * Created by qujian on 2017/6/3. + */ + +@Controller +@RequestMapping(value = "/user/") +public class userController { + + @Autowired + private IUserService iUserService; + + /** + * 用户登录 + * @param username + * @param password + * @param session + * @return + */ + + @ResponseBody + @RequestMapping(value = "login.do", method = RequestMethod.POST) + public ServerResponse login(@RequestParam("username") String username, + @RequestParam("password") String password, + @RequestParam("session") HttpSession session) { + ServerResponse response = iUserService.login(username, password); + if (response.isSuccess()) { + session.setAttribute(Const.CURRENT_USER, response.getData()); + } + return response; + } + + /** + * 用户登出 + * @param session + * @return + */ + + @ResponseBody + @RequestMapping(value = "logout.do", method = RequestMethod.POST) + public ServerResponse logout(@RequestParam HttpSession session) { + session.removeAttribute(Const.CURRENT_USER); + return ServerResponse.createBySuccess(); + } + + /** + * 用户注册 + * @param user + * @return + */ + + @ResponseBody + @RequestMapping(value = "register.do", method = RequestMethod.POST) + public ServerResponse register(@RequestParam User user) { + ServerResponse response = iUserService.register(user); + return response; + } + + /** + * 校验用户名,邮箱 + * @param str + * @param type + * @return + */ + + @ResponseBody + @RequestMapping(value = "check_valid.do", method = RequestMethod.POST) + public ServerResponse checkValid(@RequestParam("str") String str, + @RequestParam("type") String type) { + ServerResponse response = iUserService.checkValid(str, type); + return response; + } + + /** + * 获取当前登录用户信息 + * @param session + * @return + */ + + @ResponseBody + @RequestMapping(value = "get_user_info.do", method = RequestMethod.POST) + public ServerResponse getUserInfo(@RequestParam HttpSession session) { + User user = (User) session.getAttribute(Const.CURRENT_USER); + if (user != null) { + return ServerResponse.createBySuccess(user); + } + return ServerResponse.createByErrorMessage("用户未登录,无法获取当前用户的信息"); + } + + /** + * 忘记密码,返回找回密码的问题 + * @param username + * @return + */ + @ResponseBody + @RequestMapping(value = "forget_get_question.do", method = RequestMethod.POST) + public ServerResponse forgetGetQuestion(@RequestParam String username) { + return iUserService.selectQuestion(username); + } + + /** + * 使用本地缓存检查问题答案 + * @param username + * @param question + * @param answer + * @return + */ + @ResponseBody + @RequestMapping(value = "forget_check_answer.do", method = RequestMethod.POST) + public ServerResponse forgetCheckAnswer(@RequestParam String username, + @RequestParam String question, + @RequestParam String answer) { + return iUserService.checkAnswer(username, question, answer); + } + + /** + * 忘记密码中的重置密码 + * @param username + * @param passwordNew + * @param forgetToken + * @return + */ + @ResponseBody + @RequestMapping(value = "forget_rest_password.do", method = RequestMethod.POST) + public ServerResponse forgetRestPassword(@RequestParam String username, + @RequestParam String passwordNew, + @RequestParam String forgetToken) { + return iUserService.forgetRestPassword(username, passwordNew, forgetToken); + } + + /** + * 登录状态下重置密码 + * @param session + * @param passwordOld + * @param passwordNew + * @return + */ + @ResponseBody + @RequestMapping(value = "reset_password.do", method = RequestMethod.POST) + public ServerResponse resetPassword(@RequestParam("session") HttpSession session, + @RequestParam("passwordOld") String passwordOld, + @RequestParam("passwordNew") String passwordNew) { + User user = (User) session.getAttribute(Const.CURRENT_USER); + if (user == null) { + return ServerResponse.createByErrorMessage("用户未登录"); + } + return iUserService.resetPassword(passwordOld, passwordNew, user); + } + + /** + * 更新用户个人信息 + * @param session + * @param user + * @return + */ + @ResponseBody + @RequestMapping(value = "update_information.do", method = RequestMethod.POST) + public ServerResponse updateInformation(@RequestParam("session") HttpSession session, + @RequestParam("user") User user) { + User currentUser = (User) session.getAttribute(Const.CURRENT_USER); + if (currentUser == null) { + return ServerResponse.createByErrorMessage("用户未登录"); + } + user.setId(currentUser.getId()); + user.setUsername(currentUser.getUsername()); + ServerResponse response = iUserService.updateInformation(user); + if (response.isSuccess()) { + response.getData().setUsername(currentUser.getUsername()); + session.setAttribute(Const.CURRENT_USER, response.getData()); + } + return response; + } + + @ResponseBody + @RequestMapping(value = "get_information.do", method = RequestMethod.POST) + public ServerResponse getInformation(@RequestParam("session") HttpSession session) { + User currentUser = (User) session.getAttribute(Const.CURRENT_USER); + if (currentUser == null) { + return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), + "未登录,需要强制登录status=10"); + } + return iUserService.getInformation(currentUser.getId()); + } +} diff --git a/src/main/java/com/mmall/dao/CartMapper.java b/src/main/java/com/mmall/dao/CartMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..89bd15fcb1c145a4f06bf04a2e840d99dd92bc12 --- /dev/null +++ b/src/main/java/com/mmall/dao/CartMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.Cart; + +public interface CartMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Cart record); + + int insertSelective(Cart record); + + Cart selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Cart record); + + int updateByPrimaryKey(Cart record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/CategoryMapper.java b/src/main/java/com/mmall/dao/CategoryMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b69921a18c5350d7a6a8c5c695eb6c66c626eb93 --- /dev/null +++ b/src/main/java/com/mmall/dao/CategoryMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.Category; + +public interface CategoryMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Category record); + + int insertSelective(Category record); + + Category selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Category record); + + int updateByPrimaryKey(Category record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/OrderItemMapper.java b/src/main/java/com/mmall/dao/OrderItemMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..405539bd2598a2c87c575441416e746629cc3f90 --- /dev/null +++ b/src/main/java/com/mmall/dao/OrderItemMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.OrderItem; + +public interface OrderItemMapper { + int deleteByPrimaryKey(Integer id); + + int insert(OrderItem record); + + int insertSelective(OrderItem record); + + OrderItem selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(OrderItem record); + + int updateByPrimaryKey(OrderItem record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/OrderMapper.java b/src/main/java/com/mmall/dao/OrderMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..a147301da7c295c40a163e41bdabbe295f2f63f4 --- /dev/null +++ b/src/main/java/com/mmall/dao/OrderMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.Order; + +public interface OrderMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Order record); + + int insertSelective(Order record); + + Order selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Order record); + + int updateByPrimaryKey(Order record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/PayInfoMapper.java b/src/main/java/com/mmall/dao/PayInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..563fe61b20fc11304fb8003a4c6af13332e38f40 --- /dev/null +++ b/src/main/java/com/mmall/dao/PayInfoMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.PayInfo; + +public interface PayInfoMapper { + int deleteByPrimaryKey(Integer id); + + int insert(PayInfo record); + + int insertSelective(PayInfo record); + + PayInfo selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(PayInfo record); + + int updateByPrimaryKey(PayInfo record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/ProductMapper.java b/src/main/java/com/mmall/dao/ProductMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..f1c5646e8c69291f26865940c65bf8ebcc4bc0e3 --- /dev/null +++ b/src/main/java/com/mmall/dao/ProductMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.Product; + +public interface ProductMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Product record); + + int insertSelective(Product record); + + Product selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Product record); + + int updateByPrimaryKey(Product record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/ShippingMapper.java b/src/main/java/com/mmall/dao/ShippingMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..a44a81ee02bd2f55339075d14c4227ca17d9c60e --- /dev/null +++ b/src/main/java/com/mmall/dao/ShippingMapper.java @@ -0,0 +1,17 @@ +package com.mmall.dao; + +import com.mmall.pojo.Shipping; + +public interface ShippingMapper { + int deleteByPrimaryKey(Integer id); + + int insert(Shipping record); + + int insertSelective(Shipping record); + + Shipping selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(Shipping record); + + int updateByPrimaryKey(Shipping record); +} \ No newline at end of file diff --git a/src/main/java/com/mmall/dao/UserMapper.java b/src/main/java/com/mmall/dao/UserMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..d45b6cb0ad9a0062335f3b899fb52d60c85b998f --- /dev/null +++ b/src/main/java/com/mmall/dao/UserMapper.java @@ -0,0 +1,35 @@ +package com.mmall.dao; + +import com.mmall.pojo.User; +import org.apache.ibatis.annotations.Param; + +public interface UserMapper { + int deleteByPrimaryKey(Integer id); + + int insert(User record); + + int insertSelective(User record); + + User selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(User record); + + int updateByPrimaryKey(User record); + + int checkUserName(String username); + + User selectLogin(@Param("username") String username, @Param("password") String password); + + int checkEmail(String email); + + String selectQuestionByUsername(String username); + + //mybatis中多个参数需要加上@Param + int checkAnswer(@Param("username") String username,@Param("question") String question,@Param("answer") String answer); + + int updatePasswordByUsername(@Param("username") String username,@Param("passwordNew") String passwordNew); + + int checkPassword(@Param("userId") Integer userId,@Param("passwordOld") String passwordOld); + + int checkEmailByUserId(@Param("userId") Integer userId,@Param("email") String email); +} diff --git a/src/main/java/com/mmall/pojo/Cart.java b/src/main/java/com/mmall/pojo/Cart.java new file mode 100644 index 0000000000000000000000000000000000000000..fc0db5ade3f36319abd9832b931d5401a66e4cad --- /dev/null +++ b/src/main/java/com/mmall/pojo/Cart.java @@ -0,0 +1,89 @@ +package com.mmall.pojo; + +import java.util.Date; + +public class Cart { + private Integer id; + + private Integer userId; + + private Integer productId; + + private Integer quantity; + + private Integer checked; + + private Date createTime; + + private Date updateTime; + + public Cart(Integer id, Integer userId, Integer productId, Integer quantity, Integer checked, Date createTime, Date updateTime) { + this.id = id; + this.userId = userId; + this.productId = productId; + this.quantity = quantity; + this.checked = checked; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public Cart() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Integer getChecked() { + return checked; + } + + public void setChecked(Integer checked) { + this.checked = checked; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/Category.java b/src/main/java/com/mmall/pojo/Category.java new file mode 100644 index 0000000000000000000000000000000000000000..2b636da3cc9ea75416676ccdb9e0d5b3b94f9a3e --- /dev/null +++ b/src/main/java/com/mmall/pojo/Category.java @@ -0,0 +1,89 @@ +package com.mmall.pojo; + +import java.util.Date; + +public class Category { + private Integer id; + + private Integer parentId; + + private String name; + + private Boolean status; + + private Integer sortOrder; + + private Date createTime; + + private Date updateTime; + + public Category(Integer id, Integer parentId, String name, Boolean status, Integer sortOrder, Date createTime, Date updateTime) { + this.id = id; + this.parentId = parentId; + this.name = name; + this.status = status; + this.sortOrder = sortOrder; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public Category() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + public Boolean getStatus() { + return status; + } + + public void setStatus(Boolean status) { + this.status = status; + } + + public Integer getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Integer sortOrder) { + this.sortOrder = sortOrder; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/Order.java b/src/main/java/com/mmall/pojo/Order.java new file mode 100644 index 0000000000000000000000000000000000000000..77e03bde4de141f2bf9cfbe95693e74631588a3e --- /dev/null +++ b/src/main/java/com/mmall/pojo/Order.java @@ -0,0 +1,167 @@ +package com.mmall.pojo; + +import java.math.BigDecimal; +import java.util.Date; + +public class Order { + private Integer id; + + private Long orderNo; + + private Integer userId; + + private Integer shippingId; + + private BigDecimal payment; + + private Integer paymentType; + + private Integer postage; + + private Integer status; + + private Date paymentTime; + + private Date sendTime; + + private Date endTime; + + private Date closeTime; + + private Date createTime; + + private Date updateTime; + + 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) { + this.id = id; + this.orderNo = orderNo; + this.userId = userId; + this.shippingId = shippingId; + this.payment = payment; + this.paymentType = paymentType; + this.postage = postage; + this.status = status; + this.paymentTime = paymentTime; + this.sendTime = sendTime; + this.endTime = endTime; + this.closeTime = closeTime; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public Order() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Long getOrderNo() { + return orderNo; + } + + public void setOrderNo(Long orderNo) { + this.orderNo = orderNo; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getShippingId() { + return shippingId; + } + + public void setShippingId(Integer shippingId) { + this.shippingId = shippingId; + } + + public BigDecimal getPayment() { + return payment; + } + + public void setPayment(BigDecimal payment) { + this.payment = payment; + } + + public Integer getPaymentType() { + return paymentType; + } + + public void setPaymentType(Integer paymentType) { + this.paymentType = paymentType; + } + + public Integer getPostage() { + return postage; + } + + public void setPostage(Integer postage) { + this.postage = postage; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getPaymentTime() { + return paymentTime; + } + + public void setPaymentTime(Date paymentTime) { + this.paymentTime = paymentTime; + } + + public Date getSendTime() { + return sendTime; + } + + public void setSendTime(Date sendTime) { + this.sendTime = sendTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public Date getCloseTime() { + return closeTime; + } + + public void setCloseTime(Date closeTime) { + this.closeTime = closeTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/OrderItem.java b/src/main/java/com/mmall/pojo/OrderItem.java new file mode 100644 index 0000000000000000000000000000000000000000..fab078cb090107a27adad1d2d6a75403a94dce65 --- /dev/null +++ b/src/main/java/com/mmall/pojo/OrderItem.java @@ -0,0 +1,134 @@ +package com.mmall.pojo; + +import java.math.BigDecimal; +import java.util.Date; + +public class OrderItem { + private Integer id; + + private Integer userId; + + private Long orderNo; + + private Integer productId; + + private String productName; + + private String productImage; + + private BigDecimal currentUnitPrice; + + private Integer quantity; + + private BigDecimal totalPrice; + + private Date createTime; + + private Date updateTime; + + public OrderItem(Integer id, Integer userId, Long orderNo, Integer productId, String productName, String productImage, BigDecimal currentUnitPrice, Integer quantity, BigDecimal totalPrice, Date createTime, Date updateTime) { + this.id = id; + this.userId = userId; + this.orderNo = orderNo; + this.productId = productId; + this.productName = productName; + this.productImage = productImage; + this.currentUnitPrice = currentUnitPrice; + this.quantity = quantity; + this.totalPrice = totalPrice; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public OrderItem() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Long getOrderNo() { + return orderNo; + } + + public void setOrderNo(Long orderNo) { + this.orderNo = orderNo; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName == null ? null : productName.trim(); + } + + public String getProductImage() { + return productImage; + } + + public void setProductImage(String productImage) { + this.productImage = productImage == null ? null : productImage.trim(); + } + + public BigDecimal getCurrentUnitPrice() { + return currentUnitPrice; + } + + public void setCurrentUnitPrice(BigDecimal currentUnitPrice) { + this.currentUnitPrice = currentUnitPrice; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public BigDecimal getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(BigDecimal totalPrice) { + this.totalPrice = totalPrice; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/PayInfo.java b/src/main/java/com/mmall/pojo/PayInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..924ce592082f0ba8c51741e50b23a9a8142b7dd4 --- /dev/null +++ b/src/main/java/com/mmall/pojo/PayInfo.java @@ -0,0 +1,100 @@ +package com.mmall.pojo; + +import java.util.Date; + +public class PayInfo { + private Integer id; + + private Integer userId; + + private Long orderNo; + + private Integer payPlatform; + + private String platformNumber; + + private String platformStatus; + + private Date createTime; + + private Date updateTime; + + public PayInfo(Integer id, Integer userId, Long orderNo, Integer payPlatform, String platformNumber, String platformStatus, Date createTime, Date updateTime) { + this.id = id; + this.userId = userId; + this.orderNo = orderNo; + this.payPlatform = payPlatform; + this.platformNumber = platformNumber; + this.platformStatus = platformStatus; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public PayInfo() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Long getOrderNo() { + return orderNo; + } + + public void setOrderNo(Long orderNo) { + this.orderNo = orderNo; + } + + public Integer getPayPlatform() { + return payPlatform; + } + + public void setPayPlatform(Integer payPlatform) { + this.payPlatform = payPlatform; + } + + public String getPlatformNumber() { + return platformNumber; + } + + public void setPlatformNumber(String platformNumber) { + this.platformNumber = platformNumber == null ? null : platformNumber.trim(); + } + + public String getPlatformStatus() { + return platformStatus; + } + + public void setPlatformStatus(String platformStatus) { + this.platformStatus = platformStatus == null ? null : platformStatus.trim(); + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/Product.java b/src/main/java/com/mmall/pojo/Product.java new file mode 100644 index 0000000000000000000000000000000000000000..cd6fbf72bf4d843df887526307b23e96e6900b98 --- /dev/null +++ b/src/main/java/com/mmall/pojo/Product.java @@ -0,0 +1,145 @@ +package com.mmall.pojo; + +import java.math.BigDecimal; +import java.util.Date; + +public class Product { + private Integer id; + + private Integer categoryId; + + private String name; + + private String subtitle; + + private String mainImage; + + private String subImages; + + private String detail; + + private BigDecimal price; + + private Integer stock; + + private Integer status; + + private Date createTime; + + private Date updateTime; + + 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) { + this.id = id; + this.categoryId = categoryId; + this.name = name; + this.subtitle = subtitle; + this.mainImage = mainImage; + this.subImages = subImages; + this.detail = detail; + this.price = price; + this.stock = stock; + this.status = status; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public Product() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCategoryId() { + return categoryId; + } + + public void setCategoryId(Integer categoryId) { + this.categoryId = categoryId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + public String getSubtitle() { + return subtitle; + } + + public void setSubtitle(String subtitle) { + this.subtitle = subtitle == null ? null : subtitle.trim(); + } + + public String getMainImage() { + return mainImage; + } + + public void setMainImage(String mainImage) { + this.mainImage = mainImage == null ? null : mainImage.trim(); + } + + public String getSubImages() { + return subImages; + } + + public void setSubImages(String subImages) { + this.subImages = subImages == null ? null : subImages.trim(); + } + + public String getDetail() { + return detail; + } + + public void setDetail(String detail) { + this.detail = detail == null ? null : detail.trim(); + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Integer getStock() { + return stock; + } + + public void setStock(Integer stock) { + this.stock = stock; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/Shipping.java b/src/main/java/com/mmall/pojo/Shipping.java new file mode 100644 index 0000000000000000000000000000000000000000..51575bc838eb005ba7c334c610adcbf71af2b455 --- /dev/null +++ b/src/main/java/com/mmall/pojo/Shipping.java @@ -0,0 +1,144 @@ +package com.mmall.pojo; + +import java.util.Date; + +public class Shipping { + private Integer id; + + private Integer userId; + + private String receiverName; + + private String receiverPhone; + + private String receiverMobile; + + private String receiverProvince; + + private String receiverCity; + + private String receiverDistrict; + + private String receiverAddress; + + private String receiverZip; + + private Date createTime; + + private Date updateTime; + + 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) { + this.id = id; + this.userId = userId; + this.receiverName = receiverName; + this.receiverPhone = receiverPhone; + this.receiverMobile = receiverMobile; + this.receiverProvince = receiverProvince; + this.receiverCity = receiverCity; + this.receiverDistrict = receiverDistrict; + this.receiverAddress = receiverAddress; + this.receiverZip = receiverZip; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public Shipping() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getReceiverName() { + return receiverName; + } + + public void setReceiverName(String receiverName) { + this.receiverName = receiverName == null ? null : receiverName.trim(); + } + + public String getReceiverPhone() { + return receiverPhone; + } + + public void setReceiverPhone(String receiverPhone) { + this.receiverPhone = receiverPhone == null ? null : receiverPhone.trim(); + } + + public String getReceiverMobile() { + return receiverMobile; + } + + public void setReceiverMobile(String receiverMobile) { + this.receiverMobile = receiverMobile == null ? null : receiverMobile.trim(); + } + + public String getReceiverProvince() { + return receiverProvince; + } + + public void setReceiverProvince(String receiverProvince) { + this.receiverProvince = receiverProvince == null ? null : receiverProvince.trim(); + } + + public String getReceiverCity() { + return receiverCity; + } + + public void setReceiverCity(String receiverCity) { + this.receiverCity = receiverCity == null ? null : receiverCity.trim(); + } + + public String getReceiverDistrict() { + return receiverDistrict; + } + + public void setReceiverDistrict(String receiverDistrict) { + this.receiverDistrict = receiverDistrict == null ? null : receiverDistrict.trim(); + } + + public String getReceiverAddress() { + return receiverAddress; + } + + public void setReceiverAddress(String receiverAddress) { + this.receiverAddress = receiverAddress == null ? null : receiverAddress.trim(); + } + + public String getReceiverZip() { + return receiverZip; + } + + public void setReceiverZip(String receiverZip) { + this.receiverZip = receiverZip == null ? null : receiverZip.trim(); + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/pojo/User.java b/src/main/java/com/mmall/pojo/User.java new file mode 100644 index 0000000000000000000000000000000000000000..df77265f930930cc1fb130b2762dc2f07e0ab6c2 --- /dev/null +++ b/src/main/java/com/mmall/pojo/User.java @@ -0,0 +1,122 @@ +package com.mmall.pojo; + +import java.util.Date; + +public class User { + private Integer id; + + private String username; + + private String password; + + private String email; + + private String phone; + + private String question; + + private String answer; + + private Integer role; + + private Date createTime; + + private Date updateTime; + + public User(Integer id, String username, String password, String email, String phone, String question, String answer, Integer role, Date createTime, Date updateTime) { + this.id = id; + this.username = username; + this.password = password; + this.email = email; + this.phone = phone; + this.question = question; + this.answer = answer; + this.role = role; + this.createTime = createTime; + this.updateTime = updateTime; + } + + public User() { + super(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username == null ? null : username.trim(); + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password == null ? null : password.trim(); + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email == null ? null : email.trim(); + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone == null ? null : phone.trim(); + } + + public String getQuestion() { + return question; + } + + public void setQuestion(String question) { + this.question = question == null ? null : question.trim(); + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer == null ? null : answer.trim(); + } + + public Integer getRole() { + return role; + } + + public void setRole(Integer role) { + this.role = role; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/mmall/service/IUserService.java b/src/main/java/com/mmall/service/IUserService.java new file mode 100644 index 0000000000000000000000000000000000000000..6dc13d12034ec19c443c546013f90ccc9af5968c --- /dev/null +++ b/src/main/java/com/mmall/service/IUserService.java @@ -0,0 +1,29 @@ +package com.mmall.service; + +import com.mmall.common.ServerResponse; +import com.mmall.pojo.User; + +/** + * Created by qujian on 2017/6/3. +*/ + +public interface IUserService { + + ServerResponse login(String username, String password); + + ServerResponse register(User user); + + ServerResponse checkValid(String str, String type); + + ServerResponse selectQuestion(String username); + + ServerResponse checkAnswer(String username,String question,String answer); + + ServerResponse forgetRestPassword(String username,String passwordNew,String forgetToken); + + ServerResponse resetPassword(String passwordOld,String passwordNew,User user); + + ServerResponse updateInformation(User user); + + ServerResponse getInformation(Integer id); +} diff --git a/src/main/java/com/mmall/service/impl/UserServiceImpl.java b/src/main/java/com/mmall/service/impl/UserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a35ca6b143bda24d9dfe10fa0b7f079c0aed8f73 --- /dev/null +++ b/src/main/java/com/mmall/service/impl/UserServiceImpl.java @@ -0,0 +1,169 @@ +package com.mmall.service.impl; + +import java.util.UUID; + +import ch.qos.logback.classic.gaffer.PropertyUtil; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.io.CopyUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.PropertyAccessorUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.mmall.common.Const; +import com.mmall.common.ServerResponse; +import com.mmall.common.TokenCache; +import com.mmall.dao.UserMapper; +import com.mmall.pojo.User; +import com.mmall.service.IUserService; +import com.mmall.util.MD5Util; + +/** + * Created by qujian on 2017/6/3. +*/ + +@Service("iUserService") +public class UserServiceImpl implements IUserService { + + @Autowired + private UserMapper userMapper; + + public ServerResponse login(String username, String password) { + int exist = userMapper.checkUserName(username); + if (exist == 0) { + return ServerResponse.createByErrorMessage("用户名不存在"); + } + + //TODO 密码登录MD5 + + User user = userMapper.selectLogin(username, password); + if (user == null) { + return ServerResponse.createByErrorMessage("密码或用户名错误"); + } + user.setPassword(StringUtils.EMPTY); + return ServerResponse.createBySuccess("登录成功", user); + } + + public ServerResponse register(User user) { + ServerResponse validResponse = this.checkValid(user.getEmail(), Const.EMAIL); + if (!validResponse.isSuccess()) { + return validResponse; + } + validResponse = this.checkValid(user.getUsername(), Const.USERNAME); + if (!validResponse.isSuccess()) { + return validResponse; + } + user.setRole(Const.Role.ROLE_CUSTOMER); + //MD5加密 + user.setPassword(MD5Util.MD5EncodeUtf8(user.getPassword())); + int resultCount = userMapper.insertSelective(user); + if (resultCount == 0) { + return ServerResponse.createByErrorMessage("注册失败"); + } + return ServerResponse.createBySuccessMessage("注册成功"); + } + + public ServerResponse checkValid(String str, String type) { + if (StringUtils.isNotBlank(type)) { + //开始校验 + if (Const.EMAIL.equals(type)) { + int resultCount = userMapper.checkEmail(str); + if (resultCount > 0) { + ServerResponse.createByErrorMessage("email已存在"); + } + } + if (Const.USERNAME.equals(type)) { + int resultCount = userMapper.checkUserName(str); + if (resultCount > 0) { + ServerResponse.createByErrorMessage("用户名已存在"); + } + } + } else { + return ServerResponse.createByErrorMessage("参数错误"); + } + return ServerResponse.createBySuccessMessage("校验成功"); + } + + public ServerResponse selectQuestion(String username) { + ServerResponse validResponse = this.checkValid(username, Const.USERNAME); + if (!validResponse.isSuccess()) { + return ServerResponse.createByErrorMessage("用户不存在"); + } + String question = userMapper.selectQuestionByUsername(username); + if (StringUtils.isNotBlank(question)) { + return ServerResponse.createBySuccess(question); + } + return ServerResponse.createByErrorMessage("找回密码的问题是空的"); + } + + public ServerResponse checkAnswer(String username, String question, String answer) { + int resultCount = userMapper.checkAnswer(username, question, answer); + if (resultCount > 0) { //说明问题及问题答案是这个用户的并且答案是正确的 + String forgetToken = UUID.randomUUID().toString(); + TokenCache.setKey(TokenCache.TOKEN_PREFIX + username, forgetToken); + return ServerResponse.createBySuccess(forgetToken); + } + return ServerResponse.createByErrorMessage("问题的答案错误"); + } + + public ServerResponse forgetRestPassword(String username, String passwordNew, String forgetToken) { + if(StringUtils.isNotBlank(forgetToken)){ + return ServerResponse.createByErrorMessage("参数错误,token需要传递"); + } + ServerResponse validResponse = this.checkValid(username, Const.USERNAME); + if (!validResponse.isSuccess()) { + return ServerResponse.createByErrorMessage("用户不存在"); + } + String token = TokenCache.getKey(TokenCache.TOKEN_PREFIX + username); + if(StringUtils.isNotBlank(token)){ + return ServerResponse.createByErrorMessage("token无效或过期"); + } + if(StringUtils.equals(forgetToken,token)){ + String md5Password = MD5Util.MD5EncodeUtf8(passwordNew); + int rowCount = userMapper.updatePasswordByUsername(username,md5Password); + if(rowCount > 0){ + return ServerResponse.createBySuccessMessage("修改密码成功"); + }else{ + return ServerResponse.createByErrorMessage("Token错误,请重新获取重置密码的Token"); + } + } + return ServerResponse.createByErrorMessage("修改密码失败"); + } + + public ServerResponse resetPassword(String passwordOld,String passwordNew,User user){ + int resultCount = userMapper.checkPassword(user.getId(),passwordOld); + if(resultCount == 0){ + return ServerResponse.createByErrorMessage("旧密码错误"); + } + user.setPassword(MD5Util.MD5EncodeUtf8(passwordNew)); + int updateCount = userMapper.updateByPrimaryKeySelective(user); + if(updateCount > 0){ + return ServerResponse.createBySuccessMessage("密码修改成功"); + } + return ServerResponse.createByErrorMessage("密码修改失败"); + } + + public ServerResponse updateInformation(User user){ + //username是不能被更新的 + //email也要进行校验,校验新的email是不是已经存在,并且存在的email如果相同的话,不能是我们这个当前用户的 + int resultCount = userMapper.checkEmailByUserId(user.getId(),user.getEmail()); + if(resultCount > 0){ + return ServerResponse.createByErrorMessage("该email已被使用,请更换email"); + } + int updateCount = userMapper.updateByPrimaryKeySelective(user); + if(updateCount > 0){ + return ServerResponse.createBySuccess("更新个人信息成功",user); + } + return ServerResponse.createByErrorMessage("更新个人信息失败"); + } + + @Override + public ServerResponse getInformation(Integer id) { + User user = userMapper.selectByPrimaryKey(id); + if(user == null){ + ServerResponse.createByErrorMessage("找不到当前用户"); + } + user.setPassword(StringUtils.EMPTY); + return ServerResponse.createBySuccess(user); + } +} diff --git a/src/main/java/com/mmall/util/MD5Util.java b/src/main/java/com/mmall/util/MD5Util.java new file mode 100644 index 0000000000000000000000000000000000000000..85877c2265ac64b8870200a6d797dd90093d7be5 --- /dev/null +++ b/src/main/java/com/mmall/util/MD5Util.java @@ -0,0 +1,63 @@ +package com.mmall.util; +import java.security.MessageDigest; + +/** + * Created by qujian on 2017/6/5. +*/ + +public class MD5Util { + + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) + resultSb.append(byteToHexString(b[i])); + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) + n += 256; + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + hexDigits[d2]; + } + +/** + * 返回大写MD5 + * + * @param origin + * @param charsetname + * @return +*/ + + private static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) + resultString = byteArrayToHexString(md.digest(resultString.getBytes())); + else + resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); + } catch (Exception exception) { + } + return resultString.toUpperCase(); + } + +/** + * 直接返回UTF-8 + * @param origin + * @return +*/ + + public static String MD5EncodeUtf8(String origin) { + origin = origin + PropertiesUtil.getProperty("password.salt", ""); + return MD5Encode(origin, "utf-8"); + } + + + private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; +} diff --git a/src/main/java/com/mmall/util/PropertiesUtil.java b/src/main/java/com/mmall/util/PropertiesUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..a64c7b31a8767877ce6e283adc51beb2e204e943 --- /dev/null +++ b/src/main/java/com/mmall/util/PropertiesUtil.java @@ -0,0 +1,46 @@ +package com.mmall.util; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Properties; + +/** + * Created by qujian on 2017/6/5. +*/ + +public class PropertiesUtil { + private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class); + + private static Properties props; + + static { + String fileName = "mmall.properties"; + props = new Properties(); + try { + props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName),"UTF-8")); + } catch (IOException e) { + logger.error("配置文件读取异常",e); + } + } + + public static String getProperty(String key){ + String value = props.getProperty(key.trim()); + if(StringUtils.isBlank(value)){ + return null; + } + return value.trim(); + } + + public static String getProperty(String key,String defaultValue){ + + String value = props.getProperty(key.trim()); + if(StringUtils.isBlank(value)){ + value = defaultValue; + } + return value.trim(); + } + +} diff --git a/src/main/resources/applicationContext-datasource.xml b/src/main/resources/applicationContext-datasource.xml new file mode 100644 index 0000000000000000000000000000000000000000..9970571e766b03d407c119a7928d3cd9e912e479 --- /dev/null +++ b/src/main/resources/applicationContext-datasource.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + classpath:datasource.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dialect=mysql + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/applicationContext.xml b/src/main/resources/applicationContext.xml new file mode 100644 index 0000000000000000000000000000000000000000..9b94ac6af878cea0bba3327d43d481b6d809b3df --- /dev/null +++ b/src/main/resources/applicationContext.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/datasource.properties b/src/main/resources/datasource.properties new file mode 100644 index 0000000000000000000000000000000000000000..6768522352ca6012f985ebaad239a57a756e019e --- /dev/null +++ b/src/main/resources/datasource.properties @@ -0,0 +1,16 @@ +db.driverLocation=/Users/imooc/mysql-connector-java-5.1.6-bin.jar +db.driverClassName=com.mysql.jdbc.Driver + +#db.url=jdbc:mysql://192.1.1.1:3306/mmall?characterEncoding=utf-8 +db.url=jdbc:mysql://192.168.187.134:3306/mmall?characterEncoding=utf-8 +db.username=qujian +db.password=qujian + + +db.initialSize = 20 +db.maxActive = 50 +db.maxIdle = 20 +db.minIdle = 10 +db.maxWait = 10 +db.defaultAutoCommit = true +db.minEvictableIdleTimeMillis = 3600000 diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..fe13a5ee52401f7ea96c133ecb4049474495debf --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,78 @@ + + + + UTF-8 + + [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n + + + DEBUG + + + + + + /developer/apache-tomcat-7.0.73/logs/mmall.log + + /developer/apache-tomcat-7.0.73/logs/mmall.log.%d{yyyy-MM-dd}.gz + true + 10 + + + [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n + + + + + + + /developer/apache-tomcat-7.0.73/logs/error.log + + /devsoft/apache-tomcat-7.0.73/logs/error.log.%d{yyyy-MM-dd}.gz + + true + 10 + + + [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/CartMapper.xml b/src/main/resources/mappers/CartMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..399273e54407b002387247e7fd1976999d04425a --- /dev/null +++ b/src/main/resources/mappers/CartMapper.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + id, user_id, product_id, quantity, checked, create_time, update_time + + + + + delete from mmall_cart + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_cart (id, user_id, product_id, + quantity, checked, create_time, + update_time) + values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, + #{quantity,jdbcType=INTEGER}, #{checked,jdbcType=INTEGER}, now(), + now()) + + + insert into mmall_cart + + + id, + + + user_id, + + + product_id, + + + quantity, + + + checked, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{userId,jdbcType=INTEGER}, + + + #{productId,jdbcType=INTEGER}, + + + #{quantity,jdbcType=INTEGER}, + + + #{checked,jdbcType=INTEGER}, + + + now(), + + + now(), + + + + + update mmall_cart + + + user_id = #{userId,jdbcType=INTEGER}, + + + product_id = #{productId,jdbcType=INTEGER}, + + + quantity = #{quantity,jdbcType=INTEGER}, + + + checked = #{checked,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = now(), + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_cart + set user_id = #{userId,jdbcType=INTEGER}, + product_id = #{productId,jdbcType=INTEGER}, + quantity = #{quantity,jdbcType=INTEGER}, + checked = #{checked,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = now() + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/CategoryMapper.xml b/src/main/resources/mappers/CategoryMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..01331b25313f79e885b8e3fd64afdd4e277af69e --- /dev/null +++ b/src/main/resources/mappers/CategoryMapper.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + id, parent_id, name, status, sort_order, create_time, update_time + + + + delete from mmall_category + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_category (id, parent_id, name, + status, sort_order, create_time, + update_time) + values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, + #{status,jdbcType=BIT}, #{sortOrder,jdbcType=INTEGER}, now(), + now()) + + + insert into mmall_category + + + id, + + + parent_id, + + + name, + + + status, + + + sort_order, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{parentId,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{status,jdbcType=BIT}, + + + #{sortOrder,jdbcType=INTEGER}, + + + now(), + + + now(), + + + + + update mmall_category + + + parent_id = #{parentId,jdbcType=INTEGER}, + + + name = #{name,jdbcType=VARCHAR}, + + + status = #{status,jdbcType=BIT}, + + + sort_order = #{sortOrder,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = now(), + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_category + set parent_id = #{parentId,jdbcType=INTEGER}, + name = #{name,jdbcType=VARCHAR}, + status = #{status,jdbcType=BIT}, + sort_order = #{sortOrder,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = now() + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/OrderItemMapper.xml b/src/main/resources/mappers/OrderItemMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..0484818b30f5d2cff627291c31ec2da53eb1b64a --- /dev/null +++ b/src/main/resources/mappers/OrderItemMapper.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + id, user_id, order_no, product_id, product_name, product_image, current_unit_price, + quantity, total_price, create_time, update_time + + + + delete from mmall_order_item + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_order_item (id, user_id, order_no, + product_id, product_name, product_image, + current_unit_price, quantity, total_price, + create_time, update_time) + values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, + #{productId,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{productImage,jdbcType=VARCHAR}, + #{currentUnitPrice,jdbcType=DECIMAL}, #{quantity,jdbcType=INTEGER}, #{totalPrice,jdbcType=DECIMAL}, + now(),now()) + + + insert into mmall_order_item + + + id, + + + user_id, + + + order_no, + + + product_id, + + + product_name, + + + product_image, + + + current_unit_price, + + + quantity, + + + total_price, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{userId,jdbcType=INTEGER}, + + + #{orderNo,jdbcType=BIGINT}, + + + #{productId,jdbcType=INTEGER}, + + + #{productName,jdbcType=VARCHAR}, + + + #{productImage,jdbcType=VARCHAR}, + + + #{currentUnitPrice,jdbcType=DECIMAL}, + + + #{quantity,jdbcType=INTEGER}, + + + #{totalPrice,jdbcType=DECIMAL}, + + + now(), + + + now(), + + + + + update mmall_order_item + + + user_id = #{userId,jdbcType=INTEGER}, + + + order_no = #{orderNo,jdbcType=BIGINT}, + + + product_id = #{productId,jdbcType=INTEGER}, + + + product_name = #{productName,jdbcType=VARCHAR}, + + + product_image = #{productImage,jdbcType=VARCHAR}, + + + current_unit_price = #{currentUnitPrice,jdbcType=DECIMAL}, + + + quantity = #{quantity,jdbcType=INTEGER}, + + + total_price = #{totalPrice,jdbcType=DECIMAL}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = now(), + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_order_item + set user_id = #{userId,jdbcType=INTEGER}, + order_no = #{orderNo,jdbcType=BIGINT}, + product_id = #{productId,jdbcType=INTEGER}, + product_name = #{productName,jdbcType=VARCHAR}, + product_image = #{productImage,jdbcType=VARCHAR}, + current_unit_price = #{currentUnitPrice,jdbcType=DECIMAL}, + quantity = #{quantity,jdbcType=INTEGER}, + total_price = #{totalPrice,jdbcType=DECIMAL}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = now() + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/OrderMapper.xml b/src/main/resources/mappers/OrderMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..14df2211be84f03a61bcde50011d7f6a8aa2f3e3 --- /dev/null +++ b/src/main/resources/mappers/OrderMapper.xml @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + id, order_no, user_id, shipping_id, payment, payment_type, postage, status, payment_time, + send_time, end_time, close_time, create_time, update_time + + + + delete from mmall_order + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_order (id, order_no, user_id, + shipping_id, payment, payment_type, + postage, status, payment_time, + send_time, end_time, close_time, + create_time, update_time) + values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, #{userId,jdbcType=INTEGER}, + #{shippingId,jdbcType=INTEGER}, #{payment,jdbcType=DECIMAL}, #{paymentType,jdbcType=INTEGER}, + #{postage,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{paymentTime,jdbcType=TIMESTAMP}, + #{sendTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{closeTime,jdbcType=TIMESTAMP}, + now(),now()) + + + insert into mmall_order + + + id, + + + order_no, + + + user_id, + + + shipping_id, + + + payment, + + + payment_type, + + + postage, + + + status, + + + payment_time, + + + send_time, + + + end_time, + + + close_time, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{orderNo,jdbcType=BIGINT}, + + + #{userId,jdbcType=INTEGER}, + + + #{shippingId,jdbcType=INTEGER}, + + + #{payment,jdbcType=DECIMAL}, + + + #{paymentType,jdbcType=INTEGER}, + + + #{postage,jdbcType=INTEGER}, + + + #{status,jdbcType=INTEGER}, + + + #{paymentTime,jdbcType=TIMESTAMP}, + + + #{sendTime,jdbcType=TIMESTAMP}, + + + #{endTime,jdbcType=TIMESTAMP}, + + + #{closeTime,jdbcType=TIMESTAMP}, + + + now(), + + + now(), + + + + + update mmall_order + + + order_no = #{orderNo,jdbcType=BIGINT}, + + + user_id = #{userId,jdbcType=INTEGER}, + + + shipping_id = #{shippingId,jdbcType=INTEGER}, + + + payment = #{payment,jdbcType=DECIMAL}, + + + payment_type = #{paymentType,jdbcType=INTEGER}, + + + postage = #{postage,jdbcType=INTEGER}, + + + status = #{status,jdbcType=INTEGER}, + + + payment_time = #{paymentTime,jdbcType=TIMESTAMP}, + + + send_time = #{sendTime,jdbcType=TIMESTAMP}, + + + end_time = #{endTime,jdbcType=TIMESTAMP}, + + + close_time = #{closeTime,jdbcType=TIMESTAMP}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = now(), + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_order + set order_no = #{orderNo,jdbcType=BIGINT}, + user_id = #{userId,jdbcType=INTEGER}, + shipping_id = #{shippingId,jdbcType=INTEGER}, + payment = #{payment,jdbcType=DECIMAL}, + payment_type = #{paymentType,jdbcType=INTEGER}, + postage = #{postage,jdbcType=INTEGER}, + status = #{status,jdbcType=INTEGER}, + payment_time = #{paymentTime,jdbcType=TIMESTAMP}, + send_time = #{sendTime,jdbcType=TIMESTAMP}, + end_time = #{endTime,jdbcType=TIMESTAMP}, + close_time = #{closeTime,jdbcType=TIMESTAMP}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = now() + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/PayInfoMapper.xml b/src/main/resources/mappers/PayInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..5907200e8c571046ed915d219fa1c9e329737dec --- /dev/null +++ b/src/main/resources/mappers/PayInfoMapper.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + id, user_id, order_no, pay_platform, platform_number, platform_status, create_time, + update_time + + + + delete from mmall_pay_info + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_pay_info (id, user_id, order_no, + pay_platform, platform_number, platform_status, + create_time, update_time) + values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, + #{payPlatform,jdbcType=INTEGER}, #{platformNumber,jdbcType=VARCHAR}, #{platformStatus,jdbcType=VARCHAR}, + now(),now())) + + + insert into mmall_pay_info + + + id, + + + user_id, + + + order_no, + + + pay_platform, + + + platform_number, + + + platform_status, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{userId,jdbcType=INTEGER}, + + + #{orderNo,jdbcType=BIGINT}, + + + #{payPlatform,jdbcType=INTEGER}, + + + #{platformNumber,jdbcType=VARCHAR}, + + + #{platformStatus,jdbcType=VARCHAR}, + + + now(), + + + now(), + + + + + update mmall_pay_info + + + user_id = #{userId,jdbcType=INTEGER}, + + + order_no = #{orderNo,jdbcType=BIGINT}, + + + pay_platform = #{payPlatform,jdbcType=INTEGER}, + + + platform_number = #{platformNumber,jdbcType=VARCHAR}, + + + platform_status = #{platformStatus,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = now(), + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_pay_info + set user_id = #{userId,jdbcType=INTEGER}, + order_no = #{orderNo,jdbcType=BIGINT}, + pay_platform = #{payPlatform,jdbcType=INTEGER}, + platform_number = #{platformNumber,jdbcType=VARCHAR}, + platform_status = #{platformStatus,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = now() + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/ProductMapper.xml b/src/main/resources/mappers/ProductMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..8f91044421044c4047eacc0e857b9315a4ed2556 --- /dev/null +++ b/src/main/resources/mappers/ProductMapper.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + id, category_id, name, subtitle, main_image, sub_images, detail, price, stock, status, + create_time, update_time + + + + delete from mmall_product + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_product (id, category_id, name, + subtitle, main_image, sub_images, + detail, price, stock, + status, create_time, update_time + ) + values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, + #{subtitle,jdbcType=VARCHAR}, #{mainImage,jdbcType=VARCHAR}, #{subImages,jdbcType=VARCHAR}, + #{detail,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{stock,jdbcType=INTEGER}, + #{status,jdbcType=INTEGER}, now(),now() + ) + + + insert into mmall_product + + + id, + + + category_id, + + + name, + + + subtitle, + + + main_image, + + + sub_images, + + + detail, + + + price, + + + stock, + + + status, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{categoryId,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{subtitle,jdbcType=VARCHAR}, + + + #{mainImage,jdbcType=VARCHAR}, + + + #{subImages,jdbcType=VARCHAR}, + + + #{detail,jdbcType=VARCHAR}, + + + #{price,jdbcType=DECIMAL}, + + + #{stock,jdbcType=INTEGER}, + + + #{status,jdbcType=INTEGER}, + + + now(), + + + now(), + + + + + update mmall_product + + + category_id = #{categoryId,jdbcType=INTEGER}, + + + name = #{name,jdbcType=VARCHAR}, + + + subtitle = #{subtitle,jdbcType=VARCHAR}, + + + main_image = #{mainImage,jdbcType=VARCHAR}, + + + sub_images = #{subImages,jdbcType=VARCHAR}, + + + detail = #{detail,jdbcType=VARCHAR}, + + + price = #{price,jdbcType=DECIMAL}, + + + stock = #{stock,jdbcType=INTEGER}, + + + status = #{status,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = now(), + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_product + set category_id = #{categoryId,jdbcType=INTEGER}, + name = #{name,jdbcType=VARCHAR}, + subtitle = #{subtitle,jdbcType=VARCHAR}, + main_image = #{mainImage,jdbcType=VARCHAR}, + sub_images = #{subImages,jdbcType=VARCHAR}, + detail = #{detail,jdbcType=VARCHAR}, + price = #{price,jdbcType=DECIMAL}, + stock = #{stock,jdbcType=INTEGER}, + status = #{status,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = now() + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/ShippingMapper.xml b/src/main/resources/mappers/ShippingMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..3f08f98c322a9b201c1ad3e8434836615cf0a5a1 --- /dev/null +++ b/src/main/resources/mappers/ShippingMapper.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + id, user_id, receiver_name, receiver_phone, receiver_mobile, receiver_province, receiver_city, + receiver_district, receiver_address, receiver_zip, create_time, update_time + + + + delete from mmall_shipping + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_shipping (id, user_id, receiver_name, + receiver_phone, receiver_mobile, receiver_province, + receiver_city, receiver_district, receiver_address, + receiver_zip, create_time, update_time + ) + values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR}, + #{receiverPhone,jdbcType=VARCHAR}, #{receiverMobile,jdbcType=VARCHAR}, #{receiverProvince,jdbcType=VARCHAR}, + #{receiverCity,jdbcType=VARCHAR}, #{receiverDistrict,jdbcType=VARCHAR}, #{receiverAddress,jdbcType=VARCHAR}, + #{receiverZip,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} + ) + + + insert into mmall_shipping + + + id, + + + user_id, + + + receiver_name, + + + receiver_phone, + + + receiver_mobile, + + + receiver_province, + + + receiver_city, + + + receiver_district, + + + receiver_address, + + + receiver_zip, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{userId,jdbcType=INTEGER}, + + + #{receiverName,jdbcType=VARCHAR}, + + + #{receiverPhone,jdbcType=VARCHAR}, + + + #{receiverMobile,jdbcType=VARCHAR}, + + + #{receiverProvince,jdbcType=VARCHAR}, + + + #{receiverCity,jdbcType=VARCHAR}, + + + #{receiverDistrict,jdbcType=VARCHAR}, + + + #{receiverAddress,jdbcType=VARCHAR}, + + + #{receiverZip,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + + + update mmall_shipping + + + user_id = #{userId,jdbcType=INTEGER}, + + + receiver_name = #{receiverName,jdbcType=VARCHAR}, + + + receiver_phone = #{receiverPhone,jdbcType=VARCHAR}, + + + receiver_mobile = #{receiverMobile,jdbcType=VARCHAR}, + + + receiver_province = #{receiverProvince,jdbcType=VARCHAR}, + + + receiver_city = #{receiverCity,jdbcType=VARCHAR}, + + + receiver_district = #{receiverDistrict,jdbcType=VARCHAR}, + + + receiver_address = #{receiverAddress,jdbcType=VARCHAR}, + + + receiver_zip = #{receiverZip,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_shipping + set user_id = #{userId,jdbcType=INTEGER}, + receiver_name = #{receiverName,jdbcType=VARCHAR}, + receiver_phone = #{receiverPhone,jdbcType=VARCHAR}, + receiver_mobile = #{receiverMobile,jdbcType=VARCHAR}, + receiver_province = #{receiverProvince,jdbcType=VARCHAR}, + receiver_city = #{receiverCity,jdbcType=VARCHAR}, + receiver_district = #{receiverDistrict,jdbcType=VARCHAR}, + receiver_address = #{receiverAddress,jdbcType=VARCHAR}, + receiver_zip = #{receiverZip,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mappers/UserMapper.xml b/src/main/resources/mappers/UserMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..85a2c896684a7b3041df75361ca06219d53cd97c --- /dev/null +++ b/src/main/resources/mappers/UserMapper.xml @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + id, username, password, email, phone, question, answer, role, create_time, update_time + + + + + + + + + + + + + + + + + + + + + + delete from mmall_user + where id = #{id,jdbcType=INTEGER} + + + insert into mmall_user (id, username, password, + email, phone, question, + answer, role, create_time, + update_time) + values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, + #{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{question,jdbcType=VARCHAR}, + #{answer,jdbcType=VARCHAR}, #{role,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, + #{updateTime,jdbcType=TIMESTAMP}) + + + insert into mmall_user + + + id, + + + username, + + + password, + + + email, + + + phone, + + + question, + + + answer, + + + role, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{username,jdbcType=VARCHAR}, + + + #{password,jdbcType=VARCHAR}, + + + #{email,jdbcType=VARCHAR}, + + + #{phone,jdbcType=VARCHAR}, + + + #{question,jdbcType=VARCHAR}, + + + #{answer,jdbcType=VARCHAR}, + + + #{role,jdbcType=INTEGER}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + + + update mmall_user + + + username = #{username,jdbcType=VARCHAR}, + + + password = #{password,jdbcType=VARCHAR}, + + + email = #{email,jdbcType=VARCHAR}, + + + phone = #{phone,jdbcType=VARCHAR}, + + + question = #{question,jdbcType=VARCHAR}, + + + answer = #{answer,jdbcType=VARCHAR}, + + + role = #{role,jdbcType=INTEGER}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update mmall_user + set username = #{username,jdbcType=VARCHAR}, + password = #{password,jdbcType=VARCHAR}, + email = #{email,jdbcType=VARCHAR}, + phone = #{phone,jdbcType=VARCHAR}, + question = #{question,jdbcType=VARCHAR}, + answer = #{answer,jdbcType=VARCHAR}, + role = #{role,jdbcType=INTEGER}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/main/resources/mmall.properties b/src/main/resources/mmall.properties new file mode 100644 index 0000000000000000000000000000000000000000..dba9a6e88c01593ccfcaed25cd85d752f0dc626f --- /dev/null +++ b/src/main/resources/mmall.properties @@ -0,0 +1,11 @@ + +ftp.server.ip=你的FTP服务器ip地址 +ftp.user=mmallftp +ftp.pass=ftppassword +ftp.server.http.prefix=http://img.happymmall.com/ + + +alipay.callback.url=http://www.happymmall.com/order/alipay_callback.do + +password.salt = geelysdafaqj23ou89ZXcj@#$@#$#@KJdjklj;D../dSF., + diff --git a/src/main/webapp/WEB-INF/dispatcher-servlet.xml b/src/main/webapp/WEB-INF/dispatcher-servlet.xml new file mode 100644 index 0000000000000000000000000000000000000000..78afab18dd163e82a2c6aa7a490a3e5ed2d072eb --- /dev/null +++ b/src/main/webapp/WEB-INF/dispatcher-servlet.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + text/plain;charset=UTF-8 + text/html;charset=UTF-8 + + + + + + + application/json;charset=UTF-8 + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 9f88c1f9632445500e3b3688fe477b860f77d8f2..e4cbf1e83bf713ed502ea07c91a377dd7071ceed 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,55 @@ - + + + + Archetype Created Web Application + + + characterEncodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + forceEncoding + true + + + + characterEncodingFilter + /* + + + + + org.springframework.web.context.request.RequestContextListener + + + + org.springframework.web.context.ContextLoaderListener + + + contextConfigLocation + + classpath:applicationContext.xml + + + + + dispatcher + org.springframework.web.servlet.DispatcherServlet + 1 + + + + + + dispatcher + *.do + - - Archetype Created Web Application +