提交注册登录

This commit is contained in:
qiurunze 2019-01-25 19:34:07 +08:00
parent a7315c1fca
commit 7e54491e68
24 changed files with 267 additions and 85 deletions

View File

@ -16,7 +16,18 @@
<version>1.18.2</version> <version>1.18.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- servlet-api -->
<!--<dependency>-->
<!--<groupId>javax.servlet</groupId>-->
<!--<artifactId>servlet-api</artifactId>-->
<!--<version>2.5</version>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-web</artifactId>-->
<!--<version>4.0.0.RELEASE</version>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>com.geekq</groupId> <groupId>com.geekq</groupId>
<artifactId>miaosha-common</artifactId> <artifactId>miaosha-common</artifactId>

View File

@ -6,13 +6,14 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
@Setter @Setter
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class Logininfo { public class Logininfo implements Serializable {
private Long id; private Long id;
private String nickname; private String nickname;

View File

@ -2,7 +2,6 @@ package com.geekq.admin.service;
import com.geekq.admin.entity.Logininfo; import com.geekq.admin.entity.Logininfo;
import com.geekq.common.utils.resultbean.ResultGeekQ; import com.geekq.common.utils.resultbean.ResultGeekQ;
import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -13,7 +12,7 @@ public interface ILogininfoService {
* @param username * @param username
* @param password * @param password
*/ */
ResultGeekQ<Boolean> register(String username, String password); void register(String username, String password);
/** /**
* 检查是否有重复的用户名 * 检查是否有重复的用户名
@ -26,7 +25,7 @@ public interface ILogininfoService {
* @param password * @param password
* @return * @return
*/ */
Logininfo login(String name, String password, int userType, String ip); ResultGeekQ<Logininfo> login(String name, String password, int userType, String ip);
/** /**
* 是否有管理员 * 是否有管理员

View File

@ -17,10 +17,10 @@
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
<!-- 引入dubbo -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId> <artifactId>dubbo</artifactId>
<version>2.6.0</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
@ -86,6 +86,11 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>druid</artifactId> <artifactId>druid</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies> </dependencies>

View File

@ -18,9 +18,12 @@ public interface LogininfoMapper {
int updateByPrimaryKey(Logininfo record); int updateByPrimaryKey(Logininfo record);
int getCountByUsername(@Param("username") String username, int getCountByNickname(@Param("nickname") String nickname,
@Param("userType") int userType); @Param("userType") int userType);
Logininfo getLoginInfoByNickname(@Param("nickname") String nickname,
@Param("userType") int userType);
Logininfo login(@Param("name") String name, Logininfo login(@Param("name") String name,
@Param("password") String password, @Param("userType") int userType); @Param("password") String password, @Param("userType") int userType);

View File

@ -10,6 +10,11 @@
<result column="state" jdbcType="TINYINT" property="state" /> <result column="state" jdbcType="TINYINT" property="state" />
<result column="admin" property="admin" /> <result column="admin" property="admin" />
<result column="usertype" property="userType" /> <result column="usertype" property="userType" />
<result column="salt" property="salt" />
<result column="usertype" property="userType" />
<result column="registerDate" property="registerDate" />
<result column="lastLoginDate" property="lastLoginDate" />
</resultMap> </resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
@ -19,18 +24,20 @@
</delete> </delete>
<insert id="insert" keyProperty="id" parameterType="com.geekq.admin.entity.Logininfo" useGeneratedKeys="true"> <insert id="insert" keyProperty="id" parameterType="com.geekq.admin.entity.Logininfo" useGeneratedKeys="true">
insert into logininfo (username,password, state,usertype,admin) insert into logininfo (nickname,password, state,usertype,admin,salt,registerdate,lastlogindate)
values (#{username,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR},#{state,jdbcType=TINYINT},#{userType},#{admin}) values (#{nickname,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR},#{state,jdbcType=TINYINT},#{userType},#{admin}
,#{salt},#{registerDate},#{lastLoginDate})
</insert> </insert>
<update id="updateByPrimaryKey" parameterType="com.geekq.admin.entity.Logininfo"> <update id="updateByPrimaryKey" parameterType="com.geekq.admin.entity.Logininfo">
update logininfo set username = #{username,jdbcType=VARCHAR},password =#{password,jdbcType=VARCHAR}, update logininfo set nickname = #{nickname,jdbcType=VARCHAR},password =#{password,jdbcType=VARCHAR},
state = #{state,jdbcType=TINYINT},usertype = #{userType},admin=#{admin} state = #{state,jdbcType=TINYINT},usertype = #{userType},admin=#{admin},salt = #{salt},
registerdate = #{registerDate},lastlogindate = #{lastLoginDate}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<sql id="base_column"> <sql id="base_column">
id, username, password, state,usertype,admin id, nickname, password, state,usertype,admin ,salt , registerdate , lastlogindate
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap" useCache="true"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap" useCache="true">
@ -43,17 +50,24 @@
from logininfo from logininfo
</select> </select>
<select id="getCountByUsername" resultType="int" useCache="false"> <select id="getCountByNickname" resultType="int" useCache="false">
select count(id) from logininfo where username=#{username} and usertype = #{userType} select count(id) from logininfo where nickname=#{nickname} and usertype = #{userType}
</select> </select>
<select id="getLoginInfoByNickname" resultMap="BaseResultMap" useCache="false">
select <include refid="base_column" />
from logininfo where nickname=#{nickname} and usertype = #{userType}
</select>
<select id="login" resultMap="BaseResultMap" useCache="true"> <select id="login" resultMap="BaseResultMap" useCache="true">
select <include refid="base_column"/> select <include refid="base_column"/>
from logininfo where username= #{name} and password=#{password} and usertype=#{userType} from logininfo where nickname= #{name} and password=#{password} and usertype=#{userType}
</select> </select>
<select id="autoComplate" resultType="hashmap" useCache="false"> <select id="autoComplate" resultType="hashmap" useCache="false">
select id,username as name select id,nickname as name
from logininfo where username LIKE concat(#{word},'%') AND usertype = #{userType} from logininfo where nickname LIKE concat(#{word},'%') AND usertype = #{userType}
</select> </select>
</mapper> </mapper>

View File

@ -1,14 +1,15 @@
package com.geekq.admin.service.impl; package com.geekq.admin.service.impl;
import com.geekq.admin.entity.IpLog;
import com.geekq.admin.entity.Logininfo; import com.geekq.admin.entity.Logininfo;
import com.geekq.admin.entity.Userinfo; import com.geekq.admin.entity.Userinfo;
import com.geekq.admin.mapper.IpLogMapper; import com.geekq.admin.mapper.IpLogMapper;
import com.geekq.admin.mapper.LogininfoMapper; import com.geekq.admin.mapper.LogininfoMapper;
import com.geekq.admin.mapper.UserinfoMapper; import com.geekq.admin.mapper.UserinfoMapper;
import com.geekq.admin.service.ILogininfoService; import com.geekq.admin.service.ILogininfoService;
import com.geekq.admin.utils.UserContext;
import com.geekq.common.enums.Constants; import com.geekq.common.enums.Constants;
import com.geekq.common.enums.ResultStatus; import com.geekq.common.enums.ResultStatus;
import com.geekq.common.utils.Constanst;
import com.geekq.common.utils.MD5.MD5Utils; import com.geekq.common.utils.MD5.MD5Utils;
import com.geekq.common.utils.resultbean.ResultGeekQ; import com.geekq.common.utils.resultbean.ResultGeekQ;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -37,12 +38,10 @@ public class LogininfoServiceImpl implements ILogininfoService {
private UserinfoMapper userinfoMapper; private UserinfoMapper userinfoMapper;
@Override @Override
public ResultGeekQ<Boolean> register(String username, String password) { public void register(String username, String password) {
ResultGeekQ<Boolean> resultGeekQ = ResultGeekQ.build(); int count = loginInfoMapper.getCountByNickname(username, Constants.USERTYPE_NORMAL);
int count = loginInfoMapper.getCountByUsername(username, Constants.USERTYPE_NORMAL); if(count <= 0) {
if(count > 0) {
try {
Logininfo logininfo =new Logininfo(); Logininfo logininfo =new Logininfo();
logininfo.setNickname(username); logininfo.setNickname(username);
//获取随机salt //获取随机salt
@ -52,29 +51,44 @@ public class LogininfoServiceImpl implements ILogininfoService {
logininfo.setState(Constants.STATE_NORMAL); logininfo.setState(Constants.STATE_NORMAL);
logininfo.setUserType(Constants.USERTYPE_NORMAL); logininfo.setUserType(Constants.USERTYPE_NORMAL);
logininfo.setRegisterDate(new Date()); logininfo.setRegisterDate(new Date());
logininfo.setLastLoginDate(new Date());
logininfo.setSalt(salt); logininfo.setSalt(salt);
this.loginInfoMapper.insert(logininfo); this.loginInfoMapper.insert(logininfo);
//初始化一个Userinfo //初始化一个Userinfo
Userinfo userinfo = Userinfo.empty(logininfo.getId()); Userinfo userinfo = Userinfo.empty(logininfo.getId());
this.userinfoMapper.insert(userinfo); int result = this.userinfoMapper.insert(userinfo);
} catch (Exception e) {
logger.error("注册失败!",e);
resultGeekQ.withError(ResultStatus.RESIGETER_FAIL);
}
}else{ }else{
resultGeekQ.withError(ResultStatus.RESIGETER_NICKNAMEEXIST); throw new RuntimeException("用户名已经存在!");
} }
return resultGeekQ;
} }
@Override @Override
public boolean checkUsername(String name, int userType) { public boolean checkUsername(String name, int userType) {
return this.loginInfoMapper.getCountByUsername(name, userType)<=0; return this.loginInfoMapper.getCountByNickname(name, userType)<=0;
} }
@Override @Override
public Logininfo login(String name, String password, int userType, String ip) { public ResultGeekQ<Logininfo> login(String name, String password, int userType, String ip) {
return null; ResultGeekQ<Logininfo> resultGeekQ = ResultGeekQ.build();
try {
IpLog log = new IpLog(name,new Date(),ip,userType,null);
Logininfo logininfo = loginInfoMapper.getLoginInfoByNickname(name,Constants.USERTYPE_NORMAL);
String salt = logininfo.getSalt();
Logininfo current = this.loginInfoMapper.login(name,
MD5Utils.formPassToDBPass(password,salt), userType);
if(current != null){
UserContext.putLogininfo(current);
log.setLoginInfoId(current.getId());
log.setLoginState(IpLog.LOGINSTATE_SUCCESS);
}
ipLogMapper.insert(log);
resultGeekQ.setData(logininfo);
} catch (Exception e) {
logger.error("登录发生错误!",e);
resultGeekQ.withError(ResultStatus.LOGIN_FIAL);
}
return resultGeekQ;
} }
@Override @Override

View File

@ -0,0 +1,37 @@
package com.geekq.admin.utils;
import com.geekq.admin.entity.Logininfo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
public class UserContext {
public static final String LOGIN_IN_SESSION = "logininfo";
public static final String VERIFYCODE_IN_SESSION = "VERIFYCODE_IN_SESSION";
private static HttpServletRequest getRequest() {
return ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
}
public static void putLogininfo(Logininfo logininfo) {
getRequest().getSession().setAttribute(LOGIN_IN_SESSION, logininfo);
}
public static Logininfo getCurrent() {
return (Logininfo) getRequest().getSession().getAttribute(
LOGIN_IN_SESSION);
}
// public static void putVerifyCode(VerifyCode code) {
// getRequest().getSession().setAttribute(VERIFYCODE_IN_SESSION, code);
// }
//
// public static VerifyCode getVerifyCode() {
// return (VerifyCode) getRequest().getSession().getAttribute(
// VERIFYCODE_IN_SESSION);
// }
}

View File

@ -1,4 +1,4 @@
jdbc.driver=com.mysql.jdbc.Driver jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/miaosha?characterEncoding=utf-8 jdbc.url=jdbc:mysql://localhost:3306/miaosha2?characterEncoding=utf-8
jdbc.username=root jdbc.username=root
jdbc.password=nihaoma jdbc.password=nihaoma

View File

@ -6,19 +6,19 @@
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 为当前服务提供者取个名字,并且提供给注册中心 --> <!-- 为当前服务提供者取个名字,并且提供给注册中心 -->
<dubbo:application name="imooc-dubbo-order-service"></dubbo:application> <dubbo:application name="miaosha-service"></dubbo:application>
<!-- 注册中心的配置使用zk暴露服务 --> <!-- 注册中心的配置使用zk暴露服务 -->
<dubbo:registry protocol="zookeeper" address="39.107.245.253:2181"></dubbo:registry> <dubbo:registry protocol="zookeeper" address="localhost:2181"></dubbo:registry>
<!-- 定义暴露服务的端口号 --> <!-- 定义暴露服务的端口号 -->
<dubbo:protocol name="dubbo" port="20881"></dubbo:protocol> <dubbo:protocol name="dubbo" port="20881" ></dubbo:protocol>
<!-- 暴露具体的服务接口 --> <!-- 暴露具体的服务接口 -->
<dubbo:service retries="3" interface="com.geekq.admin.service.OrdersService" <dubbo:service retries="3" interface="com.geekq.admin.service.OrdersService"
ref="ordersService" timeout="6000"></dubbo:service> ref="ordersService" timeout="60000"></dubbo:service>
<dubbo:service retries="3" interface="com.geekq.admin.service.ILogininfoService" <dubbo:service retries="3" interface="com.geekq.admin.service.ILogininfoService"
ref="logininfoServiceImpl" timeout="6000"></dubbo:service> ref="logininfoServiceImpl" timeout="60000"></dubbo:service>
</beans> </beans>

View File

@ -31,12 +31,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId> <artifactId>dubbo</artifactId>
<exclusions> <version>2.6.0</version>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.zookeeper</groupId> <groupId>org.apache.zookeeper</groupId>

View File

@ -1,13 +1,18 @@
package com.geekq.web.controller; package com.geekq.web.controller;
import com.geekq.admin.entity.Logininfo;
import com.geekq.admin.service.ILogininfoService;
import com.geekq.common.enums.Constants;
import com.geekq.common.utils.resultbean.ResultGeekQ; import com.geekq.common.utils.resultbean.ResultGeekQ;
import com.geekq.common.vo.LoginVo; import com.geekq.common.vo.LoginVo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
@ -20,11 +25,20 @@ public class LoginController extends BaseController {
private static Logger logger = LoggerFactory.getLogger(LoginController.class); private static Logger logger = LoggerFactory.getLogger(LoginController.class);
@Autowired
private ILogininfoService iLogininfoService;
@RequestMapping("/login" ) @RequestMapping("/login" )
@ResponseBody @ResponseBody
public ResultGeekQ<Boolean> dologin(HttpServletResponse response, LoginVo loginVo) { public ResultGeekQ<Boolean> dologin(HttpServletResponse response,
HttpServletRequest request,
String username, String password) {
ResultGeekQ<Boolean> result = ResultGeekQ.build(); ResultGeekQ<Boolean> result = ResultGeekQ.build();
logger.info(loginVo.toString()); ResultGeekQ<Logininfo> login = this.iLogininfoService.login(username, password,
Constants.USERTYPE_NORMAL,request.getRemoteAddr());
if(ResultGeekQ.isSuccess(login)){
result.withError(login.getCode(),login.getMessage());
}
return result; return result;
} }
} }

View File

@ -1,7 +1,9 @@
package com.geekq.web.controller; package com.geekq.web.controller;
import com.geekq.web.interceptor.RequiredLogin;
import com.geekq.web.service.CulsterService; import com.geekq.web.service.CulsterService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -13,7 +15,8 @@ public class PayController {
@Autowired @Autowired
private CulsterService buyService; private CulsterService buyService;
@RequiredLogin
@RequestMapping("/index") @RequestMapping("/index")
public String index() { public String index() {
return "login"; return "login";

View File

@ -4,6 +4,7 @@ import com.geekq.admin.service.ILogininfoService;
import com.geekq.common.enums.Constants; import com.geekq.common.enums.Constants;
import com.geekq.common.enums.ResultStatus; import com.geekq.common.enums.ResultStatus;
import com.geekq.common.utils.resultbean.ResultGeekQ; import com.geekq.common.utils.resultbean.ResultGeekQ;
import com.geekq.common.utils.resultbean.ResultJSON;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,12 +25,16 @@ public class RegisterController extends BaseController{
@RequestMapping("/register") @RequestMapping("/register")
@ResponseBody @ResponseBody
public ResultGeekQ<Boolean> register(String username, String password) { public ResultJSON register(String username, String password) {
/** ResultJSON json = new ResultJSON();
* 登录注册 try {
*/ this.logininfoService.register(username, password);
return logininfoService.register(username,password); json.setSuccess(true);
} catch (RuntimeException e) {
logger.error("注册失败",e);
json.setMsg("注册失败,请联系相关人员!");
}
return json;
} }
@RequestMapping("/checkUsername") @RequestMapping("/checkUsername")

View File

@ -1,32 +1,29 @@
package com.geekq.web.interceptor; package com.geekq.web.interceptor;
import com.geekq.web.utils.UserContext;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/**
* @author 邱润泽
* 拦截器 拦截至主页面
*/
public class LoginInterceptor extends HandlerInterceptorAdapter { public class LoginInterceptor extends HandlerInterceptorAdapter {
// @Override @Override
// public boolean preHandle(HttpServletRequest request, public boolean preHandle(HttpServletRequest request,
// HttpServletResponse response, Object handler) throws Exception { HttpServletResponse response, Object handler) throws Exception {
// if (handler instanceof HandlerMethod) { if (handler instanceof HandlerMethod) {
// HandlerMethod hm = (HandlerMethod) handler; HandlerMethod hm = (HandlerMethod) handler;
// RequiredLogin rl = hm.getMethodAnnotation(RequiredLogin.class); RequiredLogin rl = hm.getMethodAnnotation(RequiredLogin.class);
// if (rl != null) { if (rl != null) {
//// if (request.getSession().getAttribute( if (request.getSession().getAttribute(
//// UserContext.LOGIN_IN_SESSION) == null) { UserContext.LOGIN_IN_SESSION) == null) {
// response.sendRedirect("/login.html"); response.sendRedirect("/login.html");
// return false; return false;
// } }
//// } }
// } }
// return super.preHandle(request, response, handler); return super.preHandle(request, response, handler);
// } }
} }

