Explorar el Código

APP和网站注册、登录、重置密码修改

anderx hace 7 años
padre
commit
3d0c74b610

+ 6 - 9
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -454,7 +454,7 @@ public class PublicController extends BaseController {
 	
 	@RequestMapping(value = "/resetPassword", method = RequestMethod.POST)
 	@ResponseBody
-	public Result resetPassword(String userName,String newPwd,String resetCode) {
+	public Result resetPassword(String mobile,Integer type,String newPwd,String resetCode) {
 		Result res=new Result();
 		if (TimeUtils.checkOverTime(VerifyCodeUtils.M_CODE)) {
 			res.getError().add(buildError(ErrorConstants.RESET_CODE_OVERTIME, "", "页面超时失效,请重新获取验证码!"));
@@ -475,11 +475,11 @@ public class PublicController extends BaseController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
 			return res;
 		}
-		if (StringUtils.isBlank(userName)) {
+		if (StringUtils.isBlank(mobile)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户名"));
 			return res;
 		}
-		User user=userService.selectByNameAndType(userName, null);
+		User user=userService.selectByNameAndType(mobile, type);
 		user.setPassword(newPwd);
 		user.setPassword(passwordUtil.getEncryptPwd(user));
 		userService.updateByPrimaryKeySelective(user);
@@ -562,7 +562,7 @@ public class PublicController extends BaseController {
 	
 	@RequestMapping(value = "/getResetMCode", method = RequestMethod.GET )
 	@ResponseBody
-	public Result getResetMCode(String mobile, Integer type) {
+	public Result getResetMCode(String mobile) {
 		Result res = new Result();
 		if (userService.selectByMobieAndTypeCount(mobile.trim())<1) {
 			res.getError().add(buildError(ErrorConstants.NON_REGISTER, "", "该用户未注册!"));
@@ -663,17 +663,14 @@ public class PublicController extends BaseController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "mobile"));
 			return res;
 		}
-		if (StringUtils.isBlank(username)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户"));
-			return res;
-		}
+		
 
 		/*if (!UserType.ORGANIZATION.getCode().equals(type) && !UserType.PERSONAL.getCode().equals(type)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "type"));
 			return res;
 		}*/
 
-		User user = userService.selectByNameAndType(username, null);
+		User user = userService.selectByMobieAndType(mobile, type);
 		if (null == user) {
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户"));
 			return res;

+ 1 - 1
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -91,7 +91,7 @@ public interface UserMapper {
 
 	Long selectNumberByPrimaryKey(String userId);
 	
-	User selectByMobieAndType(String mobile, Integer type);
+	User selectByMobieAndType(@Param("mobile")String mobile, @Param("type")Integer type);
 
 	List<OrganizationContactBook> findAllContacts(String uid);
 

+ 1 - 1
src/main/java/com/goafanti/common/mapper/DemandMapper.xml

@@ -616,7 +616,7 @@
   <select id="findAppDemandCount" parameterType="String" resultType="java.lang.Integer">
   		select count(1)
 	from  demand d 
-	where d.deleted_sign = 0 and d.audit_status=2 and d.info_sources=1 and d.release_status=1
+	where d.deleted_sign = 0 and d.audit_status=2 and d.info_sources=1  
 	<if test="employerId != null">
 	and d.employer_id = #{employerId, jdbcType=VARCHAR}
 	</if>

+ 5 - 1
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -680,7 +680,11 @@
     select
   <include refid="Base_Column_List" />
     from user
-    where mobile = #{0} and type=#{1} and source = 0
+    where  source = 0
+    and mobile = #{mobile}
+    <if test="type != null">
+     and type=#{type} 
+     </if>
   </select>
   
   <select id="selectByNameAndType" resultMap="BaseResultMap">

+ 1 - 1
src/main/java/com/goafanti/core/shiro/token/TokenManager.java

@@ -166,7 +166,7 @@ public class TokenManager {
 	 * @return
 	 */
 	public static User login(User user, Boolean rememberMe) {
-		ShiroToken token = new ShiroToken(user.getUsername(), user.getPassword(), user.getType(),AFTConstants.USER_SOURCE_REGISTER);
+		ShiroToken token = new ShiroToken(user.getMobile(), user.getPassword(), user.getType(),AFTConstants.USER_SOURCE_REGISTER);
 		token.setRememberMe(null == rememberMe ? false : rememberMe);
 		SecurityUtils.getSubject().login(token);
 		setVal2Session(CSRF_TOKEN, UUID.randomUUID().toString().replace("-", ""));

+ 1 - 1
src/main/java/com/goafanti/core/shiro/token/UserRealm.java

@@ -60,7 +60,7 @@ public class UserRealm extends AuthorizingRealm {
 			return new SimpleAuthenticationInfo(aftUser, aftUser.getPassword(), passwordUtil.getAftSalt(aftUser),
 					getName());
 		} else {
-			User user = userService.selectByNameAndType(token.getUsername(), null);
+			User user = userService.selectByMobieAndType(token.getUsername(), token.getType());
 			if (null == user) {
 				throw new UnknownAccountException();
 			}

+ 14 - 0
src/main/java/com/goafanti/user/bo/InputUser.java

@@ -1,5 +1,7 @@
 package com.goafanti.user.bo;
 
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 import javax.validation.constraints.Size;
 
 import com.goafanti.common.constant.ErrorConstants;
@@ -18,6 +20,18 @@ public class InputUser {
 	@Size(min = 0, max = 32, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	username;
 	
+	@Max(value = 2, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	type;
+	
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
 	public String getMobile() {
 		return mobile;
 	}

+ 7 - 8
src/main/java/com/goafanti/user/controller/UserRegisterController.java

@@ -65,9 +65,10 @@ public class UserRegisterController extends BaseController {
 					UserFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		User u = userService.selectByNameAndType(user.getUsername().trim(), null);
+		User u = userService.selectByMobieAndType(user.getMobile().trim(), user.getType());
 		if (null != u) {
 			res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "用户已存在"));
+			return res;
 		}
 		// 验证码15分钟有效
 		if (TimeUtils.checkOverTime("register")) {
@@ -81,7 +82,6 @@ public class UserRegisterController extends BaseController {
 		if (res.getError().isEmpty()) {
 			User us = new User();
 			us.setId(UUID.randomUUID().toString());
-			us.setUsername(user.getUsername().trim());
 			us.setMobile(user.getMobile().trim());
 			us.setPassword(user.getPassword());
 			Calendar now = Calendar.getInstance();
@@ -89,8 +89,8 @@ public class UserRegisterController extends BaseController {
 			us.setCreateTime(now.getTime());
 			us.setUpdateTime(now.getTime());
 			us.setPassword(passwordUtil.getEncryptPwd(us));
-			us.setLvl(0);
-			us.setNickname(user.getUsername());
+			us.setNickname(user.getUnitName());
+			us.setType(user.getType());
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
 			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
 			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);
@@ -119,7 +119,7 @@ public class UserRegisterController extends BaseController {
 					UserFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		User u = userService.selectByNameAndType(user.getUsername().trim(), null);
+		User u = userService.selectByMobieAndType(user.getMobile().trim(), user.getType());
 		if (null != u) {
 			res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "用户已存在"));
 		}
@@ -135,7 +135,6 @@ public class UserRegisterController extends BaseController {
 		if (res.getError().isEmpty()) {
 			User us = new User();
 			us.setId(UUID.randomUUID().toString());
-			us.setUsername(user.getUsername().trim());
 			us.setMobile(user.getMobile().trim());
 			us.setPassword(user.getPassword());
 			Calendar now = Calendar.getInstance();
@@ -143,8 +142,8 @@ public class UserRegisterController extends BaseController {
 			us.setCreateTime(now.getTime());
 			us.setUpdateTime(now.getTime());
 			us.setPassword(passwordUtil.getEncryptPwd(us));
-			us.setLvl(0);
-			us.setNickname(user.getUsername());
+			us.setType(user.getType());
+			us.setNickname(user.getUnitName());
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
 			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
 			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);

+ 6 - 2
src/main/resources/props/config_local.properties

@@ -55,8 +55,12 @@ app.name=AFT
 app.mobile.website=http://m.kedexinxi.com
 template.cacheable=false
 
-static.host=//sclient.jishutao.com:8088/client/1.0.0
-portal.host=//sportal.jishutao.com:8088/portal/1.0.0
+static.host=//sclient.jishutao.com/client/1.0.0
+#static.host=//sclient.jishutao.com:8088/client/1.0.0
+#static.host=//sclient.jishutao.com:80/client/1.0.0
+portal.host=//sportal.jishutao.com/portal/1.0.0
+#portal.host=//sportal.jishutao.com:8088/portal/1.0.0
+#portal.host=//sportal.jishutao.com:80/portal/1.0.0
 avatar.host=//sclient.jishutao.com
 avatar.upload.host=//sclient.jishutao.com/upload
 

+ 16 - 2
src/main/webapp/WEB-INF/views/common.html

@@ -418,6 +418,13 @@
 							<label for="pass"><img th:src="${portalHost+'/img/login_password.png'}"/></label>
 							<input type="password" name="pass" id="Lo_pass" placeholder="请输入密码" />
 						</div>
+						<div class="login_pass">
+							<img th:src="${portalHost+'/img/resiger_username.jpg'}" alt=""/>
+							<select id="customerType">
+								<option value="0">个人</option>
+								<option value="1">企业</option>
+							</select>
+						</div>
 						<div class="login_check">
 						<a href="#">忘记密码?</a>
 						</div>
@@ -436,16 +443,23 @@
 						<a href="">忘记密码?</a>
 					</div>
 					<div class="forget_center">
-					<div class="user">
+					<!-- <div class="user">
 						<label for="forget_user">
 							用户名:<input type="text" name="type" id="forget_user" placeholder="请输入您的用户名"/>
 						</label>
-					</div>
+					</div> -->
 						<div class="phone">
 							<label for="forget_phone">
 								手机号码:<input type="text" name="type" id="forget_phone" placeholder="请输入您的手机号码..."/>
 							</label>
 						</div>
+						<div class="login_pa">
+							客户类别:
+							<select id="customerTy">
+								<option value="0">个人</option>
+								<option value="1">企业</option>
+							</select>
+						</div>
 						<div class="cellcode_">
 							<div>
 								验证码:<input type="text" name="cellCode" placeholder="手机验证码" id="photo_n"/>

+ 6 - 4
src/main/webapp/WEB-INF/views/user/signIn.html

@@ -22,7 +22,7 @@
 					<div class="regist">
 						<div class="zhuce_input">
 							<img th:src="${portalHost+'/img/name.jpg'}" alt=""/>
-							<input type="text" name="userName" value="请输入用户名"  id="username" autocomplete="off"/>
+							<input type="text" name="userName" value="请输入名"  id="username" autocomplete="off"/>
 							<img th:src="${portalHost+'/img/login_del.png'}" class="log_del"/>
 							<span class="star"> * </span>
 						</div>
@@ -37,9 +37,11 @@
 							<span class="star"> * </span>
 						</div>
 						<div class="zhuce_input">
-				<img th:src="${portalHost+'/img/resiger_username.jpg'}" alt=""/>
-
-							<input type="text" name="customerName" value="请输入客户名称" id="customerName" autocomplete="off"/>
+							<img th:src="${portalHost+'/img/resiger_username.jpg'}" alt=""/>
+							<select id="customerType">
+								<option value="0">个人</option>
+								<option value="1">企业</option>
+							</select>
 							<span class="star"> * </span>
 						</div>
 						<div class="zhuce_input">