Browse Source

首页屏蔽指定用户的,指定功能,乐教通禁止指定用户登陆使用

zouxuan 9 months ago
parent
commit
3a87578a2f

+ 1 - 1
cms/src/main/java/com/ym/mec/cms/dal/dao/SysNewsInformationDao.java

@@ -31,7 +31,7 @@ public interface SysNewsInformationDao extends BaseDAO<Long, SysNewsInformation>
 	
 	SysNewsInformationDto queryById(Long id);
 
-	List<SysNewsInformation> queryBySubType(@Param("subType") Integer subType, @Param("memo") String memo, @Param("organIds") String organIds);
+	List<SysNewsInformation> queryBySubType(@Param("subType") Integer subType, @Param("memo") String memo, @Param("organIds") String organIds, @Param("excludeFunctionIds") String excludeFunctionIds);
 
     Boolean countStudentAttendanceError(@Param("startTime") String startTime, @Param("userId") Integer userId);
 

+ 18 - 7
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsTypeServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.cms.service.impl;
 
+import com.ym.mec.cms.dal.dao.SysConfigDao;
 import com.ym.mec.cms.dal.dao.SysNewsInformationDao;
 import com.ym.mec.cms.dal.dao.SysNewsTypeDao;
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
@@ -17,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -24,12 +26,14 @@ import java.util.stream.Collectors;
 
 @Service
 public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType> implements SysNewsTypeService {
-    @Autowired
+    @Resource
     private SysNewsTypeDao sysNewsTypeDao;
-    @Autowired
+    @Resource
     private SysNewsInformationDao informationDao;
-    @Autowired
+    @Resource
     private WebFeignService webFeignService;
+    @Resource
+    private SysConfigDao sysConfigDao;
 
     @Override
     public BaseDAO<Integer, SysNewsType> getDAO() {
@@ -61,12 +65,19 @@ public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType
 
     public List<SysNewsType> listWithTree(Integer id, String memo,Integer userId,String organIds) {
         SysNewsType newsType = sysNewsTypeDao.get(id);
+        //获取需要排除的用户编号
+        String excludeUserIds = sysConfigDao.findConfigValue("excludeUserIds");
+        String excludeFunctionIds = null;
+        if(StringUtils.isNotEmpty(excludeUserIds) && excludeUserIds.contains(userId.toString())){
+            //获取需要排除的功能点编号
+            excludeFunctionIds = sysConfigDao.findConfigValue("excludeFunctionIds");
+        }
         List<SysNewsType> all = sysNewsTypeDao.findAll(null);
         String startTime = DateUtil.format(DateUtil.getFirstDayOfMonth(DateUtil.addMonths(new Date(), -1)),DateUtil.ISO_EXPANDED_DATE_FORMAT);
-        all.forEach(e -> {
-            List<SysNewsInformation> list = informationDao.queryBySubType(e.getId(), memo,organIds);
+        for (SysNewsType e : all) {
+            List<SysNewsInformation> list = informationDao.queryBySubType(e.getId(), memo,organIds,excludeFunctionIds);
             if (CollectionUtils.isEmpty(list)) {
-            	list = informationDao.queryBySubType(e.getId(), null,organIds);
+            	list = informationDao.queryBySubType(e.getId(), null,organIds,excludeFunctionIds);
             }
             Iterator<SysNewsInformation> iterator = list.iterator();
 			SysNewsInformation sni = null;
@@ -86,7 +97,7 @@ public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType
                 }
     		}
             e.setInformationList(list);
-        });
+        }
         List<SysNewsType> treeMenus = all.stream()
                 .filter((e) -> e.getParentId().equals(newsType.getParentId()))
                 .map((menu) -> menu.setChildren(getChildren(menu, all)))

+ 3 - 0
cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml

@@ -313,6 +313,9 @@
 		<if test="memo != null and memo !=''">
 			AND memo_ = #{memo}
 		</if>
+		<if test="excludeFunctionIds != null and excludeFunctionIds !=''">
+			AND NOT FIND_IN_SET(id_,#{excludeFunctionIds})
+		</if>
 		<if test="organIds != null and organIds !=''">
 			AND (INTE_ARRAY(#{organIds},organ_id_list_) OR organ_id_list_ IS NULL OR organ_id_list_ = '')
 		</if>

+ 104 - 0
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/entity/SysConfig.java

@@ -0,0 +1,104 @@
+package com.ym.mec.auth.api.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_config):
+ */
+public class SysConfig {
+
+	/**  */
+	private Long id;
+	
+	/** 参数名称 */
+	@ApiModelProperty(value = "参数名称", required = true)
+	private String paramName;
+	
+	/** 参数值 */
+	@ApiModelProperty(value = "参数值", required = true)
+	private String paranValue;
+	
+	/** 描述 */
+	@ApiModelProperty(value = "描述", required = true)
+	private String description;
+	
+	/** 创建时间 */
+	private java.util.Date createOn;
+	
+	/** 修改时间 */
+	private java.util.Date modifyOn;
+	
+	@ApiModelProperty(value = "消息组", required = true)
+	private String group;
+	
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setParamName(String paramName){
+		this.paramName = paramName;
+	}
+	
+	public String getParamName(){
+		return this.paramName;
+	}
+			
+	public void setParanValue(String paranValue){
+		this.paranValue = paranValue;
+	}
+	
+	public String getParanValue(){
+		return this.paranValue;
+	}
+
+	public <T> T getParanValue(Class<T> cla){
+		try {
+			return cla.cast(cla.getMethod("valueOf", String.class).invoke(cla.getInterfaces(),this.paranValue));
+		} catch (Exception e) {
+			return (T)this.paranValue.getClass();
+		}
+	}
+			
+	public void setDescription(String description){
+		this.description = description;
+	}
+	
+	public String getDescription(){
+		return this.description;
+	}
+			
+	public void setCreateOn(java.util.Date createOn){
+		this.createOn = createOn;
+	}
+	
+	public java.util.Date getCreateOn(){
+		return this.createOn;
+	}
+			
+	public void setModifyOn(java.util.Date modifyOn){
+		this.modifyOn = modifyOn;
+	}
+	
+	public java.util.Date getModifyOn(){
+		return this.modifyOn;
+	}
+			
+	public String getGroup() {
+		return group;
+	}
+
+	public void setGroup(String group) {
+		this.group = group;
+	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 24 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/dal/dao/SysConfigDao.java

@@ -0,0 +1,24 @@
+package com.ym.mec.auth.dal.dao;
+
+import com.ym.mec.auth.api.entity.SysConfig;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface SysConfigDao extends BaseDAO<Long, SysConfig> {
+
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/10/9
+     * @params [paramName]
+     * @return com.ym.mec.biz.dal.entity.SysConfig
+     * @describe 根据配置名称获取配置信息
+     */
+    SysConfig findByParamName(String paramName);
+
+    /**
+     * 获取value
+     * @param paramName
+     * @return
+     */
+    String findConfigValue(String paramName);
+	
+}

+ 9 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/CbsQrCodeScanServiceImpl.java

@@ -5,9 +5,11 @@ import com.dayaedu.cbs.openfeign.wrapper.qrcode.CbsQrCodeScanWrapper;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.core.service.CustomTokenServices;
+import com.ym.mec.auth.dal.dao.SysConfigDao;
 import com.ym.mec.auth.service.SysUserService;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.stereotype.Service;
@@ -25,6 +27,8 @@ public class CbsQrCodeScanServiceImpl{
     private SysUserService sysUserService;
     @Resource
     private SysUserFeignService sysUserFeignService;
+    @Resource
+    private SysConfigDao sysConfigDao;
 
     public CbsQrCodeScanWrapper.UserInfo userInfo(CbsQrCodeScanWrapper.QrCodeScanUserInfoReq req) {
         CbsQrCodeScanWrapper.UserInfo userInfo = new CbsQrCodeScanWrapper.UserInfo();
@@ -41,6 +45,11 @@ public class CbsQrCodeScanServiceImpl{
         if (sysUser == null) {
             throw new BizException(HttpStatus.UNAUTHORIZED.value(), "用户不存在");
         }
+        //获取需要排除的用户编号
+        String excludeUserIds = sysConfigDao.findConfigValue("excludeUserIds");
+        if(StringUtils.isNotEmpty(excludeUserIds) && excludeUserIds.contains(sysUser.getId().toString())){
+            throw new BizException("扫码登陆失败: 用户已锁定");
+        }
         //调用登陆接口
         HttpResponseResult<Map<String,Object>> result = sysUserFeignService.smsLogin(phone, "qr_teacher", UUID.randomUUID().toString(), "qr_teacher");
         if (result != null){

+ 21 - 0
mec-auth/mec-auth-server/src/main/resources/config/mybatis/SysConfigMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
+<mapper namespace="com.ym.mec.auth.dal.dao.SysConfigDao">
+
+	<resultMap type="com.ym.mec.auth.api.entity.SysConfig" id="SysConfig">
+		<result column="id_" property="id" />
+		<result column="param_name_" property="paramName" />
+		<result column="paran_value_" property="paranValue" />
+		<result column="description_" property="description" />
+		<result column="create_on_" property="createOn" />
+		<result column="modify_on_" property="modifyOn" />
+		<result column="group_" property="group" />
+	</resultMap>
+	<select id="findByParamName" resultMap="SysConfig">
+		SELECT * FROM sys_config WHERE param_name_ = #{paramName}
+	</select>
+    <select id="findConfigValue" resultType="java.lang.String">
+		SELECT paran_value_ FROM sys_config WHERE param_name_ = #{paramName}
+	</select>
+</mapper>