zouxuan 5 tahun lalu
induk
melakukan
3188edfb80

+ 2 - 2
edu-auth/edu-auth-server/src/main/resources/config/mybatis/SysUserMapper.xml

@@ -165,11 +165,11 @@
     </select>
 
     <select id="queryByUsername" resultMap="SysUser">
-		select * from sys_user where username_ = #{username} OR phone_ = #{username} LIMIT 1 FOR UPDATE
+		select * from sys_user where real_name_ = #{username} OR phone_ = #{username} LIMIT 1 FOR UPDATE
 	</select>
 
     <select id="queryByPhone" resultMap="SysUser">
-		select * from sys_user where phone_ = #{phone} OR username_ = #{phone} LIMIT 1 FOR UPDATE
+		select * from sys_user where phone_ = #{phone} OR real_name_ = #{phone} LIMIT 1 FOR UPDATE
 	</select>
     
     <select id="queryByStatus" resultMap="SysUser">

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/OrganizationController.java

@@ -59,7 +59,7 @@ public class OrganizationController extends BaseController {
 	@GetMapping(value = "get")
     @PreAuthorize("@pcs.hasPermissions('organization/get')")
 	public HttpResponseResult<Organization> getConfig(Integer id) {
-		return succeed(organizationService.get(id));
+		return succeed(organizationService.getOrganization(id));
 	}
 
 	@ApiOperation(value = "删除合作单位")

+ 4 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/OrganizationService.java

@@ -1,8 +1,10 @@
 package com.keao.edu.user.service;
 
 
+import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.entity.Organization;
+import com.keao.edu.user.page.OrganizationQueryInfo;
 
 import java.util.List;
 
@@ -54,4 +56,6 @@ public interface OrganizationService extends BaseService<Integer, Organization>
      * @param id
      */
     void del(Integer id);
+
+    Organization getOrganization(Integer id);
 }

+ 10 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/OrganizationServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 
 @Service
 public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organization> implements OrganizationService {
@@ -248,4 +249,13 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 			throw new BizException("删除失败:存在考试项目,无法删除");
 		}
 	}
+
+	@Override
+	public Organization getOrganization(Integer id) {
+		Organization organization = organDao.get(id);
+		SysUser sysUser = organization.getSysUser();
+		Set<Integer> roleIds = sysUserDao.queryRoleIds(organization.getUserId());
+		sysUser.setRoles(roleIds);
+		return organization;
+	}
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/StudentServiceImpl.java

