ソースを参照

1、添加、修改用户时新增判断用户角色类型
2、客户信息表新增联系人部门和职位
3、修改新增修改接口,如果是主要联系人,同步到客户信息表

anderx 4 年 前
コミット
7aef4521fa

+ 22 - 0
src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java

@@ -6,6 +6,7 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
 
+import com.goafanti.common.model.Role;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -89,11 +90,31 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 			}
 			TokenManager.clearUserAuthByUserId(ad.getId());
 		}
+		ad.setType(sumType(roleIds));
 		int count=adminMapper.updateByPrimaryKeySelective(ad);
 		List<Admin> Nos =adminMapper.selectIDNBySuperiorId(ad.getId());
 		return count;
 	}
 
+	private int sumType(List<String > roleIds) {
+		int type=0;
+		for (String roleId : roleIds) {
+			Role r=userRoleMapper.selectById(roleId);
+			String rt=r.getRoleType().toString();
+			if (rt.equals(AFTConstants.SALESMAN)||rt.equals(AFTConstants.SALESMAN_MANAGER)||rt.equals(AFTConstants.SALESMAN_ADMIN)){
+				type=1;
+				break;
+			}else if (rt.equals(AFTConstants.FINANCE)||rt.equals(AFTConstants.FINANCE_MANAGER)||rt.equals(AFTConstants.FINANCE_ADMIN)){
+				type=2;
+				break;
+			}else if (rt.equals(AFTConstants.TECH)||rt.equals(AFTConstants.TECH_MANAGER)||rt.equals(AFTConstants.TECH_ADMIN)){
+				type=3;
+				break;
+			}
+		}
+		return type;
+	}
+
 	@Override
 	public int updateByPrimaryKey(Admin a) {
 		return adminMapper.updateByPrimaryKeySelective(a);
@@ -191,6 +212,7 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 	public int insertNewAdmin(Admin ad ,List<String> roleIds) {
 		ad.setStatus("正常");
 		ad.setId(UUID.randomUUID().toString());
+		ad.setType(sumType(roleIds));
 		/*String sdepNo=adminMapper.selectUserNoBySuperiorId(ad.getSuperiorId());
 		int Count=adminMapper.selectCountBySuperiorId(ad.getSuperiorId());
 		if(Count<10){

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

@@ -3,6 +3,7 @@ package com.goafanti.common.dao;
 import java.util.List;
 import java.util.Map;
 
+import com.goafanti.common.model.Role;
 import com.goafanti.common.model.UserRole;
 
 public interface UserRoleMapper {
@@ -16,7 +17,6 @@ public interface UserRoleMapper {
 
 	void deleteByRoleId(List<String> records);
 
-	int deleteByUserRole(Map<String, Object> params);
 
 	int deleteByUserId(String id);
 
@@ -25,4 +25,6 @@ public interface UserRoleMapper {
 	List<String> listAuditor();
 
 	List<UserRole> selectAdminRole(String roleName);
+
+    Role selectById(String roleId);
 }

+ 6 - 4
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -480,7 +480,9 @@
       <if test="openId != null">
         open_id = #{openId},
       </if>
-      
+      <if test="type != null">
+        type = #{type},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -824,13 +826,13 @@
   <insert id="insertn" parameterType="com.goafanti.common.model.Admin">
     insert into admin (id, mobile, name, 
       password, email, create_time, 
-      number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile)
+      number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile,type)
     values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
       #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
       #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
       #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
-      #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR}
-      )
+      #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},
+      #{type})
   </insert>
   <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
   	select 

+ 37 - 14
src/main/java/com/goafanti/common/mapper/OrganizationIdentityMapper.xml

@@ -73,6 +73,8 @@
     <result column="honor_picture" jdbcType="VARCHAR" property="honorPicture" />
     <result column="sales_target" jdbcType="VARCHAR" property="salesTarget" />
     <result column="intended_project" jdbcType="VARCHAR" property="intendedProject" />
+    <result column="contacts_dep" jdbcType="VARCHAR" property="contactsDep" />
+    <result column="contacts_position" jdbcType="VARCHAR" property="contactsPosition" />
   </resultMap>
   <sql id="Base_Column_List">
     id, `uid`, contacts, contact_mobile, fixed_tel, qq, postal_address, postcode, unit_name, 
@@ -86,7 +88,8 @@
     enterprise_scale, register_type, foreign_investment, field, tax_authority, ratepay_method, 
     high_tech_zone, risk_investment, business_scope, high_tech_name, patent_prory_statement_url, 
     international, review_instructions, investment, year_sales_amount, last_year_research_amount, 
-    assets, qualification, cooperation_situation, honor_picture, sales_target, intended_project
+    assets, qualification, cooperation_situation, honor_picture, sales_target, intended_project, 
+    contacts_dep, contacts_position
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select 
@@ -99,7 +102,7 @@
     where id = #{id,jdbcType=VARCHAR}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.OrganizationIdentity" useGeneratedKeys="true">
-    insert into organization_identity (id,`uid`, contacts, contact_mobile,
+    insert into organization_identity (`uid`, contacts, contact_mobile, 
       fixed_tel, qq, postal_address, 
       postcode, unit_name, registered_capital, 
       licence_number, licence_province, licence_city, 
@@ -122,9 +125,9 @@
       international, review_instructions, investment, 
       year_sales_amount, last_year_research_amount, 
       assets, qualification, cooperation_situation, 
-      honor_picture, sales_target, intended_project
-      )
-    values (#{id,jdbcType=VARCHAR},#{uid,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
+      honor_picture, sales_target, intended_project, 
+      contacts_dep, contacts_position)
+    values (#{uid,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR}, 
       #{fixedTel,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{postalAddress,jdbcType=VARCHAR}, 
       #{postcode,jdbcType=VARCHAR}, #{unitName,jdbcType=VARCHAR}, #{registeredCapital,jdbcType=DECIMAL}, 
       #{licenceNumber,jdbcType=VARCHAR}, #{licenceProvince,jdbcType=INTEGER}, #{licenceCity,jdbcType=INTEGER}, 
@@ -147,15 +150,12 @@
       #{international,jdbcType=INTEGER}, #{reviewInstructions,jdbcType=VARCHAR}, #{investment,jdbcType=INTEGER}, 
       #{yearSalesAmount,jdbcType=DECIMAL}, #{lastYearResearchAmount,jdbcType=DECIMAL}, 
       #{assets,jdbcType=DECIMAL}, #{qualification,jdbcType=VARCHAR}, #{cooperationSituation,jdbcType=VARCHAR}, 
-      #{honorPicture,jdbcType=VARCHAR}, #{salesTarget,jdbcType=VARCHAR}, #{intendedProject,jdbcType=VARCHAR}
-      )
+      #{honorPicture,jdbcType=VARCHAR}, #{salesTarget,jdbcType=VARCHAR}, #{intendedProject,jdbcType=VARCHAR}, 
+      #{contactsDep,jdbcType=VARCHAR}, #{contactsPosition,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.OrganizationIdentity" useGeneratedKeys="true">
     insert into organization_identity
     <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        `id`,
-      </if>
       <if test="uid != null">
         `uid`,
       </if>
@@ -366,11 +366,14 @@
       <if test="intendedProject != null">
         intended_project,
       </if>
+      <if test="contactsDep != null">
+        contacts_dep,
+      </if>
+      <if test="contactsPosition != null">
+        contacts_position,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=VARCHAR},
-      </if>
       <if test="uid != null">
         #{uid,jdbcType=VARCHAR},
       </if>
@@ -581,6 +584,12 @@
       <if test="intendedProject != null">
         #{intendedProject,jdbcType=VARCHAR},
       </if>
+      <if test="contactsDep != null">
+        #{contactsDep,jdbcType=VARCHAR},
+      </if>
+      <if test="contactsPosition != null">
+        #{contactsPosition,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrganizationIdentity">
@@ -796,6 +805,12 @@
       <if test="intendedProject != null">
         intended_project = #{intendedProject,jdbcType=VARCHAR},
       </if>
+      <if test="contactsDep != null">
+        contacts_dep = #{contactsDep,jdbcType=VARCHAR},
+      </if>
+      <if test="contactsPosition != null">
+        contacts_position = #{contactsPosition,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -870,7 +885,9 @@
       cooperation_situation = #{cooperationSituation,jdbcType=VARCHAR},
       honor_picture = #{honorPicture,jdbcType=VARCHAR},
       sales_target = #{salesTarget,jdbcType=VARCHAR},
-      intended_project = #{intendedProject,jdbcType=VARCHAR}
+      intended_project = #{intendedProject,jdbcType=VARCHAR},
+      contacts_dep = #{contactsDep,jdbcType=VARCHAR},
+      contacts_position = #{contactsPosition,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
 	<select id="selectOrgIdentityByUserId" parameterType="java.lang.String" resultMap="BaseResultMap">
@@ -1302,6 +1319,12 @@
       <if test="intendedProject != null">
         intended_project = #{intendedProject,jdbcType=VARCHAR},
       </if>
+      <if test="contactsDep != null">
+        contacts_dep = #{contactsDep,jdbcType=VARCHAR},
+      </if>
+      <if test="contactsPosition != null">
+        contacts_position = #{contactsPosition,jdbcType=VARCHAR},
+      </if>
     </set>
     where uid = #{uid,jdbcType=VARCHAR}
   </update>

+ 4 - 0
src/main/java/com/goafanti/common/mapper/UserRoleMapper.xml

@@ -74,4 +74,8 @@
 	left join role b on a.rid=b.id
 	where b.role_name=#{roleName,jdbcType=VARCHAR}
   </select>
+    <select id="selectById" resultType="com.goafanti.common.model.Role">
+      select id,role_name roleName,role_type roleType
+      from `role` where id = #{roleId}
+    </select>
 </mapper>

+ 10 - 1
src/main/java/com/goafanti/common/model/Admin.java

@@ -96,6 +96,15 @@ public class Admin extends BaseModel implements AftUser {
 	private String	openId;
 
 	/**
+	 * �?在市
+	 */
+	private Integer				type;
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column admin.contact_mobile
 	 * @mbg.generated  Wed Jun 13 10:27:07 CST 2018
 	 */
@@ -295,7 +304,7 @@ public class Admin extends BaseModel implements AftUser {
 
 	@Override
 	public Integer getType() {
-		return null;
+		return this.type;
 	}
 
 	public Date getLastLoginTime() {

+ 26 - 0
src/main/java/com/goafanti/common/model/OrganizationIdentity.java

@@ -358,6 +358,16 @@ public class OrganizationIdentity implements Serializable {
      */
     private String intendedProject;
 
+    /**
+     * 联系人部门
+     */
+    private String contactsDep;
+
+    /**
+     * 联系人职位
+     */
+    private String contactsPosition;
+
     private static final long serialVersionUID = 1L;
 
     public String getId() {
@@ -927,4 +937,20 @@ public class OrganizationIdentity implements Serializable {
     public void setIntendedProject(String intendedProject) {
         this.intendedProject = intendedProject;
     }
+
+    public String getContactsDep() {
+        return contactsDep;
+    }
+
+    public void setContactsDep(String contactsDep) {
+        this.contactsDep = contactsDep;
+    }
+
+    public String getContactsPosition() {
+        return contactsPosition;
+    }
+
+    public void setContactsPosition(String contactsPosition) {
+        this.contactsPosition = contactsPosition;
+    }
 }

+ 9 - 0
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -353,6 +353,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			oi.setUid(uid);
 			oi.setContacts(in.getContacts());
 			oi.setContactMobile(in.getContactMobile());
+			oi.setContactsPosition(in.getPosition());
 			oi.setLocationProvince(in.getProvince());
 			oi.setLocationCity(in.getCity());
 			oi.setLocationArea(in.getArea());
@@ -1549,6 +1550,14 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		ocb.setMajor(AFTConstants.NO);
 		Admin ad = adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
 		ocb.setAname(ad.getName());
+		if (ocb.getMajor()==1){
+			OrganizationIdentity n=new OrganizationIdentity();
+			n.setUid(ocb.getUid());
+			n.setContacts(ocb.getName());
+			n.setContactsDep(ocb.getDepartment());
+			n.setContactsPosition(ocb.getPosition());
+			organizationIdentityMapper.updateServiceByUid(n);
+		}
 		return organizationContactBookMapper.insert(ocb);
 	}
 

+ 1 - 1
src/main/java/com/goafanti/permission/service/impl/NewRoleServiceImpl.java

@@ -156,7 +156,7 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 		params.put("rid", roleId);
 		params.put("uid", userId);
 		TokenManager.clearUserAuthByUserId(new String[] { userId });
-		return userRoleMapper.deleteByUserRole(params);
+		return 0;
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/goafanti/permission/service/impl/RoleServiceImpl.java

@@ -111,7 +111,7 @@ public class RoleServiceImpl extends BaseMybatisDao<RoleMapper> implements RoleS
 		params.put("rid", roleId);
 		params.put("uid", userId);
 		TokenManager.clearUserAuthByUserId(new String[] { userId });
-		return userRoleMapper.deleteByUserRole(params);
+		return 0;
 	}
 
 	@Override