Commit 3c95d9d8 authored by luzhuang's avatar luzhuang

sysRole

parent 38d84421
...@@ -29,7 +29,7 @@ import java.util.ArrayList; ...@@ -29,7 +29,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Api(tags = "3 分类接口") @Api(tags = "3 课程分类")
@RestController @RestController
@RequestMapping("/BCourse") @RequestMapping("/BCourse")
public class BCourseController extends PaginationController<BCourse> { public class BCourseController extends PaginationController<BCourse> {
...@@ -73,7 +73,7 @@ public class BCourseController extends PaginationController<BCourse> { ...@@ -73,7 +73,7 @@ public class BCourseController extends PaginationController<BCourse> {
bCourseRepository.queryFirstLevel()); bCourseRepository.queryFirstLevel());
} }
@ApiOperation(value = "304 物理删除", notes = "根据ID删除一条记录") @ApiOperation(value = "304 逻辑删除", notes = "根据ID删除一条记录")
@ApiImplicitParam(name = "businessId", value = "课程分类id", required = true, dataType = "varchar") @ApiImplicitParam(name = "businessId", value = "课程分类id", required = true, dataType = "varchar")
@PostMapping(value = "/remove") @PostMapping(value = "/remove")
public Result remove(CurUser curUser, @Valid String businessId, BindingResult br) { public Result remove(CurUser curUser, @Valid String businessId, BindingResult br) {
......
...@@ -24,8 +24,8 @@ import java.util.List; ...@@ -24,8 +24,8 @@ import java.util.List;
/** /**
* Created by lcy on 16/7/30. * Created by lcy on 16/7/30.
*/ */
@RestController //@RestController
@RequestMapping("/dept") //@RequestMapping("/dept")
public class SysDeptController extends ResponseController { public class SysDeptController extends ResponseController {
@Autowired @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; package org.rcisoft.sys.role.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -24,6 +25,7 @@ import java.util.List; ...@@ -24,6 +25,7 @@ import java.util.List;
/** /**
* Created by lcy on 16/7/30. * Created by lcy on 16/7/30.
*/ */
@Api(tags = "10 用户角色")
@RestController @RestController
@RequestMapping("/role") @RequestMapping("/role")
public class SysRoleController extends PaginationController<SysRole> { public class SysRoleController extends PaginationController<SysRole> {
...@@ -32,7 +34,7 @@ public class SysRoleController extends PaginationController<SysRole> { ...@@ -32,7 +34,7 @@ public class SysRoleController extends PaginationController<SysRole> {
private SysRoleService sysRoleServiceImpl; private SysRoleService sysRoleServiceImpl;
@ApiOperation(value="分页查询角色", notes="分页查询角色") @ApiOperation(value="1001 分页查询角色", notes="分页查询角色")
@GetMapping(value = "/queryRoles") @GetMapping(value = "/queryRoles")
public GridModel queryRolesByPagination(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){ public GridModel queryRolesByPagination(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){
sysRoleServiceImpl.queryRolesByPagination(getPaginationUtility(), findRolePaginDTO); sysRoleServiceImpl.queryRolesByPagination(getPaginationUtility(), findRolePaginDTO);
...@@ -40,20 +42,17 @@ public class SysRoleController extends PaginationController<SysRole> { ...@@ -40,20 +42,17 @@ public class SysRoleController extends PaginationController<SysRole> {
return gridModel; return gridModel;
} }
@ApiOperation(value="查询全部角色", notes="查询全部角色") @ApiOperation(value="1002 查询全部角色", notes="查询全部角色")
@GetMapping(value = "/queryRolesAll") @GetMapping(value = "/queryRolesAll")
public Result queryRolesAll(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){ public Result queryRolesAll(CurUser curUser){
sysRoleServiceImpl.queryRolesAll(findRolePaginDTO);
GridModel gridModel = getGridModelResponse();
// return gridModel;
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
sysRoleServiceImpl.queryRolesAll(findRolePaginDTO)); sysRoleServiceImpl.queryRolesAll());
} }
@ApiOperation(value="增加/修改角色", notes="增加/修改角色") @ApiOperation(value="1003 增加/修改角色", notes="增加/修改角色")
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result roleAdd(CurUser curUser, @Valid AddOrUpdateRoleDTO addOrUpdateRoleDTO, BindingResult bindingResult){ public Result roleAdd(CurUser curUser, @Valid AddOrUpdateRoleDTO addOrUpdateRoleDTO, BindingResult bindingResult){
int line = sysRoleServiceImpl.persistRole(addOrUpdateRoleDTO); int line = sysRoleServiceImpl.persistRole(addOrUpdateRoleDTO);
...@@ -64,7 +63,7 @@ public class SysRoleController extends PaginationController<SysRole> { ...@@ -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") @ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar", paramType = "path")
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
public Result roleDelete(CurUser curUser, String businessId, BindingResult bindingResult){ public Result roleDelete(CurUser curUser, String businessId, BindingResult bindingResult){
......
...@@ -23,17 +23,16 @@ import java.util.Map; ...@@ -23,17 +23,16 @@ import java.util.Map;
public interface SysRoleRepository extends BaseMapper<SysRole> { public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 分页查询 roles * 分页查询 roles
* @param sysRole *
* @param
* @return * @return
*/ */
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' " @Select("<script>select * from s_role where flag = '1' and del_flag = '0' " +
+ " <if test=\"code !=null and code != ''\">and code = #{code} </if> " "AND role_name not in('主管理员','子管理员')" +
+ " <if test=\"roleName !=null and roleName != ''\">and role_name = #{roleName} </if> " " order by create_date desc" +
+" and code NOT in ('ROLE_1001','ROLE_1002','ROLE_1003')" "</script>")
+ " order by create_date desc" @ResultMap(value = "SelectAllAndUserNum")
+ "</script>") List<SysRole> queryRoles();
@ResultMap(value = "SelectAllAndUserNum" )
List<SysRole> queryRoles(SysRole sysRole);
//获得此角色的用户数 //获得此角色的用户数
int countUserNum(String roleId); int countUserNum(String roleId);
...@@ -41,11 +40,12 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -41,11 +40,12 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@Select("<script>select * from s_role where " @Select("<script>select * from s_role where "
+ "DEL_FLAG='0' " + "DEL_FLAG='0' "
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesSelect(SysRole sysRole); List<SysRole> queryRolesSelect(SysRole sysRole);
/** /**
* 根据角色id 删除对应权限 * 根据角色id 删除对应权限
*
* @param roleId * @param roleId
* @return * @return
*/ */
...@@ -55,6 +55,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -55,6 +55,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 根据角色id 删除对应部门 * 根据角色id 删除对应部门
*
* @param roleId * @param roleId
* @return * @return
*/ */
...@@ -63,6 +64,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -63,6 +64,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 批量插入 角色_权限 * 批量插入 角色_权限
*
* @param menuRole * @param menuRole
* @return * @return
*/ */
...@@ -71,12 +73,15 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -71,12 +73,15 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 批量插入 角色_部门 * 批量插入 角色_部门
*
* @param deptRole * @param deptRole
* @return * @return
*/ */
int insertBatchRoleDept(List<Map> deptRole); int insertBatchRoleDept(List<Map> deptRole);
/** /**
* 分页查询 roles * 分页查询 roles
*
* @param sysRole * @param sysRole
* @return * @return
*/ */
...@@ -89,12 +94,13 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -89,12 +94,13 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
+ " FROM s_dept_role dr " + " FROM s_dept_role dr "
+ " LEFT JOIN s_dept d ON d.BUSINESS_ID = dr.DEPT_ID " + " 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>") + " LEFT JOIN s_role r on dr.ROLE_ID = r.BUSINESS_ID</script>")
@ResultMap(value = "drResultMap" ) @ResultMap(value = "drResultMap")
List<DeptRole> queryUserRolesByPagination(@Param("userId") String userId, SysRole sysRole) ; List<DeptRole> queryUserRolesByPagination(@Param("userId") String userId, SysRole sysRole);
/** /**
* 分页查询 roles * 分页查询 roles
*
* @param sysRole * @param sysRole
* @return * @return
*/ */
...@@ -124,7 +130,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -124,7 +130,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
" s_role sysRole " + " s_role sysRole " +
"WHERE " + "WHERE " +
" DEL_FLAG = '0' and FLAG = '1'</script>") " DEL_FLAG = '0' and FLAG = '1'</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap")
List<SysRole> queryDeptRolesByPagination(@Param("deptId") String deptId, SysRole sysRole); List<SysRole> queryDeptRolesByPagination(@Param("deptId") String deptId, SysRole sysRole);
@Delete("<script>DELETE from s_dept_role_user where DEPT_ROLE_ID=" @Delete("<script>DELETE from s_dept_role_user where DEPT_ROLE_ID="
...@@ -135,6 +141,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -135,6 +141,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 删除岗位 * 删除岗位
*
* @param roleId * @param roleId
* @return * @return
*/ */
...@@ -143,6 +150,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -143,6 +150,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 删除权限 * 删除权限
*
* @param roleId * @param roleId
* @return * @return
*/ */
...@@ -180,7 +188,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -180,7 +188,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' " @Select("<script>select * from s_role where flag = '1' and del_flag = '0' "
+ "and (code = #{code} or role_name = #{roleName}) " + "and (code = #{code} or role_name = #{roleName}) "
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesByCodeOrName(SysRole sysRole); List<SysRole> queryRolesByCodeOrName(SysRole sysRole);
@Delete("<script>DELETE from s_r_user_role where role_id=#{id}</script>") @Delete("<script>DELETE from s_r_user_role where role_id=#{id}</script>")
...@@ -189,7 +197,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -189,7 +197,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@Select("<script>select * from s_role where flag = '1' and del_flag = '0' " @Select("<script>select * from s_role where flag = '1' and del_flag = '0' "
+ "and role_name = #{roleName}" + "and role_name = #{roleName}"
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesByName(SysRole sysRole); List<SysRole> queryRolesByName(SysRole sysRole);
// @Select("SELECT COUNT(*) FROM s_menu sm \n" + // @Select("SELECT COUNT(*) FROM s_menu sm \n" +
...@@ -206,6 +214,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -206,6 +214,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
/** /**
* 根据子表id 删除 s_r_user_role * 根据子表id 删除 s_r_user_role
*
* @param tableByKey * @param tableByKey
* @param businessId * @param businessId
* @return * @return
...@@ -229,5 +238,5 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -229,5 +238,5 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"\t\t\t\t\t${tb}.business_id = #{cid}\n" + "\t\t\t\t\t${tb}.business_id = #{cid}\n" +
"\t\t\t) ab\n" + "\t\t\t) ab\n" +
"\t)") "\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 { ...@@ -44,7 +44,7 @@ public interface SysRoleService {
List<SysRole> queryRolesByPagination(PageUtil pageUtil, FindRolePaginDTO findRolePaginDTO); List<SysRole> queryRolesByPagination(PageUtil pageUtil, FindRolePaginDTO findRolePaginDTO);
List<SysRole> queryRolesAll(FindRolePaginDTO findRolePaginDTO); List<SysRole> queryRolesAll();
//select //select
List<SysRole> queryRolesSelect(SysRole sysRole); List<SysRole> queryRolesSelect(SysRole sysRole);
......
...@@ -85,20 +85,20 @@ public class SysRoleServiceImpl implements SysRoleService { ...@@ -85,20 +85,20 @@ public class SysRoleServiceImpl implements SysRoleService {
@Override @Override
public List<SysRole> queryRolesByPagination(PageUtil pageUtil, FindRolePaginDTO findRolePaginDTO) { public List<SysRole> queryRolesByPagination(PageUtil pageUtil, FindRolePaginDTO findRolePaginDTO) {
SysRole sysRole = new SysRole(); // SysRole sysRole = new SysRole();
BeanUtils.copyProperties(findRolePaginDTO,sysRole); // BeanUtils.copyProperties(findRolePaginDTO,sysRole);
sysRole.setNotDeleted(); // sysRole.setNotDeleted();
sysRole.setStart(); // sysRole.setStart();
return sysRoleRepository.queryRoles(sysRole); return sysRoleRepository.queryRoles();
} }
@Override @Override
public List<SysRole> queryRolesAll(FindRolePaginDTO findRolePaginDTO) { public List<SysRole> queryRolesAll() {
SysRole sysRole = new SysRole(); // SysRole sysRole = new SysRole();
BeanUtils.copyProperties(findRolePaginDTO,sysRole); // BeanUtils.copyProperties(findRolePaginDTO,sysRole);
sysRole.setNotDeleted(); // sysRole.setNotDeleted();
sysRole.setStart(); // sysRole.setStart();
return sysRoleRepository.queryRoles(sysRole); return sysRoleRepository.queryRoles();
} }
@Override @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