View File

@ -0,0 +1,37 @@
package com.geekq.web.utils;
import com.geekq.admin.entity.Logininfo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
public class UserContext {
public static final String LOGIN_IN_SESSION = "logininfo";
public static final String VERIFYCODE_IN_SESSION = "VERIFYCODE_IN_SESSION";
private static HttpServletRequest getRequest() {
return ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
}
public static void putLogininfo(Logininfo logininfo) {
getRequest().getSession().setAttribute(LOGIN_IN_SESSION, logininfo);
}
public static Logininfo getCurrent() {
return (Logininfo) getRequest().getSession().getAttribute(
LOGIN_IN_SESSION);
}
// public static void putVerifyCode(VerifyCode code) {
// getRequest().getSession().setAttribute(VERIFYCODE_IN_SESSION, code);
// }
//
// public static VerifyCode getVerifyCode() {
// return (VerifyCode) getRequest().getSession().getAttribute(
// VERIFYCODE_IN_SESSION);
// }
}

View File

@ -6,10 +6,10 @@
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 为当前服务提供者取个名字,并且提供给注册中心 --> <!-- 为当前服务提供者取个名字,并且提供给注册中心 -->
<dubbo:application name="imooc-dubbo-web"></dubbo:application> <dubbo:application name="miaosha-dubbo-web"></dubbo:application>
<!-- 注册中心的配置,用于消费者的监听 --> <!-- 注册中心的配置,用于消费者的监听 -->
<dubbo:registry protocol="zookeeper" address="39.107.245.253:2181"></dubbo:registry> <dubbo:registry protocol="zookeeper" address="localhost:2181"></dubbo:registry>
<!--&lt;!&ndash; 监听服务,通过注册中心去进行查找,查找到后进行服务调用 &ndash;&gt;--> <!--&lt;!&ndash; 监听服务,通过注册中心去进行查找,查找到后进行服务调用 &ndash;&gt;-->
<!--<dubbo:reference id="itemService" interface="com.imooc.item.service.ItemsService"--> <!--<dubbo:reference id="itemService" interface="com.imooc.item.service.ItemsService"-->

