Commit 3c95d9d8 authored by luzhuang's avatar luzhuang

sysRole

parent 38d84421
......@@ -29,7 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Api(tags = "3 分类接口")
@Api(tags = "3 课程分类")
@RestController
@RequestMapping("/BCourse")
public class BCourseController extends PaginationController<BCourse> {
......@@ -73,7 +73,7 @@ public class BCourseController extends PaginationController<BCourse> {
bCourseRepository.queryFirstLevel());
}
@ApiOperation(value = "304 物理删除", notes = "根据ID删除一条记录")
@ApiOperation(value = "304 逻辑删除", notes = "根据ID删除一条记录")
@ApiImplicitParam(name = "businessId", value = "课程分类id", required = true, dataType = "varchar")
@PostMapping(value = "/remove")
public Result remove(CurUser curUser, @Valid String businessId, BindingResult br) {
......
......@@ -24,8 +24,8 @@ import java.util.List;
/**
* Created by lcy on 16/7/30.
*/
@RestController
@RequestMapping("/dept")
//@RestController
//@RequestMapping("/dept")
public class SysDeptController extends ResponseController {
@Autowired
......
package org.rcisoft.sys.excel;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.common.component.Global;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
/**
* Created by gaowenfeng on 2017/8/2.
*/
@RestController
@RequestMapping("/excelUtil")
public class ExcelDownloadController {
private static final String STUDNET_FILE_NAME = "student.xls";
private static final String TEACHER_FILE_NAME = "teacher.xls";
private static final String CLASS_FILE_NAME = "class.xls";
private static final String STUDENT_CLASS_FILE_NAME = "student-class.xls";
private static final String STUDNET_SL_FILE_NAME = "student-sl.xls";
private static final String LESSON_FILE_NAME = "lesson.xls";
private static final String SL_FILE_NAME = "sl.xls";
private static final String ROOM_FILE_NAME = "room.xls";
private static final String BUSINESS_CLASS = "business-class.xls";
private static final String IMPORT_DTO = "schedule-task.xls";
@Autowired
private Global global;
@ApiOperation(value="下载excel模板", notes="下载excel模板")
@ApiImplicitParam(name = "type", value = "模板类型", required = false, dataType = "varchar")
@GetMapping("excelWithoutAuth")
public void excelDownLoad(HttpServletRequest request,
HttpServletResponse response,
@RequestParam("type") String type)
throws Exception {
InputStream in = null;
OutputStream out = null;
//File file = getDownLoadFile(type);
String name = getDownLoadFile(type);
in = getClass().getClassLoader().getResourceAsStream(global.getEXCEL_TEMPLATE_LOCATION()+name);
/*if (file == null)
throw new ServiceException(ResultServiceEnums.TEMPLAGE_NOT_EXISTS);
in = new BufferedInputStream(new FileInputStream(file));*/
out = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(name, "UTF-8"));//如果输出的是中文名的文件,在此处就要用URLEncoder.encode方法进行处理
byte[] buffer = new byte[in.available()];
in.read(buffer);
out.write(buffer);
}
@GetMapping("excel")
public void excel(HttpServletRequest request,
HttpServletResponse response,
@RequestParam("type") String type)
throws Exception {
excelDownLoad(request,response,type);
}
private String getDownLoadFile(String type) throws Exception {
String name = "";
switch (type) {
case "1":
name = STUDNET_FILE_NAME;
break;
case "2":
name = TEACHER_FILE_NAME;
break;
case "3":
name = CLASS_FILE_NAME;
break;
case "4":
name = STUDENT_CLASS_FILE_NAME;
break;
case "5":
name = STUDNET_SL_FILE_NAME;
break;
case "6":
name = LESSON_FILE_NAME;
break;
case "7":
name = SL_FILE_NAME;
break;
case "8":
name = ROOM_FILE_NAME;
break;
case "9":
name = BUSINESS_CLASS;
break;
case "10":
name = IMPORT_DTO;
break;
}
return name;
}
}
package org.rcisoft.sys.role.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
......@@ -24,6 +25,7 @@ import java.util.List;
/**
* Created by lcy on 16/7/30.
*/
@Api(tags = "10 用户角色")
@RestController
@RequestMapping("/role")
public class SysRoleController extends PaginationController<SysRole> {
......@@ -32,7 +34,7 @@ public class SysRoleController extends PaginationController<SysRole> {
private SysRoleService sysRoleServiceImpl;
@ApiOperation(value="分页查询角色", notes="分页查询角色")
@ApiOperation(value="1001 分页查询角色", notes="分页查询角色")
@GetMapping(value = "/queryRoles")
public GridModel queryRolesByPagination(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){
sysRoleServiceImpl.queryRolesByPagination(getPaginationUtility(), findRolePaginDTO);
......@@ -40,20 +42,17 @@ public class SysRoleController extends PaginationController<SysRole> {
return gridModel;
}
@ApiOperation(value="查询全部角色", notes="查询全部角色")
@ApiOperation(value="1002 查询全部角色", notes="查询全部角色")
@GetMapping(value = "/queryRolesAll")
public Result queryRolesAll(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){
sysRoleServiceImpl.queryRolesAll(findRolePaginDTO);
GridModel gridModel = getGridModelResponse();
// return gridModel;
public Result queryRolesAll(CurUser curUser){
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
sysRoleServiceImpl.queryRolesAll(findRolePaginDTO));
sysRoleServiceImpl.queryRolesAll());
}
@ApiOperation(value="增加/修改角色", notes="增加/修改角色")
@ApiOperation(value="1003 增加/修改角色", notes="增加/修改角色")
@PostMapping(value = "/add")
public Result roleAdd(CurUser curUser, @Valid AddOrUpdateRoleDTO addOrUpdateRoleDTO, BindingResult bindingResult){
int line = sysRoleServiceImpl.persistRole(addOrUpdateRoleDTO);
......@@ -64,7 +63,7 @@ public class SysRoleController extends PaginationController<SysRole> {
}
@ApiOperation(value="删除角色", notes="删除角色")
@ApiOperation(value="1004 删除角色", notes="删除角色")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar", paramType = "path")
@PostMapping(value = "/delete")
public Result roleDelete(CurUser curUser, String businessId, BindingResult bindingResult){
......
......@@ -23,17 +23,16 @@ import java.util.Map;
public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 分页查询 roles
* @param sysRole
*
* @param
* @return
*/
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' "
+ " <if test=\"code !=null and code != ''\">and code = #{code} </if> "
+ " <if test=\"roleName !=null and roleName != ''\">and role_name = #{roleName} </if> "
+" and code NOT in ('ROLE_1001','ROLE_1002','ROLE_1003')"
+ " order by create_date desc"
+ "</script>")
@ResultMap(value = "SelectAllAndUserNum" )
List<SysRole> queryRoles(SysRole sysRole);
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' " +
"AND role_name not in('主管理员','子管理员')" +
" order by create_date desc" +
"</script>")
@ResultMap(value = "SelectAllAndUserNum")
List<SysRole> queryRoles();
//获得此角色的用户数
int countUserNum(String roleId);
......@@ -41,11 +40,12 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@Select("<script>select * from s_role where "
+ "DEL_FLAG='0' "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
@ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesSelect(SysRole sysRole);
/**
* 根据角色id 删除对应权限
*
* @param roleId
* @return
*/
......@@ -55,6 +55,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 根据角色id 删除对应部门
*
* @param roleId
* @return
*/
......@@ -63,6 +64,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 批量插入 角色_权限
*
* @param menuRole
* @return
*/
......@@ -71,12 +73,15 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 批量插入 角色_部门
*
* @param deptRole
* @return
*/
int insertBatchRoleDept(List<Map> deptRole);
/**
* 分页查询 roles
*
* @param sysRole
* @return
*/
......@@ -89,12 +94,13 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
+ " FROM s_dept_role dr "
+ " LEFT JOIN s_dept d ON d.BUSINESS_ID = dr.DEPT_ID "
+ " LEFT JOIN s_role r on dr.ROLE_ID = r.BUSINESS_ID</script>")
@ResultMap(value = "drResultMap" )
List<DeptRole> queryUserRolesByPagination(@Param("userId") String userId, SysRole sysRole) ;
@ResultMap(value = "drResultMap")
List<DeptRole> queryUserRolesByPagination(@Param("userId") String userId, SysRole sysRole);
/**
* 分页查询 roles
*
* @param sysRole
* @return
*/
......@@ -124,7 +130,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
" s_role sysRole " +
"WHERE " +
" DEL_FLAG = '0' and FLAG = '1'</script>")
@ResultMap(value = "BaseResultMap" )
@ResultMap(value = "BaseResultMap")
List<SysRole> queryDeptRolesByPagination(@Param("deptId") String deptId, SysRole sysRole);
@Delete("<script>DELETE from s_dept_role_user where DEPT_ROLE_ID="
......@@ -135,6 +141,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 删除岗位
*
* @param roleId
* @return
*/
......@@ -143,6 +150,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 删除权限
*
* @param roleId
* @return
*/
......@@ -180,7 +188,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' "
+ "and (code = #{code} or role_name = #{roleName}) "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
@ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesByCodeOrName(SysRole sysRole);
@Delete("<script>DELETE from s_r_user_role where role_id=#{id}</script>")
......@@ -189,7 +197,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' "
+ "and role_name = #{roleName}"
+ "</script>")
@ResultMap(value = "BaseResultMap" )
@ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesByName(SysRole sysRole);
// @Select("SELECT COUNT(*) FROM s_menu sm \n" +
......@@ -206,6 +214,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/**
* 根据子表id 删除 s_r_user_role
*
* @param tableByKey
* @param businessId
* @return
......@@ -229,5 +238,5 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"\t\t\t\t\t${tb}.business_id = #{cid}\n" +
"\t\t\t) ab\n" +
"\t)")
int deleteUserRoleByChildrenId(@Param("tb") String tableByKey,@Param("cid") String businessId);
int deleteUserRoleByChildrenId(@Param("tb") String tableByKey, @Param("cid") String businessId);
}
......@@ -44,7 +44,7 @@ public interface SysRoleService {
List<SysRole> queryRolesByPagination(PageUtil pageUtil, FindRolePaginDTO findRolePaginDTO);
List<SysRole> queryRolesAll(FindRolePaginDTO findRolePaginDTO);
List<SysRole> queryRolesAll();
//select
List<SysRole> queryRolesSelect(SysRole sysRole);
......
......@@ -85,20 +85,20 @@ public class SysRoleServiceImpl implements SysRoleService {
@Override
public List<SysRole> queryRolesByPagination(PageUtil pageUtil, FindRolePaginDTO findRolePaginDTO) {
SysRole sysRole = new SysRole();
BeanUtils.copyProperties(findRolePaginDTO,sysRole);
sysRole.setNotDeleted();
sysRole.setStart();
return sysRoleRepository.queryRoles(sysRole);
// SysRole sysRole = new SysRole();
// BeanUtils.copyProperties(findRolePaginDTO,sysRole);
// sysRole.setNotDeleted();
// sysRole.setStart();
return sysRoleRepository.queryRoles();
}
@Override
public List<SysRole> queryRolesAll(FindRolePaginDTO findRolePaginDTO) {
SysRole sysRole = new SysRole();
BeanUtils.copyProperties(findRolePaginDTO,sysRole);
sysRole.setNotDeleted();
sysRole.setStart();
return sysRoleRepository.queryRoles(sysRole);
public List<SysRole> queryRolesAll() {
// SysRole sysRole = new SysRole();
// BeanUtils.copyProperties(findRolePaginDTO,sysRole);
// sysRole.setNotDeleted();
// sysRole.setStart();
return sysRoleRepository.queryRoles();
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment