浏览代码

老师端支持查看教材课件

zouxuan 1 年之前
父节点
当前提交
5cf5c05501

+ 6 - 1
cms/src/main/java/com/ym/mec/cms/controller/NewsController.java

@@ -7,6 +7,7 @@ import com.ym.mec.cms.controller.queryinfo.NewsInformationQueryInfo;
 import com.ym.mec.cms.dal.dao.SysNewsInformationDao;
 import com.ym.mec.cms.dal.entity.SysConfig;
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
+import com.ym.mec.cms.service.OrganizationService;
 import com.ym.mec.cms.service.SysConfigService;
 import com.ym.mec.cms.service.SysNewsInformationService;
 import com.ym.mec.cms.service.SysNewsTypeService;
@@ -49,6 +50,8 @@ public class NewsController extends BaseController {
     @Autowired
     private WebFeignService webFeignService;
     @Autowired
+    private OrganizationService organizationService;
+    @Autowired
     private SysConfigService sysConfigService;
 
     @ApiOperation("查询底部按钮信息")
@@ -207,9 +210,11 @@ public class NewsController extends BaseController {
 	public Object listWithTree(Integer id, String memo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer userId = null;
+        String organIds = "";
         if(sysUser != null && sysUser.getId() != null){
             userId = sysUser.getId();
+            organIds = organizationService.getEmployeeOrgan(sysUser.getId(), null, sysUser.getIsSuperAdmin() && sysUser.getTenantId() == -1);
         }
-        return succeed(sysNewsTypeService.listWithTree(id,memo,userId));
+        return succeed(sysNewsTypeService.listWithTree(id,memo,userId,organIds));
 	}
 }

+ 9 - 0
cms/src/main/java/com/ym/mec/cms/dal/dao/OrganizationDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.cms.dal.dao;
+
+
+import com.ym.mec.cms.dal.entity.Organization;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface OrganizationDao extends BaseDAO<Integer, Organization> {
+
+}

+ 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);
+	List<SysNewsInformation> queryBySubType(@Param("subType") Integer subType, @Param("memo") String memo, @Param("organIds") String organIds);
 
     Boolean countStudentAttendanceError(@Param("startTime") String startTime, @Param("userId") Integer userId);
 

+ 64 - 0
cms/src/main/java/com/ym/mec/cms/dal/entity/Organization.java

@@ -0,0 +1,64 @@
+package com.ym.mec.cms.dal.entity;
+
+import com.ym.mec.common.entity.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 对应数据库表(organization):
+ */
+@Data
+public class Organization extends BaseEntity {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -8979746516597046410L;
+
+	/**  */
+	private Integer id;
+	
+	/** 机构名称 */
+	@ApiModelProperty(value = "机构名称",required = false)
+	private String name;
+
+	/** 机构名称 */
+	@ApiModelProperty(value = "区域名称",required = false)
+	private String areaName;
+	
+	/** 区域编码 */
+	@ApiModelProperty(value = "区域编码",required = false)
+	private Integer areaId;
+	
+	private String corporateName;
+	
+	private String corporateCode;
+	
+	private String corporateSeal;
+	
+	private String corporateFinancialSeal;
+	
+	private BigDecimal maxMusicalInstrumentsProfits;
+	
+	/** 创建时间 */
+	private Date createTime;
+	
+	/** 修改时间 */
+	private Date updateTime;
+
+	@ApiModelProperty(value = "成立日期",required = false)
+	private Date registerDate;
+
+	@ApiModelProperty(value = "联系人",required = false)
+	private String linkman;
+
+	@ApiModelProperty(value = "联系方式",required = false)
+	private String mobile;
+
+	@ApiModelProperty(value = "地址",required = false)
+	private String address;
+
+}

+ 13 - 1
cms/src/main/java/com/ym/mec/cms/dal/entity/TenantInfo.java

@@ -1,5 +1,6 @@
 package com.ym.mec.cms.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 /**
@@ -30,13 +31,24 @@ public class TenantInfo {
 	
 	/** 数据源 */
 	private String dataSource;
+
+	@ApiModelProperty(value = "管理员账号id")
+	private Integer userId;
 	
 	/**  */
 	private java.util.Date createTime;
 	
 	/**  */
 	private java.util.Date updateTime;
-	
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
 	public void setId(Integer id){
 		this.id = id;
 	}

+ 21 - 0
cms/src/main/java/com/ym/mec/cms/service/OrganizationService.java

@@ -0,0 +1,21 @@
+package com.ym.mec.cms.service;
+
+
+import com.ym.mec.cms.dal.entity.Organization;
+import com.ym.mec.common.service.BaseService;
+
+public interface OrganizationService extends BaseService<Integer, Organization> {
+
+    /**
+    * @description: 获取员工能访问的分部列表
+     * @param userId 当前用户
+     * @param organIds 用户选择的分部
+     * @param isSuper 是否超管
+    * @return java.lang.String
+    * @author zx
+    * @date 2022/1/5 12:44
+    */
+    String getEmployeeOrgan(Integer userId,String organIds,Boolean isSuper);
+
+
+}

+ 1 - 1
cms/src/main/java/com/ym/mec/cms/service/SysNewsTypeService.java

@@ -13,5 +13,5 @@ public interface SysNewsTypeService extends BaseService<Integer, SysNewsType> {
 	//根据父级查询子集
 	List<SysNewsTypeTree> queryByParentId(Integer parentId);
 
-	List<SysNewsType> listWithTree(Integer id,String memo,Integer userId);
+	List<SysNewsType> listWithTree(Integer id,String memo,Integer userId,String organIds);
 }

