Browse Source

会员管理接口

Antiloveg 9 years ago
parent
commit
8f274646cd

+ 3 - 3
src/main/java/com/goafanti/common/mapper/OrganizationInfoMapper.xml

@@ -135,13 +135,13 @@
         company_name = #{companyName,jdbcType=VARCHAR},
       </if>
        <if test="locationProvince != null" >
-       locationProvince =  #{locationProvince,jdbcType=VARCHAR},
+       location_Province =  #{locationProvince,jdbcType=VARCHAR},
       </if>
        <if test="locationCity != null" >
-        locationCity = #{locationCity,jdbcType=VARCHAR},
+        location_City = #{locationCity,jdbcType=VARCHAR},
       </if>
        <if test="locationArea != null" >
-       locationArea = #{locationArea,jdbcType=VARCHAR},
+       location_Area = #{locationArea,jdbcType=VARCHAR},
       </if>
       <if test="unitSize != null" >
         unit_size = #{unitSize,jdbcType=VARCHAR},

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

@@ -5,7 +5,7 @@
     <id column="id" property="id" jdbcType="VARCHAR" />
     <result column="oid" property="oid" jdbcType="VARCHAR" />
     <result column="qualification" property="qualification" jdbcType="VARCHAR" />
-    <result column="turnover" property="turnover" jdbcType="VARCHAR" />
+    <result column="turnover" property="turnover" jdbcType="INTEGER" />
     <result column="college_attribute" property="collegeAttribute" jdbcType="VARCHAR" />
     <result column="college_establish_time" property="collegeEstablishTime" jdbcType="VARCHAR" />
     <result column="academician" property="academician" jdbcType="INTEGER" />
