Compare commits
25 Commits
1a65d8ce8f
...
71bd92d18e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
71bd92d18e | ||
2880ffefa7 | |||
![]() |
2bd1d796ed | ||
![]() |
d2dc0527ab | ||
![]() |
84d3ccc5af | ||
0516e8dce4 | |||
80478baf76 | |||
a10fbce2f8 | |||
6b0c58dea9 | |||
3e67b5b94c | |||
![]() |
22cb95d1d3 | ||
045147dc30 | |||
75d471b1b6 | |||
65a13ff549 | |||
0a788005a6 | |||
87bb3fb069 | |||
a2cd19675e | |||
f0f6e53ba2 | |||
2086361a8d | |||
b368dadc3c | |||
fe62d918dc | |||
e5b87e6f4f | |||
49bcadd483 | |||
1d914a5217 | |||
![]() |
7db82c57e2 |
@ -2,7 +2,22 @@
|
|||||||
<configuration default="false" name="oa [clean,spring-boot:run]" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
|
<configuration default="false" name="oa [clean,spring-boot:run]" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
|
||||||
<MavenSettings>
|
<MavenSettings>
|
||||||
<option name="myGeneralSettings" />
|
<option name="myGeneralSettings" />
|
||||||
<option name="myRunnerSettings" />
|
<option name="myRunnerSettings">
|
||||||
|
<MavenRunnerSettings>
|
||||||
|
<option name="delegateBuildToMaven" value="false" />
|
||||||
|
<option name="environmentProperties">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="jreName" value="#USE_PROJECT_JDK" />
|
||||||
|
<option name="mavenProperties">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="passParentEnv" value="true" />
|
||||||
|
<option name="runMavenInBackground" value="true" />
|
||||||
|
<option name="skipTests" value="false" />
|
||||||
|
<option name="vmOptions" value="" />
|
||||||
|
</MavenRunnerSettings>
|
||||||
|
</option>
|
||||||
<option name="myRunnerParameters">
|
<option name="myRunnerParameters">
|
||||||
<MavenRunnerParameters>
|
<MavenRunnerParameters>
|
||||||
<option name="cmdOptions" />
|
<option name="cmdOptions" />
|
||||||
|
48
.run/wyj [clean,spring-boot_run].run.xml
Normal file
48
.run/wyj [clean,spring-boot_run].run.xml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="wyj [clean,spring-boot:run]" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
|
||||||
|
<MavenSettings>
|
||||||
|
<option name="myGeneralSettings" />
|
||||||
|
<option name="myRunnerSettings">
|
||||||
|
<MavenRunnerSettings>
|
||||||
|
<option name="delegateBuildToMaven" value="false" />
|
||||||
|
<option name="environmentProperties">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="jreName" value="corretto-17" />
|
||||||
|
<option name="mavenProperties">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="passParentEnv" value="true" />
|
||||||
|
<option name="runMavenInBackground" value="true" />
|
||||||
|
<option name="skipTests" value="false" />
|
||||||
|
<option name="vmOptions" value="-Dfile.encoding=GB2312" />
|
||||||
|
</MavenRunnerSettings>
|
||||||
|
</option>
|
||||||
|
<option name="myRunnerParameters">
|
||||||
|
<MavenRunnerParameters>
|
||||||
|
<option name="cmdOptions" />
|
||||||
|
<option name="profiles">
|
||||||
|
<set />
|
||||||
|
</option>
|
||||||
|
<option name="goals">
|
||||||
|
<list>
|
||||||
|
<option value="clean" />
|
||||||
|
<option value="spring-boot:run" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="multimoduleDir" />
|
||||||
|
<option name="pomFileName" />
|
||||||
|
<option name="profilesMap">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="projectsCmdOptionValues">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="resolveToWorkspace" value="false" />
|
||||||
|
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||||
|
</MavenRunnerParameters>
|
||||||
|
</option>
|
||||||
|
</MavenSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
3
pom.xml
3
pom.xml
@ -17,6 +17,7 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<skipTests>true</skipTests>
|
<skipTests>true</skipTests>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -166,10 +167,12 @@
|
|||||||
<goal>timestamp-property</goal>
|
<goal>timestamp-property</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
|
||||||
<name>buildDate</name>
|
<name>buildDate</name>
|
||||||
<pattern>yyyy-MM-dd HH:mm:ss</pattern>
|
<pattern>yyyy-MM-dd HH:mm:ss</pattern>
|
||||||
<locale>en_US</locale>
|
<locale>en_US</locale>
|
||||||
<timeZone>GMT+8</timeZone>
|
<timeZone>GMT+8</timeZone>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -14,7 +14,7 @@ import java.lang.annotation.*;
|
|||||||
@Documented
|
@Documented
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface NeedRoleGroup {
|
public @interface NeedPermission {
|
||||||
/**
|
/**
|
||||||
* <h2>权限名称</h2>
|
* <h2>权限名称</h2>
|
||||||
* <hr/>
|
* <hr/>
|
@ -94,7 +94,9 @@ public class BusinessAop {
|
|||||||
}
|
}
|
||||||
Object result = pjp.proceed();
|
Object result = pjp.proceed();
|
||||||
log.info("<==[DAO] 返回数据类型 {}", declaringType.descriptorString());
|
log.info("<==[DAO] 返回数据类型 {}", declaringType.descriptorString());
|
||||||
log.debug("\t> 传出信息:{}", result.toString());
|
if (result != null) {
|
||||||
|
log.debug("\t> 传出信息:{}", result);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class CheckUserAbleToUseAspect {
|
|||||||
|
|
||||||
private final UserDAO userDAO;
|
private final UserDAO userDAO;
|
||||||
|
|
||||||
@Around("@annotation(com.jsl.oa.annotations.NeedRoleGroup)")
|
@Around("@annotation(com.jsl.oa.annotations.NeedPermission)")
|
||||||
public Object checkUse(ProceedingJoinPoint pjp) throws Throwable {
|
public Object checkUse(ProceedingJoinPoint pjp) throws Throwable {
|
||||||
// 从ServletRequest中获取用户信息
|
// 从ServletRequest中获取用户信息
|
||||||
ServletRequestAttributes servletRequestAttributes =
|
ServletRequestAttributes servletRequestAttributes =
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package com.jsl.oa.aspect;
|
package com.jsl.oa.aspect;
|
||||||
|
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
|
import com.jsl.oa.common.constant.BusinessConstants;
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.exception.library.NotLoginException;
|
import com.jsl.oa.exception.library.NotLoginException;
|
||||||
import com.jsl.oa.exception.library.PermissionDeniedException;
|
import com.jsl.oa.exception.library.PermissionDeniedException;
|
||||||
|
import com.jsl.oa.exception.library.TokenNotFoundedException;
|
||||||
import com.jsl.oa.model.dodata.RoleDO;
|
import com.jsl.oa.model.dodata.RoleDO;
|
||||||
import com.jsl.oa.utils.Processing;
|
import com.jsl.oa.utils.Processing;
|
||||||
|
import com.jsl.oa.utils.redis.TokenRedisUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
@ -16,14 +21,16 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户权限切面
|
* 检查用户权限切面
|
||||||
* <hr/>
|
* <hr/>
|
||||||
* 检查访问的用户是否包含正确的访问权限,若用户有正确的访问权限则允许访问,若没有指定的权限将会返回错误的权限信息。
|
* 检查访问的用户是否包含正确的访问权限,若用户有正确的访问权限则允许访问,若没有指定的权限将会返回错误的权限信息。
|
||||||
*
|
*
|
||||||
* @since v1.2.0
|
|
||||||
* @version v1.2.0
|
|
||||||
* @author xiao_lfeng
|
* @author xiao_lfeng
|
||||||
|
* @version v1.2.0
|
||||||
|
* @since v1.2.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Aspect
|
@Aspect
|
||||||
@ -32,6 +39,8 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|||||||
public class CheckUserPermissionAspect {
|
public class CheckUserPermissionAspect {
|
||||||
|
|
||||||
private final RoleDAO roleDAO;
|
private final RoleDAO roleDAO;
|
||||||
|
private final Gson gson;
|
||||||
|
private final TokenRedisUtil<String> tokenRedisUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查权限
|
* 检查权限
|
||||||
@ -41,7 +50,7 @@ public class CheckUserPermissionAspect {
|
|||||||
* @param pjp {@link ProceedingJoinPoint}
|
* @param pjp {@link ProceedingJoinPoint}
|
||||||
* @return {@link Object}
|
* @return {@link Object}
|
||||||
*/
|
*/
|
||||||
@Around("@annotation(com.jsl.oa.annotations.NeedRoleGroup)")
|
@Around("@annotation(com.jsl.oa.annotations.NeedPermission)")
|
||||||
public Object checkPermission(ProceedingJoinPoint pjp) throws Throwable {
|
public Object checkPermission(ProceedingJoinPoint pjp) throws Throwable {
|
||||||
// 从ServletRequest中获取用户信息
|
// 从ServletRequest中获取用户信息
|
||||||
ServletRequestAttributes servletRequestAttributes =
|
ServletRequestAttributes servletRequestAttributes =
|
||||||
@ -53,22 +62,28 @@ public class CheckUserPermissionAspect {
|
|||||||
if (getUserId == null) {
|
if (getUserId == null) {
|
||||||
throw new NotLoginException("用户信息不存在");
|
throw new NotLoginException("用户信息不存在");
|
||||||
}
|
}
|
||||||
|
if (tokenRedisUtil.getData(BusinessConstants.BUSINESS_LOGIN, getUserId.toString()) == null) {
|
||||||
|
throw new TokenNotFoundedException("用户未登录");
|
||||||
|
}
|
||||||
// 获取方法签名
|
// 获取方法签名
|
||||||
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
||||||
NeedRoleGroup checkAccountPermission = signature.getMethod().getAnnotation(NeedRoleGroup.class);
|
NeedPermission checkAccountPermission = signature.getMethod().getAnnotation(NeedPermission.class);
|
||||||
String getRoleAtAnnotation = checkAccountPermission.value();
|
String getRoleAtAnnotation = checkAccountPermission.value();
|
||||||
|
|
||||||
// 获取用户所在权限组
|
// 获取用户所在权限组
|
||||||
RoleDO getUserRole = roleDAO.getRoleNameByUid(getUserId);
|
RoleDO getUserRole = roleDAO.getRoleByUserId(getUserId);
|
||||||
if (getUserRole != null) {
|
if (getUserRole != null) {
|
||||||
if (getUserRole.getRoleName().equals(getRoleAtAnnotation)) {
|
List<String> permissions = gson.fromJson(getUserRole.getPermissions(), new TypeToken<List<String>>() {
|
||||||
return pjp.proceed();
|
}.getType());
|
||||||
} else {
|
if (permissions != null) {
|
||||||
throw new PermissionDeniedException("用户组不匹配", getRoleAtAnnotation);
|
for (String it : permissions) {
|
||||||
|
if (it.equals(getRoleAtAnnotation)) {
|
||||||
|
return pjp.proceed();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new PermissionDeniedException("用户组不匹配", getRoleAtAnnotation);
|
|
||||||
}
|
}
|
||||||
|
throw new PermissionDeniedException("权限不匹配", getRoleAtAnnotation);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("无法获取信息");
|
throw new RuntimeException("无法获取信息");
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
|
|||||||
} else {
|
} else {
|
||||||
// 解析Bearer后面的令牌
|
// 解析Bearer后面的令牌
|
||||||
token = token.replace("Bearer ", "");
|
token = token.replace("Bearer ", "");
|
||||||
log.info("请求令牌:" + token);
|
log.info("[FILTER] 请求令牌:" + token);
|
||||||
return JwtUtil.verify(token);
|
return JwtUtil.verify(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
src/main/java/com/jsl/oa/config/startup/PermissionList.java
Normal file
37
src/main/java/com/jsl/oa/config/startup/PermissionList.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.jsl.oa.config.startup;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PermissionList {
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public static class PermissionVO {
|
||||||
|
private final String name;
|
||||||
|
private final String desc;
|
||||||
|
}
|
||||||
|
private final ArrayList<PermissionList.PermissionVO> permissionList = new ArrayList<>();
|
||||||
|
private final ArrayList<PermissionList.PermissionVO> permissionPrincipal = new ArrayList<>();
|
||||||
|
private final ArrayList<PermissionList.PermissionVO> permissionDeveloper = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
public PermissionList() {
|
||||||
|
permissionList.add(new PermissionVO("auth:change_password", "修改密码"));
|
||||||
|
permissionList.add(new PermissionVO("info:get_header_image", "获取头部图片"));
|
||||||
|
permissionList.add(new PermissionVO("info:edit_header_image", "编辑头部图片"));
|
||||||
|
permissionList.add(new PermissionVO("info:delete_header_image", "删除头部图片"));
|
||||||
|
|
||||||
|
permissionPrincipal.add(new PermissionVO("auth:change_password", "修改密码"));
|
||||||
|
permissionPrincipal.add(new PermissionVO("info:get_header_image", "获取头部图片"));
|
||||||
|
permissionPrincipal.add(new PermissionVO("info:edit_header_image", "编辑头部图片"));
|
||||||
|
permissionPrincipal.add(new PermissionVO("info:delete_header_image", "删除头部图片"));
|
||||||
|
|
||||||
|
permissionDeveloper.add(new PermissionVO("auth:change_password", "修改密码"));
|
||||||
|
permissionDeveloper.add(new PermissionVO("info:get_header_image", "获取头部图片"));
|
||||||
|
permissionDeveloper.add(new PermissionVO("info:edit_header_image", "编辑头部图片"));
|
||||||
|
permissionDeveloper.add(new PermissionVO("info:delete_header_image", "删除头部图片"));
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,18 @@
|
|||||||
package com.jsl.oa.config.startup;
|
package com.jsl.oa.config.startup;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.util.FileCopyUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -32,4 +41,54 @@ public class PrepareData {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查数据库是否完整
|
||||||
|
* <hr/>
|
||||||
|
* 检查数据库是否完整,若数据库保持完整则不进行任何操作,若数据库不完整将会创建对应的数据表
|
||||||
|
* @param tableName 数据表名字
|
||||||
|
*/
|
||||||
|
public void checkDatabase(String tableName) {
|
||||||
|
try {
|
||||||
|
jdbcTemplate.queryForObject(
|
||||||
|
"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME = ?",
|
||||||
|
String.class,
|
||||||
|
tableName
|
||||||
|
);
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
log.debug("[Preparation] 创建数据表 {}", tableName);
|
||||||
|
// 读取文件
|
||||||
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
// 读取 resources/mysql 目录下的所有 SQL 文件
|
||||||
|
Resource resource = resolver.getResource("classpath:/mysql/" + tableName + ".sql");
|
||||||
|
// 创建数据表
|
||||||
|
try {
|
||||||
|
String sql = FileCopyUtils
|
||||||
|
.copyToString(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8));
|
||||||
|
// 分割 SQL 语句并执行
|
||||||
|
jdbcTemplate.execute("USE organize_oa");
|
||||||
|
String[] sqlStatements = sql.split(";");
|
||||||
|
for (String statement : sqlStatements) {
|
||||||
|
if (!statement.trim().isEmpty()) {
|
||||||
|
jdbcTemplate.execute(statement.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkPermission(String roleName, ArrayList<PermissionList.PermissionVO> permissions) {
|
||||||
|
ArrayList<String> newPermissions = new ArrayList<>();
|
||||||
|
permissions.forEach(it -> newPermissions.add(it.getName()));
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String getPermissionString = gson.toJson(newPermissions);
|
||||||
|
log.debug("[Preparation] 更新角色 {} 权限", roleName);
|
||||||
|
jdbcTemplate.update(
|
||||||
|
"UPDATE organize_oa.oa_role SET permissions = ? WHERE role_name = ?",
|
||||||
|
getPermissionString,
|
||||||
|
roleName
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import java.util.HashMap;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class StartupConfiguration {
|
public class StartupConfiguration {
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
private final PermissionList getPermission = new PermissionList();
|
||||||
private PrepareData prepareData;
|
private PrepareData prepareData;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -52,17 +53,75 @@ public class StartupConfiguration {
|
|||||||
/**
|
/**
|
||||||
* 对数据库进行完整性检查
|
* 对数据库进行完整性检查
|
||||||
* <hr/>
|
* <hr/>
|
||||||
* 对数据库进行完整性检查,检查数据库是否有数据缺失等信息
|
* 对数据库进行完整性检查,检查数据库是否出现缺失数据表的情况,若出现缺失数据表的情况将会对数据表进行创建,若数据保持完整将不进行任何操作
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@Order(2)
|
@Order(2)
|
||||||
public CommandLineRunner roleDataPreparation() {
|
public CommandLineRunner checkDatabaseExist() {
|
||||||
return args -> {
|
return args -> {
|
||||||
log.info("[Preparation] 系统进行数据库完整性检查");
|
log.info("[Preparation] 系统进行数据库完整性检查");
|
||||||
|
// 数据表的检查
|
||||||
|
prepareData.checkDatabase("oa_config");
|
||||||
|
prepareData.checkDatabase("oa_user");
|
||||||
|
prepareData.checkDatabase("oa_role");
|
||||||
|
prepareData.checkDatabase("oa_permissions");
|
||||||
|
prepareData.checkDatabase("oa_news");
|
||||||
|
prepareData.checkDatabase("oa_project_tags");
|
||||||
|
prepareData.checkDatabase("oa_project");
|
||||||
|
prepareData.checkDatabase("oa_project_child");
|
||||||
|
prepareData.checkDatabase("oa_project_modules");
|
||||||
|
prepareData.checkDatabase("oa_review");
|
||||||
|
prepareData.checkDatabase("oa_message");
|
||||||
|
prepareData.checkDatabase("oa_news_user");
|
||||||
|
prepareData.checkDatabase("oa_project_daily");
|
||||||
|
prepareData.checkDatabase("oa_role_user");
|
||||||
|
prepareData.checkDatabase("oa_user_tags");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Order(3)
|
||||||
|
public CommandLineRunner permissionDataPreparation() {
|
||||||
|
return args -> {
|
||||||
|
log.info("[Preparation] 系统进行权限表完整性检查");
|
||||||
|
getPermission.getPermissionList().forEach(permissionVO -> {
|
||||||
|
try {
|
||||||
|
jdbcTemplate.queryForObject(
|
||||||
|
"SELECT id FROM organize_oa.oa_permissions WHERE name = ?",
|
||||||
|
Long.class,
|
||||||
|
permissionVO.getName()
|
||||||
|
);
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
log.debug("[Preparation] 缺失 {} 权限,正在创建", permissionVO.getName());
|
||||||
|
jdbcTemplate.update(
|
||||||
|
"INSERT INTO organize_oa.oa_permissions (name, description) VALUES (?,?)",
|
||||||
|
permissionVO.getName(),
|
||||||
|
permissionVO.getDesc()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对数据表进行完整性检查
|
||||||
|
* <hr/>
|
||||||
|
* 对数据表进行完整性检查,检查数据表是否有数据缺失等信息
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Order(4)
|
||||||
|
public CommandLineRunner roleDataPreparation() {
|
||||||
|
return args -> {
|
||||||
|
log.info("[Preparation] 系统进行角色表完整性检查");
|
||||||
// 检查角色信息是否完整
|
// 检查角色信息是否完整
|
||||||
prepareData.checkRole("console", "超级管理员");
|
prepareData.checkRole("console", "超级管理员");
|
||||||
prepareData.checkRole("principal", "负责人");
|
prepareData.checkRole("principal", "负责人");
|
||||||
prepareData.checkRole("developer", "开发者");
|
prepareData.checkRole("developer", "开发者");
|
||||||
|
|
||||||
|
// 对权限的检查
|
||||||
|
prepareData.checkPermission("console", getPermission.getPermissionList());
|
||||||
|
prepareData.checkPermission("principal", getPermission.getPermissionPrincipal());
|
||||||
|
prepareData.checkPermission("developer", getPermission.getPermissionDeveloper());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +132,7 @@ public class StartupConfiguration {
|
|||||||
* 账户。
|
* 账户。
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@Order(3)
|
@Order(5)
|
||||||
public CommandLineRunner defaultConsoleDataPreparation() {
|
public CommandLineRunner defaultConsoleDataPreparation() {
|
||||||
return args -> {
|
return args -> {
|
||||||
log.info("[Preparation] 系统进行默认超级管理员信息检查");
|
log.info("[Preparation] 系统进行默认超级管理员信息检查");
|
||||||
@ -133,7 +192,7 @@ public class StartupConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Order(4)
|
@Order(6)
|
||||||
public CommandLineRunner prepareDefaultConfigData(Gson gson) {
|
public CommandLineRunner prepareDefaultConfigData(Gson gson) {
|
||||||
return args -> {
|
return args -> {
|
||||||
// 检查加密密钥是否存在
|
// 检查加密密钥是否存在
|
||||||
@ -180,7 +239,7 @@ public class StartupConfiguration {
|
|||||||
* 准备安全密钥,用于加密解密等操作
|
* 准备安全密钥,用于加密解密等操作
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@Order(5)
|
@Order(7)
|
||||||
public CommandLineRunner prepareKey() {
|
public CommandLineRunner prepareKey() {
|
||||||
return args -> {
|
return args -> {
|
||||||
log.info("[Preparation] 系统进行安全密钥准备");
|
log.info("[Preparation] 系统进行安全密钥准备");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.jsl.oa.controllers;
|
package com.jsl.oa.controllers;
|
||||||
|
|
||||||
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
import com.jsl.oa.model.vodata.UserChangePasswordVO;
|
import com.jsl.oa.model.vodata.UserChangePasswordVO;
|
||||||
import com.jsl.oa.model.vodata.UserForgetPasswordVO;
|
import com.jsl.oa.model.vodata.UserForgetPasswordVO;
|
||||||
import com.jsl.oa.model.vodata.UserLoginVO;
|
import com.jsl.oa.model.vodata.UserLoginVO;
|
||||||
@ -162,6 +163,7 @@ public class AuthController {
|
|||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
@PutMapping("/auth/password")
|
@PutMapping("/auth/password")
|
||||||
|
@NeedPermission("auth:change_password")
|
||||||
public BaseResponse authChangePassword(
|
public BaseResponse authChangePassword(
|
||||||
@RequestBody @Validated UserChangePasswordVO userChangePasswordVO,
|
@RequestBody @Validated UserChangePasswordVO userChangePasswordVO,
|
||||||
@NotNull BindingResult bindingResult,
|
@NotNull BindingResult bindingResult,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.jsl.oa.controllers;
|
package com.jsl.oa.controllers;
|
||||||
|
|
||||||
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
import com.jsl.oa.model.vodata.business.info.CarouselVO;
|
import com.jsl.oa.model.vodata.business.info.CarouselVO;
|
||||||
import com.jsl.oa.services.InfoService;
|
import com.jsl.oa.services.InfoService;
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
@ -41,6 +42,7 @@ public class InfoController {
|
|||||||
* @return 图片信息
|
* @return 图片信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/info/header-image/get")
|
@GetMapping("/info/header-image/get")
|
||||||
|
@NeedPermission("info:get_header_image")
|
||||||
public BaseResponse infoGetHeaderImage(@RequestParam(required = false) Integer id) {
|
public BaseResponse infoGetHeaderImage(@RequestParam(required = false) Integer id) {
|
||||||
return infoService.getHeaderImage(id);
|
return infoService.getHeaderImage(id);
|
||||||
}
|
}
|
||||||
@ -54,6 +56,7 @@ public class InfoController {
|
|||||||
* @return 编辑结果
|
* @return 编辑结果
|
||||||
*/
|
*/
|
||||||
@PutMapping("/info/header-image/edit")
|
@PutMapping("/info/header-image/edit")
|
||||||
|
@NeedPermission("info:edit_header_image")
|
||||||
public BaseResponse infoEditHeaderImage(
|
public BaseResponse infoEditHeaderImage(
|
||||||
@RequestBody @Validated CarouselVO carouselVO,
|
@RequestBody @Validated CarouselVO carouselVO,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
@ -79,6 +82,7 @@ public class InfoController {
|
|||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/info/header-image/del")
|
@DeleteMapping("/info/header-image/del")
|
||||||
|
@NeedPermission("info:delete_header_image")
|
||||||
public BaseResponse infoDelHeaderImage(@RequestParam Integer id, HttpServletRequest request) {
|
public BaseResponse infoDelHeaderImage(@RequestParam Integer id, HttpServletRequest request) {
|
||||||
return infoService.delHeaderImage(request, id);
|
return infoService.delHeaderImage(request, id);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.jsl.oa.controllers;
|
package com.jsl.oa.controllers;
|
||||||
|
|
||||||
import com.jsl.oa.model.vodata.PermissionEditVO;
|
|
||||||
import com.jsl.oa.services.PermissionService;
|
import com.jsl.oa.services.PermissionService;
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
import com.jsl.oa.utils.ErrorCode;
|
import com.jsl.oa.utils.ErrorCode;
|
||||||
import com.jsl.oa.utils.Processing;
|
|
||||||
import com.jsl.oa.utils.ResultUtil;
|
import com.jsl.oa.utils.ResultUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@ -30,24 +28,6 @@ public class PermissionController {
|
|||||||
*/
|
*/
|
||||||
private final PermissionService permissionService;
|
private final PermissionService permissionService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加新的权限。
|
|
||||||
*
|
|
||||||
* @param request HTTP请求对象。
|
|
||||||
* @param rid 角色ID。
|
|
||||||
* @param pid 权限ID。
|
|
||||||
* @return {@link BaseResponse} 对象,包含操作结果。
|
|
||||||
*/
|
|
||||||
@PostMapping("/permission/add")
|
|
||||||
public BaseResponse permissionAdd(HttpServletRequest request, @RequestParam Long rid, @RequestParam Long pid) {
|
|
||||||
// 判断是否有参数错误
|
|
||||||
if (rid == null || pid == null) {
|
|
||||||
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
|
||||||
} else {
|
|
||||||
return permissionService.permissionAdd(request, rid, pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户的权限信息。
|
* 获取当前用户的权限信息。
|
||||||
*
|
*
|
||||||
@ -75,42 +55,4 @@ public class PermissionController {
|
|||||||
public BaseResponse permissionGet(HttpServletRequest request) {
|
public BaseResponse permissionGet(HttpServletRequest request) {
|
||||||
return permissionService.permissionGet(request);
|
return permissionService.permissionGet(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑权限信息。
|
|
||||||
*
|
|
||||||
* @param permissionEditVo {@link PermissionEditVO} 对象,包含更新后的权限信息。
|
|
||||||
* @param bindingResult Binding结果对象,包含任何验证错误。
|
|
||||||
* @param request HTTP请求对象。
|
|
||||||
* @return {@link BaseResponse} 对象,包含操作结果。
|
|
||||||
*/
|
|
||||||
@PutMapping("/permission/edit")
|
|
||||||
public BaseResponse permissionEdit(
|
|
||||||
@RequestBody @Validated PermissionEditVO permissionEditVo,
|
|
||||||
BindingResult bindingResult,
|
|
||||||
HttpServletRequest request
|
|
||||||
) {
|
|
||||||
// 判断是否有参数错误
|
|
||||||
if (bindingResult.hasErrors()) {
|
|
||||||
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
|
|
||||||
}
|
|
||||||
return permissionService.permissionEdit(permissionEditVo, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除权限。
|
|
||||||
*
|
|
||||||
* @param pid 权限ID。
|
|
||||||
* @param request HTTP请求对象。
|
|
||||||
* @return {@link BaseResponse} 对象,包含操作结果。
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/permission/delete")
|
|
||||||
public BaseResponse permissionDelete(@RequestParam Long pid, HttpServletRequest request) {
|
|
||||||
// 判断是否有参数错误
|
|
||||||
if (pid == null) {
|
|
||||||
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
|
||||||
} else {
|
|
||||||
return permissionService.permissionDelete(request, pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,14 @@ public class ProjectController {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 获取子模块详细
|
||||||
|
*
|
||||||
* @param id 要查询的 id
|
* @param id 要查询的 id
|
||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
@GetMapping("/project/getwork/id")
|
@GetMapping("/project/module/id")
|
||||||
public BaseResponse projectWorkGetById(@RequestParam Integer id) {
|
public BaseResponse projectModuleGetById(@RequestParam Integer id) {
|
||||||
return projectService.getWorkById(id);
|
return projectService.getModuleById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,15 +112,15 @@ public class ProjectController {
|
|||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
@GetMapping("/project/child/get")
|
@GetMapping("/project/child/get")
|
||||||
public BaseResponse projectWorkGet(
|
public BaseResponse projectModuleGet(
|
||||||
@RequestParam(required = false) List<String> tags,
|
@RequestParam(required = false) List<String> tags,
|
||||||
@RequestParam(required = false) List<String> isFinish,
|
@RequestParam(required = false) List<String> status,
|
||||||
@RequestParam(required = false) Integer is,
|
@RequestParam(required = false) Integer is,
|
||||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||||
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
|
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
|
||||||
HttpServletRequest request
|
HttpServletRequest request
|
||||||
) {
|
) {
|
||||||
return projectService.workGet(request, tags, isFinish, is, page, pageSize);
|
return projectService.workGet(request, tags, status, is, page, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -179,6 +181,42 @@ public class ProjectController {
|
|||||||
return projectService.projectEdit(request, projectEdit, projectId);
|
return projectService.projectEdit(request, projectEdit, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取我负责的项目
|
||||||
|
*
|
||||||
|
* @param page 页数
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/project/my/get")
|
||||||
|
public BaseResponse projectMyGet(
|
||||||
|
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
return projectService.getPrincipalProject(page, pageSize, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 获取我参与的项目
|
||||||
|
*
|
||||||
|
* @param page 页数
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/project/participate/get")
|
||||||
|
public BaseResponse projectParticipateGet(
|
||||||
|
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
return projectService.getParticipateProject(page, pageSize, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子系统子模块的增加
|
* 子系统子模块的增加
|
||||||
*
|
*
|
||||||
@ -219,7 +257,7 @@ public class ProjectController {
|
|||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
return ResultUtil.error(ErrorCode.PARAMETER_ERROR, Processing.getValidatedErrorList(bindingResult));
|
return ResultUtil.error(ErrorCode.PARAMETER_ERROR, Processing.getValidatedErrorList(bindingResult));
|
||||||
}
|
}
|
||||||
return ResultUtil.success(projectService.projectAdd(request, projectInfoVO));
|
return projectService.projectAdd(request, projectInfoVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -256,4 +294,32 @@ public class ProjectController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除子系统
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/project/child/delete")
|
||||||
|
public BaseResponse projectChildDelete(
|
||||||
|
@RequestParam List<Long> id,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
if (id == null) {
|
||||||
|
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
||||||
|
}
|
||||||
|
return projectService.projectChildDelete(request, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/project/module/delete")
|
||||||
|
public BaseResponse projectModuleDelete(
|
||||||
|
@RequestParam List<Long> id,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
if (id == null) {
|
||||||
|
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
|
||||||
|
}
|
||||||
|
return projectService.projectModuleDelete(request, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.jsl.oa.common.constant.BusinessConstants;
|
import com.jsl.oa.common.constant.BusinessConstants;
|
||||||
import com.jsl.oa.mapper.PermissionMapper;
|
import com.jsl.oa.mapper.PermissionMapper;
|
||||||
|
import com.jsl.oa.mapper.RoleMapper;
|
||||||
import com.jsl.oa.model.dodata.PermissionDO;
|
import com.jsl.oa.model.dodata.PermissionDO;
|
||||||
|
import com.jsl.oa.model.dodata.RoleDO;
|
||||||
import com.jsl.oa.utils.redis.RoleRedisUtil;
|
import com.jsl.oa.utils.redis.RoleRedisUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -30,6 +32,7 @@ public class PermissionDAO {
|
|||||||
private final PermissionMapper permissionMapper;
|
private final PermissionMapper permissionMapper;
|
||||||
private final RoleRedisUtil<String> roleRedisUtil;
|
private final RoleRedisUtil<String> roleRedisUtil;
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
|
private final RoleMapper roleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取用户权限信息</h2>
|
* <h2>获取用户权限信息</h2>
|
||||||
@ -40,142 +43,51 @@ public class PermissionDAO {
|
|||||||
* @return {@link List<String>}
|
* @return {@link List<String>}
|
||||||
*/
|
*/
|
||||||
public List<String> getPermission(@NotNull Long uid) {
|
public List<String> getPermission(@NotNull Long uid) {
|
||||||
List<String> getPermissionForString;
|
// 查询用户所在角色组
|
||||||
String permissionRedisString = roleRedisUtil.getData(BusinessConstants.NONE, uid.toString());
|
RoleDO getRole = roleMapper.getRoleByUserId(uid);
|
||||||
if (permissionRedisString == null) {
|
if (getRole != null) {
|
||||||
List<PermissionDO> permissionList = permissionMapper.permissionUserPid(uid);
|
List<String> getPermissionForString;
|
||||||
getPermissionForString = new ArrayList<>();
|
String permissionRedisString = roleRedisUtil.getData(BusinessConstants.NONE, uid.toString());
|
||||||
forPermissionToBuildString(permissionList, getPermissionForString);
|
if (permissionRedisString == null) {
|
||||||
// 存入 Redis
|
String permissionList = permissionMapper.getPermissionByRole(getRole.getRoleName());
|
||||||
roleRedisUtil.setData(BusinessConstants.NONE, uid.toString(), gson.toJson(getPermissionForString), 1440);
|
getPermissionForString = gson.fromJson(permissionList, new TypeToken<List<String>>() { }.getType());
|
||||||
|
// 存入 Redis
|
||||||
|
roleRedisUtil.setData(
|
||||||
|
BusinessConstants.NONE,
|
||||||
|
uid.toString(),
|
||||||
|
gson.toJson(getPermissionForString),
|
||||||
|
1440
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
getPermissionForString = gson
|
||||||
|
.fromJson(permissionRedisString, new TypeToken<List<String>>() { }.getType());
|
||||||
|
}
|
||||||
|
return getPermissionForString;
|
||||||
} else {
|
} else {
|
||||||
getPermissionForString = gson.fromJson(permissionRedisString, new TypeToken<List<String>>() { }.getType());
|
return null;
|
||||||
}
|
}
|
||||||
return getPermissionForString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAllPermissionBuildString() {
|
public List<String> getAllPermissionBuildString() {
|
||||||
List<String> getPermissionForString;
|
List<String> getPermission;
|
||||||
String getRedisData = roleRedisUtil.getData(BusinessConstants.ALL_PERMISSION, "string");
|
String getRedisData = roleRedisUtil.getData(BusinessConstants.ALL_PERMISSION, "string");
|
||||||
if (getRedisData == null) {
|
if (getRedisData == null) {
|
||||||
|
getPermission = new ArrayList<>();
|
||||||
List<PermissionDO> permissionList = permissionMapper.getAllPermission();
|
List<PermissionDO> permissionList = permissionMapper.getAllPermission();
|
||||||
permissionList.removeIf(it -> it.getPid() != null);
|
permissionList.forEach(it -> getPermission.add(it.getName()));
|
||||||
getPermissionForString = new ArrayList<>();
|
|
||||||
forPermissionToBuildString(permissionList, getPermissionForString);
|
|
||||||
// 存入 Redis
|
// 存入 Redis
|
||||||
roleRedisUtil.setData(
|
roleRedisUtil.setData(
|
||||||
BusinessConstants.ALL_PERMISSION,
|
BusinessConstants.ALL_PERMISSION,
|
||||||
"string",
|
"string",
|
||||||
gson.toJson(getPermissionForString),
|
gson.toJson(getPermission),
|
||||||
1440);
|
1440);
|
||||||
} else {
|
} else {
|
||||||
getPermissionForString = gson.fromJson(getRedisData, new TypeToken<List<String>>() { }.getType());
|
getPermission = gson.fromJson(getRedisData, new TypeToken<List<String>>() { }.getType());
|
||||||
}
|
}
|
||||||
return getPermissionForString;
|
return getPermission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PermissionDO> getRootPermission() {
|
public List<PermissionDO> getAllPermission() {
|
||||||
String getRedisData = roleRedisUtil.getData(BusinessConstants.ALL_PERMISSION, "all");
|
return permissionMapper.getAllPermission();
|
||||||
if (getRedisData == null) {
|
|
||||||
List<PermissionDO> permissionList = permissionMapper.getAllPermission();
|
|
||||||
if (!permissionList.isEmpty()) {
|
|
||||||
List<PermissionDO> getPermissionList = new ArrayList<>();
|
|
||||||
for (PermissionDO permission : permissionList) {
|
|
||||||
if (permission.getPid() == null) {
|
|
||||||
getPermissionList.add(permission);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
roleRedisUtil.setData(BusinessConstants.ALL_PERMISSION, "all", gson.toJson(getPermissionList), 1440);
|
|
||||||
return getPermissionList;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return gson.fromJson(getRedisData, new TypeToken<List<PermissionDO>>() {
|
|
||||||
}.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h2>获取全部权限信息</h2>
|
|
||||||
* <hr/>
|
|
||||||
* 获取全部权限信息
|
|
||||||
*
|
|
||||||
* @param permissionList 权限信息
|
|
||||||
* @param getPermissionForString 存储权限信息
|
|
||||||
*/
|
|
||||||
private void forPermissionToBuildString(
|
|
||||||
@NotNull List<PermissionDO> permissionList,
|
|
||||||
List<String> getPermissionForString) {
|
|
||||||
for (PermissionDO permission : permissionList) {
|
|
||||||
// 寻找是否存在父亲
|
|
||||||
StringBuilder permissionString = new StringBuilder();
|
|
||||||
if (permission.getPid() != null) {
|
|
||||||
// 存在父亲
|
|
||||||
this.getFatherPermission(permissionString, permission.getPid());
|
|
||||||
} else {
|
|
||||||
// 不存在父亲
|
|
||||||
permissionString.append(permission.getName());
|
|
||||||
}
|
|
||||||
// 寻找子类
|
|
||||||
this.getChildPermission(permissionString, permission.getId(), getPermissionForString);
|
|
||||||
getPermissionForString.add(permissionString.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h2>获取子类权限信息</h2>
|
|
||||||
* <hr/>
|
|
||||||
* 通过父类 ID 获取子类权限信息<br/>
|
|
||||||
* 递归调用
|
|
||||||
*
|
|
||||||
* @param permissionString 父类权限信息
|
|
||||||
* @param id 父类 ID
|
|
||||||
* @param getPermissionForString 存储权限信息
|
|
||||||
*/
|
|
||||||
private void getChildPermission(StringBuilder permissionString, Long id, List<String> getPermissionForString) {
|
|
||||||
// 获取子类权限信息
|
|
||||||
List<PermissionDO> permissionList = permissionMapper.getChildPermission(id);
|
|
||||||
// 判断是否存在子类
|
|
||||||
if (!permissionList.isEmpty()) {
|
|
||||||
// 存在子类
|
|
||||||
for (PermissionDO permission : permissionList) {
|
|
||||||
StringBuilder childPermissionString = new StringBuilder(permissionString);
|
|
||||||
// 遍历数据检查是否依旧存在子类
|
|
||||||
List<PermissionDO> childPermissionList = permissionMapper.getChildPermission(permission.getId());
|
|
||||||
if (!childPermissionList.isEmpty()) {
|
|
||||||
// 存在子类
|
|
||||||
permissionString.append(".").append(permission.getName());
|
|
||||||
this.getChildPermission(permissionString, permission.getId(), getPermissionForString);
|
|
||||||
} else {
|
|
||||||
// 不存在子类
|
|
||||||
permissionString.append(".").append(permission.getName());
|
|
||||||
getPermissionForString.add(permissionString.toString());
|
|
||||||
}
|
|
||||||
permissionString = childPermissionString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h2>获取父类权限信息</h2>
|
|
||||||
* <hr/>
|
|
||||||
* 通过子类 ID 获取父类权限信息<br/>
|
|
||||||
* 递归调用
|
|
||||||
*
|
|
||||||
* @param permissionString 父类权限信息
|
|
||||||
* @param pid 父类 ID
|
|
||||||
*/
|
|
||||||
public void getFatherPermission(StringBuilder permissionString, Long pid) {
|
|
||||||
// 获取权限信息
|
|
||||||
PermissionDO permissionDO = permissionMapper.getPermissionById(pid);
|
|
||||||
// 判断是否存在父亲
|
|
||||||
if (permissionDO.getPid() != null) {
|
|
||||||
// 存在父亲
|
|
||||||
this.getFatherPermission(permissionString, permissionDO.getPid());
|
|
||||||
} else {
|
|
||||||
// 不存在父亲
|
|
||||||
permissionString.append(permissionDO.getCode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,6 @@ public class RoleDAO {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleDO getRoleNameByUid(Long uid) {
|
|
||||||
return roleMapper.getRoleById(getRoleUserByUid(uid).getRid());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean roleEdit(RoleDO getRole) {
|
public boolean roleEdit(RoleDO getRole) {
|
||||||
if (roleMapper.roleEdit(getRole)) {
|
if (roleMapper.roleEdit(getRole)) {
|
||||||
List<RoleDO> roleList = roleMapper.getRole();
|
List<RoleDO> roleList = roleMapper.getRole();
|
||||||
@ -134,4 +129,8 @@ public class RoleDAO {
|
|||||||
public RoleDO getRoleByRoleName(String roleName) {
|
public RoleDO getRoleByRoleName(String roleName) {
|
||||||
return roleMapper.getRoleByRoleName(roleName);
|
return roleMapper.getRoleByRoleName(roleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RoleDO getRoleByUserId(Long uid) {
|
||||||
|
return roleMapper.getRoleByUserId(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class UserDAO {
|
|||||||
userCurrentBackVO.setUsers(new ArrayList<>())
|
userCurrentBackVO.setUsers(new ArrayList<>())
|
||||||
.setCount(userMapper.getUsersCount());
|
.setCount(userMapper.getUsersCount());
|
||||||
userCurrentDO.forEach(it -> userCurrentBackVO.getUsers()
|
userCurrentDO.forEach(it -> userCurrentBackVO.getUsers()
|
||||||
.add(Processing.returnUserInfo(it, roleDAO, permissionDAO)));
|
.add(Processing.returnUserInfo(it, roleDAO, gson)));
|
||||||
return userCurrentBackVO;
|
return userCurrentBackVO;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ public class UserDAO {
|
|||||||
userCurrentBackVO.setUsers(new ArrayList<>())
|
userCurrentBackVO.setUsers(new ArrayList<>())
|
||||||
.setCount(userMapper.getUsersCount());
|
.setCount(userMapper.getUsersCount());
|
||||||
userCurrentDO.forEach(it -> userCurrentBackVO.getUsers()
|
userCurrentDO.forEach(it -> userCurrentBackVO.getUsers()
|
||||||
.add(Processing.returnUserInfo(it, roleDAO, permissionDAO)));
|
.add(Processing.returnUserInfo(it, roleDAO, gson)));
|
||||||
return userCurrentBackVO;
|
return userCurrentBackVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.jsl.oa.exception;
|
package com.jsl.oa.exception;
|
||||||
|
|
||||||
|
import com.jsl.oa.exception.library.PermissionDeniedException;
|
||||||
|
import com.jsl.oa.exception.library.TokenNotFoundedException;
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
import com.jsl.oa.utils.ErrorCode;
|
import com.jsl.oa.utils.ErrorCode;
|
||||||
import com.jsl.oa.utils.ResultUtil;
|
import com.jsl.oa.utils.ResultUtil;
|
||||||
@ -103,4 +105,16 @@ public class ProcessException {
|
|||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return ResultUtil.error("ServerInternalError", 50002, "服务器内部错误");
|
return ResultUtil.error("ServerInternalError", 50002, "服务器内部错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = PermissionDeniedException.class)
|
||||||
|
public BaseResponse businessPermissionDeniedException(PermissionDeniedException e) {
|
||||||
|
log.warn("[EXCEPTION] 无权限操作,需要权限: {}", e.getNeedPermission());
|
||||||
|
return ResultUtil.error("需要权限: " + e.getNeedPermission(), ErrorCode.PERMISSION_NOT_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = TokenNotFoundedException.class)
|
||||||
|
public BaseResponse businessTokenNotFoundedException(TokenNotFoundedException e) {
|
||||||
|
log.warn("[EXCEPTION] {}", e.getMessage());
|
||||||
|
return ResultUtil.error(e.getMessage(), ErrorCode.TOKEN_NOT_EXIST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,10 @@ import lombok.Getter;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public class PermissionDeniedException extends RuntimeException {
|
public class PermissionDeniedException extends RuntimeException {
|
||||||
private final String needGroup;
|
private final String needPermission;
|
||||||
|
|
||||||
public PermissionDeniedException(String message, String needGroup) {
|
public PermissionDeniedException(String message, String needPermission) {
|
||||||
super(message);
|
super(message);
|
||||||
this.needGroup = needGroup;
|
this.needPermission = needPermission;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.jsl.oa.exception.library;
|
||||||
|
|
||||||
|
public class TokenNotFoundedException extends RuntimeException {
|
||||||
|
public TokenNotFoundedException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.jsl.oa.mapper;
|
package com.jsl.oa.mapper;
|
||||||
|
|
||||||
|
import com.jsl.oa.model.dodata.ProjectChildDO;
|
||||||
import com.jsl.oa.model.dodata.ProjectModuleDO;
|
import com.jsl.oa.model.dodata.ProjectModuleDO;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -12,14 +13,14 @@ public interface ModuleMapper {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<ProjectModuleDO> getByProjectId(Integer projectId, Long userId, int is);
|
List<ProjectChildDO> getByProjectId(Integer projectId, Long userId, int is);
|
||||||
|
|
||||||
List<ProjectModuleDO> getBySysId(Integer sysId, Long userId, int is);
|
List<ProjectModuleDO> getBySysId(Integer sysId, Long userId, int is);
|
||||||
|
|
||||||
@Select("select principal_id from organize_oa.oa_project where id=#{projectId}")
|
@Select("select principal_id from organize_oa.oa_project where id=#{projectId}")
|
||||||
Long getPidByProjectid(Integer projectId);
|
Long getPidByProjectid(Integer projectId);
|
||||||
|
|
||||||
@Select("select principal_id from organize_oa.oa_project_work where id=#{sysId}")
|
@Select("select principal_id from organize_oa.oa_project_child where id=#{sysId}")
|
||||||
Long getPidBySysid(Integer sysId);
|
Long getPidBySysid(Integer sysId);
|
||||||
|
|
||||||
@Delete("DELETE FROM organize_oa.oa_project_work WHERE id = #{id}")
|
@Delete("DELETE FROM organize_oa.oa_project_work WHERE id = #{id}")
|
||||||
@ -29,6 +30,6 @@ public interface ModuleMapper {
|
|||||||
List<ProjectModuleDO> getAllMoudleByPid(Long id);
|
List<ProjectModuleDO> getAllMoudleByPid(Long id);
|
||||||
|
|
||||||
@Select("select principal_id from organize_oa.oa_project where id=(select project_id "
|
@Select("select principal_id from organize_oa.oa_project where id=(select project_id "
|
||||||
+ "from organize_oa.oa_project_work where oa_project_work.id = #{sysId})")
|
+ "from organize_oa.oa_project_child where id = #{sysId})")
|
||||||
Long getPridBySysyid(Integer sysId);
|
Long getPridBySysyid(Integer sysId);
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,17 @@
|
|||||||
package com.jsl.oa.mapper;
|
package com.jsl.oa.mapper;
|
||||||
|
|
||||||
import com.jsl.oa.model.dodata.PermissionDO;
|
import com.jsl.oa.model.dodata.PermissionDO;
|
||||||
import com.jsl.oa.model.dodata.RolePermissionDO;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface PermissionMapper {
|
public interface PermissionMapper {
|
||||||
|
|
||||||
@Insert("INSERT INTO organize_oa.oa_role_permissions(rid, pid) VALUE (#{rid},#{pid})")
|
|
||||||
void permissionAdd(Long rid, Long pid);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_permissions WHERE id IN "
|
|
||||||
+ "(SELECT pid FROM organize_oa.oa_role_permissions WHERE rid IN "
|
|
||||||
+ "(SELECT rid FROM organize_oa.oa_role_user WHERE uid = #{uid}))")
|
|
||||||
List<PermissionDO> permissionUserPid(Long uid);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_permissions where id=#{id}")
|
|
||||||
PermissionDO getPermissionById(Long id);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_role_permissions where pid=#{pid}")
|
|
||||||
RolePermissionDO rolePermissionGetByPid(Long pid);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_permissions")
|
@Select("SELECT * FROM organize_oa.oa_permissions")
|
||||||
List<PermissionDO> getAllPermission();
|
List<PermissionDO> getAllPermission();
|
||||||
|
|
||||||
@Update("UPDATE organize_oa.oa_permissions SET pid = #{pid}, name = #{name}, code = #{code}, "
|
@Select("SELECT permissions FROM organize_oa.oa_role WHERE role_name = #{roleName}")
|
||||||
+ "type = #{type} WHERE id = #{id}")
|
String getPermissionByRole(String roleName);
|
||||||
boolean updatePermission(PermissionDO permissionDO);
|
|
||||||
|
|
||||||
@Delete("DELETE FROM organize_oa.oa_permissions where id=#{pid}")
|
|
||||||
boolean deletePermission(Long pid);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_permissions WHERE id IN (#{permissionList})")
|
|
||||||
List<PermissionDO> permissionGet(String permissionList);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_permissions WHERE id = #{pid}")
|
|
||||||
PermissionDO getPermissionByPid(Long pid);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM organize_oa.oa_permissions WHERE pid = #{id}")
|
|
||||||
List<PermissionDO> getChildPermission(Long id);
|
|
||||||
}
|
}
|
||||||
|
@ -90,14 +90,19 @@ public interface ProjectMapper {
|
|||||||
@Select("select * from organize_oa.oa_project_modules where id=#{id}")
|
@Select("select * from organize_oa.oa_project_modules where id=#{id}")
|
||||||
ProjectModuleDO getModuleById(Integer id);
|
ProjectModuleDO getModuleById(Integer id);
|
||||||
|
|
||||||
@Select("select principal_id from organize_oa.oa_project_work where id=#{pid}")
|
@Select("select principal_id from organize_oa.oa_project where id="
|
||||||
Long getPirIdbyWorkid(Long pid);
|
+ "(select project_id from organize_oa.oa_project_child where id=#{id})")
|
||||||
|
Long getPirIdbyId(Long id);
|
||||||
|
|
||||||
@Select("select principal_id from organize_oa.oa_project_modules where project_child_id=#{id} "
|
@Select("select principal_id from organize_oa.oa_project_child where id="
|
||||||
+ "AND is_delete = 0")
|
+ "(select project_child_id from organize_oa.oa_project_modules where id=#{id})")
|
||||||
|
Long getPirTdByModuleId(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("select principal_id from organize_oa.oa_project_modules where id=#{id} ")
|
||||||
Long getPid(Integer id);
|
Long getPid(Integer id);
|
||||||
|
|
||||||
@Select("select * from organize_oa.oa_project_work where id=#{id} "
|
@Select("select * from organize_oa.oa_project_child where id=#{id} "
|
||||||
+ "AND is_delete = 0")
|
+ "AND is_delete = 0")
|
||||||
ProjectModuleDO getProjectWorkById(Long id);
|
ProjectModuleDO getProjectWorkById(Long id);
|
||||||
|
|
||||||
@ -108,7 +113,7 @@ public interface ProjectMapper {
|
|||||||
List <Long> getMemberBySystemId(Integer id);
|
List <Long> getMemberBySystemId(Integer id);
|
||||||
|
|
||||||
@Select("select * from organize_oa.oa_project_modules "
|
@Select("select * from organize_oa.oa_project_modules "
|
||||||
+ "where DATE(deadline) = DATE(#{threeDayLater}) and status = 0")
|
+ "where DATE(dead_line) = DATE(#{threeDayLater}) and status != 'complete' ")
|
||||||
List<ProjectModuleDO> getProjectWorkByTime(LocalDateTime threeDayLater);
|
List<ProjectModuleDO> getProjectWorkByTime(LocalDateTime threeDayLater);
|
||||||
|
|
||||||
|
|
||||||
@ -126,11 +131,18 @@ public interface ProjectMapper {
|
|||||||
|
|
||||||
|
|
||||||
@Select("select * from organize_oa.oa_project_child where "
|
@Select("select * from organize_oa.oa_project_child where "
|
||||||
+ "DATE (created_at) = DATE (#{threeDaysLater}) and status = 0")
|
+ "DATE (dead_line) = DATE (#{threeDaysLater}) and status != 'complete' ")
|
||||||
List<ProjectChildDO> getProjectChildByTime(LocalDateTime threeDaysLater);
|
List<ProjectChildDO> getProjectChildByTime(LocalDateTime threeDaysLater);
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from organize_oa.oa_project_child where "
|
@Select("select * from organize_oa.oa_project_child where "
|
||||||
+ "id = #{id} and is_delete = 0")
|
+ "id = #{id} and is_delete = 0")
|
||||||
ProjectChildDO getProjectChildById(Integer id);
|
ProjectChildDO getProjectChildById(Integer id);
|
||||||
|
|
||||||
|
|
||||||
|
List<ProjectDO> getParticipateProject(Long userId);
|
||||||
|
|
||||||
|
void deleteProjectChild(Long id1);
|
||||||
|
|
||||||
|
void deleteProjectModule(Long id1);
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,6 @@ public interface RoleMapper {
|
|||||||
@Delete("DELETE FROM organize_oa.oa_role WHERE id=#{id}")
|
@Delete("DELETE FROM organize_oa.oa_role WHERE id=#{id}")
|
||||||
boolean roleDelete(Long id);
|
boolean roleDelete(Long id);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM organize_oa.oa_role WHERE id = (SELECT rid FROM organize_oa.oa_role_user WHERE uid=#{uid})")
|
||||||
|
RoleDO getRoleByUserId(Long uid);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ public class MessageDO {
|
|||||||
private String title;
|
private String title;
|
||||||
private String text;
|
private String text;
|
||||||
private Integer isDelete;
|
private Integer isDelete;
|
||||||
|
private String type;
|
||||||
|
private Long toId;
|
||||||
private Timestamp createdAt;
|
private Timestamp createdAt;
|
||||||
private Timestamp deletedAt;
|
private Timestamp deletedAt;
|
||||||
|
|
||||||
|
@ -19,10 +19,12 @@ import java.sql.Timestamp;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class PermissionDO {
|
public class PermissionDO {
|
||||||
|
// 主键
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long pid;
|
// 权限名称
|
||||||
private String name;
|
private String name;
|
||||||
private String code;
|
// 权限描述
|
||||||
private Short type;
|
private String description;
|
||||||
private Timestamp deletedAt;
|
// 创建时间
|
||||||
|
private Timestamp createdAt;
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,21 @@ import java.sql.Timestamp;
|
|||||||
*
|
*
|
||||||
* @author 筱锋xiao_lfeng
|
* @author 筱锋xiao_lfeng
|
||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
* @version v1.1.0
|
* @version v1.2.0
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class RoleDO {
|
public class RoleDO {
|
||||||
|
// 角色id
|
||||||
private Long id;
|
private Long id;
|
||||||
|
// 角色名称
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
// 中文描述
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
// 用户组权限
|
||||||
|
private String permissions;
|
||||||
|
// 创建时间
|
||||||
private Timestamp createdAt;
|
private Timestamp createdAt;
|
||||||
|
// 修改时间
|
||||||
private Timestamp updatedAt;
|
private Timestamp updatedAt;
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package com.jsl.oa.model.dodata;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h1>role 数据表</h1>
|
|
||||||
* <hr/>
|
|
||||||
* 映射 oa_role 数据表内容进入自定义实体类
|
|
||||||
*
|
|
||||||
* @author 筱锋xiao_lfeng
|
|
||||||
* @since v1.1.0
|
|
||||||
* @version v1.1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class RolePermissionDO {
|
|
||||||
private Long rid;
|
|
||||||
private Long pid;
|
|
||||||
private Timestamp createdAt;
|
|
||||||
}
|
|
@ -13,6 +13,6 @@ public class MessageAddVO {
|
|||||||
private Long uid;
|
private Long uid;
|
||||||
private Long sid;
|
private Long sid;
|
||||||
private String type;
|
private String type;
|
||||||
private Integer toId;
|
private Long toId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,12 @@ import java.sql.Timestamp;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class MessageGetVO {
|
public class MessageGetVO {
|
||||||
|
private Long id;
|
||||||
private String text;
|
private String text;
|
||||||
private String title;
|
private String title;
|
||||||
private Timestamp createdAt;
|
private Timestamp createdAt;
|
||||||
private String senderName;
|
private String senderName;
|
||||||
|
private String type;
|
||||||
|
private Long toId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
17
src/main/java/com/jsl/oa/model/vodata/PageBean.java
Normal file
17
src/main/java/com/jsl/oa/model/vodata/PageBean.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.jsl.oa.model.vodata;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PageBean<T> {
|
||||||
|
private int totalCount; // 总记录数
|
||||||
|
private int currentPage; // 当前页码
|
||||||
|
private int pageSize; // 每页记录数
|
||||||
|
private List<T> list; // 当前页的数据列表
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.jsl.oa.model.vodata;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PermissionContentVO {
|
||||||
|
// 主键
|
||||||
|
private Long id;
|
||||||
|
// 权限名称
|
||||||
|
private String name;
|
||||||
|
// 权限描述
|
||||||
|
private String description;
|
||||||
|
}
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.jsl.oa.model.vodata;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PermissionContentVo {
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
private String name;
|
|
||||||
private String code;
|
|
||||||
private Short type;
|
|
||||||
private List<PermissionContentVo> children;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -23,6 +23,7 @@ public class ProjectInfoVO {
|
|||||||
private String files;
|
private String files;
|
||||||
private Timestamp beginTime;
|
private Timestamp beginTime;
|
||||||
private Timestamp completeTime;
|
private Timestamp completeTime;
|
||||||
|
@NotNull(message = "截止时间不能为空")
|
||||||
private Timestamp deadLine;
|
private Timestamp deadLine;
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.jsl.oa.model.vodata;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ProjectModuleSimpleVO {
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private Integer workLoad;
|
||||||
|
private Timestamp deadLine;
|
||||||
|
private String status;
|
||||||
|
private String principalUser;
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@ -14,5 +16,8 @@ public class ProjectSimpleVO {
|
|||||||
private Long cycle;
|
private Long cycle;
|
||||||
private Long workLoad;
|
private Long workLoad;
|
||||||
private Long id;
|
private Long id;
|
||||||
|
private String files;
|
||||||
|
private String status;
|
||||||
|
private Date deadLine;
|
||||||
private String tags;
|
private String tags;
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,14 @@ public class ProjectWorkSimpleVO {
|
|||||||
private String name;
|
private String name;
|
||||||
private Long principalId;
|
private Long principalId;
|
||||||
private String principalUser;
|
private String principalUser;
|
||||||
private Integer isFinish;
|
|
||||||
private String description;
|
private String description;
|
||||||
private Long cycle;
|
private Long cycle;
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
private Long workLoad;
|
private Long workLoad;
|
||||||
private Long id;
|
private Long id;
|
||||||
private String tags;
|
private String tags;
|
||||||
private Integer status;
|
private String status;
|
||||||
|
private Timestamp deadLine;
|
||||||
private Timestamp beginTime;
|
private Timestamp beginTime;
|
||||||
private Timestamp completeTime;
|
private Timestamp completeTime;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
package com.jsl.oa.services;
|
package com.jsl.oa.services;
|
||||||
|
|
||||||
import com.jsl.oa.model.vodata.PermissionEditVO;
|
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public interface PermissionService {
|
public interface PermissionService {
|
||||||
|
|
||||||
BaseResponse permissionAdd(HttpServletRequest request, Long rid, Long pid);
|
|
||||||
|
|
||||||
BaseResponse permissionUser(HttpServletRequest request, Long uid);
|
BaseResponse permissionUser(HttpServletRequest request, Long uid);
|
||||||
|
|
||||||
BaseResponse permissionGet(HttpServletRequest request);
|
BaseResponse permissionGet(HttpServletRequest request);
|
||||||
|
|
||||||
BaseResponse permissionEdit(PermissionEditVO permissionEditVo, HttpServletRequest request);
|
|
||||||
|
|
||||||
BaseResponse permissionDelete(HttpServletRequest request, Long pid);
|
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ public interface ProjectService {
|
|||||||
|
|
||||||
BaseResponse projectFileGet(HttpServletRequest request, Long projectId);
|
BaseResponse projectFileGet(HttpServletRequest request, Long projectId);
|
||||||
|
|
||||||
BaseResponse getById(Integer id);
|
BaseResponse getProjectModuleById(Integer id);
|
||||||
|
|
||||||
BaseResponse getWorkById(Integer id);
|
BaseResponse getModuleById(Integer id);
|
||||||
|
|
||||||
BaseResponse projectPrincipalGet();
|
BaseResponse projectPrincipalGet();
|
||||||
|
|
||||||
@ -57,4 +57,14 @@ public interface ProjectService {
|
|||||||
* @return 根据用户所属角色组的不同返回不同的内容
|
* @return 根据用户所属角色组的不同返回不同的内容
|
||||||
*/
|
*/
|
||||||
BaseResponse getProjectById(HttpServletRequest request, Long projectId);
|
BaseResponse getProjectById(HttpServletRequest request, Long projectId);
|
||||||
|
|
||||||
|
BaseResponse getById(Integer id);
|
||||||
|
|
||||||
|
BaseResponse getPrincipalProject(Integer page, Integer pageSize, HttpServletRequest request);
|
||||||
|
|
||||||
|
BaseResponse getParticipateProject(Integer page, Integer pageSize, HttpServletRequest request);
|
||||||
|
|
||||||
|
BaseResponse projectChildDelete(HttpServletRequest request, List<Long> id);
|
||||||
|
|
||||||
|
BaseResponse projectModuleDelete(HttpServletRequest request, List<Long> id);
|
||||||
}
|
}
|
||||||
|
@ -209,11 +209,15 @@ public class AuthServiceImpl implements AuthService {
|
|||||||
public BaseResponse authLogout(HttpServletRequest request) {
|
public BaseResponse authLogout(HttpServletRequest request) {
|
||||||
// 获取用户
|
// 获取用户
|
||||||
UserDO userDO = userMapper.getUserById(Processing.getAuthHeaderToUserId(request));
|
UserDO userDO = userMapper.getUserById(Processing.getAuthHeaderToUserId(request));
|
||||||
// 删除Token
|
if (userDO != null) {
|
||||||
if (tokenRedisUtil.delData(BusinessConstants.BUSINESS_LOGIN, userDO.getId().toString())) {
|
// 删除Token
|
||||||
return ResultUtil.success("登出成功");
|
if (tokenRedisUtil.delData(BusinessConstants.BUSINESS_LOGIN, userDO.getId().toString())) {
|
||||||
|
return ResultUtil.success("登出成功");
|
||||||
|
} else {
|
||||||
|
return ResultUtil.error(ErrorCode.TOKEN_NOT_EXIST);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return ResultUtil.error(ErrorCode.DATABASE_DELETE_ERROR);
|
return ResultUtil.error(ErrorCode.TOKEN_NOT_EXIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.jsl.oa.services.impl;
|
package com.jsl.oa.services.impl;
|
||||||
|
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
import com.jsl.oa.dao.InfoDAO;
|
import com.jsl.oa.dao.InfoDAO;
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
@ -41,7 +41,7 @@ public class InfoServiceImpl implements InfoService {
|
|||||||
private final RoleDAO roleDAO;
|
private final RoleDAO roleDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.image.add")
|
@NeedPermission("info.image.add")
|
||||||
public BaseResponse addHeaderImage(HttpServletRequest request, @NotNull CarouselVO carouselVO) {
|
public BaseResponse addHeaderImage(HttpServletRequest request, @NotNull CarouselVO carouselVO) {
|
||||||
// 获取用户
|
// 获取用户
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
@ -74,7 +74,7 @@ public class InfoServiceImpl implements InfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.image.edit")
|
@NeedPermission("info.image.edit")
|
||||||
public BaseResponse editHeaderImage(HttpServletRequest request, @NotNull CarouselVO carouselVO) {
|
public BaseResponse editHeaderImage(HttpServletRequest request, @NotNull CarouselVO carouselVO) {
|
||||||
// 获取用户
|
// 获取用户
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
@ -124,10 +124,10 @@ public class InfoServiceImpl implements InfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.image.del")
|
@NeedPermission("info.image.del")
|
||||||
public BaseResponse delHeaderImage(HttpServletRequest request, Integer id) {
|
public BaseResponse delHeaderImage(HttpServletRequest request, Integer id) {
|
||||||
// 用户权限校验
|
// 用户权限校验
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 获取轮播图信息
|
// 获取轮播图信息
|
||||||
@ -146,10 +146,10 @@ public class InfoServiceImpl implements InfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.image.setting.edit")
|
@NeedPermission("info.image.setting.edit")
|
||||||
public BaseResponse editSettingHeaderImage(HttpServletRequest request, Boolean showType) {
|
public BaseResponse editSettingHeaderImage(HttpServletRequest request, Boolean showType) {
|
||||||
// 用户权限校验
|
// 用户权限校验
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 获取轮播图信息
|
// 获取轮播图信息
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.jsl.oa.services.impl;
|
package com.jsl.oa.services.impl;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.jsl.oa.annotations.UserAbleToUse;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.mapper.MessageMapper;
|
import com.jsl.oa.mapper.MessageMapper;
|
||||||
import com.jsl.oa.mapper.ProjectMapper;
|
import com.jsl.oa.mapper.ProjectMapper;
|
||||||
@ -39,7 +39,7 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
private final ProjectMapper projectMapper;
|
private final ProjectMapper projectMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@UserAbleToUse
|
|
||||||
public BaseResponse messageDelete(Long mid, HttpServletRequest request) {
|
public BaseResponse messageDelete(Long mid, HttpServletRequest request) {
|
||||||
//获取消息数据
|
//获取消息数据
|
||||||
MessageDO messageDO = messageMapper.getMessageById(mid);
|
MessageDO messageDO = messageMapper.getMessageById(mid);
|
||||||
@ -57,7 +57,7 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
|
|
||||||
@SuppressWarnings("checkstyle:Regexp")
|
@SuppressWarnings("checkstyle:Regexp")
|
||||||
@Override
|
@Override
|
||||||
@UserAbleToUse
|
|
||||||
public BaseResponse messageGet(LocalDateTime beginTime,
|
public BaseResponse messageGet(LocalDateTime beginTime,
|
||||||
LocalDateTime endTime,
|
LocalDateTime endTime,
|
||||||
Integer page,
|
Integer page,
|
||||||
@ -68,25 +68,31 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
endTime = LocalDateTime.now();
|
endTime = LocalDateTime.now();
|
||||||
beginTime = endTime.minusDays(30);
|
beginTime = endTime.minusDays(30);
|
||||||
}
|
}
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
List<MessageDO> messageDOList = messageMapper.page(beginTime, endTime, uid);
|
List<MessageDO> messageDOList = messageMapper.page(beginTime, endTime, uid);
|
||||||
//封装返回数据
|
//封装返回数据
|
||||||
List<MessageGetVO> messageGetVOList = new ArrayList<>();
|
List<MessageGetVO> messageGetVOList = new ArrayList<>();
|
||||||
for (MessageDO messageDO : messageDOList) {
|
for (MessageDO messageDO : messageDOList) {
|
||||||
MessageGetVO messageGetVO1 = new MessageGetVO();
|
MessageGetVO messageGetVO1 = new MessageGetVO();
|
||||||
|
messageGetVO1.setId(messageDO.getId());
|
||||||
messageGetVO1.setText(messageDO.getText());
|
messageGetVO1.setText(messageDO.getText());
|
||||||
messageGetVO1.setTitle(messageDO.getTitle());
|
messageGetVO1.setTitle(messageDO.getTitle());
|
||||||
messageGetVO1.setCreatedAt(messageDO.getCreatedAt());
|
messageGetVO1.setCreatedAt(messageDO.getCreatedAt());
|
||||||
if (messageDO.getSid() != null) {
|
if (messageDO.getSid() != null) {
|
||||||
messageGetVO1.setSenderName(userDAO.getUserById(messageDO.getSid()).getUsername());
|
messageGetVO1.setSenderName(userDAO.getUserById(messageDO.getSid()).getUsername());
|
||||||
}
|
}
|
||||||
|
if (messageDO.getToId() != null) {
|
||||||
|
messageGetVO1.setToId(messageDO.getToId());
|
||||||
|
}
|
||||||
|
if (messageDO.getType() != null) {
|
||||||
|
messageGetVO1.setType(messageDO.getType());
|
||||||
|
}
|
||||||
messageGetVOList.add(messageGetVO1);
|
messageGetVOList.add(messageGetVO1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//分页返回
|
//分页返回
|
||||||
int start = (page - 1) * pageSize;
|
PageInfo<MessageGetVO> pageInfo = new PageInfo<>(messageGetVOList);
|
||||||
int end = start + pageSize;
|
return ResultUtil.success(pageInfo);
|
||||||
List<MessageGetVO> pageData = messageGetVOList.subList(start,
|
|
||||||
Math.min(end, messageGetVOList.size()));
|
|
||||||
return ResultUtil.success(pageData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +129,7 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
String moddleName = projectMapper.getModuleById(moddleId).getName();
|
String moddleName = projectMapper.getModuleById(moddleId).getName();
|
||||||
messageAddVO.setText(senderName + "指派了" + projectName + "项目的" + systemName + "子系统的" + moddleName + "子模块给您");
|
messageAddVO.setText(senderName + "指派了" + projectName + "项目的" + systemName + "子系统的" + moddleName + "子模块给您");
|
||||||
}
|
}
|
||||||
messageAddVO.setType("跳转审批页");
|
messageAddVO.setType("Review");
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +165,7 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
} else {
|
} else {
|
||||||
messageAddVO.setText("您申请的" + projectName + "项目的" + systemName + "系统的" + moddleName + "模块负责人未通过");
|
messageAddVO.setText("您申请的" + projectName + "项目的" + systemName + "系统的" + moddleName + "模块负责人未通过");
|
||||||
}
|
}
|
||||||
messageAddVO.setType("消息详情");
|
messageAddVO.setType("Message");
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +201,8 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
} else if (type == 1) {
|
} else if (type == 1) {
|
||||||
messageAddVO.setText("项目负责人" + senderName + "上传了文档到" + projectName + "项目");
|
messageAddVO.setText("项目负责人" + senderName + "上传了文档到" + projectName + "项目");
|
||||||
}
|
}
|
||||||
messageAddVO.setType("跳转项目页");
|
messageAddVO.setType("Project");
|
||||||
messageAddVO.setToId(pId);
|
messageAddVO.setToId(pId.longValue());
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,8 +250,8 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
messageAddVO.setText("项目经理" + senderName + "修改了" + projectName + "项目的"
|
messageAddVO.setText("项目经理" + senderName + "修改了" + projectName + "项目的"
|
||||||
+ systemName + "系统的系统周期/工作量");
|
+ systemName + "系统的系统周期/工作量");
|
||||||
}
|
}
|
||||||
messageAddVO.setType("跳转系统页");
|
messageAddVO.setType("Project_child");
|
||||||
messageAddVO.setToId(systmeId);
|
messageAddVO.setToId(systmeId.longValue());
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,8 +314,8 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
String moddleName = projectWorkDO.getName();
|
String moddleName = projectWorkDO.getName();
|
||||||
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统的" + moddleName + "模块"
|
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统的" + moddleName + "模块"
|
||||||
+ "还有七天就要到期了,请及时处理");
|
+ "还有七天就要到期了,请及时处理");
|
||||||
messageAddVO.setType("跳转模块页");
|
messageAddVO.setType("Project_module");
|
||||||
messageAddVO.setToId(projectWorkDO.getId().intValue());
|
messageAddVO.setToId(projectWorkDO.getId());
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,8 +333,8 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
String moddleName = projectWorkDO.getName();
|
String moddleName = projectWorkDO.getName();
|
||||||
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统的" + moddleName + "模块"
|
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统的" + moddleName + "模块"
|
||||||
+ "还有三天就要到期了,请及时处理");
|
+ "还有三天就要到期了,请及时处理");
|
||||||
messageAddVO.setType("跳转模块页");
|
messageAddVO.setType("Project_module");
|
||||||
messageAddVO.setToId(projectWorkDO.getId().intValue());
|
messageAddVO.setToId(projectWorkDO.getId());
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,8 +350,8 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
String projectName = projectMapper.tgetProjectById(projectChildDO.getProjectId().intValue()).getName();
|
String projectName = projectMapper.tgetProjectById(projectChildDO.getProjectId().intValue()).getName();
|
||||||
String systemName = projectChildDO.getName();
|
String systemName = projectChildDO.getName();
|
||||||
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统还有七天就要到期了,请及时处理");
|
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统还有七天就要到期了,请及时处理");
|
||||||
messageAddVO.setType("跳转系统页");
|
messageAddVO.setType("Project_child");
|
||||||
messageAddVO.setToId(projectChildDO.getId().intValue());
|
messageAddVO.setToId(projectChildDO.getId());
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,8 +366,8 @@ public class MessageServiceImpl implements MessageService {
|
|||||||
String projectName = projectMapper.tgetProjectById(projectChildDO.getProjectId().intValue()).getName();
|
String projectName = projectMapper.tgetProjectById(projectChildDO.getProjectId().intValue()).getName();
|
||||||
String systemName = projectChildDO.getName();
|
String systemName = projectChildDO.getName();
|
||||||
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统还有三天就要到期了,请及时处理");
|
messageAddVO.setText("您负责的" + projectName + "项目的" + systemName + "系统还有三天就要到期了,请及时处理");
|
||||||
messageAddVO.setType("跳转系统页");
|
messageAddVO.setType("Project_child");
|
||||||
messageAddVO.setToId(projectChildDO.getId().intValue());
|
messageAddVO.setToId(projectChildDO.getId());
|
||||||
messageMapper.messageAdd(messageAddVO);
|
messageMapper.messageAdd(messageAddVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.jsl.oa.dao.ProjectDAO;
|
|||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.mapper.ModuleMapper;
|
import com.jsl.oa.mapper.ModuleMapper;
|
||||||
|
import com.jsl.oa.model.dodata.ProjectChildDO;
|
||||||
import com.jsl.oa.model.dodata.ProjectModuleDO;
|
import com.jsl.oa.model.dodata.ProjectModuleDO;
|
||||||
import com.jsl.oa.model.vodata.ProjectWorkAndNameVO;
|
import com.jsl.oa.model.vodata.ProjectWorkAndNameVO;
|
||||||
import com.jsl.oa.services.ModuleService;
|
import com.jsl.oa.services.ModuleService;
|
||||||
@ -42,7 +43,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|||||||
is = 0;
|
is = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ProjectModuleDO> projectWorkDOList = moduleMapper.getByProjectId(projectId, userId, is);
|
List<ProjectChildDO> projectWorkDOList = moduleMapper.getByProjectId(projectId, userId, is);
|
||||||
return ResultUtil.success(projectWorkDOList);
|
return ResultUtil.success(projectWorkDOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ public class ModuleServiceImpl implements ModuleService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse deleteById(HttpServletRequest request, Long id) {
|
public BaseResponse deleteById(HttpServletRequest request, Long id) {
|
||||||
// 检测是否为管理员
|
// 检测是否为管理员
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.jsl.oa.services.impl;
|
package com.jsl.oa.services.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
import com.jsl.oa.dao.NewsDAO;
|
import com.jsl.oa.dao.NewsDAO;
|
||||||
import com.jsl.oa.model.dodata.NewsDO;
|
import com.jsl.oa.model.dodata.NewsDO;
|
||||||
import com.jsl.oa.model.vodata.NewsAddVO;
|
import com.jsl.oa.model.vodata.NewsAddVO;
|
||||||
@ -35,7 +35,7 @@ public class NewsServiceImpl implements NewsService {
|
|||||||
private final NewsDAO newsDAO;
|
private final NewsDAO newsDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("news.add")
|
@NeedPermission("news.add")
|
||||||
public BaseResponse newsAdd(NewsAddVO newsAddVO, @NotNull HttpServletRequest request) {
|
public BaseResponse newsAdd(NewsAddVO newsAddVO, @NotNull HttpServletRequest request) {
|
||||||
// 拷贝新闻数据到实体类
|
// 拷贝新闻数据到实体类
|
||||||
NewsDO newsDO = new NewsDO();
|
NewsDO newsDO = new NewsDO();
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
package com.jsl.oa.services.impl;
|
package com.jsl.oa.services.impl;
|
||||||
|
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
|
||||||
import com.jsl.oa.dao.PermissionDAO;
|
import com.jsl.oa.dao.PermissionDAO;
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.mapper.PermissionMapper;
|
|
||||||
import com.jsl.oa.model.dodata.PermissionDO;
|
import com.jsl.oa.model.dodata.PermissionDO;
|
||||||
import com.jsl.oa.model.dodata.RoleUserDO;
|
import com.jsl.oa.model.dodata.RoleUserDO;
|
||||||
import com.jsl.oa.model.vodata.PermissionContentVo;
|
import com.jsl.oa.model.vodata.PermissionContentVO;
|
||||||
import com.jsl.oa.model.vodata.PermissionEditVO;
|
|
||||||
import com.jsl.oa.services.PermissionService;
|
import com.jsl.oa.services.PermissionService;
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
import com.jsl.oa.utils.ErrorCode;
|
import com.jsl.oa.utils.ErrorCode;
|
||||||
import com.jsl.oa.utils.Processing;
|
|
||||||
import com.jsl.oa.utils.ResultUtil;
|
import com.jsl.oa.utils.ResultUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,29 +24,20 @@ import java.util.List;
|
|||||||
* <hr/>
|
* <hr/>
|
||||||
* 用于权限服务层的实现类,实现权限的增删改查,以及用户权限的获取
|
* 用于权限服务层的实现类,实现权限的增删改查,以及用户权限的获取
|
||||||
*
|
*
|
||||||
* @since v1.0.0
|
|
||||||
* @version v1.1.0
|
|
||||||
* @author xiao_lfeng | xiangZr-hhh | 176yunxuan
|
* @author xiao_lfeng | xiangZr-hhh | 176yunxuan
|
||||||
|
* @version v1.1.0
|
||||||
|
* @since v1.0.0
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PermissionServiceImpl implements PermissionService {
|
public class PermissionServiceImpl implements PermissionService {
|
||||||
|
|
||||||
private final PermissionMapper permissionMapper;
|
|
||||||
private final RoleDAO roleDAO;
|
private final RoleDAO roleDAO;
|
||||||
private final PermissionDAO permissionDAO;
|
private final PermissionDAO permissionDAO;
|
||||||
private final UserDAO userDAO;
|
private final UserDAO userDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("permission.add")
|
|
||||||
public BaseResponse permissionAdd(HttpServletRequest request, Long rid, Long pid) {
|
|
||||||
permissionMapper.permissionAdd(rid, pid);
|
|
||||||
return ResultUtil.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NeedRoleGroup("permission.user")
|
|
||||||
public BaseResponse permissionUser(HttpServletRequest request, Long uid) {
|
public BaseResponse permissionUser(HttpServletRequest request, Long uid) {
|
||||||
if (userDAO.isExistUser(uid)) {
|
if (userDAO.isExistUser(uid)) {
|
||||||
// 此用户是否为管理员
|
// 此用户是否为管理员
|
||||||
@ -68,40 +57,11 @@ public class PermissionServiceImpl implements PermissionService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("permission.get")
|
|
||||||
public BaseResponse permissionGet(HttpServletRequest request) {
|
public BaseResponse permissionGet(HttpServletRequest request) {
|
||||||
//获取所有权限数据
|
//获取所有权限数据
|
||||||
List<PermissionDO> permissionDOList = permissionMapper.getAllPermission();
|
List<PermissionDO> permissionDOList = permissionDAO.getAllPermission();
|
||||||
//将数据按父子类封装
|
List<PermissionContentVO> permissionContentVO = new ArrayList<>();
|
||||||
List<PermissionContentVo> permissionContentVos = Processing.convertToVoList(permissionDOList);
|
BeanUtils.copyProperties(permissionDOList, permissionContentVO);
|
||||||
|
return ResultUtil.success(permissionContentVO);
|
||||||
return ResultUtil.success(permissionContentVos);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NeedRoleGroup("permission.edit")
|
|
||||||
public BaseResponse permissionEdit(PermissionEditVO permissionEditVo, HttpServletRequest request) {
|
|
||||||
//根据id获取对应permission数据
|
|
||||||
PermissionDO permissionDO = permissionMapper.getPermissionById(permissionEditVo.getId());
|
|
||||||
if (permissionDO == null) {
|
|
||||||
return ResultUtil.error(ErrorCode.PERMISSION_NOT_EXIST);
|
|
||||||
}
|
|
||||||
//传递要编辑的数据
|
|
||||||
Processing.copyProperties(permissionEditVo, permissionDO);
|
|
||||||
//更新permission
|
|
||||||
if (!permissionMapper.updatePermission(permissionDO)) {
|
|
||||||
return ResultUtil.error(ErrorCode.DATABASE_UPDATE_ERROR);
|
|
||||||
}
|
|
||||||
return ResultUtil.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NeedRoleGroup("permission.delete")
|
|
||||||
public BaseResponse permissionDelete(HttpServletRequest request, Long pid) {
|
|
||||||
//删除权限
|
|
||||||
if (!permissionMapper.deletePermission(pid)) {
|
|
||||||
return ResultUtil.error(ErrorCode.DATABASE_DELETE_ERROR);
|
|
||||||
}
|
|
||||||
return ResultUtil.success();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,21 @@ package com.jsl.oa.services.impl;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
import com.jsl.oa.dao.ProjectDAO;
|
import com.jsl.oa.dao.ProjectDAO;
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.mapper.ProjectMapper;
|
import com.jsl.oa.mapper.ProjectMapper;
|
||||||
import com.jsl.oa.mapper.UserMapper;
|
import com.jsl.oa.mapper.UserMapper;
|
||||||
import com.jsl.oa.model.dodata.ProjectDO;
|
import com.jsl.oa.model.dodata.ProjectDO;
|
||||||
|
import com.jsl.oa.model.dodata.ProjectModuleDO;
|
||||||
import com.jsl.oa.model.dodata.UserDO;
|
import com.jsl.oa.model.dodata.UserDO;
|
||||||
import com.jsl.oa.model.dodata.info.ProjectShowDO;
|
import com.jsl.oa.model.dodata.info.ProjectShowDO;
|
||||||
import com.jsl.oa.model.vodata.*;
|
import com.jsl.oa.model.vodata.*;
|
||||||
import com.jsl.oa.model.vodata.business.info.ProjectShowVO;
|
import com.jsl.oa.model.vodata.business.info.ProjectShowVO;
|
||||||
|
import com.jsl.oa.services.MessageService;
|
||||||
import com.jsl.oa.services.ProjectService;
|
import com.jsl.oa.services.ProjectService;
|
||||||
import com.jsl.oa.utils.BaseResponse;
|
import com.jsl.oa.utils.BaseResponse;
|
||||||
import com.jsl.oa.utils.ErrorCode;
|
import com.jsl.oa.utils.ErrorCode;
|
||||||
@ -30,6 +34,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static java.lang.System.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>项目服务层实现类</h1>
|
* <h1>项目服务层实现类</h1>
|
||||||
* <hr/>
|
* <hr/>
|
||||||
@ -51,13 +57,19 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
private final UserDAO userDAO;
|
private final UserDAO userDAO;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final RoleDAO roleDAO;
|
private final RoleDAO roleDAO;
|
||||||
|
private final MessageService messageService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd) {
|
public BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd) {
|
||||||
|
// 判断权限
|
||||||
|
if (!Processing.checkUserIsPrincipal(request, roleDAO)) {
|
||||||
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
|
}
|
||||||
|
|
||||||
if (projectAdd.getDescription().isEmpty()) {
|
if (projectAdd.getDescription().isEmpty()) {
|
||||||
projectAdd.setDescription("{}");
|
projectAdd.setDescription("{}");
|
||||||
} else {
|
} else {
|
||||||
projectAdd.setDescription("{\"description\":\" " + projectAdd.getDescription() + "\"}");
|
projectAdd.setDescription("{\"描述\":\" " + projectAdd.getDescription() + "\"}");
|
||||||
}
|
}
|
||||||
String tags = projectAdd.getTags();
|
String tags = projectAdd.getTags();
|
||||||
String[] split = tags.split(",");
|
String[] split = tags.split(",");
|
||||||
@ -85,14 +97,14 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
//是否是增加子系统
|
//是否是增加子系统
|
||||||
if (projectWorkVO.getType() == 0) {
|
if (projectWorkVO.getType() == 0) {
|
||||||
//是否是老师
|
//是否是老师
|
||||||
if (Processing.checkUserIsTeacher(request, roleDAO)) {
|
if (Processing.checkUserIsPrincipal(request, roleDAO)) {
|
||||||
projectDAO.projectWorkAdd(projectWorkVO);
|
projectDAO.projectWorkAdd(projectWorkVO);
|
||||||
} else {
|
} else {
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//是否是子系统的负责人
|
//是否是子系统的负责人
|
||||||
if (Objects.equals(userId, projectMapper.getPirIdbyWorkid(projectWorkVO.getPid()))) {
|
if (Objects.equals(userId, projectMapper.getPirIdbyId(projectWorkVO.getPid()))) {
|
||||||
projectDAO.projectWorkAdd(projectWorkVO);
|
projectDAO.projectWorkAdd(projectWorkVO);
|
||||||
} else {
|
} else {
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
@ -147,6 +159,11 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse getProjectModuleById(Integer id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse getById(Integer id) {
|
public BaseResponse getById(Integer id) {
|
||||||
ProjectDO projectDO = projectMapper.tgetProjectById(id);
|
ProjectDO projectDO = projectMapper.tgetProjectById(id);
|
||||||
@ -154,10 +171,79 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse getWorkById(Integer id) {
|
public BaseResponse getPrincipalProject(Integer page, Integer pageSize, HttpServletRequest request) {
|
||||||
ProjectWorkSimpleVO projectWorkSimpleVO = projectMapper.getWorkById(id);
|
//获取用户id
|
||||||
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
|
|
||||||
projectWorkSimpleVO.setPrincipalUser(userDAO.getUserById(projectMapper.getPid(id)).getUsername());
|
PageHelper.startPage(page, pageSize);
|
||||||
|
List<ProjectDO> projectDOList = projectDAO.get(userId, null, null);
|
||||||
|
|
||||||
|
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
|
||||||
|
for (ProjectDO projectDO : projectDOList) {
|
||||||
|
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
|
||||||
|
Processing.projectTosimply(projectSimpleVO1, projectDO, userDAO, objectMapper);
|
||||||
|
projectSimpleVOList.add(projectSimpleVO1);
|
||||||
|
}
|
||||||
|
//分页返回
|
||||||
|
PageInfo<ProjectSimpleVO> pageInfo = new PageInfo<>(projectSimpleVOList);
|
||||||
|
return ResultUtil.success(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse getParticipateProject(Integer page, Integer pageSize, HttpServletRequest request) {
|
||||||
|
//获取用户id
|
||||||
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
|
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
|
List<ProjectDO> projectDOList = projectMapper.getParticipateProject(userId);
|
||||||
|
|
||||||
|
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
|
||||||
|
for (ProjectDO projectDO : projectDOList) {
|
||||||
|
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
|
||||||
|
Processing.projectTosimply(projectSimpleVO1, projectDO, userDAO, objectMapper);
|
||||||
|
projectSimpleVOList.add(projectSimpleVO1);
|
||||||
|
}
|
||||||
|
//分页返回
|
||||||
|
PageInfo<ProjectSimpleVO> pageInfo = new PageInfo<>(projectSimpleVOList);
|
||||||
|
return ResultUtil.success(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse projectChildDelete(HttpServletRequest request, List<Long> id) {
|
||||||
|
//判断是否是项目负责人
|
||||||
|
for (Long id1 : id) {
|
||||||
|
if (!Objects.equals(Processing.getAuthHeaderToUserId(request), projectMapper.getPirIdbyId(id1))) {
|
||||||
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
|
} else {
|
||||||
|
projectMapper.deleteProjectChild(id1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse projectModuleDelete(HttpServletRequest request, List<Long> id) {
|
||||||
|
//判断是否是子系统负责人
|
||||||
|
for (Long id1 : id) {
|
||||||
|
if (!Objects.equals(Processing.getAuthHeaderToUserId(request), projectMapper.getPirTdByModuleId(id1))) {
|
||||||
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
|
} else {
|
||||||
|
Integer projectChildId = projectMapper.getModuleById(id1.intValue()).getProjectChildId().intValue();
|
||||||
|
out.println(projectChildId);
|
||||||
|
Integer projectId = projectMapper.getWorkById(projectChildId).getProjectId().intValue();
|
||||||
|
out.println(projectId);
|
||||||
|
projectMapper.deleteProjectModule(id1);
|
||||||
|
messageService.messageAdd(projectId, projectChildId, id1.intValue(), 1, request);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse getModuleById(Integer id) {
|
||||||
|
ProjectModuleDO projectWorkSimpleVO = projectMapper.getModuleById(id);
|
||||||
// 解析JSON字符串
|
// 解析JSON字符串
|
||||||
JsonNode rootNode;
|
JsonNode rootNode;
|
||||||
try {
|
try {
|
||||||
@ -172,7 +258,12 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
} catch (JsonProcessingException ignored) {
|
} catch (JsonProcessingException ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return ResultUtil.success(projectWorkSimpleVO);
|
ProjectModuleSimpleVO projectModuleSimpleVO = new ProjectModuleSimpleVO();
|
||||||
|
projectModuleSimpleVO.setPrincipalUser(userDAO.getUserById(projectMapper.getPid(id)).getUsername());
|
||||||
|
out.println("准备拷贝");
|
||||||
|
Processing.copyProperties(projectWorkSimpleVO, projectModuleSimpleVO);
|
||||||
|
out.println("拷贝wan");
|
||||||
|
return ResultUtil.success(projectModuleSimpleVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -201,7 +292,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
|
|
||||||
|
|
||||||
//判断用户是否为老师 或者 项目负责人
|
//判断用户是否为老师 或者 项目负责人
|
||||||
if (!Processing.checkUserIsTeacher(request, roleDAO)
|
if (!Processing.checkUserIsPrincipal(request, roleDAO)
|
||||||
|| !projectDAO.isPrincipalUser(Processing.getAuthHeaderToUserId(request), projectId)) {
|
|| !projectDAO.isPrincipalUser(Processing.getAuthHeaderToUserId(request), projectId)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
}
|
}
|
||||||
@ -232,7 +323,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.project.add")
|
@NeedPermission("info.project.add")
|
||||||
public BaseResponse addHeader(HttpServletRequest request, ProjectShowVO projectShowVO) {
|
public BaseResponse addHeader(HttpServletRequest request, ProjectShowVO projectShowVO) {
|
||||||
// 获取用户
|
// 获取用户
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
@ -247,7 +338,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
.setStatus(projectShowVO.getStatus())
|
.setStatus(projectShowVO.getStatus())
|
||||||
.setIsActive(projectShowVO.getIsActive())
|
.setIsActive(projectShowVO.getIsActive())
|
||||||
.setAuthor(userDO.getUsername())
|
.setAuthor(userDO.getUsername())
|
||||||
.setCreatedAt(new Timestamp(System.currentTimeMillis()).toString());
|
.setCreatedAt(new Timestamp(currentTimeMillis()).toString());
|
||||||
projectShowDO.getData().add(projectShow);
|
projectShowDO.getData().add(projectShow);
|
||||||
// 保存展示
|
// 保存展示
|
||||||
if (projectDAO.setProjectShow(projectShowDO)) {
|
if (projectDAO.setProjectShow(projectShowDO)) {
|
||||||
@ -258,7 +349,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.project.del")
|
@NeedPermission("info.project.del")
|
||||||
public BaseResponse delHeader(Integer id, HttpServletRequest request) {
|
public BaseResponse delHeader(Integer id, HttpServletRequest request) {
|
||||||
// 获取展示信息
|
// 获取展示信息
|
||||||
ProjectShowDO projectShowDO = projectDAO.getHeader();
|
ProjectShowDO projectShowDO = projectDAO.getHeader();
|
||||||
@ -276,7 +367,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("info.project.edit")
|
@NeedPermission("info.project.edit")
|
||||||
public BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id) {
|
public BaseResponse editHeader(HttpServletRequest request, ProjectShowVO projectShowVO, Integer id) {
|
||||||
// 获取用户
|
// 获取用户
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
@ -294,7 +385,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
.setStatus(projectShowVO.getStatus())
|
.setStatus(projectShowVO.getStatus())
|
||||||
.setIsActive(projectShowVO.getIsActive())
|
.setIsActive(projectShowVO.getIsActive())
|
||||||
.setAuthor(userDO.getUsername())
|
.setAuthor(userDO.getUsername())
|
||||||
.setUpdatedAt(new Timestamp(System.currentTimeMillis()).toString());
|
.setUpdatedAt(new Timestamp(currentTimeMillis()).toString());
|
||||||
// 保存展示信息
|
// 保存展示信息
|
||||||
if (projectDAO.setProjectShow(projectShowDO)) {
|
if (projectDAO.setProjectShow(projectShowDO)) {
|
||||||
return ResultUtil.success();
|
return ResultUtil.success();
|
||||||
@ -312,9 +403,10 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
Integer page,
|
Integer page,
|
||||||
Integer pageSize
|
Integer pageSize
|
||||||
) {
|
) {
|
||||||
//获取用户
|
//获取用户id
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
|
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
List<ProjectDO> projectDOList = projectDAO.workget(userId, tags, isFinish, is);
|
List<ProjectDO> projectDOList = projectDAO.workget(userId, tags, isFinish, is);
|
||||||
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
|
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
|
||||||
for (ProjectDO projectDO : projectDOList) {
|
for (ProjectDO projectDO : projectDOList) {
|
||||||
@ -323,12 +415,8 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
projectSimpleVOList.add(projectSimpleVO1);
|
projectSimpleVOList.add(projectSimpleVO1);
|
||||||
}
|
}
|
||||||
//分页返回
|
//分页返回
|
||||||
int start = (page - 1) * pageSize;
|
PageInfo<ProjectSimpleVO> pageInfo = new PageInfo<>(projectSimpleVOList);
|
||||||
int end = start + pageSize;
|
return ResultUtil.success(pageInfo);
|
||||||
List<ProjectSimpleVO> pageData = projectSimpleVOList.subList(start,
|
|
||||||
Math.min(end, projectSimpleVOList.size()));
|
|
||||||
|
|
||||||
return ResultUtil.success(pageData);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +433,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
public BaseResponse projectDelete(HttpServletRequest request, List<Long> id) {
|
public BaseResponse projectDelete(HttpServletRequest request, List<Long> id) {
|
||||||
|
|
||||||
//判断用户是否为老师 或者 项目负责人
|
//判断用户是否为老师 或者 项目负责人
|
||||||
if (!Processing.checkUserIsTeacher(request, roleDAO)) {
|
if (!Processing.checkUserIsPrincipal(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.jsl.oa.services.impl;
|
package com.jsl.oa.services.impl;
|
||||||
|
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
import com.jsl.oa.annotations.NeedPermission;
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.exception.ClassCopyException;
|
import com.jsl.oa.exception.ClassCopyException;
|
||||||
@ -42,9 +42,9 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
private final UserDAO userDAO;
|
private final UserDAO userDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("role.add")
|
@NeedPermission("role.add")
|
||||||
public BaseResponse roleAddUser(HttpServletRequest request, Long uid, Long rid) {
|
public BaseResponse roleAddUser(HttpServletRequest request, Long uid, Long rid) {
|
||||||
if (Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
roleDAO.addRoleUser(uid, rid);
|
roleDAO.addRoleUser(uid, rid);
|
||||||
return ResultUtil.success();
|
return ResultUtil.success();
|
||||||
} else {
|
} else {
|
||||||
@ -55,7 +55,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Override
|
@Override
|
||||||
|
|
||||||
public BaseResponse roleRemoveUser(HttpServletRequest request, Long uid) {
|
public BaseResponse roleRemoveUser(HttpServletRequest request, Long uid) {
|
||||||
if (Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
roleDAO.delRoleUser(uid);
|
roleDAO.delRoleUser(uid);
|
||||||
return ResultUtil.success();
|
return ResultUtil.success();
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +74,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
return ResultUtil.error(ErrorCode.USER_NOT_CHANGE_TO_THEMSELVES);
|
return ResultUtil.error(ErrorCode.USER_NOT_CHANGE_TO_THEMSELVES);
|
||||||
}
|
}
|
||||||
//检测用户权限是否为管理员
|
//检测用户权限是否为管理员
|
||||||
if (Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
if (roleDAO.roleChangeUser(uid, rid)) {
|
if (roleDAO.roleChangeUser(uid, rid)) {
|
||||||
return ResultUtil.success();
|
return ResultUtil.success();
|
||||||
} else {
|
} else {
|
||||||
@ -88,7 +88,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse roleGet(HttpServletRequest request, String id) {
|
public BaseResponse roleGet(HttpServletRequest request, String id) {
|
||||||
// 检查用户权限
|
// 检查用户权限
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 获取 Role 权限组
|
// 获取 Role 权限组
|
||||||
@ -114,7 +114,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse roleEdit(HttpServletRequest request, RoleEditVO roleEditVO) {
|
public BaseResponse roleEdit(HttpServletRequest request, RoleEditVO roleEditVO) {
|
||||||
// 检查用户权限
|
// 检查用户权限
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 获取 Role 相关信息
|
// 获取 Role 相关信息
|
||||||
@ -137,7 +137,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse roleDelete(HttpServletRequest request, Long id) {
|
public BaseResponse roleDelete(HttpServletRequest request, Long id) {
|
||||||
// 检查用户权限
|
// 检查用户权限
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 获取 Role 相关信息
|
// 获取 Role 相关信息
|
||||||
@ -158,7 +158,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse addRole(HttpServletRequest request, RoleAddVo roleAddVO) throws ClassCopyException {
|
public BaseResponse addRole(HttpServletRequest request, RoleAddVo roleAddVO) throws ClassCopyException {
|
||||||
// 检查用户权限
|
// 检查用户权限
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 检查权限名称是否重复
|
// 检查权限名称是否重复
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package com.jsl.oa.services.impl;
|
package com.jsl.oa.services.impl;
|
||||||
|
|
||||||
import com.jsl.oa.annotations.NeedRoleGroup;
|
import com.google.gson.Gson;
|
||||||
import com.jsl.oa.annotations.UserAbleToUse;
|
import com.jsl.oa.annotations.UserAbleToUse;
|
||||||
import com.jsl.oa.dao.PermissionDAO;
|
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.model.dodata.RoleDO;
|
|
||||||
import com.jsl.oa.model.dodata.RoleUserDO;
|
|
||||||
import com.jsl.oa.model.dodata.UserDO;
|
import com.jsl.oa.model.dodata.UserDO;
|
||||||
import com.jsl.oa.model.vodata.*;
|
import com.jsl.oa.model.vodata.*;
|
||||||
import com.jsl.oa.services.UserService;
|
import com.jsl.oa.services.UserService;
|
||||||
@ -22,8 +19,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +38,7 @@ import java.util.regex.Pattern;
|
|||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
private final UserDAO userDAO;
|
private final UserDAO userDAO;
|
||||||
private final RoleDAO roleDAO;
|
private final RoleDAO roleDAO;
|
||||||
private final PermissionDAO permissionDAO;
|
private final Gson gson;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDO getUserInfoByUsername(String username) {
|
public UserDO getUserInfoByUsername(String username) {
|
||||||
@ -54,7 +49,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
public BaseResponse userDelete(HttpServletRequest request, Long id) {
|
public BaseResponse userDelete(HttpServletRequest request, Long id) {
|
||||||
//判断用户是否存在
|
//判断用户是否存在
|
||||||
if (userDAO.isExistUser(id)) {
|
if (userDAO.isExistUser(id)) {
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
// 用户是否已删除
|
// 用户是否已删除
|
||||||
@ -71,7 +66,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse userLock(HttpServletRequest request, Long id, Long isLock) {
|
public BaseResponse userLock(HttpServletRequest request, Long id, Long isLock) {
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
//判断用户是否存在
|
//判断用户是否存在
|
||||||
@ -94,7 +89,6 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NeedRoleGroup("user.current.all")
|
|
||||||
public BaseResponse userCurrentAll(HttpServletRequest request, @NotNull UserAllCurrentVO userAllCurrentVO) {
|
public BaseResponse userCurrentAll(HttpServletRequest request, @NotNull UserAllCurrentVO userAllCurrentVO) {
|
||||||
// 检查数据
|
// 检查数据
|
||||||
if (userAllCurrentVO.getPage() == null || userAllCurrentVO.getPage() < 1) {
|
if (userAllCurrentVO.getPage() == null || userAllCurrentVO.getPage() < 1) {
|
||||||
@ -127,46 +121,22 @@ public class UserServiceImpl implements UserService {
|
|||||||
return ResultUtil.success(userCurrentBackVO);
|
return ResultUtil.success(userCurrentBackVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("checkstyle:NestedIfDepth")
|
|
||||||
@Override
|
@Override
|
||||||
@UserAbleToUse
|
@UserAbleToUse
|
||||||
public BaseResponse userCurrent(HttpServletRequest request,
|
public BaseResponse userCurrent(
|
||||||
String id,
|
HttpServletRequest request,
|
||||||
String username,
|
String id,
|
||||||
String email,
|
String username,
|
||||||
String phone) {
|
String email,
|
||||||
|
String phone
|
||||||
|
) {
|
||||||
|
UserDO userDO;
|
||||||
if (id == null && username == null && email == null && phone == null) {
|
if (id == null && username == null && email == null && phone == null) {
|
||||||
// Token获取信息
|
// Token获取信息
|
||||||
UserDO userDO = userDAO.getUserById(Processing.getAuthHeaderToUserId(request));
|
userDO = userDAO.getUserById(Processing.getAuthHeaderToUserId(request));
|
||||||
if (userDO != null) {
|
|
||||||
return ResultUtil.success(Processing.returnUserInfo(userDO, roleDAO, permissionDAO));
|
|
||||||
} else {
|
|
||||||
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// 检查是否是管理员用户
|
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
|
||||||
if (userId != null) {
|
|
||||||
List<String> getPermission = permissionDAO.getPermission(userId);
|
|
||||||
// 匹配权限
|
|
||||||
if (!getPermission.contains("user.current")) {
|
|
||||||
log.info("\t> 用户权限不足,检查是否是管理员");
|
|
||||||
// 检查用户是管理员
|
|
||||||
RoleUserDO roleUserDO = roleDAO
|
|
||||||
.getRoleUserByUid(Objects.requireNonNull(Processing.getAuthHeaderToUserId(request)));
|
|
||||||
if (roleUserDO == null) {
|
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
|
||||||
}
|
|
||||||
RoleDO roleDO = roleDAO.getRoleByRoleName("admin");
|
|
||||||
if (!roleUserDO.getRid().equals(roleDO.getId())) {
|
|
||||||
return ResultUtil.error(ErrorCode.NOT_PERMISSION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return ResultUtil.error(ErrorCode.TOKEN_NOT_EXIST);
|
|
||||||
}
|
|
||||||
// 根据顺序优先级进行用户信息获取
|
// 根据顺序优先级进行用户信息获取
|
||||||
UserDO userDO = null;
|
userDO = null;
|
||||||
if (id != null && !id.isEmpty()) {
|
if (id != null && !id.isEmpty()) {
|
||||||
userDO = userDAO.getUserById(Long.valueOf(id));
|
userDO = userDAO.getUserById(Long.valueOf(id));
|
||||||
} else if (username != null && !username.isEmpty()) {
|
} else if (username != null && !username.isEmpty()) {
|
||||||
@ -176,12 +146,12 @@ public class UserServiceImpl implements UserService {
|
|||||||
} else if (phone != null && !phone.isEmpty()) {
|
} else if (phone != null && !phone.isEmpty()) {
|
||||||
userDO = userDAO.getUserByPhone(phone);
|
userDO = userDAO.getUserByPhone(phone);
|
||||||
}
|
}
|
||||||
// 返回结果
|
}
|
||||||
if (userDO != null) {
|
// 返回结果
|
||||||
return ResultUtil.success(Processing.returnUserInfo(userDO, roleDAO, permissionDAO));
|
if (userDO != null) {
|
||||||
} else {
|
return ResultUtil.success(Processing.returnUserInfo(userDO, roleDAO, gson));
|
||||||
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
} else {
|
||||||
}
|
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +159,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse userAdd(UserAddVO userAddVo, HttpServletRequest request) {
|
public BaseResponse userAdd(UserAddVO userAddVo, HttpServletRequest request) {
|
||||||
// 检测用户是否为管理员
|
// 检测用户是否为管理员
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
//如果用户不重复,添加用户
|
//如果用户不重复,添加用户
|
||||||
@ -226,7 +196,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseResponse userEdit(UserEditVO userEditVO, HttpServletRequest request) {
|
public BaseResponse userEdit(UserEditVO userEditVO, HttpServletRequest request) {
|
||||||
// 检测用户是否为管理员
|
// 检测用户是否为管理员
|
||||||
if (!Processing.checkUserIsAdmin(request, roleDAO)) {
|
if (!Processing.checkUserIsConsole(request, roleDAO)) {
|
||||||
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
return ResultUtil.error(ErrorCode.NOT_ADMIN);
|
||||||
}
|
}
|
||||||
//根据id获取用户信息
|
//根据id获取用户信息
|
||||||
@ -262,7 +232,7 @@ public class UserServiceImpl implements UserService {
|
|||||||
UserDO userDO = userDAO.getUserById(Processing.getAuthHeaderToUserId(request));
|
UserDO userDO = userDAO.getUserById(Processing.getAuthHeaderToUserId(request));
|
||||||
UserProfileVo userProfileVo = new UserProfileVo();
|
UserProfileVo userProfileVo = new UserProfileVo();
|
||||||
Processing.copyProperties(userDO, userProfileVo);
|
Processing.copyProperties(userDO, userProfileVo);
|
||||||
userProfileVo.setRole(roleDAO.getRoleNameByUid(userDO.getId()).getRoleName());
|
userProfileVo.setRole(roleDAO.getRoleByUserId(userDO.getId()).getRoleName());
|
||||||
userProfileVo.setSex(Processing.getSex(userDO.getSex()));
|
userProfileVo.setSex(Processing.getSex(userDO.getSex()));
|
||||||
return ResultUtil.success(userProfileVo);
|
return ResultUtil.success(userProfileVo);
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,10 @@ public class JwtUtil {
|
|||||||
try {
|
try {
|
||||||
Long getTokenInUserId = getUserId(token);
|
Long getTokenInUserId = getUserId(token);
|
||||||
// 验证用户名是否匹配
|
// 验证用户名是否匹配
|
||||||
log.info("令牌用户主键:" + getTokenInUserId.toString());
|
log.info("[FILTER] 令牌用户主键:{}", getTokenInUserId.toString());
|
||||||
return Pattern.matches("^[0-9]+$", getTokenInUserId.toString());
|
return Pattern.matches("^[0-9]+$", getTokenInUserId.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("令牌错误或失效");
|
log.info("[FILTER] 令牌错误或失效");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,30 @@ package com.jsl.oa.utils;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jsl.oa.dao.PermissionDAO;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.jsl.oa.dao.RoleDAO;
|
import com.jsl.oa.dao.RoleDAO;
|
||||||
import com.jsl.oa.dao.UserDAO;
|
import com.jsl.oa.dao.UserDAO;
|
||||||
import com.jsl.oa.exception.ClassCopyException;
|
import com.jsl.oa.exception.ClassCopyException;
|
||||||
import com.jsl.oa.model.dodata.*;
|
import com.jsl.oa.model.dodata.ProjectDO;
|
||||||
import com.jsl.oa.model.vodata.PermissionContentVo;
|
import com.jsl.oa.model.dodata.RoleDO;
|
||||||
|
import com.jsl.oa.model.dodata.RoleUserDO;
|
||||||
|
import com.jsl.oa.model.dodata.UserDO;
|
||||||
import com.jsl.oa.model.vodata.ProjectSimpleVO;
|
import com.jsl.oa.model.vodata.ProjectSimpleVO;
|
||||||
import com.jsl.oa.model.vodata.UserCurrentBackVO;
|
import com.jsl.oa.model.vodata.UserCurrentBackVO;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.validation.ObjectError;
|
import org.springframework.validation.ObjectError;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.sql.Timestamp;
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>自定义快捷工具类</h1>
|
* <h1>自定义快捷工具类</h1>
|
||||||
@ -164,13 +170,13 @@ public class Processing {
|
|||||||
* <hr/>
|
* <hr/>
|
||||||
* 该方法用于检查用户是否是管理员,类型封装后字节返回结果
|
* 该方法用于检查用户是否是管理员,类型封装后字节返回结果
|
||||||
*
|
*
|
||||||
* @param request 请求
|
* @param request 请求
|
||||||
* @return 如果为 true 是管理员,false 不是管理员
|
* @return 如果为 true 是管理员,false 不是管理员
|
||||||
*/
|
*/
|
||||||
public static @NotNull Boolean checkUserIsAdmin(HttpServletRequest request, @NotNull RoleDAO roleDAO) {
|
public static @NotNull Boolean checkUserIsConsole(HttpServletRequest request, @NotNull RoleDAO roleDAO) {
|
||||||
RoleUserDO roleUserDO = roleDAO.getRoleUserByUid(Processing.getAuthHeaderToUserId(request));
|
RoleUserDO roleUserDO = roleDAO.getRoleUserByUid(Processing.getAuthHeaderToUserId(request));
|
||||||
if (roleUserDO != null) {
|
if (roleUserDO != null) {
|
||||||
RoleDO roleDO = roleDAO.getRoleByRoleName("admin");
|
RoleDO roleDO = roleDAO.getRoleByRoleName("console");
|
||||||
return roleUserDO.getRid().equals(roleDO.getId());
|
return roleUserDO.getRid().equals(roleDO.getId());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -180,13 +186,13 @@ public class Processing {
|
|||||||
/**
|
/**
|
||||||
* 检查用户是否是老师
|
* 检查用户是否是老师
|
||||||
*
|
*
|
||||||
* @param request 请求
|
* @param request 请求
|
||||||
* @return 如果为 true 是老师,false 不是老师
|
* @return 如果为 true 是老师,false 不是老师
|
||||||
*/
|
*/
|
||||||
public static @NotNull Boolean checkUserIsTeacher(HttpServletRequest request, @NotNull RoleDAO roleDAO) {
|
public static @NotNull Boolean checkUserIsPrincipal(HttpServletRequest request, @NotNull RoleDAO roleDAO) {
|
||||||
RoleUserDO roleUserDO = roleDAO.getRoleUserByUid(Processing.getAuthHeaderToUserId(request));
|
RoleUserDO roleUserDO = roleDAO.getRoleUserByUid(Processing.getAuthHeaderToUserId(request));
|
||||||
if (roleUserDO != null) {
|
if (roleUserDO != null) {
|
||||||
RoleDO roleDO = roleDAO.getRoleByRoleName("teacher");
|
RoleDO roleDO = roleDAO.getRoleByRoleName("principal");
|
||||||
return roleUserDO.getRid().equals(roleDO.getId());
|
return roleUserDO.getRid().equals(roleDO.getId());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -263,9 +269,12 @@ public class Processing {
|
|||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
public static @NotNull String getSex(short sex) {
|
public static @NotNull String getSex(short sex) {
|
||||||
switch (sex) {
|
switch (sex) {
|
||||||
case 1: return "男";
|
case 1:
|
||||||
case 2: return "女";
|
return "男";
|
||||||
default: return "保密";
|
case 2:
|
||||||
|
return "女";
|
||||||
|
default:
|
||||||
|
return "保密";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,56 +287,23 @@ public class Processing {
|
|||||||
* @return {@link BaseResponse}
|
* @return {@link BaseResponse}
|
||||||
*/
|
*/
|
||||||
public static @NotNull UserCurrentBackVO.UserCurrent returnUserInfo(
|
public static @NotNull UserCurrentBackVO.UserCurrent returnUserInfo(
|
||||||
@NotNull UserDO userDO, RoleDAO roleDAO, PermissionDAO permissionDAO) {
|
@NotNull UserDO userDO, RoleDAO roleDAO, Gson gson) {
|
||||||
UserCurrentBackVO.UserCurrent userCurrent = new UserCurrentBackVO.UserCurrent();
|
UserCurrentBackVO.UserCurrent userCurrent = new UserCurrentBackVO.UserCurrent();
|
||||||
// 获取用户角色
|
|
||||||
RoleUserDO getUserRole = roleDAO.getRoleUserByUid(userDO.getId());
|
|
||||||
if (getUserRole == null) {
|
|
||||||
getUserRole = new RoleUserDO();
|
|
||||||
getUserRole.setRid(0L).setCreatedAt(new Timestamp(System.currentTimeMillis()));
|
|
||||||
} else {
|
|
||||||
getUserRole.setUid(null);
|
|
||||||
}
|
|
||||||
// 获取用户权限
|
// 获取用户权限
|
||||||
RoleUserDO roleUserDO = roleDAO.getRoleUserByUid(userDO.getId());
|
RoleDO getRole = roleDAO.getRoleByUserId(userDO.getId());
|
||||||
List<String> getPermissionForString;
|
List<String> getPermissionForString;
|
||||||
if (roleUserDO != null) {
|
|
||||||
// 获取全部根权限
|
|
||||||
getPermissionForString = permissionDAO.getAllPermissionBuildString();
|
|
||||||
} else {
|
|
||||||
// 获取权限列表信息
|
|
||||||
getPermissionForString = permissionDAO.getPermission(userDO.getId());
|
|
||||||
}
|
|
||||||
RoleDO getRole = roleDAO.getRoleById(getUserRole.getRid());
|
|
||||||
String getRoleString;
|
|
||||||
if (getRole != null) {
|
if (getRole != null) {
|
||||||
getRoleString = getRole.getRoleName();
|
// 获取全部根权限
|
||||||
|
getPermissionForString = gson.fromJson(getRole.getPermissions(), new TypeToken<List<String>>() {
|
||||||
|
}.getType());
|
||||||
} else {
|
} else {
|
||||||
getRoleString = "default";
|
getPermissionForString = null;
|
||||||
}
|
}
|
||||||
|
UserCurrentBackVO.ReturnUser returnUser = new UserCurrentBackVO.ReturnUser();
|
||||||
|
BeanUtils.copyProperties(userDO, returnUser);
|
||||||
userCurrent
|
userCurrent
|
||||||
.setUser(new UserCurrentBackVO.ReturnUser()
|
.setUser(returnUser)
|
||||||
.setId(userDO.getId())
|
.setRole(getRole != null ? getRole.getRoleName() : "default")
|
||||||
.setJobId(userDO.getJobId())
|
|
||||||
.setUsername(userDO.getUsername())
|
|
||||||
.setAddress(userDO.getAddress())
|
|
||||||
.setPhone(userDO.getPhone())
|
|
||||||
.setEmail(userDO.getEmail())
|
|
||||||
.setAge(userDO.getAge())
|
|
||||||
.setSignature(userDO.getSignature())
|
|
||||||
.setAvatar(userDO.getAvatar())
|
|
||||||
.setNickname(userDO.getNickname())
|
|
||||||
.setSex(userDO.getSex())
|
|
||||||
.setEnabled(userDO.getEnabled())
|
|
||||||
.setAccountNoExpired(userDO.getAccountNoExpired())
|
|
||||||
.setCredentialsNoExpired(userDO.getCredentialsNoExpired())
|
|
||||||
.setRecommend(userDO.getRecommend())
|
|
||||||
.setAccountNoLocked(userDO.getAccountNoLocked())
|
|
||||||
.setDescription(userDO.getDescription())
|
|
||||||
.setCreatedAt(userDO.getCreatedAt())
|
|
||||||
.setUpdatedAt(userDO.getUpdatedAt())
|
|
||||||
.setIsDelete(userDO.getIsDelete()))
|
|
||||||
.setRole(getRoleString)
|
|
||||||
.setPermission(getPermissionForString);
|
.setPermission(getPermissionForString);
|
||||||
return userCurrent;
|
return userCurrent;
|
||||||
}
|
}
|
||||||
@ -363,8 +339,11 @@ public class Processing {
|
|||||||
projectSimpleVO.setId(projectDO.getId());
|
projectSimpleVO.setId(projectDO.getId());
|
||||||
projectSimpleVO.setName(projectDO.getName());
|
projectSimpleVO.setName(projectDO.getName());
|
||||||
projectSimpleVO.setTags(projectDO.getTags());
|
projectSimpleVO.setTags(projectDO.getTags());
|
||||||
projectSimpleVO.setCycle(Long.valueOf(projectDO.getCycle()));
|
projectSimpleVO.setCycle(projectDO.getCycle().longValue());
|
||||||
projectSimpleVO.setWorkLoad(Long.valueOf(projectDO.getWorkLoad()));
|
projectSimpleVO.setWorkLoad(projectDO.getWorkLoad().longValue());
|
||||||
|
projectSimpleVO.setFiles(projectDO.getFiles());
|
||||||
|
projectSimpleVO.setStatus(projectDO.getStatus());
|
||||||
|
projectSimpleVO.setDeadLine(projectDO.getDeadline());
|
||||||
projectSimpleVO.setPrincipalUser(userDAO.getUserById(projectDO.getPrincipalId()).getUsername());
|
projectSimpleVO.setPrincipalUser(userDAO.getUserById(projectDO.getPrincipalId()).getUsername());
|
||||||
// 解析JSON字符串
|
// 解析JSON字符串
|
||||||
JsonNode rootNode = null;
|
JsonNode rootNode = null;
|
||||||
@ -384,56 +363,6 @@ public class Processing {
|
|||||||
//return ProjectSimpleVO;
|
//return ProjectSimpleVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: 将Permission归纳为父子关系的json形式
|
|
||||||
* @Date: 2024/1/20
|
|
||||||
* @Param permissions: 权限实体类
|
|
||||||
**/
|
|
||||||
public static List<PermissionContentVo> convertToVoList(List<PermissionDO> permissions) {
|
|
||||||
List<PermissionContentVo> vos = new ArrayList<>();
|
|
||||||
Map<Long, List<PermissionDO>> childrenMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (PermissionDO permission : permissions) {
|
|
||||||
if (permission.getPid() != null) {
|
|
||||||
List<PermissionDO> children = childrenMap.getOrDefault(permission.getPid(), new ArrayList<>());
|
|
||||||
children.add(permission);
|
|
||||||
childrenMap.put(permission.getPid(), children);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PermissionDO permission : permissions) {
|
|
||||||
if (permission.getPid() == null) {
|
|
||||||
PermissionContentVo vo = convertToVo(permission, childrenMap);
|
|
||||||
vos.add(vo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vos;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: 封装PermissionContentVo的子类,被convertToVoList方法调用
|
|
||||||
* @Date: 2024/1/20
|
|
||||||
* @Param permission: 权限实体类
|
|
||||||
* @Param childrenMap: 要封装的子类
|
|
||||||
**/
|
|
||||||
public static PermissionContentVo convertToVo(PermissionDO permission, Map<Long, List<PermissionDO>> childrenMap) {
|
|
||||||
PermissionContentVo vo = new PermissionContentVo();
|
|
||||||
copyProperties(permission, vo);
|
|
||||||
|
|
||||||
List<PermissionDO> children = childrenMap.get(permission.getId());
|
|
||||||
if (children != null) {
|
|
||||||
List<PermissionContentVo> childVos = new ArrayList<>();
|
|
||||||
for (PermissionDO child : children) {
|
|
||||||
PermissionContentVo childVo = convertToVo(child, childrenMap);
|
|
||||||
childVos.add(childVo);
|
|
||||||
}
|
|
||||||
vo.setChildren(childVos);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 转换审核的类别属性为字符串
|
* @Description: 转换审核的类别属性为字符串
|
||||||
@ -443,11 +372,11 @@ public class Processing {
|
|||||||
public static String turnReviewCategory(short category) {
|
public static String turnReviewCategory(short category) {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case 0:
|
case 0:
|
||||||
return "子系统";
|
return "子系统";
|
||||||
case 1:
|
case 1:
|
||||||
return "模块";
|
return "模块";
|
||||||
default:
|
default:
|
||||||
return "其他";
|
return "其他";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,7 +394,4 @@ public class Processing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,17 @@
|
|||||||
|
|
||||||
<mapper namespace="com.jsl.oa.mapper.ModuleMapper">
|
<mapper namespace="com.jsl.oa.mapper.ModuleMapper">
|
||||||
|
|
||||||
<select id="getByProjectId" resultType="com.jsl.oa.model.dodata.ProjectModuleDO">
|
<select id="getByProjectId" resultType="com.jsl.oa.model.dodata.ProjectChildDO">
|
||||||
select * from organize_oa.oa_project_work where project_id=#{projectId} and type=0
|
select * from organize_oa.oa_project_child where project_id=#{projectId}
|
||||||
<if test="is != 1 ">
|
<if test="is != 1 ">
|
||||||
and (principal_id=#{userId} or principal_id is null)
|
and (principal_id=#{userId})
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getBySysId" resultType="com.jsl.oa.model.dodata.ProjectModuleDO">
|
<select id="getBySysId" resultType="com.jsl.oa.model.dodata.ProjectModuleDO">
|
||||||
select * from organize_oa.oa_project_work where pid=#{sysId} and type=1
|
select * from organize_oa.oa_project_modules where project_child_id=#{sysId}
|
||||||
<if test="is != 1 ">
|
<if test="is != 1 ">
|
||||||
and (principal_id=#{userId} or principal_id is null)
|
and (principal_id=#{userId})
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -47,6 +47,14 @@
|
|||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteProjectChild">
|
||||||
|
update organize_oa.oa_project_child set is_delete=true where id=#{id1}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteProjectModule">
|
||||||
|
update organize_oa.oa_project_modules set is_delete=true where id=#{id1}
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="getByTags" resultType="com.jsl.oa.model.dodata.ProjectDO">
|
<select id="getByTags" resultType="com.jsl.oa.model.dodata.ProjectDO">
|
||||||
<if test="tags != null">
|
<if test="tags != null">
|
||||||
select * from organize_oa.oa_project where is_delete=false and principal_id=#{userId} and
|
select * from organize_oa.oa_project where is_delete=false and principal_id=#{userId} and
|
||||||
@ -102,7 +110,7 @@
|
|||||||
<if test="is != null">
|
<if test="is != null">
|
||||||
(principal_id = #{userId} and is_delete=false) or
|
(principal_id = #{userId} and is_delete=false) or
|
||||||
</if>
|
</if>
|
||||||
id in(select project_id from organize_oa.oa_project_child where is_delete=false and (principal_id=#{userId}) and oa_project.status in
|
id in(select project_id from organize_oa.oa_project_child where is_delete=false and (principal_id=#{userId}) and status in
|
||||||
<foreach collection="isFinish" item="Finish" separator="," open="(" close="))">
|
<foreach collection="isFinish" item="Finish" separator="," open="(" close="))">
|
||||||
#{Finish}
|
#{Finish}
|
||||||
</foreach>
|
</foreach>
|
||||||
@ -151,7 +159,12 @@
|
|||||||
#{Finish}
|
#{Finish}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getParticipateProject" resultType="com.jsl.oa.model.dodata.ProjectDO">
|
||||||
|
select * from organize_oa.oa_project where id in
|
||||||
|
(select project_id from organize_oa.oa_project_child where id in
|
||||||
|
(select project_child_id from organize_oa.oa_project_modules
|
||||||
|
where oa_project_modules.principal_id=#{userId} and is_delete=false) )
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
12
src/main/resources/mysql/oa_config.sql
Normal file
12
src/main/resources/mysql/oa_config.sql
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
create table oa_config
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
value varchar(50) not null comment '调用关键字',
|
||||||
|
data json null comment 'json数据',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
constraint oa_config_value_uindex
|
||||||
|
unique (value)
|
||||||
|
)
|
||||||
|
comment '配置数据表';
|
19
src/main/resources/mysql/oa_message.sql
Normal file
19
src/main/resources/mysql/oa_message.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
create table oa_message
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '消息主键'
|
||||||
|
primary key,
|
||||||
|
uid bigint unsigned not null comment '用户主键',
|
||||||
|
title varchar(100) not null comment '消息抬头',
|
||||||
|
text text not null comment '消息正文',
|
||||||
|
is_delete tinyint(1) default 0 not null comment '消息是否删除',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
deleted_at timestamp null comment '删除时间',
|
||||||
|
sid bigint unsigned null comment '发送用户id',
|
||||||
|
type varchar(100) null comment '跳转类型',
|
||||||
|
to_id int unsigned null comment '跳转的id',
|
||||||
|
constraint oa_message_oa_user_id_fk
|
||||||
|
foreign key (uid) references oa_user (id)
|
||||||
|
on update cascade on delete cascade
|
||||||
|
)
|
||||||
|
comment '消息';
|
||||||
|
|
13
src/main/resources/mysql/oa_news.sql
Normal file
13
src/main/resources/mysql/oa_news.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
create table oa_news
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
title varchar(255) not null comment '标题',
|
||||||
|
content text not null comment '内容',
|
||||||
|
tags varchar(10) null comment '标签(项目,通知)',
|
||||||
|
likes int default 0 not null comment '点赞数',
|
||||||
|
comments int default 0 not null comment '评论数',
|
||||||
|
status tinyint not null comment '状态(0:草稿;1:发布;2:隐藏)',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '更新时间'
|
||||||
|
);
|
15
src/main/resources/mysql/oa_news_user.sql
Normal file
15
src/main/resources/mysql/oa_news_user.sql
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
create table oa_news_user
|
||||||
|
(
|
||||||
|
id int unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
uid bigint unsigned not null comment '用户id',
|
||||||
|
nid bigint unsigned not null comment '新闻id',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
constraint oa_news_user_nid_oa_news_id_fk
|
||||||
|
foreign key (nid) references oa_news (id)
|
||||||
|
on update cascade,
|
||||||
|
constraint oa_news_user_uid_oa_user_id_fk
|
||||||
|
foreign key (uid) references oa_user (id)
|
||||||
|
on update cascade
|
||||||
|
);
|
11
src/main/resources/mysql/oa_permissions.sql
Normal file
11
src/main/resources/mysql/oa_permissions.sql
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
create table oa_permissions
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
name varchar(100) not null comment '权限名称',
|
||||||
|
description varchar(100) not null comment '权限描述',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
constraint oa_permissions_name_uindex
|
||||||
|
unique (name)
|
||||||
|
)
|
||||||
|
comment '权限表';
|
24
src/main/resources/mysql/oa_project.sql
Normal file
24
src/main/resources/mysql/oa_project.sql
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
create table oa_project
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '项目id'
|
||||||
|
primary key,
|
||||||
|
name varchar(255) not null comment '项目名称',
|
||||||
|
principal_id bigint unsigned not null comment '项目负责人',
|
||||||
|
description json null comment '项目描述(技术选择,描述)',
|
||||||
|
tags json null comment '项目标签(项目类型:web,大数据等)',
|
||||||
|
cycle int unsigned not null comment '项目周期',
|
||||||
|
work_load int unsigned default '1' not null comment '工作量(人天)',
|
||||||
|
files json null comment '项目文件',
|
||||||
|
begin_time datetime default CURRENT_TIMESTAMP not null comment '项目开始时间',
|
||||||
|
complete_time date null comment '完成时间',
|
||||||
|
dead_line date not null comment '甲方要求结束',
|
||||||
|
status varchar(8) default 'progress' not null comment '项目状态(draft: 草稿,progress: 进行,pause: 暂停,abnormal: 异常,complete: 完成)',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
is_delete tinyint(1) default 0 not null comment '项目是否删除',
|
||||||
|
constraint oa_project_oa_user_id_fk
|
||||||
|
foreign key (principal_id) references oa_user (id)
|
||||||
|
on update cascade
|
||||||
|
)
|
||||||
|
comment '项目表';
|
||||||
|
|
@ -1,5 +1,3 @@
|
|||||||
USE organize_oa;
|
|
||||||
|
|
||||||
create table oa_project_child
|
create table oa_project_child
|
||||||
(
|
(
|
||||||
id bigint unsigned auto_increment comment '项目id'
|
id bigint unsigned auto_increment comment '项目id'
|
||||||
@ -15,6 +13,8 @@ create table oa_project_child
|
|||||||
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
updated_at timestamp null comment '更新时间',
|
updated_at timestamp null comment '更新时间',
|
||||||
is_delete tinyint(1) default 0 not null comment '项目是否删除',
|
is_delete tinyint(1) default 0 not null comment '项目是否删除',
|
||||||
|
dead_line timestamp not null comment '子系统的截止时间',
|
||||||
|
status varchar(8) default 'progress' not null comment '系统状态(draft: 草稿,progress: 进行,pause: 暂停,abnormal: 异常,complete: 完成)',
|
||||||
constraint oa_project_child_oa_user_id_fk
|
constraint oa_project_child_oa_user_id_fk
|
||||||
foreign key (principal_id) references oa_user (id)
|
foreign key (principal_id) references oa_user (id)
|
||||||
on update cascade
|
on update cascade
|
19
src/main/resources/mysql/oa_project_daily.sql
Normal file
19
src/main/resources/mysql/oa_project_daily.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
create table oa_project_daily
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '日报主键'
|
||||||
|
primary key,
|
||||||
|
user_id bigint unsigned not null comment '用户id',
|
||||||
|
project_id bigint unsigned not null comment '项目id',
|
||||||
|
content text not null comment '日报内容',
|
||||||
|
daily_time date not null comment '日志发布时间',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
is_delete tinyint(1) default 0 not null comment '是否删除',
|
||||||
|
constraint oa_project_daily_oa_project_id_fk
|
||||||
|
foreign key (project_id) references oa_project (id)
|
||||||
|
on update cascade on delete cascade,
|
||||||
|
constraint oa_project_daily_oa_user_id_fk
|
||||||
|
foreign key (user_id) references oa_user (id)
|
||||||
|
on update cascade
|
||||||
|
)
|
||||||
|
comment '项目日报';
|
@ -1,5 +1,3 @@
|
|||||||
USE organize_oa;
|
|
||||||
|
|
||||||
create table oa_project_modules
|
create table oa_project_modules
|
||||||
(
|
(
|
||||||
id bigint unsigned auto_increment comment '模块id'
|
id bigint unsigned auto_increment comment '模块id'
|
||||||
@ -13,6 +11,8 @@ create table oa_project_modules
|
|||||||
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
updated_at timestamp null comment '更新时间',
|
updated_at timestamp null comment '更新时间',
|
||||||
is_delete tinyint(1) default 0 not null comment '项目是否删除',
|
is_delete tinyint(1) default 0 not null comment '项目是否删除',
|
||||||
|
dead_line timestamp not null comment '子模块的截止时间',
|
||||||
|
status varchar(8) default 'progress' not null comment '模块状态(draft: 草稿,progress: 进行,pause: 暂停,abnormal: 异常,complete: 完成)',
|
||||||
constraint oa_project_modules_oa_user_id_fk
|
constraint oa_project_modules_oa_user_id_fk
|
||||||
foreign key (principal_id) references oa_user (id)
|
foreign key (principal_id) references oa_user (id)
|
||||||
on update cascade
|
on update cascade
|
17
src/main/resources/mysql/oa_project_tags.sql
Normal file
17
src/main/resources/mysql/oa_project_tags.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
create table oa_project_tags
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键id'
|
||||||
|
primary key,
|
||||||
|
name varchar(20) not null comment '标签名称',
|
||||||
|
pid bigint unsigned null comment '父标签id',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
is_delete tinyint(1) default 0 not null comment '是否删除',
|
||||||
|
constraint oa_project_tags_name_uindex
|
||||||
|
unique (name),
|
||||||
|
constraint oa_project_tags_oa_project_tags_id_fk
|
||||||
|
foreign key (pid) references oa_project_tags (id)
|
||||||
|
on update cascade on delete cascade
|
||||||
|
)
|
||||||
|
comment '项目标签表';
|
||||||
|
|
30
src/main/resources/mysql/oa_review.sql
Normal file
30
src/main/resources/mysql/oa_review.sql
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
create table oa_review
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
name varchar(255) not null comment '申请名称',
|
||||||
|
content longtext not null comment '申请理由',
|
||||||
|
sender_id bigint unsigned not null comment '申请者用户id',
|
||||||
|
recipient_id bigint unsigned null comment '审核者用户id',
|
||||||
|
category tinyint default 1 null comment '审核类别(0:子系统;1:子模块)',
|
||||||
|
project_id bigint unsigned not null comment '申请的项目id',
|
||||||
|
project_child_id bigint unsigned not null comment '申请的子系统id',
|
||||||
|
project_module_id bigint unsigned null comment '申请的子模块id',
|
||||||
|
application_time datetime default CURRENT_TIMESTAMP not null comment '申请时间',
|
||||||
|
review_time datetime null comment '审核时间',
|
||||||
|
review_result tinyint default 2 not null comment '审核结果(0:未通过;1:通过;2:未审批)',
|
||||||
|
is_delete tinyint default 0 not null comment '是否删除(0:未删除;1:已删除)',
|
||||||
|
created_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_time datetime null comment '更新时间',
|
||||||
|
constraint oa_review_recipient_id_oa_user_id_fk
|
||||||
|
foreign key (recipient_id) references oa_user (id)
|
||||||
|
on update cascade on delete cascade,
|
||||||
|
constraint oa_review_sender_id_oa_user_id_fk
|
||||||
|
foreign key (sender_id) references oa_user (id)
|
||||||
|
on update cascade on delete cascade
|
||||||
|
);
|
||||||
|
|
||||||
|
create index oa_review_project_id_oa_project_id_fk
|
||||||
|
on oa_review (project_id);
|
||||||
|
|
||||||
|
|
11
src/main/resources/mysql/oa_role.sql
Normal file
11
src/main/resources/mysql/oa_role.sql
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
create table oa_role
|
||||||
|
(
|
||||||
|
id int unsigned auto_increment comment '角色id'
|
||||||
|
primary key,
|
||||||
|
role_name varchar(20) not null comment '角色名称',
|
||||||
|
display_name varchar(10) null comment '中文描述',
|
||||||
|
permissions json null comment '用户组权限',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间'
|
||||||
|
)
|
||||||
|
comment '角色表';
|
10
src/main/resources/mysql/oa_role_permissions.sql
Normal file
10
src/main/resources/mysql/oa_role_permissions.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
create table oa_role_permissions
|
||||||
|
(
|
||||||
|
rid int unsigned not null comment 'Role ID',
|
||||||
|
pid bigint unsigned not null comment 'Permission ID',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
primary key (rid, pid)
|
||||||
|
);
|
||||||
|
|
||||||
|
create index oa_role_permission_oa_permissions_id_fk
|
||||||
|
on oa_role_permissions (pid);
|
14
src/main/resources/mysql/oa_role_user.sql
Normal file
14
src/main/resources/mysql/oa_role_user.sql
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
create table oa_role_user
|
||||||
|
(
|
||||||
|
uid bigint unsigned not null comment '用户id'
|
||||||
|
primary key,
|
||||||
|
rid int unsigned not null comment '角色id',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
constraint oa_role_user_oa_role_id_fk
|
||||||
|
foreign key (rid) references oa_role (id),
|
||||||
|
constraint oa_role_user_oa_user_id_fk
|
||||||
|
foreign key (uid) references oa_user (id)
|
||||||
|
on update cascade on delete cascade
|
||||||
|
)
|
||||||
|
comment '角色用户表';
|
34
src/main/resources/mysql/oa_user.sql
Normal file
34
src/main/resources/mysql/oa_user.sql
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
create table oa_user
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
job_id char(10) not null comment '工作ID:正则表达 "^[STU|TEA|OTH][0-9]{7}"',
|
||||||
|
username varchar(40) not null comment '用户名',
|
||||||
|
password varchar(255) not null comment '密码',
|
||||||
|
address varchar(255) not null comment '用户家庭地址',
|
||||||
|
phone varchar(11) not null comment '电话',
|
||||||
|
email varchar(100) not null comment '邮箱',
|
||||||
|
age tinyint unsigned not null comment '年龄',
|
||||||
|
signature varchar(50) null comment '一句话描述自己',
|
||||||
|
sex tinyint unsigned default '0' not null comment '0/1/2:保密/男/女',
|
||||||
|
avatar text null comment '头像地址',
|
||||||
|
nickname varchar(20) null comment '昵称',
|
||||||
|
enabled tinyint(1) default 1 not null comment '账户是否可用',
|
||||||
|
account_no_expired tinyint(1) default 1 not null comment '账户是否过期',
|
||||||
|
credentials_no_expired tinyint(1) default 0 not null comment '密码是否过期',
|
||||||
|
recommend tinyint(1) default 0 not null comment '账户是否被推荐',
|
||||||
|
account_no_locked tinyint(1) default 1 not null comment '账户是否被锁定',
|
||||||
|
description text null comment '个人简介',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '更新时间',
|
||||||
|
is_delete tinyint(1) default 0 not null,
|
||||||
|
constraint oa_user_email_uindex
|
||||||
|
unique (email),
|
||||||
|
constraint oa_user_job_id_uindex
|
||||||
|
unique (job_id),
|
||||||
|
constraint oa_user_phone_uindex
|
||||||
|
unique (phone),
|
||||||
|
constraint oa_user_username_uindex
|
||||||
|
unique (username)
|
||||||
|
)
|
||||||
|
comment '用户表';
|
13
src/main/resources/mysql/oa_user_tags.sql
Normal file
13
src/main/resources/mysql/oa_user_tags.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
create table oa_user_tags
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '标签主键'
|
||||||
|
primary key,
|
||||||
|
name varchar(20) not null comment '标签名',
|
||||||
|
pid bigint unsigned null comment '标签父id',
|
||||||
|
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_at timestamp null comment '修改时间',
|
||||||
|
is_delete tinyint(1) default 0 not null comment '是否删除',
|
||||||
|
constraint oa_user_tags_name_uindex
|
||||||
|
unique (name)
|
||||||
|
)
|
||||||
|
comment '用户标签';
|
@ -203,6 +203,44 @@ CREATE TABLE `oa_user`
|
|||||||
DEFAULT CHARSET = utf8mb4
|
DEFAULT CHARSET = utf8mb4
|
||||||
COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户表';
|
COLLATE = utf8mb4_0900_ai_ci COMMENT ='用户表';
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 表的结构 `oa_review`
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
create table oa_review
|
||||||
|
(
|
||||||
|
id bigint unsigned auto_increment comment '主键'
|
||||||
|
primary key,
|
||||||
|
name varchar(255) not null comment '申请名称',
|
||||||
|
content longtext not null comment '申请理由',
|
||||||
|
sender_id bigint unsigned not null comment '申请者用户id',
|
||||||
|
recipient_id bigint unsigned null comment '审核者用户id',
|
||||||
|
category tinyint default 1 null comment '审核类别(0:子系统;1:子模块)',
|
||||||
|
project_id bigint unsigned not null comment '申请的项目id',
|
||||||
|
project_child_id bigint unsigned not null comment '申请的子系统id',
|
||||||
|
project_module_id bigint unsigned null comment '申请的子模块id',
|
||||||
|
application_time datetime default CURRENT_TIMESTAMP not null comment '申请时间',
|
||||||
|
review_time datetime null comment '审核时间',
|
||||||
|
review_result tinyint default 2 not null comment '审核结果(0:未通过;1:通过;2:未审批)',
|
||||||
|
is_delete tinyint default 0 not null comment '是否删除(0:未删除;1:已删除)',
|
||||||
|
created_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||||
|
updated_time datetime null comment '更新时间',
|
||||||
|
constraint oa_review_recipient_id_oa_user_id_fk
|
||||||
|
foreign key (recipient_id) references oa_user (id)
|
||||||
|
on update cascade on delete cascade,
|
||||||
|
constraint oa_review_sender_id_oa_user_id_fk
|
||||||
|
foreign key (sender_id) references oa_user (id)
|
||||||
|
on update cascade on delete cascade
|
||||||
|
);
|
||||||
|
|
||||||
|
create index oa_review_project_id_oa_project_id_fk
|
||||||
|
on oa_review (project_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- 转储表的索引
|
-- 转储表的索引
|
||||||
--
|
--
|
Loading…
x
Reference in New Issue
Block a user