20200617-zlp-1

多部门切换
视频学习页面 过滤bug
This commit is contained in:
paidaxing444
2020-06-17 17:58:52 +08:00
parent 4b8bf8f5d4
commit 639357f280
17 changed files with 415 additions and 206 deletions

View File

@ -17,7 +17,7 @@ import eu.bitwalker.useragentutils.UserAgent;
/**
* 异步工厂(产生任务用)
*
*
* @author ruoyi
*/
public class AsyncFactory
@ -26,7 +26,7 @@ public class AsyncFactory
/**
* 记录登陆信息
*
*
* @param username 用户名
* @param status 状态
* @param message 消息
@ -34,7 +34,7 @@ public class AsyncFactory
* @return 任务task
*/
public static TimerTask recordLogininfor(final String username, final String status, final String message,
final Object... args)
final Object... args)
{
final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
final String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
@ -81,7 +81,7 @@ public class AsyncFactory
/**
* 操作日志记录
*
*
* @param operLog 操作日志信息
* @return 任务task
*/

View File

@ -22,7 +22,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
/**
* token验证处理
*
*
* @author ruoyi
*/
@Component
@ -51,7 +51,7 @@ public class TokenService
/**
* 获取用户身份信息
*
*
* @return 用户信息
*/
public LoginUser getLoginUser(HttpServletRequest request)
@ -95,7 +95,7 @@ public class TokenService
/**
* 创建令牌
*
*
* @param loginUser 用户信息
* @return 令牌
*/
@ -113,7 +113,7 @@ public class TokenService
/**
* 验证令牌有效期相差不足20分钟自动刷新缓存
*
*
* @param token 令牌
* @return 令牌
*/
@ -129,7 +129,7 @@ public class TokenService
/**
* 刷新令牌有效期
*
*
* @param loginUser 登录信息
*/
public void refreshToken(LoginUser loginUser)
@ -140,10 +140,10 @@ public class TokenService
String userKey = getTokenKey(loginUser.getToken());
redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
}
/**
* 设置用户代理信息
*
*
* @param loginUser 登录信息
*/
public void setUserAgent(LoginUser loginUser)
@ -155,7 +155,7 @@ public class TokenService
loginUser.setBrowser(userAgent.getBrowser().getName());
loginUser.setOs(userAgent.getOperatingSystem().getName());
}
/**
* 从数据声明生成令牌
*

View File

@ -77,6 +77,7 @@ public class ByTrainVideoController extends BaseController {
public AjaxResult getInfo(@PathVariable("id") Long id) {
ByTrainVideo byTrainVideo = byTrainVideoService.selectByTrainVideoById(id);
byTrainVideo.setVideourl(commonController.privateDownloadUrl(byTrainVideo.getVideourl()));
byTrainVideo.setType(byTrainVideo.getType().substring(0, byTrainVideo.getType().length() - 1));//去掉后缀的,号
return AjaxResult.success(byTrainVideo);
}

View File

@ -2,7 +2,12 @@ package com.ruoyi.project.system.controller;
import java.util.List;
import com.ruoyi.project.system.service.IBySchoolService;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.security.service.TokenService;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -25,24 +30,25 @@ import com.ruoyi.project.system.service.ISysDeptService;
/**
* 部门信息
*
*
* @author ruoyi
*/
@RestController
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
public class SysDeptController extends BaseController {
@Autowired
private ISysDeptService deptService;
@Autowired
private TokenService tokenService;
/**
* 获取部门列表
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list")
public AjaxResult list(SysDept dept)
{
public AjaxResult list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return AjaxResult.success(depts);
}
@ -52,17 +58,43 @@ public class SysDeptController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
public AjaxResult getInfo(@PathVariable Long deptId) {
return AjaxResult.success(deptService.selectDeptById(deptId));
}
/**
* 根据用户获取部门列表信息-用于切换岗位
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/getDeptsInfo"})
public TableDataInfo getDeptsInfo() {
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
List<SysDept> list = deptService.selectSysDeptList(userId);
return getDataTable(list);
}
/**
* 切换岗位
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@PostMapping(value = {"/changeDept/{deptId}"})
public AjaxResult changeDept(@PathVariable Long deptId) {
System.out.println("开始切换...");
SysDept sysDept = deptService.selectDeptById(deptId);
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
loginUser.getUser().setDeptId(deptId);
loginUser.getUser().setDept(sysDept);
// 切换岗位 设置新的岗位信息到缓存中
tokenService.refreshToken(loginUser);
return AjaxResult.success("切换成功");
}
/**
* 获取部门下拉树列表
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(SysDept dept)
{
public AjaxResult treeselect(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
}
@ -71,8 +103,7 @@ public class SysDeptController extends BaseController
* 加载对应角色部门列表树
*/
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
{
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
@ -86,10 +117,8 @@ public class SysDeptController extends BaseController
@PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept)
{
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
public AjaxResult add(@Validated @RequestBody SysDept dept) {
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(SecurityUtils.getUsername());
@ -102,14 +131,10 @@ public class SysDeptController extends BaseController
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept)
{
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(dept.getDeptId()))
{
} else if (dept.getParentId().equals(dept.getDeptId())) {
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
dept.setUpdateBy(SecurityUtils.getUsername());
@ -122,14 +147,11 @@ public class SysDeptController extends BaseController
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId)
{
if (deptService.hasChildByDeptId(deptId))
{
public AjaxResult remove(@PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) {
return AjaxResult.error("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
if (deptService.checkDeptExistUser(deptId)) {
return AjaxResult.error("部门存在用户,不允许删除");
}
return toAjax(deptService.deleteDeptById(deptId));

View File

@ -27,6 +27,14 @@ public interface SysDeptMapper
*/
public List<Integer> selectDeptListByRoleId(Long roleId);
/**
* 根据用户ID获取部门列表
*
* @param userId 用户ID
* @return 选中岗位ID列表
*/
public List<SysDept> selectSysDeptList(Long userId);
/**
* 根据用户ID获取部门选择框列表
*

View File

@ -35,6 +35,14 @@ public interface ISysDeptService
*/
public List<SysDept> buildDeptTree(List<SysDept> depts);
/**
* 根据角色ID查询部门
*
* @param userId 角色ID
* @return 选中部门列表
*/
public List<SysDept> selectSysDeptList(Long userId);
/**
* 构建前端所需要下拉树结构
*

View File

@ -50,6 +50,16 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.selectDeptListByUserId(userId);
}
/**
* 根据角色ID查询部门
*
* @param userId 角色ID
* @return 选中部门列表
*/
public List<SysDept> selectSysDeptList(Long userId){
return deptMapper.selectSysDeptList(userId);
}
/**
* 构建前端所需要树结构
*

View File

@ -1,43 +1,43 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.system.mapper.BySchoolMapper">
<resultMap type="BySchool" id="BySchoolResult">
<result property="id" column="id" />
<result property="xxdm" column="xxdm" />
<result property="schoolName" column="school_name" />
<result property="nameShort" column="name_short" />
<result property="type" column="type" />
<result property="parentId" column="parent_id" />
<result property="province" column="province" />
<result property="provincename" column="provincename" />
<result property="regionid" column="regionid" />
<result property="regionname" column="regionname" />
<result property="area" column="area" />
<result property="areaname" column="areaname" />
<result property="address" column="address" />
<result property="mastername" column="mastername" />
<result property="tel" column="tel" />
<result property="emMan" column="em_man" />
<result property="emTel" column="em_tel" />
<result property="status" column="status" />
<result property="scale" column="scale" />
<result property="createTime" column="create_time" />
<result property="createUser" column="create_user" />
<result property="approvalUser" column="approval_user" />
<result property="approvalTime" column="approval_time" />
<result property="remark" column="remark" />
<result property="location" column="location" />
<result property="isDemonstr" column="is_demonstr" />
<result property="businesslicenseimg" column="businesslicenseimg" />
<result property="openBook" column="open_book" />
<result property="feeStatus" column="fee_status" />
<result property="openDeadline" column="open_deadline" />
<result property="dqxn" column="dqxn" />
<result property="dqxq" column="dqxq" />
<result property="isDel" column="is_del" />
<result property="id" column="id"/>
<result property="xxdm" column="xxdm"/>
<result property="schoolName" column="school_name"/>
<result property="nameShort" column="name_short"/>
<result property="type" column="type"/>
<result property="parentId" column="parent_id"/>
<result property="province" column="province"/>
<result property="provincename" column="provincename"/>
<result property="regionid" column="regionid"/>
<result property="regionname" column="regionname"/>
<result property="area" column="area"/>
<result property="areaname" column="areaname"/>
<result property="address" column="address"/>
<result property="mastername" column="mastername"/>
<result property="tel" column="tel"/>
<result property="emMan" column="em_man"/>
<result property="emTel" column="em_tel"/>
<result property="status" column="status"/>
<result property="scale" column="scale"/>
<result property="createTime" column="create_time"/>
<result property="createUser" column="create_user"/>
<result property="approvalUser" column="approval_user"/>
<result property="approvalTime" column="approval_time"/>
<result property="remark" column="remark"/>
<result property="location" column="location"/>
<result property="isDemonstr" column="is_demonstr"/>
<result property="businesslicenseimg" column="businesslicenseimg"/>
<result property="openBook" column="open_book"/>
<result property="feeStatus" column="fee_status"/>
<result property="openDeadline" column="open_deadline"/>
<result property="dqxn" column="dqxn"/>
<result property="dqxq" column="dqxq"/>
<result property="isDel" column="is_del"/>
</resultMap>
@ -48,42 +48,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBySchoolList" parameterType="BySchool" resultMap="BySchoolResult">
<include refid="selectBySchoolVo"/>
where is_del = '0'
<if test="xxdm != null and xxdm != ''"> and xxdm like concat('%', #{xxdm}, '%')</if>
<if test="schoolName != null and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
<if test="nameShort != null and nameShort != ''"> and name_short = #{nameShort}</if>
<if test="type != null "> and type = #{type}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="province != null and province != ''"> and province = #{province}</if>
<if test="provincename != null and provincename != ''"> and provincename like concat('%', #{provincename}, '%')</if>
<if test="regionid != null and regionid != ''"> and regionid = #{regionid}</if>
<if test="regionname != null and regionname != ''"> and regionname like concat('%', #{regionname}, '%')</if>
<if test="area != null and area != ''"> and area = #{area}</if>
<if test="areaname != null and areaname != ''"> and areaname like concat('%', #{areaname}, '%')</if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="mastername != null and mastername != ''"> and mastername like concat('%', #{mastername}, '%')</if>
<if test="tel != null and tel != ''"> and tel = #{tel}</if>
<if test="emMan != null and emMan != ''"> and em_man = #{emMan}</if>
<if test="emTel != null and emTel != ''"> and em_tel = #{emTel}</if>
<if test="status != null "> and status = #{status}</if>
<if test="scale != null "> and scale = #{scale}</if>
<if test="createUser != null "> and create_user = #{createUser}</if>
<if test="approvalUser != null "> and approval_user = #{approvalUser}</if>
<if test="approvalTime != null "> and approval_time = #{approvalTime}</if>
<if test="location != null and location != ''"> and location = #{location}</if>
<if test="isDemonstr != null "> and is_demonstr = #{isDemonstr}</if>
<if test="businesslicenseimg != null and businesslicenseimg != ''"> and businesslicenseimg = #{businesslicenseimg}</if>
<if test="openBook != null "> and open_book = #{openBook}</if>
<if test="feeStatus != null "> and fee_status = #{feeStatus}</if>
<if test="openDeadline != null "> and open_deadline = #{openDeadline}</if>
<if test="dqxn != null and dqxn != ''"> and dqxn = #{dqxn}</if>
<if test="dqxq != null and dqxq != ''"> and dqxq = #{dqxq}</if>
<if test="xxdm != null and xxdm != ''">and xxdm like concat('%', #{xxdm}, '%')</if>
<if test="schoolName != null and schoolName != ''">and school_name like concat('%', #{schoolName}, '%')</if>
<if test="nameShort != null and nameShort != ''">and name_short = #{nameShort}</if>
<if test="type != null ">and type = #{type}</if>
<if test="parentId != null ">and parent_id = #{parentId}</if>
<if test="province != null and province != ''">and province = #{province}</if>
<if test="provincename != null and provincename != ''">and provincename like concat('%', #{provincename},
'%')
</if>
<if test="regionid != null and regionid != ''">and regionid = #{regionid}</if>
<if test="regionname != null and regionname != ''">and regionname like concat('%', #{regionname}, '%')</if>
<if test="area != null and area != ''">and area = #{area}</if>
<if test="areaname != null and areaname != ''">and areaname like concat('%', #{areaname}, '%')</if>
<if test="address != null and address != ''">and address = #{address}</if>
<if test="mastername != null and mastername != ''">and mastername like concat('%', #{mastername}, '%')</if>
<if test="tel != null and tel != ''">and tel like concat('%', #{tel}, '%')</if>
<if test="emMan != null and emMan != ''">and em_man = #{emMan}</if>
<if test="emTel != null and emTel != ''">and em_tel = #{emTel}</if>
<if test="status != null ">and status = #{status}</if>
<if test="scale != null ">and scale = #{scale}</if>
<if test="createUser != null ">and create_user = #{createUser}</if>
<if test="approvalUser != null ">and approval_user = #{approvalUser}</if>
<if test="approvalTime != null ">and approval_time = #{approvalTime}</if>
<if test="location != null and location != ''">and location = #{location}</if>
<if test="isDemonstr != null ">and is_demonstr = #{isDemonstr}</if>
<if test="businesslicenseimg != null and businesslicenseimg != ''">and businesslicenseimg =
#{businesslicenseimg}
</if>
<if test="openBook != null ">and open_book = #{openBook}</if>
<if test="feeStatus != null ">and fee_status = #{feeStatus}</if>
<if test="openDeadline != null ">and open_deadline = #{openDeadline}</if>
<if test="dqxn != null and dqxn != ''">and dqxn = #{dqxn}</if>
<if test="dqxq != null and dqxq != ''">and dqxq = #{dqxq}</if>
</select>
<select id="selectBySchoolById" parameterType="Long" resultMap="BySchoolResult">
<include refid="selectBySchoolVo"/>
where id = #{id}
</select>
<insert id="insertBySchool" parameterType="BySchool" useGeneratedKeys="true" keyProperty="id">
insert into by_school
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -118,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="openDeadline != null ">open_deadline,</if>
<if test="dqxn != null and dqxn != ''">dqxn,</if>
<if test="dqxq != null and dqxq != ''">dqxq,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="xxdm != null and xxdm != ''">#{xxdm},</if>
<if test="schoolName != null and schoolName != ''">#{schoolName},</if>
@ -151,7 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="openDeadline != null ">#{openDeadline},</if>
<if test="dqxn != null and dqxn != ''">#{dqxn},</if>
<if test="dqxq != null and dqxq != ''">#{dqxq},</if>
</trim>
</trim>
</insert>
<update id="updateBySchool" parameterType="BySchool">
@ -182,7 +186,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="location != null and location != ''">location = #{location},</if>
<if test="isDemonstr != null ">is_demonstr = #{isDemonstr},</if>
<if test="businesslicenseimg != null and businesslicenseimg != ''">businesslicenseimg = #{businesslicenseimg},</if>
<if test="businesslicenseimg != null and businesslicenseimg != ''">businesslicenseimg =
#{businesslicenseimg},
</if>
<if test="openBook != null ">open_book = #{openBook},</if>
<if test="feeStatus != null ">fee_status = #{feeStatus},</if>
<if test="openDeadline != null ">open_deadline = #{openDeadline},</if>
@ -202,5 +208,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
</mapper>

View File

@ -28,6 +28,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_dept d
</sql>
<select id="selectSysDeptList" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where dept_id in (
select dept_id from (
select dept_id,user_id from sys_user
union all
select dept_id,user_id from sys_user_dept) t
where t.user_id=#{userId})
</select>
<select id="selectDeptListByUserId" parameterType="Long" resultType="Integer">
select p.dept_id