View File

@ -42,7 +42,7 @@
//验证成功后提交操作 //验证成功后提交操作
submitHandler:function(form){ submitHandler:function(form){
$(form).ajaxSubmit(function(data){ $(form).ajaxSubmit(function(data){
if(data.success){ if(data.status='success'){
$.messager.confirm("提示","登陆成功,点击确定跳转到个人中心",function(){ $.messager.confirm("提示","登陆成功,点击确定跳转到个人中心",function(){
window.location.href="/personal.do"; window.location.href="/personal.do";
}); });
@ -91,7 +91,7 @@
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2">手机号码</label> <label class="control-label col-sm-2">手机号码</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" autocomplete="off" name="mobile" class="form-control" value="stef"/> <input type="text" autocomplete="off" name="username" class="form-control" value="stef"/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -49,7 +49,7 @@
data:{username:value}, data:{username:value},
async:false, async:false,
success:function(data){ success:function(data){
ret= data.success; ret= data.data;
} }
}); });
return ret; return ret;
@ -85,7 +85,7 @@
}, },
submitHandler:function(form){ submitHandler:function(form){
$(form).ajaxSubmit(function(data){ $(form).ajaxSubmit(function(data){
if(data.success){ if(data.data){
$.messager.confirm("提示","注册成功,请重新登录系统!",function(){ $.messager.confirm("提示","注册成功,请重新登录系统!",function(){
window.location.href="/login.html"; window.location.href="/login.html";
}); });
@ -121,7 +121,7 @@
<div class="navbar navbar-default el-navbar"> <div class="navbar navbar-default el-navbar">
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<a href=""><img alt="Brand" src="/images/logo.png"></a> <a href=""><img alt="Brand" src="/images/miaoshaxitong.png"></a>
<span class="el-page-title">用户注册</span> <span class="el-page-title">用户注册</span>
</div> </div>
</div> </div>

View File

@ -32,6 +32,8 @@ public enum ResultStatus {
RESIGETER_FAIL(200001,"注册失败!"), RESIGETER_FAIL(200001,"注册失败!"),
CODE_FAIL(200002,"验证码不一致!"), CODE_FAIL(200002,"验证码不一致!"),
RESIGETER_NICKNAMEEXIST(200003,"用户名已经存在!"), RESIGETER_NICKNAMEEXIST(200003,"用户名已经存在!"),
LOGIN_FIAL(200004,"登录失败!"),
/** /**
* check * check

View File

@ -8,6 +8,7 @@ public class AbstractResult {
private int code; private int code;
private String message; private String message;
AbstractResult() {}
protected AbstractResult(ResultStatus status, String message) { protected AbstractResult(ResultStatus status, String message) {
this.code = status.getCode(); this.code = status.getCode();
this.status = status; this.status = status;

View File

@ -1,14 +1,16 @@
package com.geekq.common.utils.resultbean; package com.geekq.common.utils.resultbean;
import com.geekq.common.enums.ResultStatus; import com.geekq.common.enums.ResultStatus;
import java.io.Serializable; import java.io.Serializable;
public class ResultGeekQ<T> extends AbstractResult implements Serializable { public class ResultGeekQ<T> extends AbstractResult implements Serializable {
private static final long serialVersionUID = 867933019328199779L;
private T data; private T data;
private Integer count; private Integer count;
protected ResultGeekQ() {
}
protected ResultGeekQ(ResultStatus status, String message) { protected ResultGeekQ(ResultStatus status, String message) {
super(status, message); super(status, message);
} }
@ -16,7 +18,7 @@ public class ResultGeekQ<T> extends AbstractResult implements Serializable {
super(status); super(status);
} }
public static <T> ResultGeekQ<T> build() { public static <T> ResultGeekQ<T> build() {
return new ResultGeekQ(ResultStatus.SUCCESS, (String)null); return new ResultGeekQ(ResultStatus.SUCCESS, "构造函数");
} }
public static <T> ResultGeekQ<T> build(String message) { public static <T> ResultGeekQ<T> build(String message) {

View File

@ -0,0 +1,30 @@
package com.geekq.common.utils.resultbean;
import lombok.Getter;
import lombok.Setter;
/**
* @author 邱润泽
*/
@Getter
@Setter
public class ResultJSON {
private Boolean success = false;
private String msg;
public ResultJSON() {
super();
}
public ResultJSON(Boolean success, String msg) {
super();
this.success = success;
this.msg = msg;
}
public ResultJSON(String msg) {
super();
this.msg = msg;
}
}

View File

@ -30,7 +30,7 @@
<!-- 使用redisTamplate结合jedisPoolConifg 必须使用jedis版本2.9.0 --> <!-- 使用redisTamplate结合jedisPoolConifg 必须使用jedis版本2.9.0 -->
<jedis.version>2.9.0</jedis.version> <jedis.version>2.9.0</jedis.version>
<commons.httpclient.version>3.1</commons.httpclient.version> <commons.httpclient.version>3.1</commons.httpclient.version>
<dubbo.version>2.5.3</dubbo.version> <dubbo.version>2.6.0</dubbo.version>
<zookeeper.version>3.4.11</zookeeper.version> <zookeeper.version>3.4.11</zookeeper.version>
<zkclient.version>0.1</zkclient.version> <zkclient.version>0.1</zkclient.version>
<apache.curator.version>4.0.0</apache.curator.version> <apache.curator.version>4.0.0</apache.curator.version>
@ -145,6 +145,12 @@
<artifactId>spring-webmvc</artifactId> <artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.springframework</groupId>-->
<!--<artifactId>spring-web</artifactId>-->
<!--<version>4.0.0.RELEASE</version>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId> <artifactId>spring-jdbc</artifactId>
@ -215,6 +221,12 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId> <artifactId>dubbo</artifactId>
<version>${dubbo.version}</version> <version>${dubbo.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.zookeeper</groupId> <groupId>org.apache.zookeeper</groupId>