commit 599356c6d47081f9ebfb6c382772a9bec4ad6990 Author: yovinchen Date: Fri Jun 9 09:04:37 2023 +0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$ new file mode 100644 index 0000000..58b7e3e --- /dev/null +++ b/.idea/$PROJECT_FILE$ @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..afa4cd3 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Zeppelin 忽略的文件 +/ZeppelinRemoteNotebooks/ diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..01a1b47 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..b0a6767 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/.idea/intellij-javadocs-4.0.1.xml b/.idea/intellij-javadocs-4.0.1.xml new file mode 100644 index 0000000..ef8f8ff --- /dev/null +++ b/.idea/intellij-javadocs-4.0.1.xml @@ -0,0 +1,204 @@ + + + + + UPDATE + false + true + + FIELD + TYPE + METHOD + + + PROTECTED + PUBLIC + DEFAULT + + + + + + ^.*(public|protected|private)*.+interface\s+\w+.* + /**\n + * The interface ${name}.\n +<#if element.typeParameters?has_content> * \n +</#if> +<#list element.typeParameters as typeParameter> + * @param <${typeParameter.name}> the type parameter\n +</#list> + */ + + + ^.*(public|protected|private)*.+enum\s+\w+.* + /**\n + * The enum ${name}.\n + */ + + + ^.*(public|protected|private)*.+class\s+\w+.* + /**\n + * The type ${name}.\n +<#if element.typeParameters?has_content> * \n +</#if> +<#list element.typeParameters as typeParameter> + * @param <${typeParameter.name}> the type parameter\n +</#list> + */ + + + .+ + /**\n + * The type ${name}.\n + */ + + + + + .+ + /**\n + * Instantiates a new ${name}.\n +<#if element.parameterList.parameters?has_content> + *\n +</#if> +<#list element.parameterList.parameters as parameter> + * @param ${parameter.name} the ${paramNames[parameter.name]}\n +</#list> +<#if element.throwsList.referenceElements?has_content> + *\n +</#if> +<#list element.throwsList.referenceElements as exception> + * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n +</#list> + */ + + + + + ^.*(public|protected|private)*\s*.*(\w(\s*<.+>)*)+\s+get\w+\s*\(.*\).+ + /**\n + * Gets ${partName}.\n +<#if element.typeParameters?has_content> * \n +</#if> +<#list element.typeParameters as typeParameter> + * @param <${typeParameter.name}> the type parameter\n +</#list> +<#if element.parameterList.parameters?has_content> + *\n +</#if> +<#list element.parameterList.parameters as parameter> + * @param ${parameter.name} the ${paramNames[parameter.name]}\n +</#list> +<#if isNotVoid> + *\n + * @return the ${partName}\n +</#if> +<#if element.throwsList.referenceElements?has_content> + *\n +</#if> +<#list element.throwsList.referenceElements as exception> + * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n +</#list> + */ + + + ^.*(public|protected|private)*\s*.*(void|\w(\s*<.+>)*)+\s+set\w+\s*\(.*\).+ + /**\n + * Sets ${partName}.\n +<#if element.typeParameters?has_content> * \n +</#if> +<#list element.typeParameters as typeParameter> + * @param <${typeParameter.name}> the type parameter\n +</#list> +<#if element.parameterList.parameters?has_content> + *\n +</#if> +<#list element.parameterList.parameters as parameter> + * @param ${parameter.name} the ${paramNames[parameter.name]}\n +</#list> +<#if isNotVoid> + *\n + * @return the ${partName}\n +</#if> +<#if element.throwsList.referenceElements?has_content> + *\n +</#if> +<#list element.throwsList.referenceElements as exception> + * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n +</#list> + */ + + + ^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+ + /**\n + * The entry point of application.\n + + <#if element.parameterList.parameters?has_content> + *\n +</#if> + * @param ${element.parameterList.parameters[0].name} the input arguments\n +<#if element.throwsList.referenceElements?has_content> + *\n +</#if> +<#list element.throwsList.referenceElements as exception> + * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n +</#list> + */ + + + .+ + /**\n + * ${name}<#if isNotVoid> ${return}</#if>.\n +<#if element.typeParameters?has_content> * \n +</#if> +<#list element.typeParameters as typeParameter> + * @param <${typeParameter.name}> the type parameter\n +</#list> +<#if element.parameterList.parameters?has_content> + *\n +</#if> +<#list element.parameterList.parameters as parameter> + * @param ${parameter.name} the ${paramNames[parameter.name]}\n +</#list> +<#if isNotVoid> + *\n + * @return the ${return}\n +</#if> +<#if element.throwsList.referenceElements?has_content> + *\n +</#if> +<#list element.throwsList.referenceElements as exception> + * @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n +</#list> + */ + + + + + ^.*(public|protected|private)*.+static.*(\w\s\w)+.+ + /**\n + * The constant ${element.getName()}.\n + */ + + + ^.*(public|protected|private)*.*(\w\s\w)+.+ + /**\n + <#if element.parent.isInterface()> + * The constant ${element.getName()}.\n +<#else> + * The ${name}.\n +</#if> */ + + + .+ + /**\n + <#if element.parent.isEnum()> + *${name} ${typeName}.\n +<#else> + * The ${name}.\n +</#if>*/ + + + + + \ No newline at end of file diff --git a/.idea/jpa-buddy.xml b/.idea/jpa-buddy.xml new file mode 100644 index 0000000..966d5f5 --- /dev/null +++ b/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..af7b14f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml new file mode 100644 index 0000000..3dfd21f --- /dev/null +++ b/.idea/qaplug_profiles.xml @@ -0,0 +1,465 @@ + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/common/common-util/.gitignore b/common/common-util/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/common/common-util/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/common/common-util/pom.xml b/common/common-util/pom.xml new file mode 100644 index 0000000..361414b --- /dev/null +++ b/common/common-util/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + + com.atguigu + common + 1.0-SNAPSHOT + + common-util + jar + + + + org.springframework.boot + spring-boot-starter-web + provided + + + io.jsonwebtoken + jjwt + + + org.projectlombok + lombok + + + com.alibaba + fastjson + + + diff --git a/common/common-util/src/main/java/com/atguigu/common/result/Result.java b/common/common-util/src/main/java/com/atguigu/common/result/Result.java new file mode 100644 index 0000000..d548bda --- /dev/null +++ b/common/common-util/src/main/java/com/atguigu/common/result/Result.java @@ -0,0 +1,92 @@ +package com.atguigu.common.result; + +import lombok.Data; + +/** + * ClassName: Result + * Package: com.atguigu.common.result + * + * @author yovinchen + * @Create 2023/6/6 17:30 + *

+ * 全局统一返回结果类 + */ +@Data +public class Result { + + //返回码 + private Integer code; + + //返回消息 + private String message; + + //返回数据 + private T data; + + public Result() { + } + + // 返回数据 + protected static Result build(T data) { + Result result = new Result(); + if (data != null) + result.setData(data); + return result; + } + + public static Result build(T body, Integer code, String message) { + Result result = build(body); + result.setCode(code); + result.setMessage(message); + return result; + } + + public static Result build(T body, ResultCodeEnum resultCodeEnum) { + Result result = build(body); + result.setCode(resultCodeEnum.getCode()); + result.setMessage(resultCodeEnum.getMessage()); + return result; + } + + public static Result ok() { + return Result.ok(null); + } + + /** + * 操作成功 + * + * @param data + * @param + * @return + */ + public static Result ok(T data) { + Result result = build(data); + return build(data, ResultCodeEnum.SUCCESS); + } + + public static Result fail() { + return Result.fail(null); + } + + /** + * 操作失败 + * + * @param data + * @param + * @return + */ + public static Result fail(T data) { + Result result = build(data); + return build(data, ResultCodeEnum.FAIL); + } + + public Result message(String msg) { + this.setMessage(msg); + return this; + } + + public Result code(Integer code) { + this.setCode(code); + return this; + } +} diff --git a/common/common-util/src/main/java/com/atguigu/common/result/ResultCodeEnum.java b/common/common-util/src/main/java/com/atguigu/common/result/ResultCodeEnum.java new file mode 100644 index 0000000..2eb7673 --- /dev/null +++ b/common/common-util/src/main/java/com/atguigu/common/result/ResultCodeEnum.java @@ -0,0 +1,33 @@ +package com.atguigu.common.result; + +import lombok.Getter; + +/** + * ClassName: result + * Package: com.atguigu.common + * + * @author yovinchen + * @Create 2023/6/6 17:28 + *

+ * 统一返回结果状态信息类 + */ +@Getter +public enum ResultCodeEnum { + + SUCCESS(200, "成功"), + FAIL(201, "失败"), + SERVICE_ERROR(2012, "服务异常"), + DATA_ERROR(204, "数据异常"), + + LOGIN_AUTH(208, "未登陆"), + PERMISSION(209, "没有权限"); + + private Integer code; + + private String message; + + private ResultCodeEnum(Integer code, String message) { + this.code = code; + this.message = message; + } +} diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..56a00df --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,17 @@ + + 4.0.0 + + com.atguigu + guigu-oa-parent + 1.0-SNAPSHOT + + + common + pom + + + common-util + service-util + + diff --git a/common/service-util/.gitignore b/common/service-util/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/common/service-util/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/common/service-util/pom.xml b/common/service-util/pom.xml new file mode 100644 index 0000000..51dc7c5 --- /dev/null +++ b/common/service-util/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + + com.atguigu + common + 1.0-SNAPSHOT + + service-util + + + + com.atguigu + common-util + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-web + + + com.baomidou + mybatis-plus-boot-starter + + + + mysql + mysql-connector-java + + + + com.github.xiaoymin + knife4j-spring-boot-starter + + + + + diff --git a/common/service-util/src/main/java/com/atguigu/common/config/knife4j/Knife4jConfig.java b/common/service-util/src/main/java/com/atguigu/common/config/knife4j/Knife4jConfig.java new file mode 100644 index 0000000..a5e2546 --- /dev/null +++ b/common/service-util/src/main/java/com/atguigu/common/config/knife4j/Knife4jConfig.java @@ -0,0 +1,70 @@ +package com.atguigu.common.config.knife4j; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +import java.util.ArrayList; +import java.util.List; + +/** + * ClassName: config + * Package: com.atguigu.common.config.knife4j + * + * @author yovinchen + * @Create 2023/6/6 17:45 + *

+ * knife4j配置信息 + */ +@Configuration +@EnableSwagger2WebMvc +public class Knife4jConfig { + + @Bean + public Docket adminApiConfig() { + List pars = new ArrayList<>(); + ParameterBuilder tokenPar = new ParameterBuilder(); + tokenPar.name("token") + .description("用户token") + .defaultValue("") + .modelRef(new ModelRef("string")) + .parameterType("header") + .required(false) + .build(); + pars.add(tokenPar.build()); + //添加head参数end + + Docket adminApi = new Docket(DocumentationType.SWAGGER_2) + .groupName("adminApi") + .apiInfo(adminApiInfo()) + .select() + //只显示admin路径下的页面 + .apis(RequestHandlerSelectors.basePackage("com.atguigu")) + .paths(PathSelectors.regex("/admin/.*")) + .build() + .globalOperationParameters(pars); + return adminApi; + } + + private ApiInfo adminApiInfo() { + + return new ApiInfoBuilder() + .title("后台管理系统-API文档") + .description("本文档描述了后台管理系统微服务接口定义") + .version("1.0") + .contact(new Contact("atguigu", "http://atguigu.com", "atguigu@qq.com")) + .build(); + } + + +} diff --git a/common/service-util/src/main/java/com/atguigu/common/config/mp/MybatisPlusConfig.java b/common/service-util/src/main/java/com/atguigu/common/config/mp/MybatisPlusConfig.java new file mode 100644 index 0000000..a506151 --- /dev/null +++ b/common/service-util/src/main/java/com/atguigu/common/config/mp/MybatisPlusConfig.java @@ -0,0 +1,39 @@ +package com.atguigu.common.config.mp; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * ClassName: MybatisPlusConfig + * Package: com.atguigu.common.config.mp + * + * @author yovinchen + * @Create 2023/6/6 17:58 + */ + +@Configuration +@MapperScan("com.atguigu.auth.mapper") +public class MybatisPlusConfig { + + /** + * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 + * MybatisConfiguration#useDeprecatedExecutor = false + * 避免缓存出现问题(该属性会在旧插件移除后一同移除) + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } + + @Bean + public ConfigurationCustomizer configurationCustomizer() { + return configuration -> configuration.setUseDeprecatedExecutor(false); + } +} diff --git a/common/service-util/src/main/java/com/atguigu/common/execption/GlobalExceptionHandler.java b/common/service-util/src/main/java/com/atguigu/common/execption/GlobalExceptionHandler.java new file mode 100644 index 0000000..aae03eb --- /dev/null +++ b/common/service-util/src/main/java/com/atguigu/common/execption/GlobalExceptionHandler.java @@ -0,0 +1,41 @@ +package com.atguigu.common.execption; + +import com.atguigu.common.result.Result; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + + +/** + * ClassName: GlobalExceptionHandler + * Package: com.atguigu.common.handler + * + * @author yovinchen + * @Create 2023/6/6 20:41 + *

+ * 全局异常处理类 + */ +@ControllerAdvice +public class GlobalExceptionHandler { + + @ExceptionHandler(Exception.class) + @ResponseBody + public Result error(Exception e) { + e.printStackTrace(); + return Result.fail(); + } + + @ExceptionHandler(ArithmeticException.class) + @ResponseBody + public Result error(ArithmeticException e) { + e.printStackTrace(); + return Result.fail().message("执行了特定异常处理"); + } + + @ExceptionHandler(GuiguException.class) + @ResponseBody + public Result error(GuiguException e) { + e.printStackTrace(); + return Result.fail().message(e.getMsg()).code(e.getCode()); + } +} diff --git a/common/service-util/src/main/java/com/atguigu/common/execption/GuiguException.java b/common/service-util/src/main/java/com/atguigu/common/execption/GuiguException.java new file mode 100644 index 0000000..f3631b1 --- /dev/null +++ b/common/service-util/src/main/java/com/atguigu/common/execption/GuiguException.java @@ -0,0 +1,46 @@ +package com.atguigu.common.execption; + +import com.atguigu.common.result.ResultCodeEnum; +import lombok.Data; + +/** + * ClassName: GuiguException + * Package: com.atguigu.common.execption + * + * @author yovinchen + * @Create 2023/6/7 10:13 + *

+ * 自定义全局异常类 + */ +@Data +public class GuiguException extends RuntimeException { + + private Integer code;//状态码 + private String msg;//描述信息 + + public GuiguException(Integer code, String msg) { + super(msg); + this.code = code; + this.msg = msg; + } + + /** + * 接收枚举类型对象 + * + * @param resultCodeEnum + */ + public GuiguException(ResultCodeEnum resultCodeEnum) { + super(resultCodeEnum.getMessage()); + this.code = resultCodeEnum.getCode(); + this.msg = resultCodeEnum.getMessage(); + } + + @Override + public String toString() { + return "GuliException{" + + "code=" + code + + ", message=" + this.getMessage() + + '}'; + } +} + diff --git a/model/.gitignore b/model/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/model/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/model/pom.xml b/model/pom.xml new file mode 100644 index 0000000..9d95f1b --- /dev/null +++ b/model/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + com.atguigu + guigu-oa-parent + 1.0-SNAPSHOT + + model + + + + org.projectlombok + lombok + + + com.github.xiaoymin + knife4j-spring-boot-starter + provided + + + com.baomidou + mybatis-plus-boot-starter + provided + + + + diff --git a/model/src/main/java/com/atguigu/model/base/BaseEntity.java b/model/src/main/java/com/atguigu/model/base/BaseEntity.java new file mode 100644 index 0000000..567daf1 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/base/BaseEntity.java @@ -0,0 +1,32 @@ +package com.atguigu.model.base; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Data +public class BaseEntity implements Serializable { + + @TableId(type = IdType.AUTO) + private Long id; + + @TableField("create_time") + private Date createTime; + + @TableField("update_time") + private Date updateTime; + + @TableLogic + @TableField("is_deleted") + private Integer isDeleted; + + @TableField(exist = false) + private Map param = new HashMap<>(); +} diff --git a/model/src/main/java/com/atguigu/model/process/Process.java b/model/src/main/java/com/atguigu/model/process/Process.java new file mode 100644 index 0000000..303f8cc --- /dev/null +++ b/model/src/main/java/com/atguigu/model/process/Process.java @@ -0,0 +1,56 @@ +package com.atguigu.model.process; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "Process") +@TableName("oa_process") +public class Process extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "审批code") + @TableField("process_code") + private String processCode; + + @ApiModelProperty(value = "用户id") + @TableField("user_id") + private Long userId; + + @ApiModelProperty(value = "审批模板id") + @TableField("process_template_id") + private Long processTemplateId; + + @ApiModelProperty(value = "审批类型id") + @TableField("process_type_id") + private Long processTypeId; + + @ApiModelProperty(value = "标题") + @TableField("title") + private String title; + + @ApiModelProperty(value = "描述") + @TableField("description") + private String description; + + @ApiModelProperty(value = "表单值") + @TableField("form_values") + private String formValues; + + @ApiModelProperty(value = "流程实例id") + @TableField("process_instance_id") + private String processInstanceId; + + @ApiModelProperty(value = "当前审批人") + @TableField("current_auditor") + private String currentAuditor; + + @ApiModelProperty(value = "状态(0:默认 1:审批中 2:审批通过 -1:驳回)") + @TableField("status") + private Integer status; +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/process/ProcessRecord.java b/model/src/main/java/com/atguigu/model/process/ProcessRecord.java new file mode 100644 index 0000000..d74b4f5 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/process/ProcessRecord.java @@ -0,0 +1,37 @@ +package com.atguigu.model.process; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "ProcessRecord") +@TableName("oa_process_record") +public class ProcessRecord extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "审批流程id") + @TableField("process_id") + private Long processId; + + @ApiModelProperty(value = "审批描述") + @TableField("description") + private String description; + + @ApiModelProperty(value = "状态") + @TableField("status") + private Integer status; + + @ApiModelProperty(value = "操作用户id") + @TableField("operate_user_id") + private Long operateUserId; + + @ApiModelProperty(value = "操作用户") + @TableField("operate_user") + private String operateUser; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/process/ProcessTemplate.java b/model/src/main/java/com/atguigu/model/process/ProcessTemplate.java new file mode 100644 index 0000000..80a71a8 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/process/ProcessTemplate.java @@ -0,0 +1,59 @@ +package com.atguigu.model.process; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "ProcessTemplate") +@TableName("oa_process_template") +public class ProcessTemplate extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "模板名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "图标路径") + @TableField("icon_url") + private String iconUrl; + + @ApiModelProperty(value = "processTypeId") + @TableField("process_type_id") + private Long processTypeId; + + @ApiModelProperty(value = "表单属性") + @TableField("form_props") + private String formProps; + + @ApiModelProperty(value = "表单选项") + @TableField("form_options") + private String formOptions; + + @ApiModelProperty(value = "描述") + @TableField("description") + private String description; + + @ApiModelProperty(value = "流程定义key") + @TableField("process_definition_key") + private String processDefinitionKey; + + @ApiModelProperty(value = "流程定义上传路process_model_id") + @TableField("process_definition_path") + private String processDefinitionPath; + + @ApiModelProperty(value = "流程定义模型id") + @TableField("process_model_id") + private String processModelId; + + @ApiModelProperty(value = "状态") + @TableField("status") + private Integer status; + + @TableField(exist = false) + private String processTypeName; +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/process/ProcessType.java b/model/src/main/java/com/atguigu/model/process/ProcessType.java new file mode 100644 index 0000000..c1e74ed --- /dev/null +++ b/model/src/main/java/com/atguigu/model/process/ProcessType.java @@ -0,0 +1,29 @@ +package com.atguigu.model.process; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(description = "ProcessType") +@TableName("oa_process_type") +public class ProcessType extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "类型名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "描述") + @TableField("description") + private String description; + + @TableField(exist = false) + private List processTemplateList; +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/system/SysDept.java b/model/src/main/java/com/atguigu/model/system/SysDept.java new file mode 100644 index 0000000..17b5f5b --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysDept.java @@ -0,0 +1,51 @@ +package com.atguigu.model.system; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(description = "部门") +@TableName("sys_dept") +public class SysDept extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "部门名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "上级部门id") + @TableField("parent_id") + private Long parentId; + + @ApiModelProperty(value = "树结构") + @TableField("tree_path") + private String treePath; + + @ApiModelProperty(value = "排序") + @TableField("sort_value") + private Integer sortValue; + + @ApiModelProperty(value = "负责人") + @TableField("leader") + private String leader; + + @ApiModelProperty(value = "电话") + @TableField("phone") + private String phone; + + @ApiModelProperty(value = "状态(1正常 0停用)") + @TableField("status") + private Integer status; + + @ApiModelProperty(value = "下级部门") + @TableField(exist = false) + private List children; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/system/SysLoginLog.java b/model/src/main/java/com/atguigu/model/system/SysLoginLog.java new file mode 100644 index 0000000..b8c216c --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysLoginLog.java @@ -0,0 +1,38 @@ +package com.atguigu.model.system; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +@Data +@ApiModel(description = "SysLoginLog") +@TableName("sys_login_log") +public class SysLoginLog extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户账号") + @TableField("username") + private String username; + + @ApiModelProperty(value = "登录IP地址") + @TableField("ipaddr") + private String ipaddr; + + @ApiModelProperty(value = "登录状态(0成功 1失败)") + @TableField("status") + private Integer status; + + @ApiModelProperty(value = "提示信息") + @TableField("msg") + private String msg; + + @ApiModelProperty(value = "访问时间") + @TableField("access_time") + private Date accessTime; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/system/SysMenu.java b/model/src/main/java/com/atguigu/model/system/SysMenu.java new file mode 100644 index 0000000..fae216d --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysMenu.java @@ -0,0 +1,62 @@ +package com.atguigu.model.system; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(description = "菜单") +@TableName("sys_menu") +public class SysMenu extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "所属上级") + @TableField("parent_id") + private Long parentId; + + @ApiModelProperty(value = "名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "类型(1:菜单,2:按钮)") + @TableField("type") + private Integer type; + + @ApiModelProperty(value = "路由地址") + @TableField("path") + private String path; + + @ApiModelProperty(value = "组件路径") + @TableField("component") + private String component; + + @ApiModelProperty(value = "权限标识") + @TableField("perms") + private String perms; + + @ApiModelProperty(value = "图标") + @TableField("icon") + private String icon; + + @ApiModelProperty(value = "排序") + @TableField("sort_value") + private Integer sortValue; + + @ApiModelProperty(value = "状态(0:禁止,1:正常)") + @TableField("status") + private Integer status; + + // 下级列表 + @TableField(exist = false) + private List children; + //是否选中 + @TableField(exist = false) + private boolean isSelect; +} + diff --git a/model/src/main/java/com/atguigu/model/system/SysOperLog.java b/model/src/main/java/com/atguigu/model/system/SysOperLog.java new file mode 100644 index 0000000..f5f0e56 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysOperLog.java @@ -0,0 +1,74 @@ +package com.atguigu.model.system; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + +@Data +@ApiModel(description = "SysOperLog") +@TableName("sys_oper_log") +public class SysOperLog extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "模块标题") + @TableField("title") + private String title; + + @ApiModelProperty(value = "业务类型(0其它 1新增 2修改 3删除)") + @TableField("business_type") + private String businessType; + + @ApiModelProperty(value = "方法名称") + @TableField("method") + private String method; + + @ApiModelProperty(value = "请求方式") + @TableField("request_method") + private String requestMethod; + + @ApiModelProperty(value = "操作类别(0其它 1后台用户 2手机端用户)") + @TableField("operator_type") + private String operatorType; + + @ApiModelProperty(value = "操作人员") + @TableField("oper_name") + private String operName; + + @ApiModelProperty(value = "部门名称") + @TableField("dept_name") + private String deptName; + + @ApiModelProperty(value = "请求URL") + @TableField("oper_url") + private String operUrl; + + @ApiModelProperty(value = "主机地址") + @TableField("oper_ip") + private String operIp; + + @ApiModelProperty(value = "请求参数") + @TableField("oper_param") + private String operParam; + + @ApiModelProperty(value = "返回参数") + @TableField("json_result") + private String jsonResult; + + @ApiModelProperty(value = "操作状态(0正常 1异常)") + @TableField("status") + private Integer status; + + @ApiModelProperty(value = "错误消息") + @TableField("error_msg") + private String errorMsg; + + @ApiModelProperty(value = "操作时间") + @TableField("oper_time") + private Date operTime; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/system/SysPost.java b/model/src/main/java/com/atguigu/model/system/SysPost.java new file mode 100644 index 0000000..8b46ed8 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysPost.java @@ -0,0 +1,33 @@ +package com.atguigu.model.system; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "岗位") +@TableName("sys_post") +public class SysPost extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "岗位编码") + @TableField("post_code") + private String postCode; + + @ApiModelProperty(value = "岗位名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "显示顺序") + @TableField("description") + private String description; + + @ApiModelProperty(value = "状态(1正常 0停用)") + @TableField("status") + private Integer status; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/model/system/SysRole.java b/model/src/main/java/com/atguigu/model/system/SysRole.java new file mode 100644 index 0000000..54dc7f2 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysRole.java @@ -0,0 +1,32 @@ +package com.atguigu.model.system; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.atguigu.model.base.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +@Data +@ApiModel(description = "角色") +@TableName("sys_role") +public class SysRole extends BaseEntity { + + private static final long serialVersionUID = 1L; + + //@NotBlank(message = "角色名称不能为空") + @ApiModelProperty(value = "角色名称") + @TableField("role_name") + private String roleName; + + @ApiModelProperty(value = "角色编码") + @TableField("role_code") + private String roleCode; + + @ApiModelProperty(value = "描述") + @TableField("description") + private String description; + +} + diff --git a/model/src/main/java/com/atguigu/model/system/SysRoleMenu.java b/model/src/main/java/com/atguigu/model/system/SysRoleMenu.java new file mode 100644 index 0000000..7fb8a39 --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysRoleMenu.java @@ -0,0 +1,26 @@ +package com.atguigu.model.system; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "角色菜单") +@TableName("sys_role_menu") +public class SysRoleMenu extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "角色id") + @TableField("role_id") + private Long roleId; + + @ApiModelProperty(value = "菜单id") + @TableField("menu_id") + private Long menuId; + +} + diff --git a/model/src/main/java/com/atguigu/model/system/SysUser.java b/model/src/main/java/com/atguigu/model/system/SysUser.java new file mode 100644 index 0000000..22c53df --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysUser.java @@ -0,0 +1,69 @@ +package com.atguigu.model.system; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; + +import com.atguigu.model.base.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(description = "用户") +@TableName("sys_user") +public class SysUser extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户名") + @TableField("username") + private String username; + + @ApiModelProperty(value = "密码") + @TableField("password") + private String password; + + @ApiModelProperty(value = "姓名") + @TableField("name") + private String name; + + @ApiModelProperty(value = "手机") + @TableField("phone") + private String phone; + + @ApiModelProperty(value = "头像地址") + @TableField("head_url") + private String headUrl; + + @ApiModelProperty(value = "部门id") + @TableField("dept_id") + private Long deptId; + + @ApiModelProperty(value = "岗位id") + @TableField("post_id") + private Long postId; + + @ApiModelProperty(value = "描述") + @TableField("description") + private String description; + + @ApiModelProperty(value = "openId") + @TableField("open_id") + private String openId; + + @ApiModelProperty(value = "状态(1:正常 0:停用)") + @TableField("status") + private Integer status; + + @TableField(exist = false) + private List roleList; + //岗位 + @TableField(exist = false) + private String postName; + //部门 + @TableField(exist = false) + private String deptName; +} + diff --git a/model/src/main/java/com/atguigu/model/system/SysUserRole.java b/model/src/main/java/com/atguigu/model/system/SysUserRole.java new file mode 100644 index 0000000..ecc122b --- /dev/null +++ b/model/src/main/java/com/atguigu/model/system/SysUserRole.java @@ -0,0 +1,25 @@ +package com.atguigu.model.system; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.atguigu.model.base.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "用户角色") +@TableName("sys_user_role") +public class SysUserRole extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "角色id") + @TableField("role_id") + private Long roleId; + + @ApiModelProperty(value = "用户id") + @TableField("user_id") + private Long userId; +} + diff --git a/model/src/main/java/com/atguigu/model/wechat/Menu.java b/model/src/main/java/com/atguigu/model/wechat/Menu.java new file mode 100644 index 0000000..ab1422e --- /dev/null +++ b/model/src/main/java/com/atguigu/model/wechat/Menu.java @@ -0,0 +1,34 @@ +package com.atguigu.model.wechat; + +import com.atguigu.model.base.BaseEntity; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "菜单") +@TableName("wechat_menu") +public class Menu extends BaseEntity { + + @ApiModelProperty(value = "id") + @TableField("parent_id") + private Long parentId; + + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "类型") + private String type; + + @ApiModelProperty(value = "网页 链接,用户点击菜单可打开链接") + private String url; + + @ApiModelProperty(value = "菜单KEY值,用于消息接口推送") + @TableField("meun_key") + private String meunKey; + + @ApiModelProperty(value = "排序") + private Integer sort; +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/vo/process/ApprovalVo.java b/model/src/main/java/com/atguigu/vo/process/ApprovalVo.java new file mode 100644 index 0000000..1bc4cca --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/process/ApprovalVo.java @@ -0,0 +1,18 @@ +package com.atguigu.vo.process; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class ApprovalVo { + + private Long processId; + + private String taskId; + + @ApiModelProperty(value = "状态") + private Integer status; + + @ApiModelProperty(value = "审批描述") + private String description; +} diff --git a/model/src/main/java/com/atguigu/vo/process/ProcessFormVo.java b/model/src/main/java/com/atguigu/vo/process/ProcessFormVo.java new file mode 100644 index 0000000..38f45b7 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/process/ProcessFormVo.java @@ -0,0 +1,20 @@ +package com.atguigu.vo.process; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "流程表单") +public class ProcessFormVo { + + @ApiModelProperty(value = "审批模板id") + private Long processTemplateId; + + @ApiModelProperty(value = "审批类型id") + private Long processTypeId; + + @ApiModelProperty(value = "表单值") + private String formValues; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/vo/process/ProcessQueryVo.java b/model/src/main/java/com/atguigu/vo/process/ProcessQueryVo.java new file mode 100644 index 0000000..aa4318b --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/process/ProcessQueryVo.java @@ -0,0 +1,31 @@ +package com.atguigu.vo.process; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(description = "Process") +public class ProcessQueryVo { + + @ApiModelProperty(value = "关键字") + private String keyword; + + @ApiModelProperty(value = "用户id") + private Long userId; + + @TableField("process_template_id") + private Long processTemplateId; + + @ApiModelProperty(value = "审批类型id") + private Long processTypeId; + + private String createTimeBegin; + private String createTimeEnd; + + @ApiModelProperty(value = "状态(0:默认 1:审批中 2:审批通过 -1:驳回)") + private Integer status; + + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/vo/process/ProcessVo.java b/model/src/main/java/com/atguigu/vo/process/ProcessVo.java new file mode 100644 index 0000000..22eefc3 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/process/ProcessVo.java @@ -0,0 +1,59 @@ +package com.atguigu.vo.process; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@ApiModel(description = "Process") +public class ProcessVo { + + private Long id; + + private Date createTime; + + @ApiModelProperty(value = "审批code") + private String processCode; + + @ApiModelProperty(value = "用户id") + private Long userId; + private String name; + + @TableField("process_template_id") + private Long processTemplateId; + private String processTemplateName; + + @ApiModelProperty(value = "审批类型id") + private Long processTypeId; + private String processTypeName; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "描述") + private String description; + + @ApiModelProperty(value = "表单属性") + private String formProps; + + @ApiModelProperty(value = "表单选项") + private String formOptions; + + @ApiModelProperty(value = "表单属性值") + private String formValues; + + @ApiModelProperty(value = "流程实例id") + private String processInstanceId; + + @ApiModelProperty(value = "当前审批人") + private String currentAuditor; + + @ApiModelProperty(value = "状态(0:默认 1:审批中 2:审批通过 -1:驳回)") + private Integer status; + + private String taskId; + +} \ No newline at end of file diff --git a/model/src/main/java/com/atguigu/vo/system/AssginMenuVo.java b/model/src/main/java/com/atguigu/vo/system/AssginMenuVo.java new file mode 100644 index 0000000..e9e91c8 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/AssginMenuVo.java @@ -0,0 +1,20 @@ +package com.atguigu.vo.system; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@ApiModel(description = "分配菜单") +@Data +public class AssginMenuVo { + + @ApiModelProperty(value = "角色id") + private Long roleId; + + @ApiModelProperty(value = "菜单id列表") + private List menuIdList; + +} diff --git a/model/src/main/java/com/atguigu/vo/system/AssginRoleVo.java b/model/src/main/java/com/atguigu/vo/system/AssginRoleVo.java new file mode 100644 index 0000000..a7c7f4f --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/AssginRoleVo.java @@ -0,0 +1,20 @@ +package com.atguigu.vo.system; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@ApiModel(description = "分配菜单") +@Data +public class AssginRoleVo { + + @ApiModelProperty(value = "用户id") + private Long userId; + + @ApiModelProperty(value = "角色id列表") + private List roleIdList; + +} diff --git a/model/src/main/java/com/atguigu/vo/system/LoginVo.java b/model/src/main/java/com/atguigu/vo/system/LoginVo.java new file mode 100644 index 0000000..277541f --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/LoginVo.java @@ -0,0 +1,34 @@ +package com.atguigu.vo.system; + + +/** + * 登录对象 + */ +public class LoginVo { + + /** + * 手机号 + */ + private String username; + + /** + * 密码 + */ + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/model/src/main/java/com/atguigu/vo/system/MetaVo.java b/model/src/main/java/com/atguigu/vo/system/MetaVo.java new file mode 100644 index 0000000..4fc422c --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/MetaVo.java @@ -0,0 +1,33 @@ +package com.atguigu.vo.system; + +import lombok.Data; + +/** + * 路由显示信息 + * + */ +@Data +public class MetaVo +{ + /** + * 设置该路由在侧边栏和面包屑中展示的名字 + */ + private String title; + + /** + * 设置该路由的图标,对应路径src/assets/icons/svg + */ + private String icon; + + public MetaVo() + { + } + + public MetaVo(String title, String icon) + { + this.title = title; + this.icon = icon; + } + +} + diff --git a/model/src/main/java/com/atguigu/vo/system/RouterVo.java b/model/src/main/java/com/atguigu/vo/system/RouterVo.java new file mode 100644 index 0000000..7f8c163 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/RouterVo.java @@ -0,0 +1,50 @@ +package com.atguigu.vo.system; + +import lombok.Data; + +import java.util.List; + +/** + * 路由配置信息 + * + */ +@Data +public class RouterVo +{ + /** + * 路由名字 + */ + //private String name; + + /** + * 路由地址 + */ + private String path; + + /** + * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现 + */ + private boolean hidden; + + /** + * 组件地址 + */ + private String component; + + /** + * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 + */ + private Boolean alwaysShow; + + /** + * 其他元素 + */ + private MetaVo meta; + + /** + * 子路由 + */ + private List children; + + +} diff --git a/model/src/main/java/com/atguigu/vo/system/SysLoginLogQueryVo.java b/model/src/main/java/com/atguigu/vo/system/SysLoginLogQueryVo.java new file mode 100644 index 0000000..9421fc8 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/SysLoginLogQueryVo.java @@ -0,0 +1,16 @@ +package com.atguigu.vo.system; + +import lombok.Data; +import io.swagger.annotations.ApiModelProperty; + +@Data +public class SysLoginLogQueryVo { + + @ApiModelProperty(value = "用户账号") + private String username; + + private String createTimeBegin; + private String createTimeEnd; + +} + diff --git a/model/src/main/java/com/atguigu/vo/system/SysOperLogQueryVo.java b/model/src/main/java/com/atguigu/vo/system/SysOperLogQueryVo.java new file mode 100644 index 0000000..0535452 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/SysOperLogQueryVo.java @@ -0,0 +1,15 @@ +package com.atguigu.vo.system; + +import lombok.Data; + +@Data +public class SysOperLogQueryVo { + + private String title; + private String operName; + + private String createTimeBegin; + private String createTimeEnd; + +} + diff --git a/model/src/main/java/com/atguigu/vo/system/SysPostQueryVo.java b/model/src/main/java/com/atguigu/vo/system/SysPostQueryVo.java new file mode 100644 index 0000000..c3d00e4 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/SysPostQueryVo.java @@ -0,0 +1,19 @@ +package com.atguigu.vo.system; + +import lombok.Data; + +@Data +public class SysPostQueryVo { + + //@ApiModelProperty(value = "岗位编码") + private String postCode; + + //@ApiModelProperty(value = "岗位名称") + private String name; + + //@ApiModelProperty(value = "状态(1正常 0停用)") + private Boolean status; + + +} + diff --git a/model/src/main/java/com/atguigu/vo/system/SysRoleQueryVo.java b/model/src/main/java/com/atguigu/vo/system/SysRoleQueryVo.java new file mode 100644 index 0000000..1cdd642 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/SysRoleQueryVo.java @@ -0,0 +1,29 @@ +// +// +package com.atguigu.vo.system; + +import java.io.Serializable; + +/** + *

+ * 角色查询实体 + *

+ * + * @author qy + * @since 2019-11-08 + */ +public class SysRoleQueryVo implements Serializable { + + private static final long serialVersionUID = 1L; + + private String roleName; + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } +} + diff --git a/model/src/main/java/com/atguigu/vo/system/SysUserQueryVo.java b/model/src/main/java/com/atguigu/vo/system/SysUserQueryVo.java new file mode 100644 index 0000000..6c3991f --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/system/SysUserQueryVo.java @@ -0,0 +1,30 @@ +// +// +package com.atguigu.vo.system; + + +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 用户查询实体 + *

+ */ +@Data +public class SysUserQueryVo implements Serializable { + + private static final long serialVersionUID = 1L; + + private String keyword; + + private String createTimeBegin; + private String createTimeEnd; + + private Long roleId; + private Long postId; + private Long deptId; + +} + diff --git a/model/src/main/java/com/atguigu/vo/wechat/BindPhoneVo.java b/model/src/main/java/com/atguigu/vo/wechat/BindPhoneVo.java new file mode 100644 index 0000000..15296e1 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/wechat/BindPhoneVo.java @@ -0,0 +1,15 @@ +package com.atguigu.vo.wechat; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class BindPhoneVo { + + @ApiModelProperty(value = "手机") + private String phone; + + @ApiModelProperty(value = "openId") + private String openId; +} diff --git a/model/src/main/java/com/atguigu/vo/wechat/MenuVo.java b/model/src/main/java/com/atguigu/vo/wechat/MenuVo.java new file mode 100644 index 0000000..227a9c8 --- /dev/null +++ b/model/src/main/java/com/atguigu/vo/wechat/MenuVo.java @@ -0,0 +1,39 @@ +package com.atguigu.vo.wechat; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(description = "菜单") +public class MenuVo { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "id") + private Long parentId; + + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "类型") + private String type; + + @ApiModelProperty(value = "url") + private String url; + + @ApiModelProperty(value = "菜单key") + private String meunKey; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "下级") + @TableField(exist = false) + private List children; + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1d0f755 --- /dev/null +++ b/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.3.6.RELEASE + + + com.atguigu + guigu-oa-parent + 1.0-SNAPSHOT + pom + + + + common + model + service-oa + + + + 1.8 + 3.4.1 + 8.0.27 + 3.0.3 + 0.9.1 + 2.0.21 + + + + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + mysql + mysql-connector-java + ${mysql.version} + + + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + + + io.jsonwebtoken + jjwt + ${jwt.version} + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + + diff --git a/service-oa/.gitignore b/service-oa/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/service-oa/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/service-oa/pom.xml b/service-oa/pom.xml new file mode 100644 index 0000000..67f7e6c --- /dev/null +++ b/service-oa/pom.xml @@ -0,0 +1,53 @@ + + 4.0.0 + + com.atguigu + guigu-oa-parent + 1.0-SNAPSHOT + + service-oa + jar + + + + com.atguigu + model + 1.0-SNAPSHOT + + + com.atguigu + service-util + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + com.baomidou + mybatis-plus-generator + 3.4.1 + + + + org.apache.velocity + velocity-engine-core + 2.0 + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/service-oa/src/main/java/com/atguigu/auth/ServiceAuthApplication.java b/service-oa/src/main/java/com/atguigu/auth/ServiceAuthApplication.java new file mode 100644 index 0000000..9d86453 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/ServiceAuthApplication.java @@ -0,0 +1,20 @@ +package com.atguigu.auth; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +/** + * ClassName: ServiceAuthApplication + * Package: com.atguigu.auth + * + * @author yovinchen + * @Create 2023/6/1 23:03 + */ +@SpringBootApplication +@ComponentScan("com.atguigu") +public class ServiceAuthApplication { + public static void main(String[] args) { + SpringApplication.run(ServiceAuthApplication.class, args); + } +} diff --git a/service-oa/src/main/java/com/atguigu/auth/controller/IndexController.java b/service-oa/src/main/java/com/atguigu/auth/controller/IndexController.java new file mode 100644 index 0000000..57e6f5c --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/controller/IndexController.java @@ -0,0 +1,67 @@ +package com.atguigu.auth.controller; + +import com.atguigu.common.result.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +/** + * ClassName: IndexController + * Package: com.atguigu.auth.controller + * + * @author yovinchen + * @Create 2023/6/8 20:32 + * 后台登录登出 + */ +@Api(tags = "后台登录管理") +@RestController +@RequestMapping("/admin/system/index") +public class IndexController { + + + /** + * 登录 + * + * @return + */ + @ApiOperation("登陆") + @PostMapping("login") + public Result login() { + Map map = new HashMap<>(); + map.put("token", "admin"); + return Result.ok(map); + } + + /** + * 获取用户信息 + * + * @return + */ + @ApiOperation("获取用户信息") + @GetMapping("info") + public Result info() { + Map map = new HashMap<>(); + map.put("roles", "[admin]"); + map.put("name", "admin"); + map.put("avatar", "https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg"); + return Result.ok(map); + } + + /** + * 退出 + * + * @return + */ + @ApiOperation("登出") + @PostMapping("logout") + public Result logout() { + return Result.ok(); + } + +} diff --git a/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java b/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java new file mode 100644 index 0000000..825fe0c --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/controller/SysRoleController.java @@ -0,0 +1,185 @@ +package com.atguigu.auth.controller; + +import com.atguigu.auth.service.SysRoleService; +import com.atguigu.common.result.Result; +import com.atguigu.model.system.SysRole; +import com.atguigu.vo.system.AssginRoleVo; +import com.atguigu.vo.system.SysRoleQueryVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * ClassName: SysRoleService + * Package: com.atguigu.auth.controller + * + * @author yovinchen + * @Create 2023/6/6 17:19 + */ +@Api(tags = "角色管理接口") +@RestController +@RequestMapping("/admin/system/sysRole") +public class SysRoleController { + + @Autowired + private SysRoleService sysRoleService; + + /** + * 查询所有角色和当前用户所属角色 + * + * @param userId + * @return + */ + @ApiOperation(value = "根据用户获取角色数据") + @GetMapping("/toAssign/{userId}") + public Result toAssign(@PathVariable Long userId) { + Map roleMap = sysRoleService.findRoleByUserId(userId); + return Result.ok(roleMap); + } + + /** + * 为用户分配角色 + * + * @param assginRoleVo + * @return + */ + @ApiOperation(value = "根据用户分配角色") + @PostMapping("/doAssign") + public Result doAssign(@RequestBody AssginRoleVo assginRoleVo) { + sysRoleService.doAssign(assginRoleVo); + return Result.ok(); + } + + /** + * 查询所有角色 + * + * @return + */ + @ApiOperation("查询所有角色") + @GetMapping("findAll") + public Result findAll() { + return Result.ok(sysRoleService.list()); + } + + /** + * 条件分页查询 + * page 当前页 + * limit 每页显示记录数 + * + * @return + */ + @ApiOperation("条件分页查询") + @GetMapping("{page}/{limit}") + public Result pageQueryRole(@PathVariable Long page, + @PathVariable Long limit, + SysRoleQueryVo sysRoleQueryVo) { + //调用service的方法实现 + //1 创建Page对象,传递分页相关参数 + //page 当前页 limit 每页显示记录数 + Page pageParam = new Page<>(page, limit); + + //2 封装条件,判断条件是否为空,不为空进行封装 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + String roleName = sysRoleQueryVo.getRoleName(); + if (!StringUtils.isEmpty(roleName)) { + //封装 like模糊查询 + wrapper.like(SysRole::getRoleName, roleName); + } + + //3 调用方法实现 + IPage pageModel = sysRoleService.page(pageParam, wrapper); + return Result.ok(pageModel); + } + + /** + * 添加角色 + * + * @param role + * @return + */ + @ApiOperation("添加角色") + @PostMapping("save") + public Result save(@RequestBody SysRole role) { + //调用service的方法 + boolean is_success = sysRoleService.save(role); + if (is_success) { + return Result.ok(); + } else { + return Result.fail(); + } + } + + /** + * 修改角色-根据id查询 + * + * @param id + * @return + */ + @ApiOperation("根据id查询") + @GetMapping("get/{id}") + public Result get(@PathVariable Long id) { + SysRole sysRole = sysRoleService.getById(id); + return Result.ok(sysRole); + } + + /** + * 修改角色-最终修改 + * + * @param role + * @return + */ + @ApiOperation("修改角色") + @PutMapping("update") + public Result update(@RequestBody SysRole role) { + //调用service的方法 + boolean is_success = sysRoleService.updateById(role); + if (is_success) { + return Result.ok(); + } else { + return Result.fail(); + } + } + + /** + * 根据id删除 + * + * @param id + * @return + */ + @ApiOperation("根据id删除") + @DeleteMapping("remove/{id}") + public Result remove(@PathVariable Long id) { + boolean is_success = sysRoleService.removeById(id); + if (is_success) { + return Result.ok(); + } else { + return Result.fail(); + } + } + + /** + * 批量删除 + * 前端数组 [1,2,3] + * + * @param idList + * @return + */ + @ApiOperation("批量删除") + @DeleteMapping("batchRemove") + public Result batchRemove(@RequestBody List idList) { + boolean is_success = sysRoleService.removeByIds(idList); + if (is_success) { + return Result.ok(); + } else { + return Result.fail(); + } + } +} diff --git a/service-oa/src/main/java/com/atguigu/auth/controller/SysUserController.java b/service-oa/src/main/java/com/atguigu/auth/controller/SysUserController.java new file mode 100644 index 0000000..95bbede --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/controller/SysUserController.java @@ -0,0 +1,140 @@ +package com.atguigu.auth.controller; + + +import com.atguigu.auth.service.SysUserService; +import com.atguigu.common.result.Result; +import com.atguigu.model.system.SysUser; +import com.atguigu.vo.system.SysUserQueryVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +/** + *

+ * 用户表 前端控制器 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +@Api(tags = "用户管理接口") +@RestController +@RequestMapping("/admin/system/sysUser") +public class SysUserController { + + @Autowired + private SysUserService sysUserService; + + /** + * 更新用户状态 + * + * @param id + * @param status + * @return + */ + @ApiOperation(value = "更新状态") + @GetMapping("updateStatus/{id}/{status}") + public Result updateStatus(@PathVariable Long id, @PathVariable Integer status) { + sysUserService.updateStatus(id, status); + return Result.ok(); + } + + /** + * 用户条件分页查询 + * + * @param page + * @param limit + * @param sysUserQueryVo + * @return + */ + @ApiOperation("用户条件分页查询") + @GetMapping("{page}/{limit}") + public Result index(@PathVariable Long page, + @PathVariable Long limit, + SysUserQueryVo sysUserQueryVo) { + //创建page对象 + Page pageParam = new Page<>(page, limit); + + //封装条件,判断条件值不为空 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + //获取条件值 + String username = sysUserQueryVo.getKeyword(); + String createTimeBegin = sysUserQueryVo.getCreateTimeBegin(); + String createTimeEnd = sysUserQueryVo.getCreateTimeEnd(); + //判断条件值不为空 + //like 模糊查询 + if (!StringUtils.isEmpty(username)) { + wrapper.like(SysUser::getUsername, username); + } + //ge 大于等于 + if (!StringUtils.isEmpty(createTimeBegin)) { + wrapper.ge(SysUser::getCreateTime, createTimeBegin); + } + //le 小于等于 + if (!StringUtils.isEmpty(createTimeEnd)) { + wrapper.le(SysUser::getCreateTime, createTimeEnd); + } + + //调用mp的方法实现条件分页查询 + IPage pageModel = sysUserService.page(pageParam, wrapper); + return Result.ok(pageModel); + } + + /** + * 获取用户 + * + * @param id + * @return + */ + @ApiOperation(value = "获取用户") + @GetMapping("get/{id}") + public Result get(@PathVariable Long id) { + SysUser user = sysUserService.getById(id); + return Result.ok(user); + } + + /** + * 保存用户 + * + * @param user + * @return + */ + @ApiOperation(value = "保存用户") + @PostMapping("save") + public Result save(@RequestBody SysUser user) { + sysUserService.save(user); + return Result.ok(); + } + + /** + * 更新用户 + * + * @param user + * @return + */ + @ApiOperation(value = "更新用户") + @PutMapping("update") + public Result updateById(@RequestBody SysUser user) { + sysUserService.updateById(user); + return Result.ok(); + } + + /** + * 删除用户 + * + * @param id + * @return + */ + @ApiOperation(value = "删除用户") + @DeleteMapping("remove/{id}") + public Result remove(@PathVariable Long id) { + sysUserService.removeById(id); + return Result.ok(); + } +} + diff --git a/service-oa/src/main/java/com/atguigu/auth/mapper/SysRoleMapper.java b/service-oa/src/main/java/com/atguigu/auth/mapper/SysRoleMapper.java new file mode 100644 index 0000000..f58c25e --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/mapper/SysRoleMapper.java @@ -0,0 +1,17 @@ +package com.atguigu.auth.mapper; + +import com.atguigu.model.system.SysRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * ClassName: SysRoleMapper + * Package: com.atguigu.auth.mapper + * + * @author yovinchen + * @Create 2023/6/1 23:01 + */ +@Mapper +public interface SysRoleMapper extends BaseMapper { + +} diff --git a/service-oa/src/main/java/com/atguigu/auth/mapper/SysUserMapper.java b/service-oa/src/main/java/com/atguigu/auth/mapper/SysUserMapper.java new file mode 100644 index 0000000..d4b7051 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/mapper/SysUserMapper.java @@ -0,0 +1,18 @@ +package com.atguigu.auth.mapper; + +import com.atguigu.model.system.SysUser; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 用户表 Mapper 接口 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +@Mapper +public interface SysUserMapper extends BaseMapper { + +} diff --git a/service-oa/src/main/java/com/atguigu/auth/mapper/SysUserRoleMapper.java b/service-oa/src/main/java/com/atguigu/auth/mapper/SysUserRoleMapper.java new file mode 100644 index 0000000..ebf7a38 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/mapper/SysUserRoleMapper.java @@ -0,0 +1,20 @@ +package com.atguigu.auth.mapper; + +import com.atguigu.model.system.SysUserRole; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * 用户角色 Mapper 接口 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +@Repository +@Mapper +public interface SysUserRoleMapper extends BaseMapper { + +} diff --git a/service-oa/src/main/java/com/atguigu/auth/mapper/xml/SysUserMapper.xml b/service-oa/src/main/java/com/atguigu/auth/mapper/xml/SysUserMapper.xml new file mode 100644 index 0000000..c47ccb5 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/mapper/xml/SysUserMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/service-oa/src/main/java/com/atguigu/auth/mapper/xml/SysUserRoleMapper.xml b/service-oa/src/main/java/com/atguigu/auth/mapper/xml/SysUserRoleMapper.xml new file mode 100644 index 0000000..54bb1fd --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/mapper/xml/SysUserRoleMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java b/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java new file mode 100644 index 0000000..e7730c8 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/service/SysRoleService.java @@ -0,0 +1,24 @@ +package com.atguigu.auth.service; + +import com.atguigu.model.system.SysRole; +import com.atguigu.vo.system.AssginRoleVo; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * ClassName: SysRoleService + * Package: com.atguigu.auth.service + * + * @author yovinchen + * @Create 2023/6/1 23:03 + */ +public interface SysRoleService extends IService { + + //查询所有角色和当前用户所属角色 + Map findRoleByUserId(Long userId); + + //为用户分配角色 + + void doAssign(AssginRoleVo assginRoleVo); +} diff --git a/service-oa/src/main/java/com/atguigu/auth/service/SysUserRoleService.java b/service-oa/src/main/java/com/atguigu/auth/service/SysUserRoleService.java new file mode 100644 index 0000000..a32d2d9 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/service/SysUserRoleService.java @@ -0,0 +1,16 @@ +package com.atguigu.auth.service; + +import com.atguigu.model.system.SysUserRole; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户角色 服务类 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +public interface SysUserRoleService extends IService { + +} diff --git a/service-oa/src/main/java/com/atguigu/auth/service/SysUserService.java b/service-oa/src/main/java/com/atguigu/auth/service/SysUserService.java new file mode 100644 index 0000000..ccec3eb --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/service/SysUserService.java @@ -0,0 +1,23 @@ +package com.atguigu.auth.service; + +import com.atguigu.model.system.SysUser; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 用户表 服务类 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +public interface SysUserService extends IService { + + /** + * 更新用户状态 + * + * @param id + * @param status + */ + void updateStatus(Long id, Integer status); +} diff --git a/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java new file mode 100644 index 0000000..08d512b --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,81 @@ +package com.atguigu.auth.service.impl; + +import com.atguigu.auth.mapper.SysRoleMapper; +import com.atguigu.auth.mapper.SysUserRoleMapper; +import com.atguigu.auth.service.SysRoleService; +import com.atguigu.model.system.SysRole; +import com.atguigu.model.system.SysUserRole; +import com.atguigu.vo.system.AssginRoleVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * ClassName: SysRoleServiceImpl + * Package: com.atguigu.auth.service.impl + * + * @author yovinchen + * @Create 2023/6/1 23:02 + */ +@Service +public class SysRoleServiceImpl extends ServiceImpl implements SysRoleService { + + @Autowired + private SysUserRoleMapper sysUserRoleMapper; + + @Override + public Map findRoleByUserId(Long userId) { + //查询所有的角色 + List allRolesList = this.list(); + + //查询的角色id + List existUserRoleList = sysUserRoleMapper.selectList(new LambdaQueryWrapper().eq(SysUserRole::getUserId, userId).select(SysUserRole::getRoleId)); + + List existRoleIdList = existUserRoleList.stream().map(c -> c.getRoleId()).collect(Collectors.toList()); + + //对角色进行分类 + List assginRoleList = new ArrayList<>(); + for (SysRole role : allRolesList) { + //比较,已分配 + if (existRoleIdList.contains(role.getId())) { + assginRoleList.add(role); + } + } + + Map roleMap = new HashMap<>(); + roleMap.put("assginRoleList", assginRoleList); + roleMap.put("allRolesList", allRolesList); + return roleMap; + } + + /** + * 为用户分配角色 + * + * @param assginRoleVo + */ + @Transactional + @Override + public void doAssign(AssginRoleVo assginRoleVo) { + //删除用户的角色数据,在用户角色表 sys_user_role表中根据userid删除 + sysUserRoleMapper.delete(new LambdaQueryWrapper().eq(SysUserRole::getUserId, assginRoleVo.getUserId())); + //重新为用户分配角色 + for (Long roleId : assginRoleVo.getRoleIdList()) { + //判空 + if (StringUtils.isEmpty(roleId)) continue; + + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(assginRoleVo.getUserId()); + sysUserRole.setRoleId(roleId); + sysUserRoleMapper.insert(sysUserRole); + } + } +} diff --git a/service-oa/src/main/java/com/atguigu/auth/service/impl/SysUserRoleServiceImpl.java b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysUserRoleServiceImpl.java new file mode 100644 index 0000000..44e4e3b --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysUserRoleServiceImpl.java @@ -0,0 +1,20 @@ +package com.atguigu.auth.service.impl; + +import com.atguigu.auth.mapper.SysUserRoleMapper; +import com.atguigu.auth.service.SysUserRoleService; +import com.atguigu.model.system.SysUserRole; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户角色 服务实现类 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +@Service +public class SysUserRoleServiceImpl extends ServiceImpl implements SysUserRoleService { + +} diff --git a/service-oa/src/main/java/com/atguigu/auth/service/impl/SysUserServiceImpl.java b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysUserServiceImpl.java new file mode 100644 index 0000000..3b55418 --- /dev/null +++ b/service-oa/src/main/java/com/atguigu/auth/service/impl/SysUserServiceImpl.java @@ -0,0 +1,40 @@ +package com.atguigu.auth.service.impl; + +import com.atguigu.auth.mapper.SysUserMapper; +import com.atguigu.auth.service.SysUserService; +import com.atguigu.model.system.SysUser; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +/** + *

+ * 用户表 服务实现类 + *

+ * + * @author yovinchen + * @since 2023-06-09 + */ +@Service +public class SysUserServiceImpl extends ServiceImpl implements SysUserService { + + /** + * 更新用户状态 + * + * @param id + * @param status + */ + @Transactional + @Override + public void updateStatus(Long id, Integer status) { + //根据userid查询用户对象、 + SysUser sysUser = baseMapper.selectById(id); + //设置修改状态值 + if (status.intValue() == 1) { + sysUser.setStatus(status); + } else { + sysUser.setStatus(0); + } + baseMapper.updateById(sysUser); + } +} diff --git a/service-oa/src/main/resources/application-dev.yml b/service-oa/src/main/resources/application-dev.yml new file mode 100644 index 0000000..68ac13b --- /dev/null +++ b/service-oa/src/main/resources/application-dev.yml @@ -0,0 +1,16 @@ +server: + port: 8800 +mybatis-plus: + configuration: + # 查看日志 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/guigu-oa?useSSL=false&useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true + username: root + password: root + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 diff --git a/service-oa/src/main/resources/application.yml b/service-oa/src/main/resources/application.yml new file mode 100644 index 0000000..bad46e3 --- /dev/null +++ b/service-oa/src/main/resources/application.yml @@ -0,0 +1,5 @@ +spring: + application: + name: service-oa + profiles: + active: dev diff --git a/service-oa/src/test/java/com/atguigu/auth/TestMpDemo1.java b/service-oa/src/test/java/com/atguigu/auth/TestMpDemo1.java new file mode 100644 index 0000000..527af6c --- /dev/null +++ b/service-oa/src/test/java/com/atguigu/auth/TestMpDemo1.java @@ -0,0 +1,130 @@ +package com.atguigu.auth; + +import com.atguigu.auth.mapper.SysRoleMapper; +import com.atguigu.auth.service.SysRoleService; +import com.atguigu.model.system.SysRole; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.Arrays; +import java.util.List; + +/** + * ClassName: TestMpDemo1 + * Package: com.atguigu.auth + * + * @author yovinchen + * @Create 2023/6/1 23:04 + */ +@SpringBootTest +public class TestMpDemo1 { + + /** + * MyBatisPlus 对 service 层和 dao 层都做了很好的封装,直接调对应的CRUD方法就行 + */ + @Autowired + private SysRoleMapper sysRoleMapper; + + @Autowired + private SysRoleService sysRoleService; + + /** + * 使用MP 封装的 service 来操作数据库,查询所有记录 + */ + @Test + public void getAllByService() { + List list = sysRoleService.list(); + list.forEach(System.out::println); + } + + /** + * 使用MP 封装的 mapper查询所有记录 + */ + @Test + public void getAllByMapper() { + List sysRoles = sysRoleMapper.selectList(null); + sysRoles.forEach(System.out::println); + } + + /** + * 添加操作 + */ + @Test + public void insert() { + SysRole sysRole = new SysRole(); + sysRole.setRoleName("角色管理员"); + sysRole.setRoleCode("role"); + sysRole.setDescription("角色管理员"); + int result = sysRoleMapper.insert(sysRole); + + System.out.println(result); //影响的行数 + System.out.println(sysRole.getId()); //id自动回填 + } + + /** + * 修改操作 + */ + @Test + public void updateById() { + // 根据id查询 + SysRole sysRole = sysRoleMapper.selectById(9); + // 设置修改值 + sysRole.setRoleName("角色管理员1"); + // 调用方法实现最终修改 + int update = sysRoleMapper.updateById(sysRole); + // 受影响的行数 + System.out.println("update = " + update); + } + + /** + * 根据id删除 + */ + @Test + public void deleteById() { + int delete = sysRoleMapper.deleteById(9); + // 受影响的行数 + System.out.println("delete = " + delete); + } + + /** + * 批量删除 + */ + @Test + public void deleteBatchByIds() { + // 或者下面这种写法 + int delete = sysRoleMapper.deleteBatchIds(Arrays.asList(8, 9)); + // 受影响的行数 + System.out.println("ids = " + delete); + } + + /** + * 条件查询 + */ + @Test + public void testQueryWrapper1() { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("role_name", "系统管理员"); + + List list = sysRoleMapper.selectList(queryWrapper); + list.forEach(System.out::println); + } + + /** + * 条件查询 + */ + @Test + public void testQueryWrapper2() { + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + //java 8 中写法 + queryWrapper.eq(SysRole::getRoleName, "系统管理员"); + + List list = sysRoleMapper.selectList(queryWrapper); + list.forEach(System.out::println); + } + +} diff --git a/service-oa/src/test/java/com/atguigu/code/CodeGet.java b/service-oa/src/test/java/com/atguigu/code/CodeGet.java new file mode 100644 index 0000000..4e93cdb --- /dev/null +++ b/service-oa/src/test/java/com/atguigu/code/CodeGet.java @@ -0,0 +1,67 @@ +package com.atguigu.code; + + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.generator.AutoGenerator; +import com.baomidou.mybatisplus.generator.config.DataSourceConfig; +import com.baomidou.mybatisplus.generator.config.GlobalConfig; +import com.baomidou.mybatisplus.generator.config.PackageConfig; +import com.baomidou.mybatisplus.generator.config.StrategyConfig; +import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; + +public class CodeGet { + + public static void main(String[] args) { + + // 1、创建代码生成器 + AutoGenerator mpg = new AutoGenerator(); + + // 2、全局配置 + // 全局配置 + GlobalConfig gc = new GlobalConfig(); + gc.setOutputDir("/Users/yovinchen/project/Java/project/guigu-oa-parent/service-oa" + "/src/main/java"); + + gc.setServiceName("%sService"); //去掉Service接口的首字母I + gc.setAuthor("yovinchen"); + gc.setOpen(false); + mpg.setGlobalConfig(gc); + + // 3、数据源配置 + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setUrl("jdbc:mysql://localhost:3306/guigu-oa?serverTimezone=UTC&useSSL=false"); + dsc.setDriverName("com.mysql.cj.jdbc.Driver"); + dsc.setUsername("root"); + dsc.setPassword("root"); + dsc.setDbType(DbType.MYSQL); + mpg.setDataSource(dsc); + + // 4、包配置 + PackageConfig pc = new PackageConfig(); + pc.setParent("com.atguigu"); + pc.setModuleName("auth"); //模块名 + pc.setController("controller"); + pc.setService("service"); + pc.setMapper("mapper"); + mpg.setPackageInfo(pc); + + // 5、策略配置 + StrategyConfig strategy = new StrategyConfig(); + + strategy.setInclude("sys_user_role"); + //数据库表映射到实体的命名策略 + strategy.setNaming(NamingStrategy.underline_to_camel); + //数据库表字段映射到实体的命名策略 + strategy.setColumnNaming(NamingStrategy.underline_to_camel); + // lombok 模型 @Accessors(chain = true) setter链式操作 + strategy.setEntityLombokModel(true); + //restful api风格控制器 + strategy.setRestControllerStyle(true); + //url中驼峰转连字符¬ + strategy.setControllerMappingHyphenStyle(true); + + mpg.setStrategy(strategy); + + // 6、执行 + mpg.execute(); + } +}