zouxuan 5 年之前
父节点
当前提交
6025a9920e
共有 23 个文件被更改,包括 288 次插入77 次删除
  1. 1 12
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRole.java
  2. 2 1
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleMenuDao.java
  3. 1 1
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleServiceImpl.java
  4. 10 19
      edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/RoleController.java
  5. 3 9
      edu-auth/edu-auth-server/src/main/resources/config/mybatis/SysRoleMapper.xml
  6. 14 12
      edu-auth/edu-auth-server/src/main/resources/config/mybatis/SysUserMapper.xml
  7. 12 0
      edu-common/src/main/java/com/keao/edu/common/service/BaseService.java
  8. 66 5
      edu-common/src/main/java/com/keao/edu/common/service/impl/BaseServiceImpl.java
  9. 2 0
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/SealClassApplication.java
  10. 2 2
      edu-im/edu-im-server/src/main/resources/application.yml
  11. 9 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamCertificationController.java
  12. 1 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/OrganizationController.java
  13. 2 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/SubjectController.java
  14. 7 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamOrganizationRelationDao.java
  15. 40 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/ExamCertificationDto.java
  16. 29 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/ExamCertificationQueryInfo.java
  17. 11 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamCertificationService.java
  18. 6 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/OrganizationService.java
  19. 45 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamCertificationServiceImpl.java
  20. 14 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/OrganizationServiceImpl.java
  21. 7 11
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamCertificationMapper.xml
  22. 3 0
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamOrganizationRelationMapper.xml
  23. 1 0
      edu-zuul/src/main/java/com/keao/edu/zuul/web/config/SwaggerDocumentConfig.java

+ 1 - 12
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysRole.java

@@ -1,11 +1,10 @@
 package com.keao.edu.auth.api.entity;
 
 import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.util.List;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
 /**
  * 对应数据库表(sys_role):
  */
@@ -37,8 +36,6 @@ public class SysRole {
 	/** 删除标识(0-正常,1-删除) */
 	@ApiModelProperty(value = "删除标识(0-正常,1-删除)",required = false)
 	private String delFlag;
-	
-	private Integer organId;
 
 	@ApiModelProperty(value = "菜单列表",required = false)
 	private List<Integer> menuIds;
@@ -114,14 +111,6 @@ public class SysRole {
 	public String getDelFlag(){
 		return this.delFlag;
 	}
-			
-	public Integer getOrganId() {
-		return organId;
-	}
-
-	public void setOrganId(Integer organId) {
-		this.organId = organId;
-	}
 
 	@Override
 	public String toString() {

+ 2 - 1
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/dal/dao/SysRoleMenuDao.java

@@ -40,6 +40,7 @@ public interface SysRoleMenuDao extends BaseDAO<Integer, SysRoleMenu> {
 	 * 批量插入角色菜单
 	 * @param roleId
 	 * @param menuIds
+	 * @param tenantId
 	 */
-    void batchAdd(@Param("roleId") Integer roleId,@Param("menuIds")  List<Integer> menuIds);
+    void batchAdd(@Param("roleId") Integer roleId,@Param("menuIds")  List<Integer> menuIds,@Param("tenantId") String tenantId);
 }

+ 1 - 1
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysRoleServiceImpl.java

@@ -71,7 +71,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<Integer, SysRole>  imple
 		List<Integer> menuIds = sysRole.getMenuIds();
 		if(menuIds != null && menuIds.size() > 0){
 //			SysRoleMenu sysRoleMenu = new SysRoleMenu(sysRole.getId(),null);
-			sysRoleMenuDao.batchAdd(sysRole.getId(),menuIds);
+			sysRoleMenuDao.batchAdd(sysRole.getId(),menuIds,sysRole.getTenantId());
 //			menuIds.forEach(e->{
 //				sysRoleMenu.setMenuId(e);
 //				sysRoleMenuDao.insert(sysRoleMenu);

+ 10 - 19
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/web/controller/RoleController.java

@@ -1,24 +1,5 @@
 package com.keao.edu.auth.web.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-
-import java.util.Date;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.keao.edu.auth.api.entity.SysRole;
 import com.keao.edu.auth.api.util.SecurityConstants;
 import com.keao.edu.auth.service.SysMenuService;
@@ -27,6 +8,15 @@ import com.keao.edu.auth.service.SysRoleService;
 import com.keao.edu.auth.service.SysUserRoleService;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.common.tenant.TenantContextHolder;
+import io.swagger.annotations.*;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
 
 @RestController()
 @RequestMapping("role")
@@ -76,6 +66,7 @@ public class RoleController extends BaseController {
 	@PostMapping(value = "/add")
     @PreAuthorize("@pcs.hasPermissions('role/add')")
 	public Object addRole(@RequestBody SysRole sysRole) {
+		sysRole.setTenantId(TenantContextHolder.getTenantId().toString());
 		sysRoleService.addRole(sysRole);
 		return succeed();
 	}

+ 3 - 9
edu-auth/edu-auth-server/src/main/resources/config/mybatis/SysRoleMapper.xml

@@ -14,7 +14,6 @@
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
         <result column="del_flag_" property="delFlag"/>
-        <result column="organ_id_" property="organId"/>
         <result column="tenant_id_" property="tenantId"/>
     </resultMap>
 
@@ -31,8 +30,8 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.keao.edu.auth.api.entity.SysRole" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
-        INSERT INTO sys_role (id_,role_name_,role_code_,role_desc_,create_time_,update_time_,organ_id_,tenant_id_)
-        VALUES(#{id},#{roleName},#{roleCode},#{roleDesc},now(),now(),#{organId},#{tenantId})
+        INSERT INTO sys_role (id_,role_name_,role_code_,role_desc_,create_time_,update_time_,tenant_id_)
+        VALUES(#{id},#{roleName},#{roleCode},#{roleDesc},now(),now(),#{tenantId})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -51,15 +50,10 @@
             <if test="roleDesc != null">
                 role_desc_ = #{roleDesc},
             </if>
-            <if test="updateTime != null">
-                update_time_ = NOW(),
-            </if>
-            <if test="organId != null">
-                organ_id_ = #{organId},
-            </if>
             <if test="tenantId != null">
                 tenant_id_ = #{tenantId},
             </if>
+            update_time_ = NOW()
         </set>
         WHERE id_ = #{id}
     </update>

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

@@ -34,16 +34,18 @@
 
     <!-- 查询条件 -->
     <sql id="queryCondition">
-        tenant_id_ = #{tenantId}
-        <if test="userStartDate != null">
-            and create_time_ &gt;= #{createStartDate}
-        </if>
-        <if test="userEndDate != null">
-            and create_time_ &lt;= #{createEndDate}
-        </if>
-        <if test="userType != null">
-            and user_type_ = #{userType}
-        </if>
+        <where>
+            tenant_id_ = #{tenantId}
+            <if test="userStartDate != null">
+                AND create_time_ &gt;= #{createStartDate}
+            </if>
+            <if test="userEndDate != null">
+                AND create_time_ &lt;= #{createEndDate}
+            </if>
+            <if test="userType != null">
+                AND user_type_ = #{userType}
+            </if>
+        </where>
     </sql>
 
     <!-- 根据主键查询一条记录 -->
@@ -150,9 +152,9 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="SysUser" parameterType="map">
-        SELECT * FROM sys_user ORDER BY id_
+        SELECT * FROM sys_user
         <include refid="queryCondition"/>
-        <include refid="global.orderby"/>
+        ORDER BY update_time_ DESC
         <include refid="global.limit"/>
     </select>
 

+ 12 - 0
edu-common/src/main/java/com/keao/edu/common/service/BaseService.java

@@ -8,6 +8,7 @@ package com.keao.edu.common.service;
  * @create 2015年7月13日
  */
 import java.io.Serializable;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -88,6 +89,17 @@ public interface BaseService<PK extends Serializable, T> {
 	 * @date 2020.06.23
 	 * @param columnKey: key所对应的列名
 	 * @param columnValue: value所对应的列名
+	 * @param paramMap: 查询条件
+	 * @return java.util.List<java.util.Map>
+	 */
+	<K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, Map<String,Object> paramMap, Class<Y> keyType, Class<Z> valueType);
+
+	/**
+	 * @describe 获取columnKey-columnValue集合
+	 * @author Joburgess
+	 * @date 2020.06.23
+	 * @param columnKey: key所对应的列名
+	 * @param columnValue: value所对应的列名
 	 * @param ids: key条件
 	 * @return java.util.List<java.util.Map>
 	 */

+ 66 - 5
edu-common/src/main/java/com/keao/edu/common/service/impl/BaseServiceImpl.java

@@ -7,26 +7,26 @@ package com.keao.edu.common.service.impl;
  * @author pengdc
  * @create 2015年7月13日
  */
+
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.ibatis.io.Resources;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 
 import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.ParameterizedType;
 import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * SERVICE操作基类
@@ -164,6 +164,67 @@ public abstract class BaseServiceImpl<PK extends Serializable, T> implements Bas
 	}
 
 	@Override
+	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, Map<String,Object> paramMap, Class<Y> keyType, Class<Z> valueType){
+		StringBuffer sql=new StringBuffer();
+		Map<Y,Z> result = new HashMap();
+		try {
+			Connection connection = sqlSessionFactory.openSession().getConnection();
+			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ");
+			boolean resultFlag = false;
+			for (Map.Entry<String, Object> entry : paramMap.entrySet()) {
+				if(entry.getValue() instanceof List){
+					List entryValue = (List) entry.getValue();
+					if(!CollectionUtils.isEmpty(entryValue)){
+						sql.append(entry.getKey()).append(" IN (").append(StringUtils.join(entryValue, ",")).append(") AND ");
+						resultFlag = true;
+					}
+				}else {
+					sql.append(entry.getKey()).append(" = ").append(entry.getValue()).append(" AND ");
+					resultFlag = true;
+				}
+			}
+			if (!resultFlag){
+				return result;
+			}
+			sql.append(" 1 = 1 GROUP BY ").append(columnKey);
+			PreparedStatement ps = connection.prepareStatement(sql.toString());
+			ResultSet resultSet = ps.executeQuery();
+			while (resultSet.next()){
+				Y key;
+				Z value;
+				if(keyType.isAssignableFrom(BigDecimal.class)){
+					key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
+				}else if(keyType.isAssignableFrom(String.class)){
+					key = (Y) resultSet.getString(1);
+				}else{
+					key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
+				}
+				if(valueType.isAssignableFrom(BigDecimal.class)){
+					value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
+				}else if(valueType.isAssignableFrom(String.class)){
+					value = (Z) resultSet.getString(2);
+				}else{
+					value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
+				}
+				result.put(key, value);
+			}
+			if(resultSet!=null){
+				resultSet.close();
+			}
+			if(ps!=null){
+				ps.close();
+			}
+			if(connection!=null){
+				connection.close();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		return result;
+	}
+
+	@Override
 	public <K extends List> Map<String, String> getMap(String tableName, String columnKey, String columnValue, K ids) {
 		StringBuffer sql=new StringBuffer();
 		Map<String, String> result=new HashMap();

+ 2 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/SealClassApplication.java

@@ -1,5 +1,6 @@
 package com.keao.edu.im;
 
+import com.spring4all.swagger.EnableSwagger2Doc;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@@ -20,6 +21,7 @@ import org.springframework.web.client.RestTemplate;
 @EnableScheduling
 @EnableDiscoveryClient
 @Configuration
+@EnableSwagger2Doc
 @EnableAsync
 public class SealClassApplication {
 

+ 2 - 2
edu-im/edu-im-server/src/main/resources/application.yml

@@ -95,8 +95,8 @@ cn:
       secret: ay9pL#$Ws8Lpapo
       ttlInMilliSec: -1
     im:
-      appkey: c9kqb3rdc451j
-      secret: gnskN9VRnbm
+      appkey: 8luwapkv84g3l
+      secret: 7s6m56VCL6Pi
       host: http://api-cn.ronghub.com
     whiteboard:
       host: https://sealclass.rongcloud.cn/ewb

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

@@ -4,8 +4,10 @@ import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.user.dto.ExamCertificationDto;
 import com.keao.edu.user.entity.ExamCertification;
 import com.keao.edu.user.entity.ExamLocation;
+import com.keao.edu.user.page.ExamCertificationQueryInfo;
 import com.keao.edu.user.service.ExamCertificationService;
 import com.keao.edu.user.service.ExamLocationService;
 import io.swagger.annotations.Api;
@@ -24,9 +26,15 @@ public class ExamCertificationController extends BaseController {
     @Autowired
     private ExamCertificationService examCertificationService;
 
-    @ApiOperation("分页查询")
+    @ApiOperation("获取学员准考证详情")
     @GetMapping(value = "findByStuAndBasicId")
     public HttpResponseResult<ExamCertification> findByStuAndBasicId(Integer studentId,Integer basicId) {
         return succeed(examCertificationService.findByStuAndBasicId(studentId,basicId));
     }
+
+    @ApiOperation("获取学员准考证列表")
+    @GetMapping(value = "queryCertificationPage")
+    public HttpResponseResult<PageInfo<ExamCertificationDto>> queryCertificationPage(ExamCertificationQueryInfo queryInfo) {
+        return succeed(examCertificationService.queryCertificationPage(queryInfo));
+    }
 }

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

@@ -66,7 +66,7 @@ public class OrganizationController extends BaseController {
 	@PostMapping(value = "del")
     @PreAuthorize("@pcs.hasPermissions('organization/del')")
 	public HttpResponseResult del(Integer id) {
-		organizationService.delete(id);
+		organizationService.del(id);
 		return succeed();
 	}
 

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/SubjectController.java

@@ -58,7 +58,7 @@ public class SubjectController extends BaseController {
     @ApiOperation(value = "获取子集科目列表")
     @GetMapping("/findSubSubjects")
     @PreAuthorize("@pcs.hasPermissions('subject/findSubSubjects')")
-    public HttpResponseResult<List<Subject>> findSubSubjects(Integer tenantId){
-        return succeed(subjectService.findSubSubjects(tenantId));
+    public HttpResponseResult<List<Subject>> findSubSubjects(){
+        return succeed(subjectService.findSubSubjects(Integer.parseInt(TenantContextHolder.getTenantId().toString())));
     }
 }

+ 7 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamOrganizationRelationDao.java

@@ -72,5 +72,11 @@ public interface ExamOrganizationRelationDao extends BaseDAO<Long, ExamOrganizat
      */
     List<ExamOrganizationRelation> countExamOrganStudentAndPayment(@Param("examId") Integer examId,
                                                                        @Param("organIds") List<Integer> organIds);
-	
+
+    /**
+     * 是否有考试项目
+     * @param organId
+     * @return
+     */
+    Integer findByOrganId(@Param("organId") Integer organId);
 }

+ 40 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/ExamCertificationDto.java

@@ -0,0 +1,40 @@
+package com.keao.edu.user.dto;
+
+import com.keao.edu.user.entity.ExamCertification;
+import io.swagger.annotations.ApiModelProperty;
+
+public class ExamCertificationDto extends ExamCertification {
+
+    @ApiModelProperty(value = "考试项目")
+    private String examBaseName;
+
+    @ApiModelProperty(value = "科目名称")
+    private String subjectName;
+
+    @ApiModelProperty(value = "是否考试")
+    private Integer finishedExam;
+
+    public String getExamBaseName() {
+        return examBaseName;
+    }
+
+    public void setExamBaseName(String examBaseName) {
+        this.examBaseName = examBaseName;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public Integer isFinishedExam() {
+        return finishedExam;
+    }
+
+    public void setFinishedExam(Integer finishedExam) {
+        this.finishedExam = finishedExam;
+    }
+}

+ 29 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/ExamCertificationQueryInfo.java

@@ -0,0 +1,29 @@
+package com.keao.edu.user.page;
+
+import com.keao.edu.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+public class ExamCertificationQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "学员编号",required = false)
+    private Integer studentId;
+
+    @ApiModelProperty(value = "考试编号",required = false)
+    private Integer basicId;
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+
+    public Integer getBasicId() {
+        return basicId;
+    }
+
+    public void setBasicId(Integer basicId) {
+        this.basicId = basicId;
+    }
+}

+ 11 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamCertificationService.java

@@ -1,8 +1,12 @@
 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.dto.ExamCertificationDto;
 import com.keao.edu.user.entity.ExamCertification;
+import com.keao.edu.user.page.ExamCertificationQueryInfo;
+import org.springframework.data.domain.Page;
 
 public interface ExamCertificationService extends BaseService<Long, ExamCertification> {
 
@@ -13,4 +17,11 @@ public interface ExamCertificationService extends BaseService<Long, ExamCertific
      * @return
      */
     ExamCertification findByStuAndBasicId(Integer studentId, Integer basicId);
+
+    /**
+     * 获取学员的准考证列表
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<ExamCertificationDto> queryCertificationPage(ExamCertificationQueryInfo queryInfo);
 }

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

@@ -48,4 +48,10 @@ public interface OrganizationService extends BaseService<Integer, Organization>
      * @return java.util.List<java.lang.Integer>
      */
     List<Integer> getNextLevelOrganIds(Integer organId, boolean includeSelf);
+
+    /**
+     * 删除
+     * @param id
+     */
+    void del(Integer id);
 }

+ 45 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamCertificationServiceImpl.java

@@ -1,14 +1,25 @@
 package com.keao.edu.user.service.impl;
 
 
+import com.alibaba.fastjson.JSON;
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.user.dao.ExamCertificationDao;
+import com.keao.edu.user.dto.ExamCertificationDto;
 import com.keao.edu.user.entity.ExamCertification;
+import com.keao.edu.user.page.ExamCertificationQueryInfo;
 import com.keao.edu.user.service.ExamCertificationService;
+import com.keao.edu.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 @Service
 public class ExamCertificationServiceImpl extends BaseServiceImpl<Long, ExamCertification> implements ExamCertificationService {
 	
@@ -24,4 +35,38 @@ public class ExamCertificationServiceImpl extends BaseServiceImpl<Long, ExamCert
 	public ExamCertification findByStuAndBasicId(Integer studentId, Integer basicId) {
 		return examCertificationDao.findByStuAndBasicId(studentId,basicId);
 	}
+
+	@Override
+	public PageInfo<ExamCertificationDto> queryCertificationPage(ExamCertificationQueryInfo queryInfo) {
+		PageInfo<ExamCertificationDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<ExamCertificationDto> dataList = null;
+		int count = this.findCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = JSON.parseArray(JSON.toJSONString(this.getDAO().queryPage(params)),ExamCertificationDto.class);
+			List<Integer> basicIds = dataList.stream().map(e -> e.getExaminationBasicId()).collect(Collectors.toList());
+			List<Integer> studentIds = dataList.stream().map(e -> e.getStudentId()).collect(Collectors.toList());
+			List<Integer> subjectIds = dataList.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
+			Map<Integer, String> basicNameMap = this.getMap("examination_basic", "id_", "name_", basicIds, Integer.class, String.class);
+			Map<Integer, String> subjectNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class);
+			Map<String, Object> paramMap = new HashMap<>();
+			paramMap.put("examination_basic_id_",basicIds);
+			paramMap.put("student_id_",studentIds);
+			Map<Integer, Integer> finishedExamMap = this.getMap("student_exam_result", "examination_basic_id_", "is_finished_exam_", paramMap, Integer.class, Integer.class);
+			dataList.forEach(e->{
+				e.setSubjectName(subjectNameMap.get(e.getSubjectId()));
+				e.setExamBaseName(basicNameMap.get(e.getExaminationBasicId()));
+				e.setFinishedExam(finishedExamMap.get(e.getExaminationBasicId()));
+			});
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
 }

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

@@ -9,6 +9,7 @@ import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.im.api.client.ImFeignService;
 import com.keao.edu.im.api.entity.ImResult;
 import com.keao.edu.im.api.entity.ImUserModel;
+import com.keao.edu.user.dao.ExamOrganizationRelationDao;
 import com.keao.edu.user.dao.OrganizationDao;
 import com.keao.edu.user.dao.SysUserDao;
 import com.keao.edu.user.entity.Organization;
@@ -35,6 +36,8 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 	private SysUserFeignService sysUserFeignService;
 	@Autowired
 	private SysUserDao sysUserDao;
+	@Autowired
+	private ExamOrganizationRelationDao examOrganizationRelationDao;
 
 	@Override
 	public BaseDAO<Integer, Organization> getDAO() {
@@ -177,4 +180,15 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 		}
 		return selfAndChildOrganIds;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void del(Integer id) {
+		Integer count = examOrganizationRelationDao.findByOrganId(id);
+		if(count == null || count == 0){
+			organDao.delete(id);
+		}else {
+			throw new BizException("删除失败:存在考试项目,无法删除");
+		}
+	}
 }

+ 7 - 11
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamCertificationMapper.xml

@@ -33,13 +33,10 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.keao.edu.user.entity.ExamCertification" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!--
-		<selectKey resultClass="int" keyProperty="id" > 
-		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
-		</selectKey>
-		-->
-		INSERT INTO exam_certification (id_,examination_basic_id_,student_id_,card_no_,subject_id_,level_,exam_start_time_,exam_end_time_,exam_address_,create_time_,update_time_,tenant_id_)
-		VALUES(#{id},#{examinationBasicId},#{studentId},#{cardNo},#{subjectId},#{level},#{examStartTime},#{examEndTime},#{examAddress},NOW(),NOW(),#{tenantId})
+		INSERT INTO exam_certification (id_,examination_basic_id_,student_id_,card_no_,subject_id_,
+		level_,exam_start_time_,exam_end_time_,exam_address_,create_time_,update_time_,tenant_id_)
+		VALUES(#{id},#{examinationBasicId},#{studentId},#{cardNo},#{subjectId},#{level},#{examStartTime},
+		#{examEndTime},#{examAddress},NOW(),NOW(),#{tenantId})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -55,9 +52,6 @@
 			<if test="examEndTime != null">
 				exam_end_time_ = #{examEndTime},
 			</if>
-			<if test="id != null">
-				id_ = #{id},
-			</if>
 			<if test="examStartTime != null">
 				exam_start_time_ = #{examStartTime},
 			</if>
@@ -87,13 +81,15 @@
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamCertification" parameterType="map">
-		SELECT * FROM exam_certification ORDER BY id_ <include refid="global.limit"/>
+		SELECT * FROM exam_certification ORDER BY id_
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM exam_certification
 	</select>
+
     <select id="findByStuAndBasicId" resultMap="ExamCertification">
 		SELECT * FROM exam_certification WHERE examination_basic_id_ = #{basicId} AND student_id_ = #{studentId} LIMIT 1
 	</select>

+ 3 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamOrganizationRelationMapper.xml

@@ -218,4 +218,7 @@
 			</foreach>
 		GROUP BY o.id_
 	</select>
+    <select id="findByOrganId" resultType="java.lang.Integer">
+		SELECT COUNT(DISTINCT id_) FROM exam_organization_relation WHERE organ_id_ = #{organId}
+	</select>
 </mapper>

+ 1 - 0
edu-zuul/src/main/java/com/keao/edu/zuul/web/config/SwaggerDocumentConfig.java

@@ -20,6 +20,7 @@ public class SwaggerDocumentConfig implements SwaggerResourcesProvider {
 		resources.add(swaggerResource("CMS服务", "/cms-server/v2/api-docs", "2.0"));
 		resources.add(swaggerResource("TASK服务", "/task-server/v2/api-docs", "2.0"));
 		resources.add(swaggerResource("USER服务", "/user-server/v2/api-docs", "2.0"));
+		resources.add(swaggerResource("IM服务", "/im-server/v2/api-docs", "2.0"));
 		return resources;
 	}