# Conflicts: # src/test/java/com/msdw/tms/service/AchievementManagementTest.javahehai
commit
2e0414c791
55 changed files with 2249 additions and 923 deletions
@ -1,118 +0,0 @@ |
||||
/* |
||||
* Copyright 2007-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import java.net.*; |
||||
import java.io.*; |
||||
import java.nio.channels.*; |
||||
import java.util.Properties; |
||||
|
||||
public class MavenWrapperDownloader { |
||||
|
||||
private static final String WRAPPER_VERSION = "0.5.6"; |
||||
/** |
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. |
||||
*/ |
||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" |
||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; |
||||
|
||||
/** |
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to |
||||
* use instead of the default one. |
||||
*/ |
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = |
||||
".mvn/wrapper/maven-wrapper.properties"; |
||||
|
||||
/** |
||||
* Path where the maven-wrapper.jar will be saved to. |
||||
*/ |
||||
private static final String MAVEN_WRAPPER_JAR_PATH = |
||||
".mvn/wrapper/maven-wrapper.jar"; |
||||
|
||||
/** |
||||
* Name of the property which should be used to override the default download url for the wrapper. |
||||
*/ |
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; |
||||
|
||||
public static void main(String args[]) { |
||||
System.out.println("- Downloader started"); |
||||
File baseDirectory = new File(args[0]); |
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); |
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); |
||||
String url = DEFAULT_DOWNLOAD_URL; |
||||
if (mavenWrapperPropertyFile.exists()) { |
||||
FileInputStream mavenWrapperPropertyFileInputStream = null; |
||||
try { |
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); |
||||
Properties mavenWrapperProperties = new Properties(); |
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); |
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); |
||||
} catch (IOException e) { |
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); |
||||
} finally { |
||||
try { |
||||
if (mavenWrapperPropertyFileInputStream != null) { |
||||
mavenWrapperPropertyFileInputStream.close(); |
||||
} |
||||
} catch (IOException e) { |
||||
// Ignore ...
|
||||
} |
||||
} |
||||
} |
||||
System.out.println("- Downloading from: " + url); |
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); |
||||
if (!outputFile.getParentFile().exists()) { |
||||
if (!outputFile.getParentFile().mkdirs()) { |
||||
System.out.println( |
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); |
||||
} |
||||
} |
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); |
||||
try { |
||||
downloadFileFromURL(url, outputFile); |
||||
System.out.println("Done"); |
||||
System.exit(0); |
||||
} catch (Throwable e) { |
||||
System.out.println("- Error downloading"); |
||||
e.printStackTrace(); |
||||
System.exit(1); |
||||
} |
||||
} |
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception { |
||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { |
||||
String username = System.getenv("MVNW_USERNAME"); |
||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); |
||||
Authenticator.setDefault(new Authenticator() { |
||||
@Override |
||||
protected PasswordAuthentication getPasswordAuthentication() { |
||||
return new PasswordAuthentication(username, password); |
||||
} |
||||
}); |
||||
} |
||||
URL website = new URL(urlString); |
||||
ReadableByteChannel rbc; |
||||
rbc = Channels.newChannel(website.openStream()); |
||||
FileOutputStream fos = new FileOutputStream(destination); |
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); |
||||
fos.close(); |
||||
rbc.close(); |
||||
} |
||||
|
||||
} |
Binary file not shown.
@ -1,2 +0,0 @@ |
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip |
||||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar |
@ -0,0 +1,156 @@ |
||||
package com.msdw.tms.controller; |
||||
|
||||
|
||||
import com.msdw.tms.common.exception.ExceptionCast; |
||||
import com.msdw.tms.common.utils.PageUtils; |
||||
import com.msdw.tms.entity.SysPermission; |
||||
import com.msdw.tms.entity.SysRole; |
||||
import com.msdw.tms.entity.SysRolePermission; |
||||
import com.msdw.tms.entity.request.RolePermissionRequest; |
||||
import com.msdw.tms.entity.response.CommonCode; |
||||
import com.msdw.tms.entity.response.ResponseResult; |
||||
import com.msdw.tms.entity.response.RolePermissionResponse; |
||||
import com.msdw.tms.service.ISysPermissionService; |
||||
import io.swagger.annotations.Api; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.validation.Valid; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* <p> |
||||
* 菜单权限表 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/sys-permission") |
||||
@Api(tags = {"角色权限管理"}) |
||||
public class SysPermissionController { |
||||
|
||||
@Autowired |
||||
private ISysPermissionService permissionService; |
||||
|
||||
/** |
||||
* 权限菜单树形列表展示 |
||||
* @return |
||||
*/ |
||||
@GetMapping("/tree") |
||||
public ResponseResult tree(){ |
||||
List<SysPermission> list = permissionService.listWithTree(); |
||||
return new ResponseResult<List<SysPermission>>().SUCCESS(list); |
||||
} |
||||
|
||||
/** |
||||
* 新增角色权限 |
||||
*/ |
||||
@Transactional |
||||
@PostMapping("/saveRolePermission") |
||||
public ResponseResult saveRolePermission(@Valid @RequestBody RolePermissionRequest rolePermission) { |
||||
Date date = new Date(); |
||||
rolePermission.setCreateTime(date); |
||||
rolePermission.setMotifyTime(date); |
||||
//此处要判重,新增的角色名称要唯一
|
||||
int count = permissionService.uniqueRoleName(rolePermission.getName()); |
||||
if(count >0){ |
||||
ExceptionCast.cast(CommonCode.ROLE_NAME_EXIST); |
||||
} |
||||
//新增角色到角色表
|
||||
int request = permissionService.addHrmsRole(rolePermission); |
||||
//根据选中的permissionId批量新增数据到hrms_role_permission
|
||||
List<Long> asList = Arrays.asList(rolePermission.getPermissionIds()); |
||||
List<RolePermissionRequest> rolePermissionList = getRolePermissionList(asList, rolePermission.getRoleId()); |
||||
boolean result = permissionService.addHrmsRolePermission(rolePermissionList); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
|
||||
private List<RolePermissionRequest> getRolePermissionList(List<Long> asList, Long roleId) { |
||||
return asList.stream().map(permissionId -> { |
||||
RolePermissionRequest request = new RolePermissionRequest(); |
||||
request.setRoleId(roleId); |
||||
request.setPermissionId(permissionId); |
||||
return request; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* 修改角色权限 |
||||
*/ |
||||
@Transactional |
||||
@PostMapping("/updateRolePermission") |
||||
public ResponseResult updateRolePermission(@Valid @RequestBody RolePermissionRequest rolePermission) { |
||||
Date date = new Date(); |
||||
rolePermission.setMotifyTime(date); |
||||
//根据角色Id修改角色内容
|
||||
int request = permissionService.updateHrmsRole(rolePermission); |
||||
//删除该角色Id对应的所有权限
|
||||
List<Long> asList = Arrays.asList(rolePermission.getPermissionIds()); |
||||
permissionService.deleteHrmsRolePermission(rolePermission.getRoleId()); |
||||
//根据选中的permissionId批量新增数据到hrms_role_permission
|
||||
List<RolePermissionRequest> rolePermissionList = getRolePermissionList(asList, rolePermission.getRoleId()); |
||||
boolean result = permissionService.addHrmsRolePermission(rolePermissionList); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
|
||||
/** |
||||
* 删除用户角色权限 |
||||
*/ |
||||
@Transactional |
||||
@PostMapping("/delRolePermission") |
||||
public ResponseResult delRolePermission(@RequestBody RolePermissionRequest rolePermission) { |
||||
//根据角色Id查询该角色是否有用户关联
|
||||
int count = permissionService.queryCountByRoleId(rolePermission.getRoleIds()); |
||||
if(count >0){ |
||||
ExceptionCast.cast(CommonCode.ROLE_EMP_EXIST); |
||||
} |
||||
//没有关联则根据roleId删除hrms_role表对应记录
|
||||
boolean b = permissionService.deleteHrmsRoleByRoleId(rolePermission.getRoleIds()); |
||||
//根据角色id删除对应所有权限
|
||||
boolean result = permissionService.deleteHrmsRolePermission(rolePermission.getRoleIds()); |
||||
|
||||
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); |
||||
} |
||||
|
||||
/** |
||||
* 查看权限数组 |
||||
* @param roleId |
||||
* @return |
||||
*/ |
||||
@GetMapping("/queryPermissionArrById") |
||||
public ResponseResult queryPermissionArrById(@RequestParam("roleId") Long roleId) { |
||||
List<SysRolePermission> list = permissionService.queryPermissionArrById(roleId); |
||||
ArrayList<Integer> sb = new ArrayList<Integer>(); |
||||
for (SysRolePermission rolePermission:list) { |
||||
sb.add(rolePermission.getPermissionId().intValue()); |
||||
} |
||||
Integer[] ids = sb.toArray(new Integer[sb.size()]); |
||||
//根据roleId查询角色名称和角色描述
|
||||
SysRole roleMsg = permissionService.queryRoleMsg(roleId); |
||||
Map map = new HashMap(); |
||||
map.put("permissionIds",ids); |
||||
map.put("name",roleMsg.getName()); |
||||
map.put("description",roleMsg.getDescription()); |
||||
return new ResponseResult<List<RolePermissionResponse>>().SUCCESS(map); |
||||
} |
||||
|
||||
/** |
||||
* 角色权限列表展示 |
||||
* @param page |
||||
* @param size |
||||
* @return |
||||
*/ |
||||
@GetMapping("/rolePermissionList") |
||||
public ResponseResult rolePermissionList(@RequestParam("page") Integer page, |
||||
@RequestParam("size") Integer size,@RequestParam("name")String name) { |
||||
PageUtils data = permissionService.queryPage(page, size, name); |
||||
return new ResponseResult<PageUtils>().SUCCESS(data); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,22 @@ |
||||
package com.msdw.tms.dao; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.msdw.tms.entity.SysPermission; |
||||
import com.msdw.tms.entity.response.RolePermissionResponse; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* <p> |
||||
* 菜单权限表 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Mapper |
||||
public interface SysPermissionMapper extends BaseMapper<SysPermission> { |
||||
|
||||
IPage<RolePermissionResponse> pageByCondition(Page page,String name); |
||||
} |
@ -0,0 +1,28 @@ |
||||
package com.msdw.tms.dao; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.msdw.tms.entity.SysRole; |
||||
import com.msdw.tms.entity.request.RolePermissionRequest; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色表 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Mapper |
||||
public interface SysRoleMapper extends BaseMapper<SysRole> { |
||||
|
||||
int addHrmsRole(RolePermissionRequest rolePermission); |
||||
|
||||
int updateHrmsRole(RolePermissionRequest rolePermission); |
||||
|
||||
boolean deleteHrmsRoleByRoleId(@Param("roleIds") List<Long> roleIds); |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
package com.msdw.tms.dao; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.msdw.tms.entity.SysRolePermission; |
||||
import com.msdw.tms.entity.request.RolePermissionRequest; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 角色权限中间表 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Mapper |
||||
public interface SysRolePermissionMapper extends BaseMapper<SysRolePermission> { |
||||
|
||||
int uniqueRoleName(String name); |
||||
|
||||
boolean addHrmsRolePermission(@Param("rolePermissionList") List<RolePermissionRequest> rolePermissionList); |
||||
|
||||
boolean deleteHrmsRolePermission(@Param("roleIds") List<Long> roleIds); |
||||
|
||||
boolean deleteHrmsRolePermissionSingle(Long roleId); |
||||
|
||||
List<SysRolePermission> queryPermissionArrById(Long roleId); |
||||
} |
@ -0,0 +1,22 @@ |
||||
package com.msdw.tms.dao; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.msdw.tms.entity.SysUserRole; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色中间表 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Mapper |
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> { |
||||
|
||||
int queryCountByRoleId(@Param("roleIds") List<Long> roleIds); |
||||
} |
@ -0,0 +1,100 @@ |
||||
package com.msdw.tms.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import java.util.Date; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 菜单权限表 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Data |
||||
@TableName("sys_permission") |
||||
public class SysPermission implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 权限标识符 |
||||
*/ |
||||
private String code; |
||||
|
||||
/** |
||||
* 名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 父权限id |
||||
*/ |
||||
private Long parentId; |
||||
|
||||
/** |
||||
* 层级 |
||||
*/ |
||||
private Integer level; |
||||
|
||||
/** |
||||
* 是否是菜单:1、是,0、不是(0目前为按钮) |
||||
*/ |
||||
private Integer menuOrNot; |
||||
|
||||
/** |
||||
* 状态:0、启用,1、禁用 |
||||
*/ |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 路径 |
||||
*/ |
||||
private String url; |
||||
|
||||
/** |
||||
* 页面路径 |
||||
*/ |
||||
private String menuUrl; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
private Integer sort; |
||||
|
||||
/** |
||||
* 图标 |
||||
*/ |
||||
private String icon; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
private Date motifyTime; |
||||
|
||||
/** |
||||
* 子权限 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
@TableField(exist = false) |
||||
private List<SysPermission> children; |
||||
} |
@ -0,0 +1,60 @@ |
||||
package com.msdw.tms.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import java.util.Date; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色表 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Data |
||||
@TableName("sys_role") |
||||
public class SysRole implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 角色名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 角色描述 |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* 是否删除:0、未删除,1、删除 |
||||
*/ |
||||
private Integer delOrNot; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
private Date motifyTime; |
||||
|
||||
/** |
||||
* 编码 |
||||
*/ |
||||
private String code; |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.msdw.tms.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p> |
||||
* 角色权限中间表 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Data |
||||
@TableName("sys_role_permission") |
||||
public class SysRolePermission implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 角色id |
||||
*/ |
||||
private Long roleId; |
||||
|
||||
/** |
||||
* 权限id |
||||
*/ |
||||
private Long permissionId; |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.msdw.tms.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色中间表 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Data |
||||
@TableName("sys_user_role") |
||||
public class SysUserRole implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
/** |
||||
* 用户id |
||||
*/ |
||||
private Long userId; |
||||
|
||||
/** |
||||
* 角色id |
||||
*/ |
||||
private Long roleId; |
||||
} |
@ -0,0 +1,83 @@ |
||||
package com.msdw.tms.entity.request; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotEmpty; |
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 记录菜单权限 |
||||
* |
||||
* @author gongsj |
||||
* @email gongsj@gmail.com |
||||
* @date 2020-09-07 17:12:14 |
||||
*/ |
||||
@Data |
||||
public class RolePermissionRequest implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 角色id |
||||
*/ |
||||
private Long roleId; |
||||
|
||||
/** |
||||
* 角色ids |
||||
*/ |
||||
private Long[] roleIds; |
||||
/** |
||||
* 角色名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 角色描述 |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 更新时间 |
||||
*/ |
||||
private Date motifyTime; |
||||
|
||||
/** |
||||
* 权限ids |
||||
*/ |
||||
@NotEmpty(message = "权限至少选中一项!") |
||||
private Long[] permissionIds; |
||||
|
||||
private Long permissionId; |
||||
|
||||
/** |
||||
* 拥有权限名称 |
||||
*/ |
||||
private String permissionName; |
||||
|
||||
/** |
||||
* 父级id |
||||
*/ |
||||
private Long parentId; |
||||
|
||||
/** |
||||
* 子权限 |
||||
*/ |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
@TableField(exist = false) |
||||
private List<RolePermissionRequest> children; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
private Integer sort; |
||||
|
||||
} |
@ -0,0 +1,89 @@ |
||||
package com.msdw.tms.entity.resp; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @ProjectName: tms |
||||
* @Package: com.msdw.tms.entity.resp |
||||
* @ClassName: GetByUserRecordResp |
||||
* @Description: java类作用描述 |
||||
* @Author: Maureen.Rong |
||||
* @CreateDate: 2021/2/25 15:26 |
||||
* @UpdateDate: 2021/2/25 15:26 |
||||
* @Version: 1.0 |
||||
*/ |
||||
|
||||
public class GetByUserRecordResp { |
||||
private String projectName; |
||||
private Integer recordId; |
||||
private Integer score; |
||||
private Integer codeId; |
||||
private String startingTime; |
||||
private String submitTime; |
||||
private Integer timeSum; |
||||
private Integer userId; |
||||
|
||||
public String getProjectName() { |
||||
return projectName; |
||||
} |
||||
|
||||
public void setProjectName(String projectName) { |
||||
this.projectName = projectName; |
||||
} |
||||
|
||||
public Integer getRecordId() { |
||||
return recordId; |
||||
} |
||||
|
||||
public void setRecordId(Integer recordId) { |
||||
this.recordId = recordId; |
||||
} |
||||
|
||||
public Integer getScore() { |
||||
return score; |
||||
} |
||||
|
||||
public void setScore(Integer score) { |
||||
this.score = score; |
||||
} |
||||
|
||||
public Integer getCodeId() { |
||||
return codeId; |
||||
} |
||||
|
||||
public void setCodeId(Integer codeId) { |
||||
this.codeId = codeId; |
||||
} |
||||
|
||||
public String getStartingTime() { |
||||
return startingTime; |
||||
} |
||||
|
||||
public void setStartingTime(String startingTime) { |
||||
this.startingTime = startingTime; |
||||
} |
||||
|
||||
public String getSubmitTime() { |
||||
return submitTime; |
||||
} |
||||
|
||||
public void setSubmitTime(String submitTime) { |
||||
this.submitTime = submitTime; |
||||
} |
||||
|
||||
public Integer getTimeSum() { |
||||
return timeSum; |
||||
} |
||||
|
||||
public void setTimeSum(Integer timeSum) { |
||||
this.timeSum = timeSum; |
||||
} |
||||
|
||||
public Integer getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(Integer userId) { |
||||
this.userId = userId; |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
package com.msdw.tms.entity.response; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 记录菜单权限 |
||||
* |
||||
* @author gongsj |
||||
* @email gongsj@gmail.com |
||||
* @date 2020-09-07 17:12:14 |
||||
*/ |
||||
@Data |
||||
@TableName("hrms_permission") |
||||
public class RolePermissionResponse implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 角色id |
||||
*/ |
||||
@ApiModelProperty("id") |
||||
private Long roleId; |
||||
/** |
||||
* 角色名称 |
||||
*/ |
||||
@ApiModelProperty("名称") |
||||
private String name; |
||||
|
||||
/** |
||||
* 角色描述 |
||||
*/ |
||||
@ApiModelProperty("角色描述") |
||||
private String description; |
||||
|
||||
/** |
||||
* 权限id |
||||
*/ |
||||
@ApiModelProperty("权限id") |
||||
private Long permissionId; |
||||
|
||||
/** |
||||
* 拥有权限名称 |
||||
*/ |
||||
@ApiModelProperty("权限名称") |
||||
private String permissionName; |
||||
|
||||
/** |
||||
* 父级id |
||||
*/ |
||||
@ApiModelProperty("父级id") |
||||
private Long parentId; |
||||
|
||||
/** |
||||
* 子权限 |
||||
*/ |
||||
@ApiModelProperty("子权限") |
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||
@TableField(exist = false) |
||||
private List<RolePermissionResponse> children; |
||||
|
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@ApiModelProperty("子权限") |
||||
private Integer sort; |
||||
|
||||
/** |
||||
* 权限标识 |
||||
*/ |
||||
private String code; |
||||
|
||||
private boolean disabled=true; |
||||
|
||||
} |
@ -0,0 +1,45 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.common.utils.PageUtils; |
||||
import com.msdw.tms.entity.SysPermission; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.msdw.tms.entity.SysRole; |
||||
import com.msdw.tms.entity.SysRolePermission; |
||||
import com.msdw.tms.entity.request.RolePermissionRequest; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 菜单权限表 服务类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
public interface ISysPermissionService extends IService<SysPermission> { |
||||
|
||||
List<SysPermission> listWithTree(); |
||||
|
||||
int uniqueRoleName(String name); |
||||
|
||||
int addHrmsRole(RolePermissionRequest rolePermission); |
||||
|
||||
boolean addHrmsRolePermission(List<RolePermissionRequest> rolePermissionList); |
||||
|
||||
int updateHrmsRole(RolePermissionRequest rolePermission); |
||||
|
||||
boolean deleteHrmsRolePermission(Long roleId); |
||||
|
||||
boolean deleteHrmsRolePermission(Long[] roleIds); |
||||
|
||||
int queryCountByRoleId(Long[] roleIds); |
||||
|
||||
boolean deleteHrmsRoleByRoleId(Long[] roleIds); |
||||
|
||||
List<SysRolePermission> queryPermissionArrById(Long roleId); |
||||
|
||||
SysRole queryRoleMsg(Long roleId); |
||||
|
||||
PageUtils queryPage(Integer page, Integer size, String name); |
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.entity.SysRolePermission; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* <p> |
||||
* 角色权限中间表 服务类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
public interface ISysRolePermissionService extends IService<SysRolePermission> { |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.entity.SysRole; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色表 服务类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
public interface ISysRoleService extends IService<SysRole> { |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.entity.SysUserRole; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色中间表 服务类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
public interface ISysUserRoleService extends IService<SysUserRole> { |
||||
|
||||
} |
@ -0,0 +1,127 @@ |
||||
package com.msdw.tms.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.msdw.tms.common.utils.PageUtils; |
||||
import com.msdw.tms.dao.SysPermissionMapper; |
||||
import com.msdw.tms.dao.SysRoleMapper; |
||||
import com.msdw.tms.dao.SysRolePermissionMapper; |
||||
import com.msdw.tms.dao.SysUserRoleMapper; |
||||
import com.msdw.tms.entity.SysPermission; |
||||
import com.msdw.tms.entity.SysRole; |
||||
import com.msdw.tms.entity.SysRolePermission; |
||||
import com.msdw.tms.entity.request.RolePermissionRequest; |
||||
import com.msdw.tms.entity.response.RolePermissionResponse; |
||||
import com.msdw.tms.service.ISysPermissionService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Arrays; |
||||
import java.util.Comparator; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* <p> |
||||
* 菜单权限表 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Service |
||||
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements ISysPermissionService { |
||||
|
||||
@Resource |
||||
private SysRolePermissionMapper rolePermissionMapper; |
||||
|
||||
@Resource |
||||
private SysRoleMapper roleMapper; |
||||
|
||||
@Resource |
||||
private SysUserRoleMapper userRoleMapper; |
||||
|
||||
@Override |
||||
public List<SysPermission> listWithTree() { |
||||
/* List<SysPermission>list = this.getBaseMapper().queryPermissionTree(); |
||||
return getPermissionTreeList(list,0L);*/ |
||||
System.out.println("this.list()=================="+this.list()); |
||||
return getPermissionTreeList(this.list(), 0L); |
||||
} |
||||
|
||||
private List<SysPermission> getPermissionTreeList(List<SysPermission> list, Long parentId){ |
||||
return list.stream() |
||||
.filter(item -> parentId.equals(item.getParentId())) |
||||
.peek(item -> item.setChildren(getPermissionTreeList(list, item.getId()))) |
||||
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) |
||||
.collect(Collectors.toList()); |
||||
} |
||||
|
||||
@Override |
||||
public int uniqueRoleName(String name) { |
||||
return rolePermissionMapper.uniqueRoleName(name); |
||||
} |
||||
|
||||
@Override |
||||
public int addHrmsRole(RolePermissionRequest rolePermission) { |
||||
int request = roleMapper.addHrmsRole(rolePermission); |
||||
return request; |
||||
} |
||||
|
||||
@Override |
||||
public boolean addHrmsRolePermission(List<RolePermissionRequest> rolePermissionList) { |
||||
return rolePermissionMapper.addHrmsRolePermission(rolePermissionList); |
||||
} |
||||
|
||||
@Override |
||||
public int updateHrmsRole(RolePermissionRequest rolePermission) { |
||||
return roleMapper.updateHrmsRole(rolePermission); |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteHrmsRolePermission(Long roleId) { |
||||
return rolePermissionMapper.deleteHrmsRolePermissionSingle(roleId); |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteHrmsRolePermission(Long[] roleIds) { |
||||
return rolePermissionMapper.deleteHrmsRolePermission(Arrays.asList(roleIds)); |
||||
} |
||||
|
||||
@Override |
||||
public int queryCountByRoleId(Long[] roleIds) { |
||||
int count = userRoleMapper.queryCountByRoleId(Arrays.asList(roleIds)); |
||||
return count; |
||||
} |
||||
|
||||
@Override |
||||
public boolean deleteHrmsRoleByRoleId(Long[] roleIds) { |
||||
return roleMapper.deleteHrmsRoleByRoleId(Arrays.asList(roleIds)); |
||||
} |
||||
|
||||
@Override |
||||
public List<SysRolePermission> queryPermissionArrById(Long roleId) { |
||||
return rolePermissionMapper.queryPermissionArrById(roleId); |
||||
} |
||||
|
||||
@Override |
||||
public SysRole queryRoleMsg(Long roleId) { |
||||
return roleMapper.selectById(roleId); |
||||
} |
||||
|
||||
@Override |
||||
public PageUtils queryPage(Integer page, Integer size, String name) { |
||||
//分页参数
|
||||
if (page <= 0) { |
||||
page = 1; |
||||
} |
||||
if (size <= 0) { |
||||
size = 10; |
||||
} |
||||
IPage<RolePermissionResponse> systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size),name); |
||||
|
||||
return new PageUtils(systemLogVo); |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.msdw.tms.service.impl; |
||||
|
||||
import com.msdw.tms.dao.SysRolePermissionMapper; |
||||
import com.msdw.tms.entity.SysRolePermission; |
||||
import com.msdw.tms.service.ISysRolePermissionService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 角色权限中间表 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Service |
||||
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements ISysRolePermissionService { |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.msdw.tms.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.msdw.tms.dao.SysRoleMapper; |
||||
import com.msdw.tms.entity.SysRole; |
||||
import com.msdw.tms.service.ISysRoleService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色表 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Service |
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService { |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.msdw.tms.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.msdw.tms.dao.SysUserRoleMapper; |
||||
import com.msdw.tms.entity.SysUserRole; |
||||
import com.msdw.tms.service.ISysUserRoleService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* <p> |
||||
* 用户角色中间表 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author Qyq |
||||
* @since 2021-02-24 |
||||
*/ |
||||
@Service |
||||
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService { |
||||
|
||||
} |
@ -0,0 +1,115 @@ |
||||
package com.msdw.tms.util; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import com.baomidou.mybatisplus.generator.AutoGenerator; |
||||
import com.baomidou.mybatisplus.generator.InjectionConfig; |
||||
import com.baomidou.mybatisplus.generator.config.*; |
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType; |
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: LvFang |
||||
* @Date: Created in 2019/6/11. |
||||
* @Description: |
||||
*/ |
||||
public class MyBatisPlusCodeGenerator { |
||||
|
||||
//包名
|
||||
public static final String PACKAGE_NAME = "com.msdw.tms"; |
||||
|
||||
public static void main(String[] args) { |
||||
String[] tables = new String[] {"sys_role","sys_role_permission","sys_user_role"};//表名数组
|
||||
String[] tablePrefixs = new String[] {""};//去掉前缀
|
||||
executeCode(PACKAGE_NAME,tables,tablePrefixs); |
||||
} |
||||
|
||||
private static void executeCode(String pack, String[] tables, String[] tablePrefixs) { |
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator(); |
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig(); |
||||
// 是否覆盖已有文件
|
||||
gc.setFileOverride(false); |
||||
// 生成文件的输出目录
|
||||
String projectPath = System.getProperty("user.dir");//user.dir 表示当前工程路径无需替换
|
||||
gc.setOutputDir(projectPath + "/src/main/java"); |
||||
//设置bean命名规范
|
||||
gc.setEntityName("%s"); |
||||
// 开发人员
|
||||
gc.setAuthor("Qyq"); |
||||
// 是否打开输出目录
|
||||
gc.setOpen(false); |
||||
// 开启 BaseResultMap
|
||||
gc.setBaseResultMap(true); |
||||
// 指定生成的主键的ID类型
|
||||
gc.setIdType(IdType.ID_WORKER); |
||||
// 时间类型对应策略: 只使用 java.util.date 代替
|
||||
gc.setDateType(DateType.ONLY_DATE); |
||||
mpg.setGlobalConfig(gc); |
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig config= new DataSourceConfig(); |
||||
// 从试图获取
|
||||
config.setUrl("jdbc:mysql://localhost:3306/msdw_tms?serverTimezone=UTC"); |
||||
config.setDriverName("com.mysql.cj.jdbc.Driver"); |
||||
config.setUsername("root"); |
||||
config.setPassword("root"); |
||||
mpg.setDataSource(config); |
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig(); |
||||
// 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
|
||||
pc.setParent(pack); |
||||
// Entity包名
|
||||
pc.setEntity("entity"); |
||||
mpg.setPackageInfo(pc); |
||||
|
||||
// 自定义配置
|
||||
InjectionConfig cfg = new InjectionConfig() { |
||||
@Override |
||||
public void initMap() { |
||||
// to do nothing
|
||||
} |
||||
}; |
||||
List<FileOutConfig> focList = new ArrayList<>(); |
||||
focList.add(new FileOutConfig("/templates/mapper.xml.ftl") { |
||||
public String outputFile(TableInfo tableInfo) { |
||||
// 自定义输入文件名称
|
||||
if (StringUtils.isEmpty(pc.getModuleName())) { |
||||
return projectPath + "/src/main/resources/mapper/tms/" + tableInfo.getXmlName() + StringPool.DOT_XML; |
||||
}else { |
||||
return projectPath + "/src/main/resources/mapper/tms/" + pc.getModuleName() + "/" + tableInfo.getXmlName() + StringPool.DOT_XML; |
||||
} |
||||
} |
||||
}); |
||||
cfg.setFileOutConfigList(focList); |
||||
mpg.setCfg(cfg); |
||||
mpg.setTemplate(new TemplateConfig().setXml(null)); |
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig(); |
||||
// 数据库表映射到实体的命名策略: 下划线转驼峰命名
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel); |
||||
// 数据库表字段映射到实体的命名策略: 下划线转驼峰命名
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel); |
||||
// 【实体】是否为lombok模型(默认 false)
|
||||
strategy.setEntityLombokModel(false); |
||||
// 需要包含的表名,允许正则表达式(与exclude二选一配置)
|
||||
strategy.setInclude(tables); |
||||
// 驼峰转连字符
|
||||
strategy.setControllerMappingHyphenStyle(true); |
||||
// 表前缀
|
||||
strategy.setTablePrefix(tablePrefixs); |
||||
mpg.setStrategy(strategy); |
||||
mpg.setTemplateEngine(new FreemarkerTemplateEngine()); |
||||
mpg.execute(); |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
<?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.msdw.tms.dao.SysPermissionMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="BaseResultMap" type="com.msdw.tms.entity.SysPermission"> |
||||
<id column="id" property="id" /> |
||||
<result column="code" property="code" /> |
||||
<result column="name" property="name" /> |
||||
<result column="parent_id" property="parentId" /> |
||||
<result column="level" property="level" /> |
||||
<result column="menu_or_not" property="menuOrNot" /> |
||||
<result column="status" property="status" /> |
||||
<result column="url" property="url" /> |
||||
<result column="menu_url" property="menuUrl" /> |
||||
<result column="sort" property="sort" /> |
||||
<result column="icon" property="icon" /> |
||||
<result column="create_time" property="createTime" /> |
||||
<result column="motify_time" property="motifyTime" /> |
||||
</resultMap> |
||||
|
||||
<select id="pageByCondition" resultType="com.msdw.tms.entity.response.RolePermissionResponse"> |
||||
select rp.role_id as roleId, hr.`name`,hr.description,GROUP_CONCAT(hp.`name`separator '/') as permissionName |
||||
FROM sys_role_permission rp |
||||
LEFT JOIN sys_role hr on hr.id = rp.role_id |
||||
LEFT JOIN sys_permission hp on hp.id= rp.permission_id |
||||
<where> |
||||
hr.del_or_not=0 |
||||
<if test="name != null and name != ''"> |
||||
AND hr.name LIKE CONCAT('%' #{name} '%') |
||||
</if> |
||||
</where> |
||||
GROUP BY rp.role_id |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,40 @@ |
||||
<?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.msdw.tms.dao.SysRoleMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="BaseResultMap" type="com.msdw.tms.entity.SysRole"> |
||||
<id column="id" property="id" /> |
||||
<result column="name" property="name" /> |
||||
<result column="description" property="description" /> |
||||
<result column="del_or_not" property="delOrNot" /> |
||||
<result column="create_time" property="createTime" /> |
||||
<result column="motify_time" property="motifyTime" /> |
||||
<result column="code" property="code" /> |
||||
</resultMap> |
||||
|
||||
<insert id="addHrmsRole" parameterType="com.msdw.tms.entity.request.RolePermissionRequest" |
||||
useGeneratedKeys="true" keyProperty="roleId" keyColumn="id"> |
||||
INSERT INTO sys_role |
||||
(`name`,description,create_time,motify_time) |
||||
values (#{name},#{description},#{createTime},#{motifyTime}); |
||||
</insert> |
||||
|
||||
<update id="updateHrmsRole" parameterType="com.msdw.tms.entity.request.RolePermissionRequest"> |
||||
UPDATE sys_role |
||||
<set> |
||||
`name`=#{name}, |
||||
description=#{description}, |
||||
motify_time=#{motifyTime}, |
||||
</set> |
||||
WHERE id = #{roleId} |
||||
</update> |
||||
|
||||
<delete id="deleteHrmsRoleByRoleId"> |
||||
update sys_role set del_or_not = 1 where id IN |
||||
<foreach collection="roleIds" index="index" open="(" separator="," close=")" item="item"> |
||||
#{item} |
||||
</foreach> |
||||
</delete> |
||||
|
||||
</mapper> |
@ -0,0 +1,38 @@ |
||||
<?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.msdw.tms.dao.SysRolePermissionMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="BaseResultMap" type="com.msdw.tms.entity.SysRolePermission"> |
||||
<id column="id" property="id" /> |
||||
<result column="role_id" property="roleId" /> |
||||
<result column="permission_id" property="permissionId" /> |
||||
</resultMap> |
||||
|
||||
<select id="uniqueRoleName" parameterType="string" resultType="java.lang.Integer"> |
||||
select count(0) from sys_role where `name` = #{name} |
||||
</select> |
||||
|
||||
<insert id="addHrmsRolePermission" parameterType="com.msdw.tms.entity.request.RolePermissionRequest"> |
||||
INSERT INTO sys_role_permission (role_id,permission_id) values |
||||
<foreach collection="rolePermissionList" index="index" separator="," item="item"> |
||||
(#{item.roleId},#{item.permissionId}) |
||||
</foreach> |
||||
</insert> |
||||
|
||||
<delete id="deleteHrmsRolePermission"> |
||||
delete from sys_role_permission where role_id in |
||||
<foreach collection="roleIds" index="index" open="(" separator="," close=")" item="item"> |
||||
#{item} |
||||
</foreach> |
||||
</delete> |
||||
|
||||
<delete id="deleteHrmsRolePermissionSingle"> |
||||
delete from sys_role_permission where role_id=#{roleId} |
||||
</delete> |
||||
|
||||
<select id="queryPermissionArrById" resultMap="BaseResultMap"> |
||||
select id, permission_id from sys_role_permission where role_id = #{roleId} |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,19 @@ |
||||
<?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.msdw.tms.dao.SysUserRoleMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="BaseResultMap" type="com.msdw.tms.entity.SysUserRole"> |
||||
<id column="id" property="id" /> |
||||
<result column="user_id" property="userId" /> |
||||
<result column="role_id" property="roleId" /> |
||||
</resultMap> |
||||
|
||||
<select id="queryCountByRoleId" resultType="java.lang.Integer"> |
||||
select count(0) from sys_user_role where role_id in |
||||
<foreach collection="roleIds" index="index" open="(" separator="," close=")" item="item"> |
||||
#{item} |
||||
</foreach> |
||||
</select> |
||||
|
||||
</mapper> |
@ -1,142 +1,145 @@ |
||||
package com.msdw.tms.service; |
||||
|
||||
import com.msdw.tms.common.utils.R; |
||||
import com.msdw.tms.dao.AchievementManagementDao; |
||||
import com.msdw.tms.entity.ProjectRecordEntity; |
||||
import com.msdw.tms.entity.request.AchievementImportRequest; |
||||
import com.msdw.tms.entity.vo.AchievementManagementVO; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@SpringBootTest |
||||
public class AchievementManagementTest { |
||||
|
||||
@Autowired |
||||
private AchievementManagementService achievementManagementService; |
||||
|
||||
@Autowired |
||||
private ProjectRecordService projectRecordService; |
||||
|
||||
@Autowired |
||||
AchievementManagementDao achievementManagementDao; |
||||
|
||||
//测试新增实验记录
|
||||
//package com.msdw.tms.service;
|
||||
//
|
||||
//import com.msdw.tms.common.utils.R;
|
||||
//import com.msdw.tms.dao.AchievementManagementDao;
|
||||
//import com.msdw.tms.entity.ProjectEntity;
|
||||
//import com.msdw.tms.entity.ProjectRecordEntity;
|
||||
//import com.msdw.tms.entity.request.AchievementImportRequest;
|
||||
//import com.msdw.tms.entity.vo.AchievementManagementVo;
|
||||
//import com.msdw.tms.entity.vo.SearchAchievementVo;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@SpringBootTest
|
||||
//public class AchievementManagementTest {
|
||||
//
|
||||
// @Autowired
|
||||
// private AchievementManagementService achievementManagementService;
|
||||
//
|
||||
// @Autowired
|
||||
// private ProjectRecordService projectRecordService;
|
||||
//
|
||||
// @Autowired
|
||||
// AchievementManagementDao achievementManagementDao;
|
||||
//
|
||||
// //测试新增实验记录
|
||||
//// @Test
|
||||
//// public void addReport(){
|
||||
//// AchievementManagementVo vo = new AchievementManagementVo();
|
||||
//// ProjectRecordEntity entity = new ProjectRecordEntity();
|
||||
//// Date date = new Date();
|
||||
//// //用户id
|
||||
//// Integer userId = 385;
|
||||
////
|
||||
//// entity.setUserid(userId)
|
||||
//// .setProjectid(368)
|
||||
//// .setScore(100)
|
||||
//// .setRecordstate(0)
|
||||
//// .setStartingtime(date)
|
||||
//// .setEndtime(date)
|
||||
//// .setSubmittime(date)
|
||||
//// .setTimeSum(0)
|
||||
//// .setIsdel(0);
|
||||
//// vo.setUserId(userId)
|
||||
//// .setEvaluationId(158)
|
||||
//// .setExperimentalGoal("目标2")
|
||||
//// .setPrinciple("原理2")
|
||||
//// .setStep("步骤2")
|
||||
//// .setAnalysis("实验分析2")
|
||||
//// .setSummarize("实验总结2")
|
||||
//// .setImprovement("实验建议2")
|
||||
//// .setCommentId(3)
|
||||
//// .setTeacherId(178)
|
||||
//// .setPeriod("学时")
|
||||
//// .setLaboratory("实验室名称2")
|
||||
//// .setIsSignature(0)
|
||||
//// .setSignatureId(4)
|
||||
//// .setIsdel(0);
|
||||
//// vo.setEntity(entity);
|
||||
//// R r = achievementManagementService.addReport(vo);
|
||||
//// System.out.println(r);
|
||||
//// }
|
||||
//
|
||||
// @Test
|
||||
// public void addReport(){
|
||||
// AchievementManagementVO vo = new AchievementManagementVO();
|
||||
// ProjectRecordEntity entity = new ProjectRecordEntity();
|
||||
// Date date = new Date();
|
||||
// //用户id
|
||||
// Integer userId = 385;
|
||||
// public void queryReport(){
|
||||
// Integer reportId = 4;
|
||||
// Integer recordId = 100;
|
||||
// R r = achievementManagementService.queryReport(reportId);
|
||||
// System.out.println(r);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void updateScore(){
|
||||
// ProjectRecordEntity vo = new ProjectRecordEntity();
|
||||
// Integer recordId = 100;
|
||||
// Integer score = 99;
|
||||
// vo.setRecordid(recordId).setScore(score);
|
||||
// projectRecordService.updateScore(vo);
|
||||
// }
|
||||
//
|
||||
// entity.setUserid(userId)
|
||||
// .setProjectid(368)
|
||||
// .setScore(100)
|
||||
// .setRecordstate(0)
|
||||
// .setStartingtime(date)
|
||||
// .setEndtime(date)
|
||||
// .setSubmittime(date)
|
||||
// .setTimeSum(0)
|
||||
// .setIsdel(0);
|
||||
// vo.setUserId(userId)
|
||||
// .setEvaluationId(158)
|
||||
// .setExperimentalGoal("目标2")
|
||||
// .setPrinciple("原理2")
|
||||
// .setStep("步骤2")
|
||||
// .setAnalysis("实验分析2")
|
||||
// .setSummarize("实验总结2")
|
||||
// .setImprovement("实验建议2")
|
||||
// .setCommentId(3)
|
||||
// .setTeacherId(178)
|
||||
// .setPeriod("学时")
|
||||
// .setLaboratory("实验室名称2")
|
||||
// .setIsSignature(0)
|
||||
// .setSignatureId(4)
|
||||
// .setIsdel(0);
|
||||
// @Test
|
||||
// public void daleteReport(){
|
||||
// Integer reportId = 4;
|
||||
// Integer recordId = 100;
|
||||
// AchievementManagementVo vo = new AchievementManagementVo();
|
||||
// ProjectRecordEntity entity = new ProjectRecordEntity();
|
||||
// entity.setRecordid(recordId);
|
||||
// vo.setReportId(reportId);
|
||||
// vo.setEntity(entity);
|
||||
// R r = achievementManagementService.addReport(vo);
|
||||
// R r = achievementManagementService.deleteReport(reportId);
|
||||
// System.out.println(r);
|
||||
// }
|
||||
|
||||
@Test |
||||
public void queryReport(){ |
||||
Integer reportId = 4; |
||||
Integer recordId = 100; |
||||
R r = achievementManagementService.queryReport(reportId); |
||||
System.out.println(r); |
||||
} |
||||
|
||||
@Test |
||||
public void updateScore(){ |
||||
ProjectRecordEntity vo = new ProjectRecordEntity(); |
||||
Integer recordId = 100; |
||||
Integer score = 99; |
||||
vo.setRecordid(recordId).setScore(score); |
||||
projectRecordService.updateScore(vo); |
||||
} |
||||
|
||||
@Test |
||||
public void daleteReport(){ |
||||
Integer reportId = 4; |
||||
Integer recordId = 100; |
||||
AchievementManagementVO vo = new AchievementManagementVO(); |
||||
ProjectRecordEntity entity = new ProjectRecordEntity(); |
||||
entity.setRecordid(recordId); |
||||
vo.setReportId(reportId); |
||||
vo.setEntity(entity); |
||||
R r = achievementManagementService.deleteReport(reportId); |
||||
System.out.println(r); |
||||
} |
||||
|
||||
//测试查询班级实验成绩列表
|
||||
@Test |
||||
public void queryEvaluationReport(){ |
||||
String searchContant = "michonne"; |
||||
// String searchContant = "";
|
||||
Integer projectId = 368; |
||||
Integer page = 1; |
||||
Integer size = 2; |
||||
R r = achievementManagementService.queryEvaluationReport(searchContant,projectId,page,size); |
||||
System.out.println(r); |
||||
} |
||||
|
||||
//筛选查询-教学实验
|
||||
@Test |
||||
public void queryEvaluationReportByRecordId(){ |
||||
Integer month = 1; |
||||
Integer systemId = 1; |
||||
String searchContent= ""; |
||||
String staingTime = ""; |
||||
String endTime = ""; |
||||
List<Integer> list = achievementManagementDao.countEducationProjectId(); |
||||
List<AchievementManagementVO> result = achievementManagementDao.queryEducationRecord(systemId, searchContent, staingTime, endTime, month, list); |
||||
System.out.println(result); |
||||
} |
||||
//筛选查询-虚拟实验
|
||||
@Test |
||||
public void queryFictitiousReportByRecordId(){ |
||||
Integer month = null; |
||||
Integer systemId = 1; |
||||
String searchContent= ""; |
||||
String staingTime = ""; |
||||
String endTime = ""; |
||||
List<Integer> list = achievementManagementDao.countFictitiousProjectId(); |
||||
List<AchievementManagementVO> result = achievementManagementDao.queryFictitiousRecord(systemId, searchContent, staingTime, endTime, month, list); |
||||
System.out.println(result); |
||||
} |
||||
|
||||
@Test |
||||
public void testQuery(){ |
||||
// String str = "184,185";
|
||||
ArrayList<Integer> integers = new ArrayList<>(); |
||||
integers.add(184); |
||||
integers.add(185); |
||||
|
||||
List<AchievementImportRequest> achievementImportRequests = achievementManagementDao.queryAchievement(integers); |
||||
System.out.println(achievementImportRequests); |
||||
} |
||||
} |
||||
//
|
||||
// //测试查询班级实验成绩列表
|
||||
// @Test
|
||||
// public void queryEvaluationReport(){
|
||||
// String searchContant = "michonne";
|
||||
// // String searchContant = "";
|
||||
// Integer projectId = 368;
|
||||
// Integer page = 1;
|
||||
// Integer size = 2;
|
||||
// R r = achievementManagementService.queryEvaluationReport(searchContant,projectId,page,size);
|
||||
// System.out.println(r);
|
||||
//}
|
||||
//
|
||||
// //筛选查询-教学实验
|
||||
// @Test
|
||||
// public void queryEvaluationReportByRecordId(){
|
||||
// Integer month = 1;
|
||||
// Integer systemId = 1;
|
||||
// String searchContent= "";
|
||||
// String staingTime = "";
|
||||
// String endTime = "";
|
||||
// List<Integer> list = achievementManagementDao.countEducationProjectId();
|
||||
// List<AchievementManagementVo> result = achievementManagementDao.queryEducationRecord(systemId, searchContent, staingTime, endTime, month, list);
|
||||
// System.out.println(result);
|
||||
// }
|
||||
// //筛选查询-虚拟实验
|
||||
// @Test
|
||||
// public void queryFictitiousReportByRecordId(){
|
||||
// Integer month = null;
|
||||
// Integer systemId = 1;
|
||||
// String searchContent= "";
|
||||
// String staingTime = "";
|
||||
// String endTime = "";
|
||||
// List<Integer> list = achievementManagementDao.countFictitiousProjectId();
|
||||
// List<AchievementManagementVo> result = achievementManagementDao.queryFictitiousRecord(systemId, searchContent, staingTime, endTime, month, list);
|
||||
// System.out.println(result);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testQuery(){
|
||||
//// String str = "184,185";
|
||||
// ArrayList<Integer> integers = new ArrayList<>();
|
||||
// integers.add(184);
|
||||
// integers.add(185);
|
||||
//
|
||||
// List<AchievementImportRequest> achievementImportRequests = achievementManagementDao.queryAchievement(integers);
|
||||
// System.out.println(achievementImportRequests);
|
||||
// }
|
||||
//}
|
||||
|
Loading…
Reference in new issue