+ 55 - 0
cms/src/main/java/com/ym/mec/cms/service/impl/OrganizationServiceImpl.java

@@ -0,0 +1,55 @@
+package com.ym.mec.cms.service.impl;
+
+import com.ym.mec.cms.dal.dao.OrganizationDao;
+import com.ym.mec.cms.dal.entity.Organization;
+import com.ym.mec.cms.dal.entity.TenantInfo;
+import com.ym.mec.cms.service.OrganizationService;
+import com.ym.mec.cms.service.TenantInfoService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.common.tenant.TenantContextHolder;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organization> implements OrganizationService {
+
+	@Resource
+	private OrganizationDao organizationDao;
+	@Resource
+	private TenantInfoService tenantInfoService;
+
+	@Override
+	public BaseDAO<Integer, Organization> getDAO() {
+		return organizationDao;
+	}
+
+
+	@Override
+	public String getEmployeeOrgan(Integer userId, String organIds,Boolean isSuper) {
+		if(StringUtils.isEmpty(organIds)){
+			Integer tenantId = TenantContextHolder.getTenantId();
+			TenantInfo tenantInfo = tenantInfoService.get(tenantId);
+			//如果是超管,或者是机构管理员,可以查看当前机构所有分部数据
+			if(isSuper || (tenantInfo.getUserId() != null && tenantInfo.getUserId().equals(userId))){
+				Map<String,Object> param = new HashMap<>();
+				param.put("tenantId",tenantId);
+				List<Organization> all = this.findAll(param);
+				if(all != null && all.size() > 0){
+					organIds = StringUtils.join(all.stream().map(e->e.getId()).collect(Collectors.toSet()),",");
+				}
+			}
+		}
+		/*if(StringUtils.isEmpty(organIds)){
+			Employee employee = employeeDao.get(userId);
+			organIds = employee.getOrganIdList();
+		}*/
+		return organIds;
+	}
+}

+ 0 - 1
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -166,5 +166,4 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		}
 		return true;
 	}
-
 }

+ 5 - 6
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsTypeServiceImpl.java

@@ -19,9 +19,7 @@ import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -61,14 +59,14 @@ public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType
         return sysNewsTypeDao.queryByParentId(parentId);
     }
 
-    public List<SysNewsType> listWithTree(Integer id, String memo,Integer userId) {
+    public List<SysNewsType> listWithTree(Integer id, String memo,Integer userId,String organIds) {
         SysNewsType newsType = sysNewsTypeDao.get(id);
         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);
+            List<SysNewsInformation> list = informationDao.queryBySubType(e.getId(), memo,organIds);
             if (CollectionUtils.isEmpty(list)) {
-            	list = informationDao.queryBySubType(e.getId(), null);
+            	list = informationDao.queryBySubType(e.getId(), null,organIds);
             }
             Iterator<SysNewsInformation> iterator = list.iterator();
 			SysNewsInformation sni = null;
@@ -120,4 +118,5 @@ public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType
                 .collect(Collectors.toList());
         return childrenList;
     }
+
 }

+ 37 - 0
cms/src/main/resources/config/mybatis/OrganizationMapper.xml

@@ -0,0 +1,37 @@
+<?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.biz.dal.dao.OrganizationDao">
+
+    <resultMap type="com.ym.mec.cms.dal.entity.Organization" id="Organization">
+        <result column="id_" property="id"/>
+        <result column="name_" property="name"/>
+        <result column="area_name_" property="areaName"/>
+        <result column="area_id_" property="areaId"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+        <result column="register_date_" property="registerDate"/>
+        <result column="linkman_" property="linkman"/>
+        <result column="mobile_" property="mobile"/>
+        <result column="address_" property="address"/>
+        <result column="corporate_name_" property="corporateName"/>
+        <result column="corporate_code_" property="corporateCode"/>
+        <result column="corporate_seal_" property="corporateSeal"/>
+        <result column="corporate_financial_seal_" property="corporateFinancialSeal"/>
+        <result column="max_musical_instruments_profits_" property="maxMusicalInstrumentsProfits"/>
+        <result column="tenant_id_" property="tenantId"/>
+    </resultMap>
+
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="Organization">
+		SELECT * FROM organization WHERE id_ = #{id} 
+	</select>
+
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="Organization">
+		SELECT * FROM organization WHERE tenant_id_ = #{tenantId} AND del_flag_ = 0 ORDER BY id_
+	</select>
+</mapper>

+ 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="organIds != null and organIds !=''">
+			AND INTE_ARRAY(#{organIds},organ_id_list_)
+		</if>
 		ORDER BY order_ DESC
 	</select>
     <select id="countStudentAttendanceError" resultType="java.lang.Boolean">

+ 1 - 2
cms/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -9,6 +9,7 @@
 		<result column="address_" property="address" />
 		<result column="domain_name_" property="domainName" />
 		<result column="logo_url_" property="logoUrl" />
+		<result column="user_id_" property="userId" />
 		<result column="contact_name_" property="contactName" />
 		<result column="contact_phone_" property="contactPhone" />
 		<result column="data_source_" property="dataSource" />
@@ -31,8 +32,6 @@
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.cms.dal.entity.TenantInfo"
 		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
-			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO tenant_info
 		(id_,name_,address_,domain_name_,logo_url_,contact_name_,contact_phone_,data_source_,create_time_,update_time_)
 		VALUES(#{id},#{name},#{address},#{domainName},#{logoUrl},#{contactName},#{contactPhone},#{dataSource},#{createTime},#{updateTime})