新增训练任务步骤

master
yz 2 years ago
parent ba7c18f659
commit bdcfe7a75a

@ -6,6 +6,8 @@ import java.util.Set;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -27,8 +29,7 @@ import com.ruoyi.system.service.ISysMenuService;
* @author ruoyi
*/
@RestController
public class SysLoginController
{
public class SysLoginController {
@Autowired
private SysLoginService loginService;
@ -41,6 +42,12 @@ public class SysLoginController
@Autowired
private TokenService tokenService;
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private SysUserMapper sysUserMapper;
/**
*
*
@ -48,14 +55,18 @@ public class SysLoginController
* @return
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax;
public AjaxResult login(@RequestBody LoginBody loginBody) {
SysUser sysUser = sysUserMapper.selectUserByUserName(loginBody.getUsername());
String roleId= String.valueOf(sysUserRoleMapper.selectRoleIdByUserId(sysUser.getUserId()));
if (("student".equals(loginBody.getRole()) && "2".equals(roleId)) || ("teacher".equals(loginBody.getRole()) && "100".equals(roleId)) || "admin".equals(loginBody.getUsername())) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
return ajax;
}
return new AjaxResult(403,"用户权限不正确");
}
/**
@ -64,8 +75,7 @@ public class SysLoginController
* @return
*/
@GetMapping("getInfo")
public AjaxResult getInfo()
{
public AjaxResult getInfo() {
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
@ -84,11 +94,18 @@ public class SysLoginController
* @return
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
public AjaxResult getRouters() {
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(user);
return AjaxResult.success(menuService.buildMenus(menus));
}
@GetMapping("getTeacherRouters")
public AjaxResult getTeacherRouters() {
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
List<SysMenu> menus = menuService.selectTeacherMenuTreeByUserId(user);
return AjaxResult.success(menuService.buildMenus(menus));
}
}

@ -367,6 +367,9 @@ public class DocInfoController extends BaseController {
@PostMapping ("/splitWordDocInfo")
public AjaxResult splitWordDocInfo(@RequestBody DocInfo docInfo){
if("".equals(docInfo.getContent()) || docInfo.getContent()==null){
return AjaxResult.error(400,"文章不能为空");
}
String title = docInfo.getContent();
Segment segment= HanLP.newSegment();
List<Term> termList = segment.seg(title);

@ -27,6 +27,16 @@ public class LoginBody
*/
private String uuid;
private String role;
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getUsername()
{
return username;

@ -58,14 +58,14 @@ public class SysPermissionService
Set<String> perms = new HashSet<String>();
// 管理员拥有所有权限
if (user.isAdmin()||hasRole(user.getRoles()))
{
// if (user.isAdmin()||hasRole(user.getRoles()))
// {
perms.add("*:*:*");
}
else
{
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
}
// }
// else
// {
// perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
// }
return perms;
}

@ -48,6 +48,7 @@ public interface SysMenuMapper
* @return
*/
public List<SysMenu> selectMenuTreeAll();
public List<SysMenu> selectTeacherMenuTreeAll();
/**
* ID
@ -114,4 +115,5 @@ public interface SysMenuMapper
* @return
*/
public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId);
}

@ -1,14 +1,18 @@
package com.ruoyi.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.system.domain.SysUserRole;
import org.apache.ibatis.annotations.Select;
/**
*
*
* @author ruoyi
*/
@Mapper
public interface SysUserRoleMapper
{
/**
@ -59,4 +63,7 @@ public interface SysUserRoleMapper
* @return
*/
public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
@Select("select role_id from sys_user_role where user_id = #{userId}")
Long selectRoleIdByUserId(@Param("userId") Long userId);
}

@ -46,7 +46,7 @@ public interface ISysMenuService
* @return
*/
public List<SysMenu> selectMenuTreeByUserId(SysUser user);
public List<SysMenu> selectTeacherMenuTreeByUserId(SysUser user);
/**
* ID
*

@ -121,6 +121,21 @@ public class SysMenuServiceImpl implements ISysMenuService
return getChildPerms(menus, 0);
}
@Override
public List<SysMenu> selectTeacherMenuTreeByUserId(SysUser user)
{
List<SysMenu> menus = null;
if (SecurityUtils.isAdmin(user.getUserId())||hasRole(user.getRoles()))
{
menus = menuMapper.selectTeacherMenuTreeAll();
}
else
{
menus = menuMapper.selectMenuTreeByUserId(user.getUserId());
}
return getChildPerms(menus, 0);
}
/**
* ID
*

@ -53,6 +53,11 @@
from sys_menu_stu m where m.menu_type in ('M', 'C') and m.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectTeacherMenuTreeAll" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu_stu m where m.menu_type in ('M', 'C') and m.status = 0 and menu_id not in(2000,2004,2008,2009)
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time

Loading…
Cancel
Save