@@ -111,7 +111,7 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         if (rows != null && rows.size() > 0) {
             List<Integer> studentIds = rows.stream().map(e -> e.getUserId()).collect(Collectors.toList());
             //获取考试次数
-            Map<Integer, Integer> examNumMap = MapUtil.convertIntegerMap(studentExamResultDao.countExamNum(studentIds, queryInfo.getTenantId()),Integer.class,Integer.class);
+            Map<Integer, Integer> examNumMap = MapUtil.convertMybatisMap(studentExamResultDao.countExamNum(studentIds, queryInfo.getTenantId()),Integer.class,Integer.class);
             rows.forEach(e -> {
                 e.setExamNum(examNumMap.get(e.getUserId()));
             });

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/TeacherServiceImpl.java

@@ -132,7 +132,7 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher> implem
 			params.put("offset", pageInfo.getOffset());
 			dataList = this.getDAO().queryPage(params);
 			Set<Integer> teacherIds = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
-			Map<Integer,String> subjectNames = MapUtil.convertIntegerMap(teacherDao.queryTeacherSubjectNames(teacherIds),Integer.class,String.class);
+			Map<Integer,String> subjectNames = MapUtil.convertMybatisMap(teacherDao.queryTeacherSubjectNames(teacherIds),Integer.class,String.class);
 			dataList.forEach(e->{
 				e.setSubjectName(subjectNames.get(e.getUserId()));
 			});

+ 14 - 7
edu-user/edu-user-server/src/main/resources/config/mybatis/OrganizationMapper.xml

@@ -7,7 +7,7 @@
 <mapper namespace="com.keao.edu.user.dao.OrganizationDao">
 	
 	<resultMap type="com.keao.edu.user.entity.Organization" id="Organization">
-		<result column="id_" property="id" />
+		<result column="organization_id_" property="id" />
 		<result column="user_id_" property="userId" />
 		<result column="name_" property="name" />
 		<result column="contact_name_" property="contactName" />
@@ -24,17 +24,24 @@
 		<result column="tenant_id_" property="tenantId" />
 		<association property="sysUser" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
 	</resultMap>
+	<sql id="organizationColumn">
+		o.id_ organization_id_, o.user_id_, o.name_, o.contact_name_, o.contact_phone_,
+		o.settlement_type_, o.share_profit_amount_, o.level_, o.parent_organ_id_,
+		o.parent_organ_id_tag_, o.is_allow_arrange_exam_, o.create_time_,
+		o.update_time_, o.del_flag_, o.tenant_id_
+	</sql>
 	
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="Organization" >
-		SELECT * FROM organization o
+		SELECT <include refid="organizationColumn"/>,su.*
+		FROM organization o
 		LEFT JOIN sys_user su ON o.user_id_ = su.id_
 		WHERE o.id_ = #{id} LIMIT 1
 	</select>
 	
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="Organization">
-		SELECT * FROM organization WHERE tenant_id_ = #{tenantId} ORDER BY id_
+		SELECT <include refid="organizationColumn"/> FROM organization o WHERE tenant_id_ = #{tenantId} ORDER BY id_
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
@@ -112,7 +119,7 @@
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="Organization" parameterType="map">
-		SELECT * FROM organization
+		SELECT <include refid="organizationColumn"/> FROM organization o
 		<include refid="organQueryPage"/>
 		ORDER BY update_time_ DESC <include refid="global.limit"/>
 	</select>
@@ -124,7 +131,7 @@
 	</select>
 
 	<select id="getByTenant" resultMap="Organization">
-		SELECT * FROM organization WHERE tenant_id_ = #{tenantId} ORDER BY id_
+		SELECT <include refid="organizationColumn"/> FROM organization o WHERE tenant_id_ = #{tenantId} ORDER BY id_
 	</select>
 
 	<select id="getChildOrganIds" resultType="int">
@@ -132,14 +139,14 @@
 	</select>
 
 	<select id="getChildOrgans" resultMap="Organization">
-		SELECT * FROM organization WHERE parent_organ_id_tag_ LIKE CONCAT(#{parentOrganIdTag}, '%');
+		SELECT <include refid="organizationColumn"/> FROM organization o WHERE parent_organ_id_tag_ LIKE CONCAT(#{parentOrganIdTag}, '%');
 	</select>
 
 	<select id="getNextLevelOrganIds" resultType="int">
 		SELECT id_ FROM organization WHERE parent_organ_id_ =#{organId};
 	</select>
     <select id="getOrgans" resultMap="Organization">
-		SELECT * FROM organization WHERE id_ IN
+		SELECT <include refid="organizationColumn"/> FROM organization o WHERE id_ IN
 		<foreach collection="organIds" item="organId" separator="," open="(" close=")">
 			#{organId}
 		</foreach>

+ 14 - 10
edu-util/src/main/java/com/keao/edu/util/collection/MapUtil.java

@@ -1,5 +1,7 @@
 package com.keao.edu.util.collection;
 
+import org.apache.commons.lang3.StringUtils;
+
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
@@ -10,11 +12,8 @@ import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Objects;
 
-import org.apache.commons.lang3.StringUtils;
-
 public class MapUtil {
 
 	private static final Object[] EMPTY_ARRAY = {};
@@ -113,20 +112,25 @@ public class MapUtil {
 	 * @return java.util.Map
 	 * @describe mybatis返回结果转换为Map
 	 */
-	public static <T,K> Map convertMybatisMap(List<Map<T,K>> maps){
+	/*public static <T,K> Map convertMybatisMap(List<Map<T,K>> maps){
 		int size = 0;
 		if(maps != null){
 			size = maps.size();
 		}
-		Map result=new HashMap(size);
-		maps.forEach(stringIntegerMap -> {
+		Map<T,K> result = new HashMap(size);
+		for (Map<T, K> map : maps) {
+			if(map.get("value") != null){
+				result.put((T) (map.get("key").toString()),(K) (map.get("value").toString()));
+			}
+		}
+		*//*maps.forEach(stringIntegerMap -> {
 			if(Objects.isNull(stringIntegerMap)){
 				return;
 			}
-			result.put(stringIntegerMap.get("key"),stringIntegerMap.get("value").toString());
-		});
+			result.put(stringIntegerMap.get("key"),stringIntegerMap.get("value"));
+		});*//*
 		return result;
-	}
+	}*/
 
 	/**
 	 * @param <K>
@@ -136,7 +140,7 @@ public class MapUtil {
 	 * @return java.util.Map
 	 * @describe mybatis返回结果转换为Map
 	 */
-	public static <K, V> Map<K, V> convertIntegerMap(List<Map<K, V>> maps,Class keyType,Class valueType) {
+	public static <K, V> Map<K, V> convertMybatisMap(List<Map<K, V>> maps,Class keyType,Class valueType) {
 		int size = 0;
 		if(maps != null){
 			size = maps.size();