@@ -41,7 +41,7 @@
       enterprise_center, other_center, institution_establish_time
       )
     values (#{id,jdbcType=VARCHAR}, #{oid,jdbcType=VARCHAR}, #{qualification,jdbcType=VARCHAR}, 
-      #{turnover,jdbcType=VARCHAR}, #{collegeAttribute,jdbcType=VARCHAR}, #{collegeEstablishTime,jdbcType=VARCHAR}, 
+      #{turnover,jdbcType=INTEGER}, #{collegeAttribute,jdbcType=VARCHAR}, #{collegeEstablishTime,jdbcType=VARCHAR}, 
       #{academician,jdbcType=INTEGER}, #{doctoralTutor,jdbcType=INTEGER}, #{masterTutor,jdbcType=INTEGER}, 
       #{otherExpert,jdbcType=INTEGER}, #{nationalLab,jdbcType=INTEGER}, #{educationLab,jdbcType=INTEGER}, 
       #{enterpriseCenter,jdbcType=INTEGER}, #{otherCenter,jdbcType=INTEGER}, #{institutionEstablishTime,jdbcType=VARCHAR}
@@ -107,7 +107,7 @@
         #{qualification,jdbcType=VARCHAR},
       </if>
       <if test="turnover != null" >
-        #{turnover,jdbcType=VARCHAR},
+        #{turnover,jdbcType=INTEGER},
       </if>
       <if test="collegeAttribute != null" >
         #{collegeAttribute,jdbcType=VARCHAR},
@@ -154,7 +154,7 @@
         qualification = #{qualification,jdbcType=VARCHAR},
       </if>
       <if test="turnover != null" >
-        turnover = #{turnover,jdbcType=VARCHAR},
+        turnover = #{turnover,jdbcType=INTEGER},
       </if>
       <if test="collegeAttribute != null" >
         college_attribute = #{collegeAttribute,jdbcType=VARCHAR},
@@ -196,7 +196,7 @@
     update organization_properties
     set oid = #{oid,jdbcType=VARCHAR},
       qualification = #{qualification,jdbcType=VARCHAR},
-      turnover = #{turnover,jdbcType=VARCHAR},
+      turnover = #{turnover,jdbcType=INTEGER},
       college_attribute = #{collegeAttribute,jdbcType=VARCHAR},
       college_establish_time = #{collegeEstablishTime,jdbcType=VARCHAR},
       academician = #{academician,jdbcType=INTEGER},

+ 13 - 9
src/main/java/com/goafanti/common/model/OrganizationProperties.java

@@ -13,7 +13,7 @@ public class OrganizationProperties {
     /**
     * 年营业额
     */
-    private String turnover;
+    private Integer turnover;
 
     /**
     * 院校属性
@@ -49,7 +49,10 @@ public class OrganizationProperties {
     * 国家重点实验室
     */
     private Integer nationalLab;
-
+    
+    /**
+     * 教育部重点实验室
+     */
     private Integer educationLab;
 
     /**
@@ -91,15 +94,16 @@ public class OrganizationProperties {
         this.qualification = qualification;
     }
 
-    public String getTurnover() {
-        return turnover;
-    }
 
-    public void setTurnover(String turnover) {
-        this.turnover = turnover;
-    }
+    public Integer getTurnover() {
+		return turnover;
+	}
+
+	public void setTurnover(Integer turnover) {
+		this.turnover = turnover;
+	}
 
-    public String getCollegeAttribute() {
+	public String getCollegeAttribute() {
         return collegeAttribute;
     }
 

+ 44 - 27
src/main/java/com/goafanti/core/shiro/token/ShiroToken.java

@@ -1,27 +1,44 @@
-package com.goafanti.core.shiro.token;
-
-import java.io.Serializable;
-
-import org.apache.shiro.authc.UsernamePasswordToken;
-
-public class ShiroToken extends UsernamePasswordToken implements Serializable {
-
-	private static final long serialVersionUID = 4364371216579943671L;
-
-	public ShiroToken(String username, String pwd) {
-		super(username, pwd);
-		this.pwd = pwd;
-	}
-
-	/** 登录密码[字符串类型] 因为父类是char[] ] **/
-	private String pwd;
-
-	public String getPwd() {
-		return pwd;
-	}
-
-	public void setPwd(String pwd) {
-		this.pwd = pwd;
-	}
-
-}
+package com.goafanti.core.shiro.token;
+
+import java.io.Serializable;
+
+import org.apache.shiro.authc.UsernamePasswordToken;
+
+public class ShiroToken extends UsernamePasswordToken implements Serializable {
+
+	private static final long serialVersionUID = 4364371216579943671L;
+
+	public ShiroToken(String username, String pwd, Integer type) {
+		super(username, pwd);
+		this.pwd = pwd;
+		this.type = type;
+	}
+
+	/** 登录密码[字符串类型] 因为父类是char[] ] **/
+	private String pwd;
+	
+	private Integer type;
+
+	public String getPwd() {
+		return pwd;
+	}
+
+	public void setPwd(String pwd) {
+		this.pwd = pwd;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+	
+	
+
+}

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

@@ -93,7 +93,7 @@ public class TokenManager {
 	 * @return
 	 */
 	public static User login(User user, Boolean rememberMe) {
-		ShiroToken token = new ShiroToken(user.getMobile(), user.getPassword());
+		ShiroToken token = new ShiroToken(user.getMobile(), user.getPassword(),user.getType());
 		token.setRememberMe(null == rememberMe ? false : rememberMe);
 		SecurityUtils.getSubject().login(token);
 		return getToken();

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

@@ -1,17 +1,29 @@
 package com.goafanti.core.shiro.token;
 
+import javax.annotation.Resource;
+
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authc.AuthenticationException;
 import org.apache.shiro.authc.AuthenticationInfo;
 import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
 import org.apache.shiro.authc.UnknownAccountException;
 import org.apache.shiro.authz.AuthorizationInfo;
 import org.apache.shiro.realm.AuthorizingRealm;
 import org.apache.shiro.subject.PrincipalCollection;
 import org.apache.shiro.subject.SimplePrincipalCollection;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.goafanti.common.model.User;
+import com.goafanti.common.utils.PasswordUtil;
+import com.goafanti.user.service.UserService;
 
-public class UserRealm extends AuthorizingRealm {
 
+public class UserRealm extends AuthorizingRealm {
+	@Autowired
+    UserService userService;
+	@Resource(name = "passwordUtil")
+	private PasswordUtil passwordUtil;
 	public UserRealm() {
 		super();
 	}
@@ -23,6 +35,11 @@ public class UserRealm extends AuthorizingRealm {
 			throws AuthenticationException {
 
 		ShiroToken token = (ShiroToken) authcToken;
+		 User user = userService.selectByMobieAndType(token.getUsername(),token.getType());
+		 if (null == user){
+			 throw new UnknownAccountException();
+		 }
+		 return new SimpleAuthenticationInfo(user, user.getPassword(), passwordUtil.getSalt(user), getName());
 //		User user = userService.findUserByEmail(token.getUsername());
 //		if (null == user) {
 //			throw new UnknownAccountException();
@@ -36,7 +53,7 @@ public class UserRealm extends AuthorizingRealm {
 //			userService.updateByPrimaryKeySelective(user);
 //		}
 //		return new SimpleAuthenticationInfo(user, user.getPwd(), passwordUtil.getSalt(user), getName());
-		return null;
+		//return null;
 	}
 
 	/**

+ 6 - 2
src/main/java/com/goafanti/user/controller/UserApiController.java

@@ -331,9 +331,12 @@ public class UserApiController extends BaseApiController {
 			 organizationInfoService.updateByPrimaryKeySelective(orgInfo);
 		 }
 		 if(pro == null){
-			 
+			 orgPro.setId(UUID.randomUUID().toString());
+			 orgPro.setOid(orgInfo.getId());
+			 organizationPropertiesService.insert(orgPro);
 		 }else{
-			 
+			 orgPro.setId(pro.getId());
+			 organizationPropertiesService.updateByPrimaryKeySelective(orgPro);
 		 }
 		 res.setData(proBo);
 		return res;
@@ -352,6 +355,7 @@ public class UserApiController extends BaseApiController {
 			orgTech.setId(UUID.randomUUID().toString());
 			orgTech.setUid(TokenManager.getUserId());
 			organizationTechService.insert(orgTech);
+			
 		}else{
 			orgTech.setId(tech.getId());
 			organizationTechService.updateByPrimaryKeySelective(orgTech);

+ 1 - 1
src/main/java/com/goafanti/user/controller/UserLoginController.java

@@ -44,7 +44,7 @@ public class UserLoginController extends BaseController {
 	@ResponseBody
 	public Result signin(User user,Boolean remember, HttpServletRequest request) {
 		Result res = new Result();
-		res.setData(TokenManager.login(user, false));
+		res.setData(TokenManager.login(user, remember));
 		return res;
 	}
 

+ 4 - 0
src/main/java/com/goafanti/user/service/OrganizationPropertiesService.java

@@ -5,5 +5,9 @@ import com.goafanti.common.model.OrganizationProperties;
 public interface OrganizationPropertiesService {
 
 	  OrganizationProperties selectOrgProByUserId(String userId);
+
+	OrganizationProperties insert(OrganizationProperties orgPro);
+
+	int updateByPrimaryKeySelective(OrganizationProperties orgPro);
 	
 }

+ 11 - 0
src/main/java/com/goafanti/user/service/impl/OrganizationPropertiesServiceImpl.java

@@ -15,4 +15,15 @@ public class OrganizationPropertiesServiceImpl implements OrganizationProperties
 	public OrganizationProperties selectOrgProByUserId(String uid) {
 		return organizationPropertiesMapper.selectOrgProByUserId(uid);
 	}
+
+	@Override
+	public OrganizationProperties insert(OrganizationProperties orgPro) {
+		organizationPropertiesMapper.insert(orgPro);
+		return orgPro;
+	}
+
+	@Override
+	public int updateByPrimaryKeySelective(OrganizationProperties orgPro) {
+		return organizationPropertiesMapper.updateByPrimaryKeySelective(orgPro);
+	}
 }