portal commit
This commit is contained in:
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# 依赖于环境的 Maven 主目录路径
|
||||||
|
/mavenHomeManager.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
9
.idea/lingniu-platform.iml
generated
Normal file
9
.idea/lingniu-platform.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/lingniu-platform.iml" filepath="$PROJECT_DIR$/.idea/lingniu-platform.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
CREATE TABLE oauth2_authorization (
|
|
||||||
id varchar(100) NOT NULL COMMENT '授权记录的唯一标识符',
|
|
||||||
registered_client_id varchar(100) NOT NULL COMMENT '注册客户端的ID,关联到客户端注册表',
|
|
||||||
principal_name varchar(200) NOT NULL COMMENT '授权主体的名称(通常是用户ID或用户名)',
|
|
||||||
authorization_grant_type varchar(100) NOT NULL COMMENT '授权类型(如:authorization_code, client_credentials, refresh_token等)',
|
|
||||||
authorized_scopes varchar(1000) DEFAULT NULL COMMENT '已授权的范围(用空格分隔的scope列表)',
|
|
||||||
attributes blob DEFAULT NULL COMMENT '附加属性,以二进制格式存储',
|
|
||||||
state varchar(500) DEFAULT NULL COMMENT 'OAuth2状态参数,用于防止CSRF攻击',
|
|
||||||
authorization_code_value blob DEFAULT NULL COMMENT '授权码的值(加密存储)',
|
|
||||||
authorization_code_issued_at timestamp NULL DEFAULT NULL COMMENT '授权码的颁发时间',
|
|
||||||
authorization_code_expires_at timestamp NULL DEFAULT NULL COMMENT '授权码的过期时间',
|
|
||||||
authorization_code_metadata blob DEFAULT NULL COMMENT '授权码的元数据',
|
|
||||||
access_token_value blob DEFAULT NULL COMMENT '访问令牌的值(加密存储)',
|
|
||||||
access_token_issued_at timestamp NULL DEFAULT NULL COMMENT '访问令牌的颁发时间',
|
|
||||||
access_token_expires_at timestamp NULL DEFAULT NULL COMMENT '访问令牌的过期时间',
|
|
||||||
access_token_metadata blob DEFAULT NULL COMMENT '访问令牌的元数据',
|
|
||||||
access_token_type varchar(100) DEFAULT NULL COMMENT '访问令牌类型(如:Bearer)',
|
|
||||||
access_token_scopes varchar(1000) DEFAULT NULL COMMENT '访问令牌的有效范围',
|
|
||||||
oidc_id_token_value blob DEFAULT NULL COMMENT 'OIDC ID令牌的值(加密存储)',
|
|
||||||
oidc_id_token_issued_at timestamp NULL DEFAULT NULL COMMENT 'OIDC ID令牌的颁发时间',
|
|
||||||
oidc_id_token_expires_at timestamp NULL DEFAULT NULL COMMENT 'OIDC ID令牌的过期时间',
|
|
||||||
oidc_id_token_metadata blob DEFAULT NULL COMMENT 'OIDC ID令牌的元数据',
|
|
||||||
refresh_token_value blob DEFAULT NULL COMMENT '刷新令牌的值(加密存储)',
|
|
||||||
refresh_token_issued_at timestamp NULL DEFAULT NULL COMMENT '刷新令牌的颁发时间',
|
|
||||||
refresh_token_expires_at timestamp NULL DEFAULT NULL COMMENT '刷新令牌的过期时间',
|
|
||||||
refresh_token_metadata blob DEFAULT NULL COMMENT '刷新令牌的元数据',
|
|
||||||
user_code_value blob DEFAULT NULL COMMENT '设备流用户码的值(加密存储)',
|
|
||||||
user_code_issued_at timestamp NULL DEFAULT NULL COMMENT '设备流用户码的颁发时间',
|
|
||||||
user_code_expires_at timestamp NULL DEFAULT NULL COMMENT '设备流用户码的过期时间',
|
|
||||||
user_code_metadata blob DEFAULT NULL COMMENT '设备流用户码的元数据',
|
|
||||||
device_code_value blob DEFAULT NULL COMMENT '设备流设备码的值(加密存储)',
|
|
||||||
device_code_issued_at timestamp NULL DEFAULT NULL COMMENT '设备流设备码的颁发时间',
|
|
||||||
device_code_expires_at timestamp NULL DEFAULT NULL COMMENT '设备流设备码的过期时间',
|
|
||||||
device_code_metadata blob DEFAULT NULL COMMENT '设备流设备码的元数据',
|
|
||||||
PRIMARY KEY (id)
|
|
||||||
) COMMENT='OAuth2 授权表,存储所有OAuth2和OpenID Connect的授权信息';
|
|
||||||
|
|
||||||
CREATE INDEX idx_registered_client_id ON oauth2_authorization(registered_client_id);
|
|
||||||
CREATE INDEX idx_principal_name ON oauth2_authorization(principal_name);
|
|
||||||
CREATE INDEX idx_state ON oauth2_authorization(state);
|
|
||||||
CREATE INDEX idx_access_token_expires_at ON oauth2_authorization(access_token_expires_at);
|
|
||||||
CREATE INDEX idx_refresh_token_expires_at ON oauth2_authorization(refresh_token_expires_at);
|
|
||||||
CREATE INDEX idx_authorization_code_expires_at ON oauth2_authorization(authorization_code_expires_at);
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE oauth2_authorization_consent (
|
|
||||||
registered_client_id varchar(100) NOT NULL COMMENT '注册客户端的ID,关联到客户端注册表',
|
|
||||||
principal_name varchar(200) NOT NULL COMMENT '授权主体的名称(通常是用户ID或用户名)',
|
|
||||||
authorities varchar(1000) NOT NULL COMMENT '已授予的权限列表(逗号分隔的权限字符串)',
|
|
||||||
PRIMARY KEY (registered_client_id, principal_name)
|
|
||||||
) COMMENT='OAuth2授权同意表,存储用户对客户端的授权同意记录';
|
|
||||||
|
|
||||||
CREATE INDEX idx_oauth2_authorization_consent_principal_name ON oauth2_authorization_consent(principal_name);
|
|
||||||
CREATE INDEX idx_oauth2_authorization_consent_client_id ON oauth2_authorization_consent(registered_client_id);
|
|
||||||
@@ -4,7 +4,8 @@ VITE_APP_TITLE = IDP统一登录系统
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
VITE_APP_ENV = 'development'
|
VITE_APP_ENV = 'development'
|
||||||
|
|
||||||
|
VITE_APP_BASE_URL=/idp-ui/
|
||||||
# 开发环境
|
# 开发环境
|
||||||
VITE_APP_BASE_API = '/dev-api'
|
VITE_APP_BASE_API = '/idp-api2'
|
||||||
|
|
||||||
VITE_APP_DEFAULT_PAGE=''
|
VITE_APP_DEFAULT_PAGE=''
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ VITE_APP_TITLE = IDP统一登录系统
|
|||||||
|
|
||||||
# 生产环境配置
|
# 生产环境配置
|
||||||
VITE_APP_ENV = 'production'
|
VITE_APP_ENV = 'production'
|
||||||
|
VITE_APP_BASE_URL=/idp-ui/
|
||||||
# 生产环境
|
# 生产环境
|
||||||
VITE_APP_BASE_API = '/prod-api'
|
VITE_APP_BASE_API = '/idp-api2'
|
||||||
|
|
||||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||||
VITE_BUILD_COMPRESS = gzip
|
VITE_BUILD_COMPRESS = gzip
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export function logout(): Promise<AxiosResponse<any>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
export function getCodeImg(): Promise<AxiosResponse<CaptchaResponse>> {
|
export function getCodeImg(): Promise<CaptchaResponse> {
|
||||||
return request({
|
return request({
|
||||||
url: '/captcha/image',
|
url: '/captcha/image',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ import App from './App.vue'
|
|||||||
import router from './router'
|
import router from './router'
|
||||||
import 'virtual:svg-icons-register'
|
import 'virtual:svg-icons-register'
|
||||||
import SvgIcon from '@/components/SvgIcon'
|
import SvgIcon from '@/components/SvgIcon'
|
||||||
import elementIcons from '@/components/SvgIcon/svgicon'
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(ElementPlus)
|
app.use(ElementPlus)
|
||||||
app.use(elementIcons)
|
|
||||||
app.component('svg-icon', SvgIcon)
|
app.component('svg-icon', SvgIcon)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
@@ -13,15 +13,15 @@ const privateKey: string = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHy
|
|||||||
'UP8iWi1Qw0Y='
|
'UP8iWi1Qw0Y='
|
||||||
|
|
||||||
// 加密
|
// 加密
|
||||||
export function encrypt(txt: string): string | false {
|
export function encrypt(txt: string): string {
|
||||||
const encryptor = new JSEncrypt()
|
const encryptor = new JSEncrypt()
|
||||||
encryptor.setPublicKey(publicKey) // 设置公钥
|
encryptor.setPublicKey(publicKey) // 设置公钥
|
||||||
return encryptor.encrypt(txt) // 对数据进行加密
|
return encryptor.encrypt(txt)|| "" // 对数据进行加密
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解密
|
// 解密
|
||||||
export function decrypt(txt: string): string | false {
|
export function decrypt(txt: string): string {
|
||||||
const encryptor = new JSEncrypt()
|
const encryptor = new JSEncrypt()
|
||||||
encryptor.setPrivateKey(privateKey) // 设置私钥
|
encryptor.setPrivateKey(privateKey) // 设置私钥
|
||||||
return encryptor.decrypt(txt) // 对数据进行解密
|
return encryptor.decrypt(txt) || ""// 对数据进行解密
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, getCurrentInstance } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { getCodeImg } from '@/api/login'
|
import { getCodeImg } from '@/api/login'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
@@ -78,9 +78,9 @@ import type { FormInstance, FormRules } from 'element-plus'
|
|||||||
interface LoginForm {
|
interface LoginForm {
|
||||||
username: string
|
username: string
|
||||||
password: string
|
password: string
|
||||||
rememberMe: boolean
|
rememberMe?: boolean
|
||||||
code: string
|
code?: string
|
||||||
uuid: string
|
uuid?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CaptchaResponse {
|
interface CaptchaResponse {
|
||||||
@@ -99,7 +99,7 @@ const footerContent = defaultSettings.footerContent
|
|||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { proxy } = getCurrentInstance() as { proxy: { $refs: { loginRef: FormInstance } } }
|
const loginRef = ref<FormInstance>()
|
||||||
|
|
||||||
const loginForm = ref<LoginForm>({
|
const loginForm = ref<LoginForm>({
|
||||||
username: "admin",
|
username: "admin",
|
||||||
@@ -128,34 +128,15 @@ watch(route, (newRoute) => {
|
|||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
function handleLogin(): void {
|
function handleLogin(): void {
|
||||||
proxy.$refs.loginRef.validate((valid: boolean) => {
|
loginRef.value?.validate((valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
// 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
// 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
||||||
if (loginForm.value.rememberMe) {
|
handleRememberMe()
|
||||||
Cookies.set("username", loginForm.value.username, { expires: 30 })
|
|
||||||
Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 })
|
|
||||||
Cookies.set("rememberMe", String(loginForm.value.rememberMe), { expires: 30 })
|
|
||||||
} else {
|
|
||||||
// 否则移除
|
|
||||||
Cookies.remove("username")
|
|
||||||
Cookies.remove("password")
|
|
||||||
Cookies.remove("rememberMe")
|
|
||||||
}
|
|
||||||
// 调用action的登录方法
|
// 调用action的登录方法
|
||||||
userStore.login(loginForm.value).then(() => {
|
userStore.login(loginForm.value).then(() => {
|
||||||
const query: QueryParams = route.query
|
const query: QueryParams = route.query
|
||||||
const otherQueryParams = Object.keys(query).reduce((acc: QueryParams, cur: string) => {
|
handleRedirect(query)
|
||||||
if (cur !== "redirect") {
|
|
||||||
acc[cur] = query[cur]
|
|
||||||
}
|
|
||||||
return acc
|
|
||||||
}, {})
|
|
||||||
if(query.redirect){
|
|
||||||
router.push(query.redirect)
|
|
||||||
}else{
|
|
||||||
router.push({ path: redirect.value || "/", query: otherQueryParams })
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
// 重新获取验证码
|
// 重新获取验证码
|
||||||
@@ -166,13 +147,37 @@ function handleLogin(): void {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function handleRememberMe(): void {
|
||||||
|
if (loginForm.value.rememberMe) {
|
||||||
|
Cookies.set("username", loginForm.value.username, { expires: 30 })
|
||||||
|
Cookies.set("password", encrypt(loginForm.value.password), {expires: 30})
|
||||||
|
Cookies.set("rememberMe", String(loginForm.value.rememberMe), { expires: 30 })
|
||||||
|
} else {
|
||||||
|
Cookies.remove("username")
|
||||||
|
Cookies.remove("password")
|
||||||
|
Cookies.remove("rememberMe")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRedirect(query: QueryParams): void {
|
||||||
|
if (query.redirect) {
|
||||||
|
router.push(query.redirect);
|
||||||
|
} else {
|
||||||
|
router.push({
|
||||||
|
path: redirect.value || "/",
|
||||||
|
query: Object.keys(query).reduce((acc: Record<string, any>, cur: string) => {
|
||||||
|
if (cur !== "redirect") acc[cur] = query[cur];
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
function getCode(): void {
|
function getCode(): void {
|
||||||
getCodeImg().then((res: CaptchaResponse) => {
|
getCodeImg().then((data: CaptchaResponse) => {
|
||||||
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
captchaEnabled.value = data.captchaEnabled === undefined ? true : data.captchaEnabled
|
||||||
if (captchaEnabled.value && res.img && res.uuid) {
|
if (captchaEnabled.value && data.img && data.uuid) {
|
||||||
codeUrl.value = "data:image/gif;base64," + res.img
|
codeUrl.value = "data:image/gif;base64," + data.img
|
||||||
loginForm.value.uuid = res.uuid
|
loginForm.value.uuid = data.uuid
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -184,7 +189,7 @@ function getCookie(): void {
|
|||||||
loginForm.value = {
|
loginForm.value = {
|
||||||
username: username === undefined ? loginForm.value.username : username,
|
username: username === undefined ? loginForm.value.username : username,
|
||||||
password: password === undefined ? loginForm.value.password : decrypt(password),
|
password: password === undefined ? loginForm.value.password : decrypt(password),
|
||||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,6 @@
|
|||||||
"~/*": ["./*"]
|
"~/*": ["./*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue","vite/**/*.ts"],
|
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||||
"references": [{ "path": "./tsconfig.node.json" }]
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ export default defineConfig(({ mode, command }) => {
|
|||||||
return {
|
return {
|
||||||
// 部署生产环境和开发环境下的URL。
|
// 部署生产环境和开发环境下的URL。
|
||||||
// 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
|
// 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
|
||||||
base: VITE_APP_ENV === 'production' ? '/' : '/',
|
base: VITE_APP_ENV === 'production' ? env?.VITE_APP_BASE_URL || '/idp/' : env?.VITE_APP_BASE_URL || '/',
|
||||||
plugins: createVitePlugins(env, command === 'build'),
|
plugins: createVitePlugins(env, command === 'build'),
|
||||||
resolve: {
|
resolve: {
|
||||||
// https://cn.vitejs.dev/config/#resolve-alias
|
// https://cn.vitejs.dev/config/#resolve-alias
|
||||||
|
|||||||
0
portal/backend/README.md
Normal file
0
portal/backend/README.md
Normal file
249
portal/backend/pom.xml
Normal file
249
portal/backend/pom.xml
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.version>1.0.0</project.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
|
<mybatis-spring-boot.version>3.0.5</mybatis-spring-boot.version>
|
||||||
|
<druid.version>1.2.27</druid.version>
|
||||||
|
<yauaa.version>7.32.0</yauaa.version>
|
||||||
|
<swagger.version>3.0.0</swagger.version>
|
||||||
|
<kaptcha.version>2.3.3</kaptcha.version>
|
||||||
|
<pagehelper.boot.version>2.1.1</pagehelper.boot.version>
|
||||||
|
<fastjson.version>2.0.60</fastjson.version>
|
||||||
|
<oshi.version>6.9.1</oshi.version>
|
||||||
|
<commons.io.version>2.21.0</commons.io.version>
|
||||||
|
<poi.version>4.1.2</poi.version>
|
||||||
|
<velocity.version>2.3</velocity.version>
|
||||||
|
<jwt.version>0.9.1</jwt.version>
|
||||||
|
<quartz.version>2.5.2</quartz.version>
|
||||||
|
<mysql.version>8.2.0</mysql.version>
|
||||||
|
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||||
|
<jakarta.version>6.0.0</jakarta.version>
|
||||||
|
<springdoc.version>2.8.14</springdoc.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<!-- 依赖声明 -->
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringBoot的依赖配置-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>3.5.10</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 阿里数据库连接池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
|
<version>${druid.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 解析客户端操作系统、浏览器等 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.basjes.parse.useragent</groupId>
|
||||||
|
<artifactId>yauaa</artifactId>
|
||||||
|
<version>${yauaa.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- pagehelper 分页插件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>${pagehelper.boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${mybatis-spring-boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>${mysql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
<version>${jaxb-api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
<version>${jakarta.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 获取系统信息 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.oshi</groupId>
|
||||||
|
<artifactId>oshi-core</artifactId>
|
||||||
|
<version>${oshi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- spring-doc -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>${springdoc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- io常用工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>${commons.io.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- velocity代码生成使用模板 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
<version>${velocity.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 定时任务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.quartz-scheduler</groupId>
|
||||||
|
<artifactId>quartz</artifactId>
|
||||||
|
<version>${quartz.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 阿里JSON解析器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Token生成与解析-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>${jwt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 验证码 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>pro.fessional</groupId>
|
||||||
|
<artifactId>kaptcha</artifactId>
|
||||||
|
<version>${kaptcha.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 定时任务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal-quartz</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码生成-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal-generator</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 核心模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal-framework</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 系统模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal-system</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>portal-admin</module>
|
||||||
|
<module>portal-framework</module>
|
||||||
|
<module>portal-system</module>
|
||||||
|
<module>portal-common</module>
|
||||||
|
</modules>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<configuration>
|
||||||
|
<parameters>true</parameters>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>https://maven.aliyun.com/repository/public</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
|
</project>
|
||||||
78
portal/backend/portal-admin/pom.xml
Normal file
78
portal/backend/portal-admin/pom.xml
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>portal</artifactId>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<artifactId>portal-admin</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
web服务入口
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- spring-boot-devtools -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- spring-doc -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql驱动包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 核心模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>portal-framework</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>3.5.4</version>
|
||||||
|
<configuration>
|
||||||
|
<addResources>true</addResources>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
<warName>${project.artifactId}</warName>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package org.lingniu.portal;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动程序
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class },scanBasePackages = {"org.lingniu.**"})
|
||||||
|
public class PortalApplication
|
||||||
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
|
SpringApplication.run(PortalApplication.class, args);
|
||||||
|
System.out.println("项目启动成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.lingniu.portal;
|
||||||
|
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* web容器中进行部署
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class PortalServletInitializer extends SpringBootServletInitializer
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
|
||||||
|
{
|
||||||
|
return application.sources(PortalApplication.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package org.lingniu.portal.web.controller.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
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 org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.lingniu.portal.common.config.ProjectConfig;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.common.utils.file.FileUploadUtils;
|
||||||
|
import org.lingniu.portal.common.utils.file.FileUtils;
|
||||||
|
import org.lingniu.portal.framework.config.ServerConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用请求处理
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/common")
|
||||||
|
public class CommonController
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServerConfig serverConfig;
|
||||||
|
|
||||||
|
private static final String FILE_DELIMITER = ",";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用下载请求
|
||||||
|
*
|
||||||
|
* @param fileName 文件名称
|
||||||
|
* @param delete 是否删除
|
||||||
|
*/
|
||||||
|
@GetMapping("/download")
|
||||||
|
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!FileUtils.checkAllowDownload(fileName))
|
||||||
|
{
|
||||||
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||||
|
}
|
||||||
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||||
|
String filePath = ProjectConfig.getDownloadPath() + fileName;
|
||||||
|
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
||||||
|
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||||
|
if (delete)
|
||||||
|
{
|
||||||
|
FileUtils.deleteFile(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("下载文件失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用上传请求(单个)
|
||||||
|
*/
|
||||||
|
@PostMapping("/upload")
|
||||||
|
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 上传文件路径
|
||||||
|
String filePath = ProjectConfig.getUploadPath();
|
||||||
|
// 上传并返回新文件名称
|
||||||
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
|
String url = serverConfig.getUrl() + fileName;
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("url", url);
|
||||||
|
ajax.put("fileName", fileName);
|
||||||
|
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||||
|
ajax.put("originalFilename", file.getOriginalFilename());
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用上传请求(多个)
|
||||||
|
*/
|
||||||
|
@PostMapping("/uploads")
|
||||||
|
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 上传文件路径
|
||||||
|
String filePath = ProjectConfig.getUploadPath();
|
||||||
|
List<String> urls = new ArrayList<String>();
|
||||||
|
List<String> fileNames = new ArrayList<String>();
|
||||||
|
List<String> newFileNames = new ArrayList<String>();
|
||||||
|
List<String> originalFilenames = new ArrayList<String>();
|
||||||
|
for (MultipartFile file : files)
|
||||||
|
{
|
||||||
|
// 上传并返回新文件名称
|
||||||
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
|
String url = serverConfig.getUrl() + fileName;
|
||||||
|
urls.add(url);
|
||||||
|
fileNames.add(fileName);
|
||||||
|
newFileNames.add(FileUtils.getName(fileName));
|
||||||
|
originalFilenames.add(file.getOriginalFilename());
|
||||||
|
}
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("urls", StringUtils.join(urls, FILE_DELIMITER));
|
||||||
|
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMITER));
|
||||||
|
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMITER));
|
||||||
|
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMITER));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地资源通用下载
|
||||||
|
*/
|
||||||
|
@GetMapping("/download/resource")
|
||||||
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!FileUtils.checkAllowDownload(resource))
|
||||||
|
{
|
||||||
|
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
||||||
|
}
|
||||||
|
// 本地资源路径
|
||||||
|
String localPath = ProjectConfig.getProfile();
|
||||||
|
// 数据库资源地址
|
||||||
|
String downloadPath = localPath + FileUtils.stripPrefix(resource);
|
||||||
|
// 下载名称
|
||||||
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||||
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
|
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
||||||
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.error("下载文件失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package org.lingniu.portal.web.controller.monitor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.constant.CacheConstants;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.system.domain.SysCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存监控
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/cache")
|
||||||
|
public class CacheController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
|
private final static List<SysCache> caches = new ArrayList<SysCache>();
|
||||||
|
{
|
||||||
|
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
|
||||||
|
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
|
||||||
|
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
|
||||||
|
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
|
||||||
|
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
|
||||||
|
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
|
||||||
|
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@GetMapping()
|
||||||
|
public AjaxResult getInfo() throws Exception
|
||||||
|
{
|
||||||
|
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
||||||
|
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||||
|
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>(3);
|
||||||
|
result.put("info", info);
|
||||||
|
result.put("dbSize", dbSize);
|
||||||
|
|
||||||
|
List<Map<String, String>> pieList = new ArrayList<>();
|
||||||
|
commandStats.stringPropertyNames().forEach(key -> {
|
||||||
|
Map<String, String> data = new HashMap<>(2);
|
||||||
|
String property = commandStats.getProperty(key);
|
||||||
|
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
||||||
|
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
||||||
|
pieList.add(data);
|
||||||
|
});
|
||||||
|
result.put("commandStats", pieList);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@GetMapping("/getNames")
|
||||||
|
public AjaxResult cache()
|
||||||
|
{
|
||||||
|
return AjaxResult.success(caches);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@GetMapping("/getKeys/{cacheName}")
|
||||||
|
public AjaxResult getCacheKeys(@PathVariable String cacheName)
|
||||||
|
{
|
||||||
|
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||||
|
return AjaxResult.success(new TreeSet<>(cacheKeys));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||||
|
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
|
||||||
|
{
|
||||||
|
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||||
|
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
||||||
|
return AjaxResult.success(sysCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||||
|
public AjaxResult clearCacheName(@PathVariable String cacheName)
|
||||||
|
{
|
||||||
|
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||||
|
redisTemplate.delete(cacheKeys);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
||||||
|
public AjaxResult clearCacheKey(@PathVariable String cacheKey)
|
||||||
|
{
|
||||||
|
redisTemplate.delete(cacheKey);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||||
|
@DeleteMapping("/clearCacheAll")
|
||||||
|
public AjaxResult clearCacheAll()
|
||||||
|
{
|
||||||
|
Collection<String> cacheKeys = redisTemplate.keys("*");
|
||||||
|
redisTemplate.delete(cacheKeys);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.lingniu.portal.web.controller.monitor;
|
||||||
|
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.framework.web.domain.Server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器监控
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/server")
|
||||||
|
public class ServerController
|
||||||
|
{
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||||
|
@GetMapping()
|
||||||
|
public AjaxResult getInfo() throws Exception
|
||||||
|
{
|
||||||
|
Server server = new Server();
|
||||||
|
server.copyTo();
|
||||||
|
return AjaxResult.success(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package org.lingniu.portal.web.controller.monitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.framework.web.service.SysPasswordService;
|
||||||
|
import org.lingniu.portal.system.domain.SysLogininfor;
|
||||||
|
import org.lingniu.portal.system.service.ISysLogininforService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统访问记录
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/logininfor")
|
||||||
|
public class SysLogininforController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysLogininforService logininforService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysPasswordService passwordService;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysLogininfor logininfor)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysLogininfor logininfor)
|
||||||
|
{
|
||||||
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
|
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||||
|
util.exportExcel(response, list, "登录日志");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
|
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{infoIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] infoIds)
|
||||||
|
{
|
||||||
|
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||||
|
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||||
|
@DeleteMapping("/clean")
|
||||||
|
public AjaxResult clean()
|
||||||
|
{
|
||||||
|
logininforService.cleanLogininfor();
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
|
||||||
|
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||||
|
@GetMapping("/unlock/{userName}")
|
||||||
|
public AjaxResult unlock(@PathVariable("userName") String userName)
|
||||||
|
{
|
||||||
|
passwordService.clearLoginRecordCache(userName);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package org.lingniu.portal.web.controller.monitor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.system.domain.SysOperLog;
|
||||||
|
import org.lingniu.portal.system.service.ISysOperLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日志记录
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/operlog")
|
||||||
|
public class SysOperlogController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysOperLogService operLogService;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysOperLog operLog)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysOperLog operLog)
|
||||||
|
{
|
||||||
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
|
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||||
|
util.exportExcel(response, list, "操作日志");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
|
@DeleteMapping("/{operIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||||
|
{
|
||||||
|
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||||
|
@DeleteMapping("/clean")
|
||||||
|
public AjaxResult clean()
|
||||||
|
{
|
||||||
|
operLogService.cleanOperLog();
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package org.lingniu.portal.web.controller.monitor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.constant.CacheConstants;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.model.LoginUser;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.core.redis.RedisCache;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.system.domain.SysUserOnline;
|
||||||
|
import org.lingniu.portal.system.service.ISysUserOnlineService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线用户监控
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/monitor/online")
|
||||||
|
public class SysUserOnlineController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysUserOnlineService userOnlineService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(String ipaddr, String userName)
|
||||||
|
{
|
||||||
|
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||||
|
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||||
|
for (String key : keys)
|
||||||
|
{
|
||||||
|
LoginUser user = redisCache.getCacheObject(key);
|
||||||
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||||
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(ipaddr))
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||||
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.reverse(userOnlineList);
|
||||||
|
userOnlineList.removeAll(Collections.singleton(null));
|
||||||
|
return getDataTable(userOnlineList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强退用户
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||||
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
|
@DeleteMapping("/{tokenId}")
|
||||||
|
public AjaxResult forceLogout(@PathVariable String tokenId)
|
||||||
|
{
|
||||||
|
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.system.domain.SysConfig;
|
||||||
|
import org.lingniu.portal.system.service.ISysConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数配置 信息操作处理
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/config")
|
||||||
|
public class SysConfigController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysConfigService configService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取参数配置列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysConfig config)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysConfig config)
|
||||||
|
{
|
||||||
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
|
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||||
|
util.exportExcel(response, list, "参数数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||||
|
@GetMapping(value = "/{configId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long configId)
|
||||||
|
{
|
||||||
|
return success(configService.selectConfigById(configId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数键名查询参数值
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/configKey/{configKey}")
|
||||||
|
public AjaxResult getConfigKey(@PathVariable String configKey)
|
||||||
|
{
|
||||||
|
return success(configService.selectConfigByKey(configKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增参数配置
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||||
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysConfig config)
|
||||||
|
{
|
||||||
|
if (!configService.checkConfigKeyUnique(config))
|
||||||
|
{
|
||||||
|
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
|
}
|
||||||
|
config.setCreateBy(getUsername());
|
||||||
|
return toAjax(configService.insertConfig(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改参数配置
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||||
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysConfig config)
|
||||||
|
{
|
||||||
|
if (!configService.checkConfigKeyUnique(config))
|
||||||
|
{
|
||||||
|
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
|
}
|
||||||
|
config.setUpdateBy(getUsername());
|
||||||
|
return toAjax(configService.updateConfig(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除参数配置
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{configIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] configIds)
|
||||||
|
{
|
||||||
|
configService.deleteConfigByIds(configIds);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新参数缓存
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
|
@DeleteMapping("/refreshCache")
|
||||||
|
public AjaxResult refreshCache()
|
||||||
|
{
|
||||||
|
configService.resetConfigCache();
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.constant.UserConstants;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysDept;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.system.service.ISysDeptService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/dept")
|
||||||
|
public class SysDeptController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult list(SysDept dept)
|
||||||
|
{
|
||||||
|
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||||
|
return success(depts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询部门列表(排除节点)
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||||
|
@GetMapping("/list/exclude/{deptId}")
|
||||||
|
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
|
||||||
|
{
|
||||||
|
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||||
|
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
||||||
|
return success(depts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||||
|
@GetMapping(value = "/{deptId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long deptId)
|
||||||
|
{
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
|
return success(deptService.selectDeptById(deptId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增部门
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||||
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysDept dept)
|
||||||
|
{
|
||||||
|
if (!deptService.checkDeptNameUnique(dept))
|
||||||
|
{
|
||||||
|
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
|
}
|
||||||
|
dept.setCreateBy(getUsername());
|
||||||
|
return toAjax(deptService.insertDept(dept));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改部门
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||||
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||||
|
{
|
||||||
|
Long deptId = dept.getDeptId();
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
|
if (!deptService.checkDeptNameUnique(dept))
|
||||||
|
{
|
||||||
|
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
|
}
|
||||||
|
else if (dept.getParentId().equals(deptId))
|
||||||
|
{
|
||||||
|
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
|
}
|
||||||
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
||||||
|
{
|
||||||
|
return error("该部门包含未停用的子部门!");
|
||||||
|
}
|
||||||
|
dept.setUpdateBy(getUsername());
|
||||||
|
return toAjax(deptService.updateDept(dept));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除部门
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||||
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{deptId}")
|
||||||
|
public AjaxResult remove(@PathVariable Long deptId)
|
||||||
|
{
|
||||||
|
if (deptService.hasChildByDeptId(deptId))
|
||||||
|
{
|
||||||
|
return warn("存在下级部门,不允许删除");
|
||||||
|
}
|
||||||
|
if (deptService.checkDeptExistUser(deptId))
|
||||||
|
{
|
||||||
|
return warn("部门存在用户,不允许删除");
|
||||||
|
}
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysDictData;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.system.service.ISysDictDataService;
|
||||||
|
import org.lingniu.portal.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据字典信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/dict/data")
|
||||||
|
public class SysDictDataController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysDictDataService dictDataService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysDictData dictData)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysDictData dictData)
|
||||||
|
{
|
||||||
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
|
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||||
|
util.exportExcel(response, list, "字典数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典数据详细
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
|
@GetMapping(value = "/{dictCode}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long dictCode)
|
||||||
|
{
|
||||||
|
return success(dictDataService.selectDictDataById(dictCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型查询字典数据信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/type/{dictType}")
|
||||||
|
public AjaxResult dictType(@PathVariable String dictType)
|
||||||
|
{
|
||||||
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
|
if (StringUtils.isNull(data))
|
||||||
|
{
|
||||||
|
data = new ArrayList<SysDictData>();
|
||||||
|
}
|
||||||
|
return success(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
|
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
||||||
|
{
|
||||||
|
dict.setCreateBy(getUsername());
|
||||||
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改保存字典类型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
|
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||||
|
{
|
||||||
|
dict.setUpdateBy(getUsername());
|
||||||
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{dictCodes}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
||||||
|
{
|
||||||
|
dictDataService.deleteDictDataByIds(dictCodes);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysDictType;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据字典信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/dict/type")
|
||||||
|
public class SysDictTypeController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysDictType dictType)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysDictType dictType)
|
||||||
|
{
|
||||||
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
|
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||||
|
util.exportExcel(response, list, "字典类型");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型详细
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||||
|
@GetMapping(value = "/{dictId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long dictId)
|
||||||
|
{
|
||||||
|
return success(dictTypeService.selectDictTypeById(dictId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||||
|
{
|
||||||
|
if (!dictTypeService.checkDictTypeUnique(dict))
|
||||||
|
{
|
||||||
|
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
|
}
|
||||||
|
dict.setCreateBy(getUsername());
|
||||||
|
return toAjax(dictTypeService.insertDictType(dict));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||||
|
{
|
||||||
|
if (!dictTypeService.checkDictTypeUnique(dict))
|
||||||
|
{
|
||||||
|
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
|
}
|
||||||
|
dict.setUpdateBy(getUsername());
|
||||||
|
return toAjax(dictTypeService.updateDictType(dict));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{dictIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||||
|
{
|
||||||
|
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新字典缓存
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||||
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
|
@DeleteMapping("/refreshCache")
|
||||||
|
public AjaxResult refreshCache()
|
||||||
|
{
|
||||||
|
dictTypeService.resetDictCache();
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典选择框列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/optionselect")
|
||||||
|
public AjaxResult optionselect()
|
||||||
|
{
|
||||||
|
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||||
|
return success(dictTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.config.ProjectConfig;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class SysIndexController
|
||||||
|
{
|
||||||
|
/** 系统基础配置 */
|
||||||
|
@Autowired
|
||||||
|
private ProjectConfig projectConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问首页,提示语
|
||||||
|
*/
|
||||||
|
@RequestMapping("/")
|
||||||
|
public String index()
|
||||||
|
{
|
||||||
|
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", projectConfig.getName(), projectConfig.getVersion());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.constant.UserConstants;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysMenu;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.system.service.ISysMenuService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/menu")
|
||||||
|
public class SysMenuController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult list(SysMenu menu)
|
||||||
|
{
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
|
return success(menus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||||
|
@GetMapping(value = "/{menuId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long menuId)
|
||||||
|
{
|
||||||
|
return success(menuService.selectMenuById(menuId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单下拉树列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/treeselect")
|
||||||
|
public AjaxResult treeselect(SysMenu menu)
|
||||||
|
{
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||||
|
return success(menuService.buildMenuTreeSelect(menus));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载对应角色菜单列表树
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
|
||||||
|
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
|
||||||
|
{
|
||||||
|
List<SysMenu> menus = menuService.selectMenuList(getUserId());
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||||
|
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增菜单
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||||
|
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysMenu menu)
|
||||||
|
{
|
||||||
|
if (!menuService.checkMenuNameUnique(menu))
|
||||||
|
{
|
||||||
|
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
|
}
|
||||||
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||||
|
{
|
||||||
|
return error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
|
}
|
||||||
|
else if (!menuService.checkRouteConfigUnique(menu))
|
||||||
|
{
|
||||||
|
return error("新增菜单'" + menu.getMenuName() + "'失败,路由名称或地址已存在");
|
||||||
|
}
|
||||||
|
menu.setCreateBy(getUsername());
|
||||||
|
return toAjax(menuService.insertMenu(menu));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改菜单
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
|
||||||
|
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
|
||||||
|
{
|
||||||
|
if (!menuService.checkMenuNameUnique(menu))
|
||||||
|
{
|
||||||
|
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
|
}
|
||||||
|
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
|
||||||
|
{
|
||||||
|
return error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
|
||||||
|
}
|
||||||
|
else if (menu.getMenuId().equals(menu.getParentId()))
|
||||||
|
{
|
||||||
|
return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
|
||||||
|
}
|
||||||
|
else if (!menuService.checkRouteConfigUnique(menu))
|
||||||
|
{
|
||||||
|
return error("修改菜单'" + menu.getMenuName() + "'失败,路由名称或地址已存在");
|
||||||
|
}
|
||||||
|
menu.setUpdateBy(getUsername());
|
||||||
|
return toAjax(menuService.updateMenu(menu));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除菜单
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
|
||||||
|
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{menuId}")
|
||||||
|
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
||||||
|
{
|
||||||
|
if (menuService.hasChildByMenuId(menuId))
|
||||||
|
{
|
||||||
|
return warn("存在子菜单,不允许删除");
|
||||||
|
}
|
||||||
|
if (menuService.checkMenuExistRole(menuId))
|
||||||
|
{
|
||||||
|
return warn("菜单已分配,不允许删除");
|
||||||
|
}
|
||||||
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.system.domain.SysNotice;
|
||||||
|
import org.lingniu.portal.system.service.ISysNoticeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公告 信息操作处理
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/notice")
|
||||||
|
public class SysNoticeController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysNoticeService noticeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取通知公告列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysNotice notice)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据通知公告编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||||
|
@GetMapping(value = "/{noticeId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long noticeId)
|
||||||
|
{
|
||||||
|
return success(noticeService.selectNoticeById(noticeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通知公告
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||||
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysNotice notice)
|
||||||
|
{
|
||||||
|
notice.setCreateBy(getUsername());
|
||||||
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改通知公告
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||||
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
|
||||||
|
{
|
||||||
|
notice.setUpdateBy(getUsername());
|
||||||
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除通知公告
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||||
|
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{noticeIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] noticeIds)
|
||||||
|
{
|
||||||
|
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.system.domain.SysPost;
|
||||||
|
import org.lingniu.portal.system.service.ISysPostService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位信息操作处理
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/post")
|
||||||
|
public class SysPostController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysPostService postService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取岗位列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysPost post)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysPost post)
|
||||||
|
{
|
||||||
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
|
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||||
|
util.exportExcel(response, list, "岗位数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据岗位编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||||
|
@GetMapping(value = "/{postId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long postId)
|
||||||
|
{
|
||||||
|
return success(postService.selectPostById(postId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增岗位
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||||
|
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysPost post)
|
||||||
|
{
|
||||||
|
if (!postService.checkPostNameUnique(post))
|
||||||
|
{
|
||||||
|
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
|
}
|
||||||
|
else if (!postService.checkPostCodeUnique(post))
|
||||||
|
{
|
||||||
|
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
|
}
|
||||||
|
post.setCreateBy(getUsername());
|
||||||
|
return toAjax(postService.insertPost(post));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改岗位
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||||
|
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysPost post)
|
||||||
|
{
|
||||||
|
if (!postService.checkPostNameUnique(post))
|
||||||
|
{
|
||||||
|
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
|
}
|
||||||
|
else if (!postService.checkPostCodeUnique(post))
|
||||||
|
{
|
||||||
|
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
|
}
|
||||||
|
post.setUpdateBy(getUsername());
|
||||||
|
return toAjax(postService.updatePost(post));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除岗位
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||||
|
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{postIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] postIds)
|
||||||
|
{
|
||||||
|
return toAjax(postService.deletePostByIds(postIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取岗位选择框列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/optionselect")
|
||||||
|
public AjaxResult optionselect()
|
||||||
|
{
|
||||||
|
List<SysPost> posts = postService.selectPostAll();
|
||||||
|
return success(posts);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.config.ProjectConfig;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysUser;
|
||||||
|
import org.lingniu.portal.common.core.domain.model.LoginUser;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.DateUtils;
|
||||||
|
import org.lingniu.portal.common.utils.SecurityUtils;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.common.utils.file.FileUploadUtils;
|
||||||
|
import org.lingniu.portal.common.utils.file.FileUtils;
|
||||||
|
import org.lingniu.portal.common.utils.file.MimeTypeUtils;
|
||||||
|
import org.lingniu.portal.system.service.ISysUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人信息 业务处理
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/user/profile")
|
||||||
|
public class SysProfileController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人信息
|
||||||
|
*/
|
||||||
|
@GetMapping
|
||||||
|
public AjaxResult profile()
|
||||||
|
{
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
SysUser user = loginUser.getUser();
|
||||||
|
AjaxResult ajax = AjaxResult.success(user);
|
||||||
|
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||||
|
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*/
|
||||||
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||||
|
{
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
SysUser currentUser = loginUser.getUser();
|
||||||
|
currentUser.setNickName(user.getNickName());
|
||||||
|
currentUser.setEmail(user.getEmail());
|
||||||
|
currentUser.setPhonenumber(user.getPhonenumber());
|
||||||
|
currentUser.setSex(user.getSex());
|
||||||
|
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
|
||||||
|
{
|
||||||
|
return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
|
||||||
|
{
|
||||||
|
return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在");
|
||||||
|
}
|
||||||
|
if (userService.updateUserProfile(currentUser) > 0)
|
||||||
|
{
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
return error("修改个人信息异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码
|
||||||
|
*/
|
||||||
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/updatePwd")
|
||||||
|
public AjaxResult updatePwd(@RequestBody Map<String, String> params)
|
||||||
|
{
|
||||||
|
String oldPassword = params.get("oldPassword");
|
||||||
|
String newPassword = params.get("newPassword");
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
Long userId = loginUser.getUserId();
|
||||||
|
SysUser user = userService.selectUserById(userId);
|
||||||
|
String password = user.getPassword();
|
||||||
|
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||||
|
{
|
||||||
|
return error("修改密码失败,旧密码错误");
|
||||||
|
}
|
||||||
|
if (SecurityUtils.matchesPassword(newPassword, password))
|
||||||
|
{
|
||||||
|
return error("新密码不能与旧密码相同");
|
||||||
|
}
|
||||||
|
newPassword = SecurityUtils.encryptPassword(newPassword);
|
||||||
|
if (userService.resetUserPwd(userId, newPassword) > 0)
|
||||||
|
{
|
||||||
|
// 更新缓存用户密码&密码最后更新时间
|
||||||
|
loginUser.getUser().setPwdUpdateDate(DateUtils.getNowDate());
|
||||||
|
loginUser.getUser().setPassword(newPassword);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
return error("修改密码异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头像上传
|
||||||
|
*/
|
||||||
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||||
|
@PostMapping("/avatar")
|
||||||
|
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception
|
||||||
|
{
|
||||||
|
if (!file.isEmpty())
|
||||||
|
{
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
String avatar = FileUploadUtils.upload(ProjectConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION, true);
|
||||||
|
if (userService.updateUserAvatar(loginUser.getUserId(), avatar))
|
||||||
|
{
|
||||||
|
String oldAvatar = loginUser.getUser().getAvatar();
|
||||||
|
if (StringUtils.isNotEmpty(oldAvatar))
|
||||||
|
{
|
||||||
|
FileUtils.deleteFile(ProjectConfig.getProfile() + FileUtils.stripPrefix(oldAvatar));
|
||||||
|
}
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("imgUrl", avatar);
|
||||||
|
// 更新缓存用户头像
|
||||||
|
loginUser.getUser().setAvatar(avatar);
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return error("上传图片异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.model.RegisterBody;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.framework.web.service.SysRegisterService;
|
||||||
|
import org.lingniu.portal.system.service.ISysConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册验证
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class SysRegisterController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SysRegisterService registerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysConfigService configService;
|
||||||
|
|
||||||
|
@PostMapping("/register")
|
||||||
|
public AjaxResult register(@RequestBody RegisterBody user)
|
||||||
|
{
|
||||||
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||||
|
{
|
||||||
|
return error("当前系统没有开启注册功能!");
|
||||||
|
}
|
||||||
|
String msg = registerService.register(user);
|
||||||
|
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,257 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysDept;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysRole;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysUser;
|
||||||
|
import org.lingniu.portal.common.core.domain.model.LoginUser;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.framework.web.service.SysPermissionService;
|
||||||
|
import org.lingniu.portal.system.domain.SysUserRole;
|
||||||
|
import org.lingniu.portal.system.service.ISysDeptService;
|
||||||
|
import org.lingniu.portal.system.service.ISysRoleService;
|
||||||
|
import org.lingniu.portal.system.service.ISysUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/role")
|
||||||
|
public class SysRoleController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysRole role)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysRole role)
|
||||||
|
{
|
||||||
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||||
|
util.exportExcel(response, list, "角色数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
|
@GetMapping(value = "/{roleId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable Long roleId)
|
||||||
|
{
|
||||||
|
roleService.checkRoleDataScope(roleId);
|
||||||
|
return success(roleService.selectRoleById(roleId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysRole role)
|
||||||
|
{
|
||||||
|
if (!roleService.checkRoleNameUnique(role))
|
||||||
|
{
|
||||||
|
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
|
}
|
||||||
|
else if (!roleService.checkRoleKeyUnique(role))
|
||||||
|
{
|
||||||
|
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
|
}
|
||||||
|
role.setCreateBy(getUsername());
|
||||||
|
return toAjax(roleService.insertRole(role));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改保存角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||||
|
{
|
||||||
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
|
if (!roleService.checkRoleNameUnique(role))
|
||||||
|
{
|
||||||
|
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
|
}
|
||||||
|
else if (!roleService.checkRoleKeyUnique(role))
|
||||||
|
{
|
||||||
|
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
|
}
|
||||||
|
role.setUpdateBy(getUsername());
|
||||||
|
|
||||||
|
if (roleService.updateRole(role) > 0)
|
||||||
|
{
|
||||||
|
// 更新缓存用户权限
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
||||||
|
{
|
||||||
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
||||||
|
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
||||||
|
}
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改保存数据权限
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/dataScope")
|
||||||
|
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||||
|
{
|
||||||
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
|
return toAjax(roleService.authDataScope(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态修改
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/changeStatus")
|
||||||
|
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||||
|
{
|
||||||
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
|
role.setUpdateBy(getUsername());
|
||||||
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{roleIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] roleIds)
|
||||||
|
{
|
||||||
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色选择框列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
|
@GetMapping("/optionselect")
|
||||||
|
public AjaxResult optionselect()
|
||||||
|
{
|
||||||
|
return success(roleService.selectRoleAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询已分配用户角色列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||||
|
@GetMapping("/authUser/allocatedList")
|
||||||
|
public TableDataInfo allocatedList(SysUser user)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysUser> list = userService.selectAllocatedList(user);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询未分配用户角色列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||||
|
@GetMapping("/authUser/unallocatedList")
|
||||||
|
public TableDataInfo unallocatedList(SysUser user)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysUser> list = userService.selectUnallocatedList(user);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消授权用户
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
|
@PutMapping("/authUser/cancel")
|
||||||
|
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
|
||||||
|
{
|
||||||
|
return toAjax(roleService.deleteAuthUser(userRole));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量取消授权用户
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
|
@PutMapping("/authUser/cancelAll")
|
||||||
|
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
|
||||||
|
{
|
||||||
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量选择用户授权
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||||
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
|
@PutMapping("/authUser/selectAll")
|
||||||
|
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
||||||
|
{
|
||||||
|
roleService.checkRoleDataScope(roleId);
|
||||||
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应角色部门树列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||||
|
@GetMapping(value = "/deptTree/{roleId}")
|
||||||
|
public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
|
||||||
|
{
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||||
|
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
package org.lingniu.portal.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.lingniu.portal.common.annotation.Log;
|
||||||
|
import org.lingniu.portal.common.core.controller.BaseController;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysDept;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysRole;
|
||||||
|
import org.lingniu.portal.common.core.domain.entity.SysUser;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.utils.SecurityUtils;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelUtil;
|
||||||
|
import org.lingniu.portal.system.service.ISysDeptService;
|
||||||
|
import org.lingniu.portal.system.service.ISysPostService;
|
||||||
|
import org.lingniu.portal.system.service.ISysRoleService;
|
||||||
|
import org.lingniu.portal.system.service.ISysUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/user")
|
||||||
|
public class SysUserController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysPostService postService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysUser user)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysUser user)
|
||||||
|
{
|
||||||
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
|
util.exportExcel(response, list, "用户数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||||
|
@PostMapping("/importData")
|
||||||
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||||
|
{
|
||||||
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||||
|
String operName = getUsername();
|
||||||
|
String message = userService.importUser(userList, updateSupport, operName);
|
||||||
|
return success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/importTemplate")
|
||||||
|
public void importTemplate(HttpServletResponse response)
|
||||||
|
{
|
||||||
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
|
util.importTemplateExcel(response, "用户数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户编号获取详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||||
|
@GetMapping(value = { "/", "/{userId}" })
|
||||||
|
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||||
|
{
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
if (StringUtils.isNotNull(userId))
|
||||||
|
{
|
||||||
|
userService.checkUserDataScope(userId);
|
||||||
|
SysUser sysUser = userService.selectUserById(userId);
|
||||||
|
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||||
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
|
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
List<SysRole> roles = roleService.selectRoleAll();
|
||||||
|
ajax.put("roles", SecurityUtils.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
|
ajax.put("posts", postService.selectPostAll());
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||||
|
{
|
||||||
|
deptService.checkDeptDataScope(user.getDeptId());
|
||||||
|
roleService.checkRoleDataScope(user.getRoleIds());
|
||||||
|
if (!userService.checkUserNameUnique(user))
|
||||||
|
{
|
||||||
|
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||||
|
{
|
||||||
|
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
||||||
|
{
|
||||||
|
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
|
}
|
||||||
|
user.setCreateBy(getUsername());
|
||||||
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
|
return toAjax(userService.insertUser(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||||
|
{
|
||||||
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
|
deptService.checkDeptDataScope(user.getDeptId());
|
||||||
|
roleService.checkRoleDataScope(user.getRoleIds());
|
||||||
|
if (!userService.checkUserNameUnique(user))
|
||||||
|
{
|
||||||
|
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||||
|
{
|
||||||
|
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
||||||
|
{
|
||||||
|
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
|
}
|
||||||
|
user.setUpdateBy(getUsername());
|
||||||
|
return toAjax(userService.updateUser(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{userIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||||
|
{
|
||||||
|
if (ArrayUtils.contains(userIds, getUserId()))
|
||||||
|
{
|
||||||
|
return error("当前用户不能删除");
|
||||||
|
}
|
||||||
|
return toAjax(userService.deleteUserByIds(userIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/resetPwd")
|
||||||
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||||
|
{
|
||||||
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
|
user.setUpdateBy(getUsername());
|
||||||
|
return toAjax(userService.resetPwd(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态修改
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/changeStatus")
|
||||||
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||||
|
{
|
||||||
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
|
user.setUpdateBy(getUsername());
|
||||||
|
return toAjax(userService.updateUserStatus(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户编号获取授权角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||||
|
@GetMapping("/authRole/{userId}")
|
||||||
|
public AjaxResult authRole(@PathVariable("userId") Long userId)
|
||||||
|
{
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
SysUser user = userService.selectUserById(userId);
|
||||||
|
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||||
|
ajax.put("user", user);
|
||||||
|
ajax.put("roles", SecurityUtils.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户授权角色
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||||
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||||
|
@PutMapping("/authRole")
|
||||||
|
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||||
|
{
|
||||||
|
userService.checkUserDataScope(userId);
|
||||||
|
roleService.checkRoleDataScope(roleIds);
|
||||||
|
userService.insertUserAuth(userId, roleIds);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门树列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||||
|
@GetMapping("/deptTree")
|
||||||
|
public AjaxResult deptTree(SysDept dept)
|
||||||
|
{
|
||||||
|
return success(deptService.selectDeptTreeList(dept));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
restart.include.json=/com.alibaba.fastjson2.*.jar
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# 数据源配置
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
username: root
|
||||||
|
password: Zhang!@#
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
druid:
|
||||||
|
# 主库数据源
|
||||||
|
# master:
|
||||||
|
# url: jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
# username: root
|
||||||
|
# password: Zhang!@#
|
||||||
|
# 初始连接数
|
||||||
|
initialSize: 5
|
||||||
|
# 最小连接池数量
|
||||||
|
minIdle: 10
|
||||||
|
# 最大连接池数量
|
||||||
|
maxActive: 20
|
||||||
|
# 配置获取连接等待超时的时间
|
||||||
|
maxWait: 60000
|
||||||
|
# 配置连接超时时间
|
||||||
|
connectTimeout: 30000
|
||||||
|
# 配置网络超时时间
|
||||||
|
socketTimeout: 60000
|
||||||
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
|
maxEvictableIdleTimeMillis: 900000
|
||||||
|
# 配置检测连接是否有效
|
||||||
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
|
testWhileIdle: true
|
||||||
|
testOnBorrow: false
|
||||||
|
testOnReturn: false
|
||||||
|
webStatFilter:
|
||||||
|
enabled: true
|
||||||
|
statViewServlet:
|
||||||
|
enabled: true
|
||||||
|
# 设置白名单,不填则允许所有访问
|
||||||
|
allow:
|
||||||
|
url-pattern: /druid/*
|
||||||
|
# 控制台管理用户名和密码
|
||||||
|
login-username: project
|
||||||
|
login-password: 123456
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
enabled: true
|
||||||
|
# 慢SQL记录
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: true
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
security:
|
||||||
|
oauth2:
|
||||||
|
resourceserver:
|
||||||
|
jwt:
|
||||||
|
jwk-set-uri: http://localhost:8000/oauth2/jwks
|
||||||
|
client:
|
||||||
|
registration:
|
||||||
|
portal:
|
||||||
|
client-id: 2c6f1d9ff78641c78d72a848
|
||||||
|
client-secret: i1bper1Jw2gLeTzUN1oniwuICPDQgNuQEcYxTKJ5iv0
|
||||||
|
client-name: 羚牛OneOs运营管理
|
||||||
|
authorization-grant-type: authorization_code
|
||||||
|
redirect-uri: http://localhost:81/callback
|
||||||
|
scope:
|
||||||
|
- openid
|
||||||
|
- profile
|
||||||
|
# 返回权限
|
||||||
|
- perms
|
||||||
|
provider: idp
|
||||||
|
|
||||||
|
provider:
|
||||||
|
idp:
|
||||||
|
# issuer-uri: http://localhost:8000
|
||||||
|
authorization-uri: http://localhost/sso
|
||||||
|
token-uri: http://localhost:8000/oauth2/token
|
||||||
|
user-info-uri: http://localhost:8000/userinfo
|
||||||
|
jwk-set-uri: http://localhost:8000/oauth2/jwks
|
||||||
|
user-name-attribute: sub
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# 数据源配置
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://localhost:3306/platform?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
|
username: lingniu
|
||||||
|
password: Lingniu2026!
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
druid:
|
||||||
|
# 主库数据源
|
||||||
|
# master:
|
||||||
|
# url: jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
# username: root
|
||||||
|
# password: Zhang!@#
|
||||||
|
# 初始连接数
|
||||||
|
initialSize: 5
|
||||||
|
# 最小连接池数量
|
||||||
|
minIdle: 10
|
||||||
|
# 最大连接池数量
|
||||||
|
maxActive: 20
|
||||||
|
# 配置获取连接等待超时的时间
|
||||||
|
maxWait: 60000
|
||||||
|
# 配置连接超时时间
|
||||||
|
connectTimeout: 30000
|
||||||
|
# 配置网络超时时间
|
||||||
|
socketTimeout: 60000
|
||||||
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
|
maxEvictableIdleTimeMillis: 900000
|
||||||
|
# 配置检测连接是否有效
|
||||||
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
|
testWhileIdle: true
|
||||||
|
testOnBorrow: false
|
||||||
|
testOnReturn: false
|
||||||
|
webStatFilter:
|
||||||
|
enabled: true
|
||||||
|
statViewServlet:
|
||||||
|
enabled: true
|
||||||
|
# 设置白名单,不填则允许所有访问
|
||||||
|
allow:
|
||||||
|
url-pattern: /druid/*
|
||||||
|
# 控制台管理用户名和密码
|
||||||
|
login-username: project
|
||||||
|
login-password: 123456
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
enabled: true
|
||||||
|
# 慢SQL记录
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: true
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
security:
|
||||||
|
oauth2:
|
||||||
|
resourceserver:
|
||||||
|
jwt:
|
||||||
|
jwk-set-uri: http://localhost:8000/oauth2/jwks
|
||||||
|
client:
|
||||||
|
registration:
|
||||||
|
portal:
|
||||||
|
client-id: 2c6f1d9ff78641c78d72a848
|
||||||
|
client-secret: i1bper1Jw2gLeTzUN1oniwuICPDQgNuQEcYxTKJ5iv0
|
||||||
|
client-name: 羚牛OneOs运营管理
|
||||||
|
authorization-grant-type: authorization_code
|
||||||
|
redirect-uri: http://106.14.217.120/portal-ui/callback
|
||||||
|
scope:
|
||||||
|
- openid
|
||||||
|
- profile
|
||||||
|
# 返回权限
|
||||||
|
- perms
|
||||||
|
provider: idp
|
||||||
|
|
||||||
|
provider:
|
||||||
|
idp:
|
||||||
|
# issuer-uri: http://localhost:8000
|
||||||
|
authorization-uri: http://106.14.217.120/idp-ui/sso
|
||||||
|
token-uri: http://localhost:8082/oauth2/token
|
||||||
|
user-info-uri: http://localhost:8082/userinfo
|
||||||
|
jwk-set-uri: http://localhost:8082/oauth2/jwks
|
||||||
|
user-name-attribute: sub
|
||||||
140
portal/backend/portal-admin/src/main/resources/application.yml
Normal file
140
portal/backend/portal-admin/src/main/resources/application.yml
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
# 项目相关配置
|
||||||
|
project:
|
||||||
|
# 名称
|
||||||
|
name: lingniu
|
||||||
|
# 版本
|
||||||
|
version: 1.0.0
|
||||||
|
# 版权年份
|
||||||
|
copyrightYear: 2026
|
||||||
|
# 文件路径 示例( Windows配置D:/lingniu/uploadPath,Linux配置 /home/lingniu/uploadPath)
|
||||||
|
profile: /opt
|
||||||
|
# 获取ip地址开关
|
||||||
|
addressEnabled: false
|
||||||
|
# 验证码类型 math 数字计算 char 字符验证
|
||||||
|
captchaType: math
|
||||||
|
|
||||||
|
# 开发环境配置
|
||||||
|
server:
|
||||||
|
# 服务器的HTTP端口,默认为8080
|
||||||
|
port: 8080
|
||||||
|
servlet:
|
||||||
|
# 应用的访问路径
|
||||||
|
context-path: /
|
||||||
|
tomcat:
|
||||||
|
# tomcat的URI编码
|
||||||
|
uri-encoding: UTF-8
|
||||||
|
# 连接数满后的排队数,默认为100
|
||||||
|
accept-count: 1000
|
||||||
|
threads:
|
||||||
|
# tomcat最大线程数,默认为200
|
||||||
|
max: 800
|
||||||
|
# Tomcat启动初始化的线程数,默认值10
|
||||||
|
min-spare: 100
|
||||||
|
|
||||||
|
# 日志配置
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
org.lingniu.portal: debug
|
||||||
|
org.springframework: warn
|
||||||
|
|
||||||
|
# 用户配置
|
||||||
|
user:
|
||||||
|
password:
|
||||||
|
# 密码最大错误次数
|
||||||
|
maxRetryCount: 5
|
||||||
|
# 密码锁定时间(默认10分钟)
|
||||||
|
lockTime: 10
|
||||||
|
|
||||||
|
# Spring配置
|
||||||
|
spring:
|
||||||
|
# 资源信息
|
||||||
|
messages:
|
||||||
|
# 国际化资源文件路径
|
||||||
|
basename: i18n/messages
|
||||||
|
profiles:
|
||||||
|
active: local
|
||||||
|
# 文件上传
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
# 单个文件大小
|
||||||
|
max-file-size: 10MB
|
||||||
|
# 设置总上传的文件大小
|
||||||
|
max-request-size: 20MB
|
||||||
|
# 服务模块
|
||||||
|
devtools:
|
||||||
|
restart:
|
||||||
|
# 热部署开关
|
||||||
|
enabled: true
|
||||||
|
data:
|
||||||
|
# redis 配置
|
||||||
|
redis:
|
||||||
|
# 地址
|
||||||
|
host: localhost
|
||||||
|
# 端口,默认为6379
|
||||||
|
port: 6379
|
||||||
|
# 数据库索引
|
||||||
|
database: 0
|
||||||
|
# 密码
|
||||||
|
password:
|
||||||
|
# 连接超时时间
|
||||||
|
timeout: 10s
|
||||||
|
lettuce:
|
||||||
|
pool:
|
||||||
|
# 连接池中的最小空闲连接
|
||||||
|
min-idle: 0
|
||||||
|
# 连接池中的最大空闲连接
|
||||||
|
max-idle: 8
|
||||||
|
# 连接池的最大数据库连接数
|
||||||
|
max-active: 8
|
||||||
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-wait: -1ms
|
||||||
|
|
||||||
|
# token配置
|
||||||
|
token:
|
||||||
|
# 令牌自定义标识
|
||||||
|
header: Authorization
|
||||||
|
|
||||||
|
# MyBatis配置
|
||||||
|
mybatis:
|
||||||
|
# 搜索指定包别名
|
||||||
|
typeAliasesPackage: org.lingniu.**.domain
|
||||||
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
|
# 加载全局的配置文件
|
||||||
|
configLocation: classpath:mybatis/mybatis-config.xml
|
||||||
|
|
||||||
|
# PageHelper分页插件
|
||||||
|
pagehelper:
|
||||||
|
helperDialect: mysql
|
||||||
|
supportMethodsArguments: true
|
||||||
|
params: count=countSql
|
||||||
|
|
||||||
|
# Springdoc配置
|
||||||
|
springdoc:
|
||||||
|
api-docs:
|
||||||
|
path: /v3/api-docs
|
||||||
|
swagger-ui:
|
||||||
|
enabled: true
|
||||||
|
path: /swagger-ui.html
|
||||||
|
tags-sorter: alpha
|
||||||
|
group-configs:
|
||||||
|
- group: 'default'
|
||||||
|
display-name: '测试模块'
|
||||||
|
paths-to-match: '/**'
|
||||||
|
packages-to-scan: org.lingniu.portal.web.controller.tool
|
||||||
|
|
||||||
|
# 防盗链配置
|
||||||
|
referer:
|
||||||
|
# 防盗链开关
|
||||||
|
enabled: false
|
||||||
|
# 允许的域名列表
|
||||||
|
allowed-domains: localhost,127.0.0.1
|
||||||
|
|
||||||
|
# 防止XSS攻击
|
||||||
|
xss:
|
||||||
|
# 过滤开关
|
||||||
|
enabled: true
|
||||||
|
# 排除链接(多个用逗号分隔)
|
||||||
|
excludes: /system/notice
|
||||||
|
# 匹配链接
|
||||||
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Application Version: ${project.version}
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#错误消息
|
||||||
|
not.null=* 必须填写
|
||||||
|
user.jcaptcha.error=验证码错误
|
||||||
|
user.jcaptcha.expire=验证码已失效
|
||||||
|
user.not.exists=用户不存在/密码错误
|
||||||
|
user.password.not.match=用户不存在/密码错误
|
||||||
|
user.password.retry.limit.count=密码输入错误{0}次
|
||||||
|
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||||
|
user.password.delete=对不起,您的账号已被删除
|
||||||
|
user.blocked=用户已封禁,请联系管理员
|
||||||
|
role.blocked=角色已封禁,请联系管理员
|
||||||
|
login.blocked=很遗憾,访问IP已被列入系统黑名单
|
||||||
|
user.logout.success=退出成功
|
||||||
|
|
||||||
|
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||||
|
|
||||||
|
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||||
|
user.password.not.valid=* 5-50个字符
|
||||||
|
|
||||||
|
user.email.not.valid=邮箱格式错误
|
||||||
|
user.mobile.phone.number.not.valid=手机号格式错误
|
||||||
|
user.login.success=登录成功
|
||||||
|
user.register.success=注册成功
|
||||||
|
user.notfound=请重新登录
|
||||||
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
|
user.unknown.error=未知错误,请重新登录
|
||||||
|
|
||||||
|
##文件上传消息
|
||||||
|
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||||
|
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||||
|
|
||||||
|
##权限
|
||||||
|
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||||
93
portal/backend/portal-admin/src/main/resources/logback.xml
Normal file
93
portal/backend/portal-admin/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="/home/project/logs" />
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 用户访问日志输出 -->
|
||||||
|
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-user.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 按天回滚 daily -->
|
||||||
|
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="org.lingniu.portal" level="info" />
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn" />
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info" />
|
||||||
|
<appender-ref ref="file_error" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统用户操作日志-->
|
||||||
|
<logger name="sys-user" level="info">
|
||||||
|
<appender-ref ref="sys-user"/>
|
||||||
|
</logger>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE configuration
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
|
<configuration>
|
||||||
|
<!-- 全局参数 -->
|
||||||
|
<settings>
|
||||||
|
<!-- 使全局的映射器启用或禁用缓存 -->
|
||||||
|
<setting name="cacheEnabled" value="true" />
|
||||||
|
<!-- 允许JDBC 支持自动生成主键 -->
|
||||||
|
<setting name="useGeneratedKeys" value="true" />
|
||||||
|
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
||||||
|
<setting name="defaultExecutorType" value="SIMPLE" />
|
||||||
|
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||||
|
<setting name="logImpl" value="SLF4J" />
|
||||||
|
<!-- 使用驼峰命名法转换字段 -->
|
||||||
|
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
||||||
|
</settings>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
restart.include.json=/com.alibaba.fastjson2.*.jar
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# 数据源配置
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
username: root
|
||||||
|
password: Zhang!@#
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
druid:
|
||||||
|
# 主库数据源
|
||||||
|
# master:
|
||||||
|
# url: jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
# username: root
|
||||||
|
# password: Zhang!@#
|
||||||
|
# 初始连接数
|
||||||
|
initialSize: 5
|
||||||
|
# 最小连接池数量
|
||||||
|
minIdle: 10
|
||||||
|
# 最大连接池数量
|
||||||
|
maxActive: 20
|
||||||
|
# 配置获取连接等待超时的时间
|
||||||
|
maxWait: 60000
|
||||||
|
# 配置连接超时时间
|
||||||
|
connectTimeout: 30000
|
||||||
|
# 配置网络超时时间
|
||||||
|
socketTimeout: 60000
|
||||||
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
|
maxEvictableIdleTimeMillis: 900000
|
||||||
|
# 配置检测连接是否有效
|
||||||
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
|
testWhileIdle: true
|
||||||
|
testOnBorrow: false
|
||||||
|
testOnReturn: false
|
||||||
|
webStatFilter:
|
||||||
|
enabled: true
|
||||||
|
statViewServlet:
|
||||||
|
enabled: true
|
||||||
|
# 设置白名单,不填则允许所有访问
|
||||||
|
allow:
|
||||||
|
url-pattern: /druid/*
|
||||||
|
# 控制台管理用户名和密码
|
||||||
|
login-username: project
|
||||||
|
login-password: 123456
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
enabled: true
|
||||||
|
# 慢SQL记录
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: true
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
security:
|
||||||
|
oauth2:
|
||||||
|
resourceserver:
|
||||||
|
jwt:
|
||||||
|
jwk-set-uri: http://localhost:8000/oauth2/jwks
|
||||||
|
client:
|
||||||
|
registration:
|
||||||
|
portal:
|
||||||
|
client-id: 2c6f1d9ff78641c78d72a848
|
||||||
|
client-secret: i1bper1Jw2gLeTzUN1oniwuICPDQgNuQEcYxTKJ5iv0
|
||||||
|
client-name: 羚牛OneOs运营管理
|
||||||
|
authorization-grant-type: authorization_code
|
||||||
|
redirect-uri: http://localhost:81/callback
|
||||||
|
scope:
|
||||||
|
- openid
|
||||||
|
- profile
|
||||||
|
# 返回权限
|
||||||
|
- perms
|
||||||
|
provider: idp
|
||||||
|
|
||||||
|
provider:
|
||||||
|
idp:
|
||||||
|
# issuer-uri: http://localhost:8000
|
||||||
|
authorization-uri: http://localhost/sso
|
||||||
|
token-uri: http://localhost:8000/oauth2/token
|
||||||
|
user-info-uri: http://localhost:8000/userinfo
|
||||||
|
jwk-set-uri: http://localhost:8000/oauth2/jwks
|
||||||
|
user-name-attribute: sub
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# 数据源配置
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://localhost:3306/platform?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||||
|
username: lingniu
|
||||||
|
password: Lingniu2026!
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
|
druid:
|
||||||
|
# 主库数据源
|
||||||
|
# master:
|
||||||
|
# url: jdbc:mysql://localhost:3306/portal?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
# username: root
|
||||||
|
# password: Zhang!@#
|
||||||
|
# 初始连接数
|
||||||
|
initialSize: 5
|
||||||
|
# 最小连接池数量
|
||||||
|
minIdle: 10
|
||||||
|
# 最大连接池数量
|
||||||
|
maxActive: 20
|
||||||
|
# 配置获取连接等待超时的时间
|
||||||
|
maxWait: 60000
|
||||||
|
# 配置连接超时时间
|
||||||
|
connectTimeout: 30000
|
||||||
|
# 配置网络超时时间
|
||||||
|
socketTimeout: 60000
|
||||||
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
|
minEvictableIdleTimeMillis: 300000
|
||||||
|
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||||
|
maxEvictableIdleTimeMillis: 900000
|
||||||
|
# 配置检测连接是否有效
|
||||||
|
validationQuery: SELECT 1 FROM DUAL
|
||||||
|
testWhileIdle: true
|
||||||
|
testOnBorrow: false
|
||||||
|
testOnReturn: false
|
||||||
|
webStatFilter:
|
||||||
|
enabled: true
|
||||||
|
statViewServlet:
|
||||||
|
enabled: true
|
||||||
|
# 设置白名单,不填则允许所有访问
|
||||||
|
allow:
|
||||||
|
url-pattern: /druid/*
|
||||||
|
# 控制台管理用户名和密码
|
||||||
|
login-username: project
|
||||||
|
login-password: 123456
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
enabled: true
|
||||||
|
# 慢SQL记录
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: true
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
security:
|
||||||
|
oauth2:
|
||||||
|
resourceserver:
|
||||||
|
jwt:
|
||||||
|
jwk-set-uri: http://localhost:8000/oauth2/jwks
|
||||||
|
client:
|
||||||
|
registration:
|
||||||
|
portal:
|
||||||
|
client-id: 2c6f1d9ff78641c78d72a848
|
||||||
|
client-secret: i1bper1Jw2gLeTzUN1oniwuICPDQgNuQEcYxTKJ5iv0
|
||||||
|
client-name: 羚牛OneOs运营管理
|
||||||
|
authorization-grant-type: authorization_code
|
||||||
|
redirect-uri: http://106.14.217.120/portal-ui/callback
|
||||||
|
scope:
|
||||||
|
- openid
|
||||||
|
- profile
|
||||||
|
# 返回权限
|
||||||
|
- perms
|
||||||
|
provider: idp
|
||||||
|
|
||||||
|
provider:
|
||||||
|
idp:
|
||||||
|
# issuer-uri: http://localhost:8000
|
||||||
|
authorization-uri: http://106.14.217.120/idp-ui/sso
|
||||||
|
token-uri: http://localhost:8082/oauth2/token
|
||||||
|
user-info-uri: http://localhost:8082/userinfo
|
||||||
|
jwk-set-uri: http://localhost:8082/oauth2/jwks
|
||||||
|
user-name-attribute: sub
|
||||||
140
portal/backend/portal-admin/target/classes/application.yml
Normal file
140
portal/backend/portal-admin/target/classes/application.yml
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
# 项目相关配置
|
||||||
|
project:
|
||||||
|
# 名称
|
||||||
|
name: lingniu
|
||||||
|
# 版本
|
||||||
|
version: 1.0.0
|
||||||
|
# 版权年份
|
||||||
|
copyrightYear: 2026
|
||||||
|
# 文件路径 示例( Windows配置D:/lingniu/uploadPath,Linux配置 /home/lingniu/uploadPath)
|
||||||
|
profile: /opt
|
||||||
|
# 获取ip地址开关
|
||||||
|
addressEnabled: false
|
||||||
|
# 验证码类型 math 数字计算 char 字符验证
|
||||||
|
captchaType: math
|
||||||
|
|
||||||
|
# 开发环境配置
|
||||||
|
server:
|
||||||
|
# 服务器的HTTP端口,默认为8080
|
||||||
|
port: 8080
|
||||||
|
servlet:
|
||||||
|
# 应用的访问路径
|
||||||
|
context-path: /
|
||||||
|
tomcat:
|
||||||
|
# tomcat的URI编码
|
||||||
|
uri-encoding: UTF-8
|
||||||
|
# 连接数满后的排队数,默认为100
|
||||||
|
accept-count: 1000
|
||||||
|
threads:
|
||||||
|
# tomcat最大线程数,默认为200
|
||||||
|
max: 800
|
||||||
|
# Tomcat启动初始化的线程数,默认值10
|
||||||
|
min-spare: 100
|
||||||
|
|
||||||
|
# 日志配置
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
org.lingniu.portal: debug
|
||||||
|
org.springframework: warn
|
||||||
|
|
||||||
|
# 用户配置
|
||||||
|
user:
|
||||||
|
password:
|
||||||
|
# 密码最大错误次数
|
||||||
|
maxRetryCount: 5
|
||||||
|
# 密码锁定时间(默认10分钟)
|
||||||
|
lockTime: 10
|
||||||
|
|
||||||
|
# Spring配置
|
||||||
|
spring:
|
||||||
|
# 资源信息
|
||||||
|
messages:
|
||||||
|
# 国际化资源文件路径
|
||||||
|
basename: i18n/messages
|
||||||
|
profiles:
|
||||||
|
active: local
|
||||||
|
# 文件上传
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
# 单个文件大小
|
||||||
|
max-file-size: 10MB
|
||||||
|
# 设置总上传的文件大小
|
||||||
|
max-request-size: 20MB
|
||||||
|
# 服务模块
|
||||||
|
devtools:
|
||||||
|
restart:
|
||||||
|
# 热部署开关
|
||||||
|
enabled: true
|
||||||
|
data:
|
||||||
|
# redis 配置
|
||||||
|
redis:
|
||||||
|
# 地址
|
||||||
|
host: localhost
|
||||||
|
# 端口,默认为6379
|
||||||
|
port: 6379
|
||||||
|
# 数据库索引
|
||||||
|
database: 0
|
||||||
|
# 密码
|
||||||
|
password:
|
||||||
|
# 连接超时时间
|
||||||
|
timeout: 10s
|
||||||
|
lettuce:
|
||||||
|
pool:
|
||||||
|
# 连接池中的最小空闲连接
|
||||||
|
min-idle: 0
|
||||||
|
# 连接池中的最大空闲连接
|
||||||
|
max-idle: 8
|
||||||
|
# 连接池的最大数据库连接数
|
||||||
|
max-active: 8
|
||||||
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-wait: -1ms
|
||||||
|
|
||||||
|
# token配置
|
||||||
|
token:
|
||||||
|
# 令牌自定义标识
|
||||||
|
header: Authorization
|
||||||
|
|
||||||
|
# MyBatis配置
|
||||||
|
mybatis:
|
||||||
|
# 搜索指定包别名
|
||||||
|
typeAliasesPackage: org.lingniu.**.domain
|
||||||
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
|
# 加载全局的配置文件
|
||||||
|
configLocation: classpath:mybatis/mybatis-config.xml
|
||||||
|
|
||||||
|
# PageHelper分页插件
|
||||||
|
pagehelper:
|
||||||
|
helperDialect: mysql
|
||||||
|
supportMethodsArguments: true
|
||||||
|
params: count=countSql
|
||||||
|
|
||||||
|
# Springdoc配置
|
||||||
|
springdoc:
|
||||||
|
api-docs:
|
||||||
|
path: /v3/api-docs
|
||||||
|
swagger-ui:
|
||||||
|
enabled: true
|
||||||
|
path: /swagger-ui.html
|
||||||
|
tags-sorter: alpha
|
||||||
|
group-configs:
|
||||||
|
- group: 'default'
|
||||||
|
display-name: '测试模块'
|
||||||
|
paths-to-match: '/**'
|
||||||
|
packages-to-scan: org.lingniu.portal.web.controller.tool
|
||||||
|
|
||||||
|
# 防盗链配置
|
||||||
|
referer:
|
||||||
|
# 防盗链开关
|
||||||
|
enabled: false
|
||||||
|
# 允许的域名列表
|
||||||
|
allowed-domains: localhost,127.0.0.1
|
||||||
|
|
||||||
|
# 防止XSS攻击
|
||||||
|
xss:
|
||||||
|
# 过滤开关
|
||||||
|
enabled: true
|
||||||
|
# 排除链接(多个用逗号分隔)
|
||||||
|
excludes: /system/notice
|
||||||
|
# 匹配链接
|
||||||
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
2
portal/backend/portal-admin/target/classes/banner.txt
Normal file
2
portal/backend/portal-admin/target/classes/banner.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Application Version: ${project.version}
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#错误消息
|
||||||
|
not.null=* 必须填写
|
||||||
|
user.jcaptcha.error=验证码错误
|
||||||
|
user.jcaptcha.expire=验证码已失效
|
||||||
|
user.not.exists=用户不存在/密码错误
|
||||||
|
user.password.not.match=用户不存在/密码错误
|
||||||
|
user.password.retry.limit.count=密码输入错误{0}次
|
||||||
|
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||||
|
user.password.delete=对不起,您的账号已被删除
|
||||||
|
user.blocked=用户已封禁,请联系管理员
|
||||||
|
role.blocked=角色已封禁,请联系管理员
|
||||||
|
login.blocked=很遗憾,访问IP已被列入系统黑名单
|
||||||
|
user.logout.success=退出成功
|
||||||
|
|
||||||
|
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||||
|
|
||||||
|
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||||
|
user.password.not.valid=* 5-50个字符
|
||||||
|
|
||||||
|
user.email.not.valid=邮箱格式错误
|
||||||
|
user.mobile.phone.number.not.valid=手机号格式错误
|
||||||
|
user.login.success=登录成功
|
||||||
|
user.register.success=注册成功
|
||||||
|
user.notfound=请重新登录
|
||||||
|
user.forcelogout=管理员强制退出,请重新登录
|
||||||
|
user.unknown.error=未知错误,请重新登录
|
||||||
|
|
||||||
|
##文件上传消息
|
||||||
|
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||||
|
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||||
|
|
||||||
|
##权限
|
||||||
|
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||||
93
portal/backend/portal-admin/target/classes/logback.xml
Normal file
93
portal/backend/portal-admin/target/classes/logback.xml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="/home/project/logs" />
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 用户访问日志输出 -->
|
||||||
|
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-user.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 按天回滚 daily -->
|
||||||
|
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="org.lingniu.portal" level="info" />
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn" />
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info" />
|
||||||
|
<appender-ref ref="file_error" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统用户操作日志-->
|
||||||
|
<logger name="sys-user" level="info">
|
||||||
|
<appender-ref ref="sys-user"/>
|
||||||
|
</logger>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE configuration
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
|
<configuration>
|
||||||
|
<!-- 全局参数 -->
|
||||||
|
<settings>
|
||||||
|
<!-- 使全局的映射器启用或禁用缓存 -->
|
||||||
|
<setting name="cacheEnabled" value="true" />
|
||||||
|
<!-- 允许JDBC 支持自动生成主键 -->
|
||||||
|
<setting name="useGeneratedKeys" value="true" />
|
||||||
|
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
||||||
|
<setting name="defaultExecutorType" value="SIMPLE" />
|
||||||
|
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||||
|
<setting name="logImpl" value="SLF4J" />
|
||||||
|
<!-- 使用驼峰命名法转换字段 -->
|
||||||
|
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
|
||||||
|
</settings>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
#Generated by Maven
|
||||||
|
#Tue Feb 10 15:14:17 CST 2026
|
||||||
|
groupId=org.lingniu
|
||||||
|
artifactId=portal-admin
|
||||||
|
version=1.0.0
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
org\lingniu\portal\web\controller\system\SysUserController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysConfigController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysNoticeController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysIndexController.class
|
||||||
|
org\lingniu\portal\PortalServletInitializer.class
|
||||||
|
org\lingniu\portal\web\controller\monitor\CacheController.class
|
||||||
|
org\lingniu\portal\web\controller\monitor\SysLogininforController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysDeptController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysMenuController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysDictTypeController.class
|
||||||
|
org\lingniu\portal\PortalApplication.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysPostController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysDictDataController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysProfileController.class
|
||||||
|
org\lingniu\portal\web\controller\monitor\SysOperlogController.class
|
||||||
|
org\lingniu\portal\web\controller\monitor\ServerController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysRegisterController.class
|
||||||
|
org\lingniu\portal\web\controller\system\SysRoleController.class
|
||||||
|
org\lingniu\portal\web\controller\monitor\SysUserOnlineController.class
|
||||||
|
org\lingniu\portal\web\controller\common\CommonController.class
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\PortalApplication.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\PortalServletInitializer.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\common\CommonController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\monitor\CacheController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\monitor\ServerController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\monitor\SysLogininforController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\monitor\SysOperlogController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\monitor\SysUserOnlineController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysConfigController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysDeptController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysDictDataController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysDictTypeController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysIndexController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysMenuController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysNoticeController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysPostController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysProfileController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysRegisterController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysRoleController.java
|
||||||
|
D:\RuoYi-Vue\portal-admin\src\main\java\org\lingniu\portal\web\controller\system\SysUserController.java
|
||||||
BIN
portal/backend/portal-admin/target/portal-admin.jar
Normal file
BIN
portal/backend/portal-admin/target/portal-admin.jar
Normal file
Binary file not shown.
BIN
portal/backend/portal-admin/target/portal-admin.jar.original
Normal file
BIN
portal/backend/portal-admin/target/portal-admin.jar.original
Normal file
Binary file not shown.
123
portal/backend/portal-common/pom.xml
Normal file
123
portal/backend/portal-common/pom.xml
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>portal</artifactId>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>portal-common</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
common通用工具
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- Spring框架基本的核心工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context-support</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringWeb模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- spring security 安全认证 -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lingniu</groupId>
|
||||||
|
<artifactId>oauth2-login-sdk</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- pagehelper 分页插件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 自定义验证注解 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--常用工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JSON工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 阿里JSON解析器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- io常用工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Token生成与解析-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Jaxb -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- redis 缓存操作 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- pool 对象池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-pool2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 解析客户端操作系统、浏览器等 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.basjes.parse.useragent</groupId>
|
||||||
|
<artifactId>yauaa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- servlet包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匿名访问不鉴权注解
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface Anonymous
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据权限过滤注解
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface DataScope
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 部门表的别名
|
||||||
|
*/
|
||||||
|
public String deptAlias() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户表的别名
|
||||||
|
*/
|
||||||
|
public String userAlias() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@ss获取,多个权限用逗号分隔开来
|
||||||
|
*/
|
||||||
|
public String permission() default "";
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import org.lingniu.portal.common.enums.DataSourceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义多数据源切换注解
|
||||||
|
*
|
||||||
|
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
public @interface DataSource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 切换数据源名称
|
||||||
|
*/
|
||||||
|
public DataSourceType value() default DataSourceType.MASTER;
|
||||||
|
}
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||||
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
|
import org.lingniu.portal.common.utils.poi.ExcelHandlerAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义导出Excel数据注解
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
public @interface Excel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 导出时在excel中排序
|
||||||
|
*/
|
||||||
|
public int sort() default Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出到Excel中的名字.
|
||||||
|
*/
|
||||||
|
public String name() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期格式, 如: yyyy-MM-dd
|
||||||
|
*/
|
||||||
|
public String dateFormat() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||||
|
*/
|
||||||
|
public String dictType() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||||
|
*/
|
||||||
|
public String readConverterExp() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分隔符,读取字符串组内容
|
||||||
|
*/
|
||||||
|
public String separator() default ",";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||||
|
*/
|
||||||
|
public int scale() default -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出时在excel中每个列的高度
|
||||||
|
*/
|
||||||
|
public double height() default 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出时在excel中每个列的宽度
|
||||||
|
*/
|
||||||
|
public double width() default 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文字后缀,如% 90 变成90%
|
||||||
|
*/
|
||||||
|
public String suffix() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当值为空时,字段的默认值
|
||||||
|
*/
|
||||||
|
public String defaultValue() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示信息
|
||||||
|
*/
|
||||||
|
public String prompt() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否允许内容换行
|
||||||
|
*/
|
||||||
|
public boolean wrapText() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置只能选择不能输入的列内容.
|
||||||
|
*/
|
||||||
|
public String[] combo() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否从字典读数据到combo,默认不读取,如读取需要设置dictType注解.
|
||||||
|
*/
|
||||||
|
public boolean comboReadDict() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
||||||
|
*/
|
||||||
|
public boolean needMerge() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||||
|
*/
|
||||||
|
public boolean isExport() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||||
|
*/
|
||||||
|
public String targetAttr() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||||
|
*/
|
||||||
|
public boolean isStatistics() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出类型(0数字 1字符串 2图片)
|
||||||
|
*/
|
||||||
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出列头背景颜色
|
||||||
|
*/
|
||||||
|
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出列头字体颜色
|
||||||
|
*/
|
||||||
|
public IndexedColors headerColor() default IndexedColors.WHITE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出单元格背景颜色
|
||||||
|
*/
|
||||||
|
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出单元格字体颜色
|
||||||
|
*/
|
||||||
|
public IndexedColors color() default IndexedColors.BLACK;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字段对齐方式
|
||||||
|
*/
|
||||||
|
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义数据处理器
|
||||||
|
*/
|
||||||
|
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义数据处理器参数
|
||||||
|
*/
|
||||||
|
public String[] args() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
|
*/
|
||||||
|
Type type() default Type.ALL;
|
||||||
|
|
||||||
|
public enum Type
|
||||||
|
{
|
||||||
|
ALL(0), EXPORT(1), IMPORT(2);
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
Type(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value()
|
||||||
|
{
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ColumnType
|
||||||
|
{
|
||||||
|
NUMERIC(0), STRING(1), IMAGE(2), TEXT(3);
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
ColumnType(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value()
|
||||||
|
{
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel注解集
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface Excels
|
||||||
|
{
|
||||||
|
public Excel[] value();
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import org.lingniu.portal.common.enums.BusinessType;
|
||||||
|
import org.lingniu.portal.common.enums.OperatorType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义操作日志记录注解
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface Log
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 模块
|
||||||
|
*/
|
||||||
|
public String title() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能
|
||||||
|
*/
|
||||||
|
public BusinessType businessType() default BusinessType.OTHER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作人类别
|
||||||
|
*/
|
||||||
|
public OperatorType operatorType() default OperatorType.MANAGE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否保存请求的参数
|
||||||
|
*/
|
||||||
|
public boolean isSaveRequestData() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否保存响应的参数
|
||||||
|
*/
|
||||||
|
public boolean isSaveResponseData() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排除指定的请求参数
|
||||||
|
*/
|
||||||
|
public String[] excludeParamNames() default {};
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import org.lingniu.portal.common.constant.CacheConstants;
|
||||||
|
import org.lingniu.portal.common.enums.LimitType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流注解
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface RateLimiter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 限流key
|
||||||
|
*/
|
||||||
|
public String key() default CacheConstants.RATE_LIMIT_KEY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流时间,单位秒
|
||||||
|
*/
|
||||||
|
public int time() default 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流次数
|
||||||
|
*/
|
||||||
|
public int count() default 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流类型
|
||||||
|
*/
|
||||||
|
public LimitType limitType() default LimitType.DEFAULT;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义注解防止表单重复提交
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Inherited
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface RepeatSubmit
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 间隔时间(ms),小于此时间视为重复提交
|
||||||
|
*/
|
||||||
|
public int interval() default 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示消息
|
||||||
|
*/
|
||||||
|
public String message() default "不允许重复提交,请稍候再试";
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package org.lingniu.portal.common.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import org.lingniu.portal.common.config.serializer.SensitiveJsonSerializer;
|
||||||
|
import org.lingniu.portal.common.enums.DesensitizedType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据脱敏注解
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@JacksonAnnotationsInside
|
||||||
|
@JsonSerialize(using = SensitiveJsonSerializer.class)
|
||||||
|
public @interface Sensitive
|
||||||
|
{
|
||||||
|
DesensitizedType desensitizedType();
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package org.lingniu.portal.common.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取项目相关配置
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "project")
|
||||||
|
public class ProjectConfig
|
||||||
|
{
|
||||||
|
/** 项目名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 版本 */
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
/** 版权年份 */
|
||||||
|
private String copyrightYear;
|
||||||
|
|
||||||
|
/** 上传路径 */
|
||||||
|
private static String profile;
|
||||||
|
|
||||||
|
/** 获取地址开关 */
|
||||||
|
private static boolean addressEnabled;
|
||||||
|
|
||||||
|
/** 验证码类型 */
|
||||||
|
private static String captchaType;
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion()
|
||||||
|
{
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version)
|
||||||
|
{
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCopyrightYear()
|
||||||
|
{
|
||||||
|
return copyrightYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCopyrightYear(String copyrightYear)
|
||||||
|
{
|
||||||
|
this.copyrightYear = copyrightYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getProfile()
|
||||||
|
{
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfile(String profile)
|
||||||
|
{
|
||||||
|
ProjectConfig.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAddressEnabled()
|
||||||
|
{
|
||||||
|
return addressEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddressEnabled(boolean addressEnabled)
|
||||||
|
{
|
||||||
|
ProjectConfig.addressEnabled = addressEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCaptchaType() {
|
||||||
|
return captchaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaptchaType(String captchaType) {
|
||||||
|
ProjectConfig.captchaType = captchaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取导入上传路径
|
||||||
|
*/
|
||||||
|
public static String getImportPath()
|
||||||
|
{
|
||||||
|
return getProfile() + "/import";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取头像上传路径
|
||||||
|
*/
|
||||||
|
public static String getAvatarPath()
|
||||||
|
{
|
||||||
|
return getProfile() + "/avatar";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下载路径
|
||||||
|
*/
|
||||||
|
public static String getDownloadPath()
|
||||||
|
{
|
||||||
|
return getProfile() + "/download/";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取上传路径
|
||||||
|
*/
|
||||||
|
public static String getUploadPath()
|
||||||
|
{
|
||||||
|
return getProfile() + "/upload";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package org.lingniu.portal.common.config.serializer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.BeanProperty;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
|
||||||
|
import org.lingniu.portal.common.annotation.Sensitive;
|
||||||
|
import org.lingniu.portal.common.core.domain.model.LoginUser;
|
||||||
|
import org.lingniu.portal.common.enums.DesensitizedType;
|
||||||
|
import org.lingniu.portal.common.utils.SecurityUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据脱敏序列化过滤
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer
|
||||||
|
{
|
||||||
|
private DesensitizedType desensitizedType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException
|
||||||
|
{
|
||||||
|
if (desensitization())
|
||||||
|
{
|
||||||
|
gen.writeString(desensitizedType.desensitizer().apply(value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gen.writeString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
|
||||||
|
throws JsonMappingException
|
||||||
|
{
|
||||||
|
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
||||||
|
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass()))
|
||||||
|
{
|
||||||
|
this.desensitizedType = annotation.desensitizedType();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return prov.findValueSerializer(property.getType(), property);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要脱敏处理
|
||||||
|
*/
|
||||||
|
private boolean desensitization()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoginUser securityUser = SecurityUtils.getLoginUser();
|
||||||
|
// 管理员不脱敏
|
||||||
|
return !securityUser.getUser().isAdmin();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package org.lingniu.portal.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存的key 常量
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class CacheConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 登录用户 redis key
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码 redis key
|
||||||
|
*/
|
||||||
|
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数管理 cache key
|
||||||
|
*/
|
||||||
|
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典管理 cache key
|
||||||
|
*/
|
||||||
|
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 防重提交 redis key
|
||||||
|
*/
|
||||||
|
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流 redis key
|
||||||
|
*/
|
||||||
|
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录账户密码错误次数 redis key
|
||||||
|
*/
|
||||||
|
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
package org.lingniu.portal.common.constant;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用常量信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class Constants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* UTF-8 字符集
|
||||||
|
*/
|
||||||
|
public static final String UTF8 = "UTF-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GBK 字符集
|
||||||
|
*/
|
||||||
|
public static final String GBK = "GBK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统语言
|
||||||
|
*/
|
||||||
|
public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* www主域
|
||||||
|
*/
|
||||||
|
public static final String WWW = "www.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http请求
|
||||||
|
*/
|
||||||
|
public static final String HTTP = "http://";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https请求
|
||||||
|
*/
|
||||||
|
public static final String HTTPS = "https://";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用成功标识
|
||||||
|
*/
|
||||||
|
public static final String SUCCESS = "0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用失败标识
|
||||||
|
*/
|
||||||
|
public static final String FAIL = "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录成功
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_SUCCESS = "Success";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销
|
||||||
|
*/
|
||||||
|
public static final String LOGOUT = "Logout";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册
|
||||||
|
*/
|
||||||
|
public static final String REGISTER = "Register";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录失败
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_FAIL = "Error";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有权限标识
|
||||||
|
*/
|
||||||
|
public static final String ALL_PERMISSION = "*:*:*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员角色权限标识
|
||||||
|
*/
|
||||||
|
public static final String SUPER_ADMIN = "admin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色权限分隔符
|
||||||
|
*/
|
||||||
|
public static final String ROLE_DELIMITER = ",";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限标识分隔符
|
||||||
|
*/
|
||||||
|
public static final String PERMISSION_DELIMITER = ",";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码有效期(分钟)
|
||||||
|
*/
|
||||||
|
public static final Integer CAPTCHA_EXPIRATION = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌
|
||||||
|
*/
|
||||||
|
public static final String TOKEN = "token";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌前缀
|
||||||
|
*/
|
||||||
|
public static final String TOKEN_PREFIX = "Bearer ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌前缀
|
||||||
|
*/
|
||||||
|
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
public static final String JWT_USERID = "userid";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
public static final String JWT_USERNAME = Claims.SUBJECT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像
|
||||||
|
*/
|
||||||
|
public static final String JWT_AVATAR = "avatar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
public static final String JWT_CREATED = "created";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户权限
|
||||||
|
*/
|
||||||
|
public static final String JWT_AUTHORITIES = "authorities";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源映射路径 前缀
|
||||||
|
*/
|
||||||
|
public static final String RESOURCE_PREFIX = "/profile";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RMI 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_RMI = "rmi:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAP 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAP = "ldap:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAPS 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
|
||||||
|
*/
|
||||||
|
public static final String[] JSON_WHITELIST_STR = { "org.lingniu.portal" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_WHITELIST_STR = { "org.lingniu.portal.quartz.task" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务违规的字符
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||||
|
"org.springframework", "org.apache", "org.lingniu.portal.common.utils.file", "org.lingniu.portal.common.config", "org.lingniu.portal.generator" };
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package org.lingniu.portal.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码生成通用常量
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class GenConstants
|
||||||
|
{
|
||||||
|
/** 单表(增删改查) */
|
||||||
|
public static final String TPL_CRUD = "crud";
|
||||||
|
|
||||||
|
/** 树表(增删改查) */
|
||||||
|
public static final String TPL_TREE = "tree";
|
||||||
|
|
||||||
|
/** 主子表(增删改查) */
|
||||||
|
public static final String TPL_SUB = "sub";
|
||||||
|
|
||||||
|
/** 树编码字段 */
|
||||||
|
public static final String TREE_CODE = "treeCode";
|
||||||
|
|
||||||
|
/** 树父编码字段 */
|
||||||
|
public static final String TREE_PARENT_CODE = "treeParentCode";
|
||||||
|
|
||||||
|
/** 树名称字段 */
|
||||||
|
public static final String TREE_NAME = "treeName";
|
||||||
|
|
||||||
|
/** 上级菜单ID字段 */
|
||||||
|
public static final String PARENT_MENU_ID = "parentMenuId";
|
||||||
|
|
||||||
|
/** 上级菜单名称字段 */
|
||||||
|
public static final String PARENT_MENU_NAME = "parentMenuName";
|
||||||
|
|
||||||
|
/** 数据库字符串类型 */
|
||||||
|
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
||||||
|
|
||||||
|
/** 数据库文本类型 */
|
||||||
|
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
||||||
|
|
||||||
|
/** 数据库时间类型 */
|
||||||
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||||
|
|
||||||
|
/** 数据库数字类型 */
|
||||||
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
|
"bit", "bigint", "float", "double", "decimal" };
|
||||||
|
|
||||||
|
/** 页面不需要编辑字段 */
|
||||||
|
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||||
|
|
||||||
|
/** 页面不需要显示的列表字段 */
|
||||||
|
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||||
|
"update_time" };
|
||||||
|
|
||||||
|
/** 页面不需要查询字段 */
|
||||||
|
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||||
|
"update_time", "remark" };
|
||||||
|
|
||||||
|
/** Entity基类字段 */
|
||||||
|
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||||
|
|
||||||
|
/** Tree基类字段 */
|
||||||
|
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
|
||||||
|
|
||||||
|
/** 文本框 */
|
||||||
|
public static final String HTML_INPUT = "input";
|
||||||
|
|
||||||
|
/** 文本域 */
|
||||||
|
public static final String HTML_TEXTAREA = "textarea";
|
||||||
|
|
||||||
|
/** 下拉框 */
|
||||||
|
public static final String HTML_SELECT = "select";
|
||||||
|
|
||||||
|
/** 单选框 */
|
||||||
|
public static final String HTML_RADIO = "radio";
|
||||||
|
|
||||||
|
/** 复选框 */
|
||||||
|
public static final String HTML_CHECKBOX = "checkbox";
|
||||||
|
|
||||||
|
/** 日期控件 */
|
||||||
|
public static final String HTML_DATETIME = "datetime";
|
||||||
|
|
||||||
|
/** 图片上传控件 */
|
||||||
|
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
||||||
|
|
||||||
|
/** 文件上传控件 */
|
||||||
|
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
||||||
|
|
||||||
|
/** 富文本控件 */
|
||||||
|
public static final String HTML_EDITOR = "editor";
|
||||||
|
|
||||||
|
/** 字符串类型 */
|
||||||
|
public static final String TYPE_STRING = "String";
|
||||||
|
|
||||||
|
/** 整型 */
|
||||||
|
public static final String TYPE_INTEGER = "Integer";
|
||||||
|
|
||||||
|
/** 长整型 */
|
||||||
|
public static final String TYPE_LONG = "Long";
|
||||||
|
|
||||||
|
/** 浮点型 */
|
||||||
|
public static final String TYPE_DOUBLE = "Double";
|
||||||
|
|
||||||
|
/** 高精度计算类型 */
|
||||||
|
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
||||||
|
|
||||||
|
/** 时间类型 */
|
||||||
|
public static final String TYPE_DATE = "Date";
|
||||||
|
|
||||||
|
/** 模糊查询 */
|
||||||
|
public static final String QUERY_LIKE = "LIKE";
|
||||||
|
|
||||||
|
/** 相等查询 */
|
||||||
|
public static final String QUERY_EQ = "EQ";
|
||||||
|
|
||||||
|
/** 需要 */
|
||||||
|
public static final String REQUIRE = "1";
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package org.lingniu.portal.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回状态码
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class HttpStatus
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 操作成功
|
||||||
|
*/
|
||||||
|
public static final int SUCCESS = 200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对象创建成功
|
||||||
|
*/
|
||||||
|
public static final int CREATED = 201;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求已经被接受
|
||||||
|
*/
|
||||||
|
public static final int ACCEPTED = 202;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作已经执行成功,但是没有返回数据
|
||||||
|
*/
|
||||||
|
public static final int NO_CONTENT = 204;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源已被移除
|
||||||
|
*/
|
||||||
|
public static final int MOVED_PERM = 301;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重定向
|
||||||
|
*/
|
||||||
|
public static final int SEE_OTHER = 303;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源没有被修改
|
||||||
|
*/
|
||||||
|
public static final int NOT_MODIFIED = 304;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数列表错误(缺少,格式不匹配)
|
||||||
|
*/
|
||||||
|
public static final int BAD_REQUEST = 400;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未授权
|
||||||
|
*/
|
||||||
|
public static final int UNAUTHORIZED = 401;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问受限,授权过期
|
||||||
|
*/
|
||||||
|
public static final int FORBIDDEN = 403;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源,服务未找到
|
||||||
|
*/
|
||||||
|
public static final int NOT_FOUND = 404;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不允许的http方法
|
||||||
|
*/
|
||||||
|
public static final int BAD_METHOD = 405;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源冲突,或者资源被锁
|
||||||
|
*/
|
||||||
|
public static final int CONFLICT = 409;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不支持的数据,媒体类型
|
||||||
|
*/
|
||||||
|
public static final int UNSUPPORTED_TYPE = 415;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统内部错误
|
||||||
|
*/
|
||||||
|
public static final int ERROR = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口未实现
|
||||||
|
*/
|
||||||
|
public static final int NOT_IMPLEMENTED = 501;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统警告消息
|
||||||
|
*/
|
||||||
|
public static final int WARN = 601;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.lingniu.portal.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务调度通用常量
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class ScheduleConstants
|
||||||
|
{
|
||||||
|
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||||
|
|
||||||
|
/** 执行目标key */
|
||||||
|
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
||||||
|
|
||||||
|
/** 默认 */
|
||||||
|
public static final String MISFIRE_DEFAULT = "0";
|
||||||
|
|
||||||
|
/** 立即触发执行 */
|
||||||
|
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
||||||
|
|
||||||
|
/** 触发一次执行 */
|
||||||
|
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
||||||
|
|
||||||
|
/** 不触发立即执行 */
|
||||||
|
public static final String MISFIRE_DO_NOTHING = "3";
|
||||||
|
|
||||||
|
public enum Status
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 正常
|
||||||
|
*/
|
||||||
|
NORMAL("0"),
|
||||||
|
/**
|
||||||
|
* 暂停
|
||||||
|
*/
|
||||||
|
PAUSE("1");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private Status(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.lingniu.portal.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户常量信息
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class UserConstants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台内系统用户的唯一标志
|
||||||
|
*/
|
||||||
|
public static final String SYS_USER = "SYS_USER";
|
||||||
|
|
||||||
|
/** 正常状态 */
|
||||||
|
public static final String NORMAL = "0";
|
||||||
|
|
||||||
|
/** 异常状态 */
|
||||||
|
public static final String EXCEPTION = "1";
|
||||||
|
|
||||||
|
/** 用户封禁状态 */
|
||||||
|
public static final String USER_DISABLE = "1";
|
||||||
|
|
||||||
|
/** 角色正常状态 */
|
||||||
|
public static final String ROLE_NORMAL = "0";
|
||||||
|
|
||||||
|
/** 角色封禁状态 */
|
||||||
|
public static final String ROLE_DISABLE = "1";
|
||||||
|
|
||||||
|
/** 部门正常状态 */
|
||||||
|
public static final String DEPT_NORMAL = "0";
|
||||||
|
|
||||||
|
/** 部门停用状态 */
|
||||||
|
public static final String DEPT_DISABLE = "1";
|
||||||
|
|
||||||
|
/** 字典正常状态 */
|
||||||
|
public static final String DICT_NORMAL = "0";
|
||||||
|
|
||||||
|
/** 是否为系统默认(是) */
|
||||||
|
public static final String YES = "Y";
|
||||||
|
|
||||||
|
/** 是否菜单外链(是) */
|
||||||
|
public static final String YES_FRAME = "0";
|
||||||
|
|
||||||
|
/** 是否菜单外链(否) */
|
||||||
|
public static final String NO_FRAME = "1";
|
||||||
|
|
||||||
|
/** 菜单类型(目录) */
|
||||||
|
public static final String TYPE_DIR = "M";
|
||||||
|
|
||||||
|
/** 菜单类型(菜单) */
|
||||||
|
public static final String TYPE_MENU = "C";
|
||||||
|
|
||||||
|
/** 菜单类型(按钮) */
|
||||||
|
public static final String TYPE_BUTTON = "F";
|
||||||
|
|
||||||
|
/** Layout组件标识 */
|
||||||
|
public final static String LAYOUT = "Layout";
|
||||||
|
|
||||||
|
/** ParentView组件标识 */
|
||||||
|
public final static String PARENT_VIEW = "ParentView";
|
||||||
|
|
||||||
|
/** InnerLink组件标识 */
|
||||||
|
public final static String INNER_LINK = "InnerLink";
|
||||||
|
|
||||||
|
/** 校验是否唯一的返回标识 */
|
||||||
|
public final static boolean UNIQUE = true;
|
||||||
|
public final static boolean NOT_UNIQUE = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名长度限制
|
||||||
|
*/
|
||||||
|
public static final int USERNAME_MIN_LENGTH = 2;
|
||||||
|
public static final int USERNAME_MAX_LENGTH = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码长度限制
|
||||||
|
*/
|
||||||
|
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||||
|
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||||
|
}
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
package org.lingniu.portal.common.core.controller;
|
||||||
|
|
||||||
|
import java.beans.PropertyEditorSupport;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.lingniu.portal.common.constant.HttpStatus;
|
||||||
|
import org.lingniu.portal.common.core.domain.AjaxResult;
|
||||||
|
import org.lingniu.portal.common.core.domain.model.LoginUser;
|
||||||
|
import org.lingniu.portal.common.core.page.PageDomain;
|
||||||
|
import org.lingniu.portal.common.core.page.TableDataInfo;
|
||||||
|
import org.lingniu.portal.common.core.page.TableSupport;
|
||||||
|
import org.lingniu.portal.common.utils.DateUtils;
|
||||||
|
import org.lingniu.portal.common.utils.PageUtils;
|
||||||
|
import org.lingniu.portal.common.utils.SecurityUtils;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
import org.lingniu.portal.common.utils.sql.SqlUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* web层通用数据处理
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class BaseController
|
||||||
|
{
|
||||||
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
|
*/
|
||||||
|
@InitBinder
|
||||||
|
public void initBinder(WebDataBinder binder)
|
||||||
|
{
|
||||||
|
// Date 类型转换
|
||||||
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void setAsText(String text)
|
||||||
|
{
|
||||||
|
setValue(DateUtils.parseDate(text));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置请求分页数据
|
||||||
|
*/
|
||||||
|
protected void startPage()
|
||||||
|
{
|
||||||
|
PageUtils.startPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置请求排序数据
|
||||||
|
*/
|
||||||
|
protected void startOrderBy()
|
||||||
|
{
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||||
|
{
|
||||||
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
|
PageHelper.orderBy(orderBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理分页的线程变量
|
||||||
|
*/
|
||||||
|
protected void clearPage()
|
||||||
|
{
|
||||||
|
PageUtils.clearPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应请求分页数据
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
protected TableDataInfo getDataTable(List<?> list)
|
||||||
|
{
|
||||||
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
|
rspData.setCode(HttpStatus.SUCCESS);
|
||||||
|
rspData.setMsg("查询成功");
|
||||||
|
rspData.setRows(list);
|
||||||
|
rspData.setTotal(new PageInfo(list).getTotal());
|
||||||
|
return rspData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功
|
||||||
|
*/
|
||||||
|
public AjaxResult success()
|
||||||
|
{
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult error()
|
||||||
|
{
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*/
|
||||||
|
public AjaxResult success(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*/
|
||||||
|
public AjaxResult success(Object data)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回失败消息
|
||||||
|
*/
|
||||||
|
public AjaxResult error(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*/
|
||||||
|
public AjaxResult warn(String message)
|
||||||
|
{
|
||||||
|
return AjaxResult.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应返回结果
|
||||||
|
*
|
||||||
|
* @param rows 影响行数
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
protected AjaxResult toAjax(int rows)
|
||||||
|
{
|
||||||
|
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应返回结果
|
||||||
|
*
|
||||||
|
* @param result 结果
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
protected AjaxResult toAjax(boolean result)
|
||||||
|
{
|
||||||
|
return result ? success() : error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面跳转
|
||||||
|
*/
|
||||||
|
public String redirect(String url)
|
||||||
|
{
|
||||||
|
return StringUtils.format("redirect:{}", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户缓存信息
|
||||||
|
*/
|
||||||
|
public LoginUser getLoginUser()
|
||||||
|
{
|
||||||
|
return SecurityUtils.getLoginUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录用户id
|
||||||
|
*/
|
||||||
|
public Long getUserId()
|
||||||
|
{
|
||||||
|
return getLoginUser().getUserId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录部门id
|
||||||
|
*/
|
||||||
|
public Long getDeptId()
|
||||||
|
{
|
||||||
|
return getLoginUser().getDeptId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录用户名
|
||||||
|
*/
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
return getLoginUser().getUsername();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
package org.lingniu.portal.common.core.domain;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.lingniu.portal.common.constant.HttpStatus;
|
||||||
|
import org.lingniu.portal.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作消息提醒
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class AjaxResult extends HashMap<String, Object>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 状态码 */
|
||||||
|
public static final String CODE_TAG = "code";
|
||||||
|
|
||||||
|
/** 返回内容 */
|
||||||
|
public static final String MSG_TAG = "msg";
|
||||||
|
|
||||||
|
/** 数据对象 */
|
||||||
|
public static final String DATA_TAG = "data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||||
|
*/
|
||||||
|
public AjaxResult()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
*/
|
||||||
|
public AjaxResult(int code, String msg)
|
||||||
|
{
|
||||||
|
super.put(CODE_TAG, code);
|
||||||
|
super.put(MSG_TAG, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
*/
|
||||||
|
public AjaxResult(int code, String msg, Object data)
|
||||||
|
{
|
||||||
|
super.put(CODE_TAG, code);
|
||||||
|
super.put(MSG_TAG, msg);
|
||||||
|
if (StringUtils.isNotNull(data))
|
||||||
|
{
|
||||||
|
super.put(DATA_TAG, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success()
|
||||||
|
{
|
||||||
|
return AjaxResult.success("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功数据
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success(Object data)
|
||||||
|
{
|
||||||
|
return AjaxResult.success("操作成功", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success(String msg)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult success(String msg, Object data)
|
||||||
|
{
|
||||||
|
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult warn(String msg)
|
||||||
|
{
|
||||||
|
return AjaxResult.warn(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回警告消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 警告消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult warn(String msg, Object data)
|
||||||
|
{
|
||||||
|
return new AjaxResult(HttpStatus.WARN, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error()
|
||||||
|
{
|
||||||
|
return AjaxResult.error("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error(String msg)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @param data 数据对象
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error(String msg, Object data)
|
||||||
|
{
|
||||||
|
return new AjaxResult(HttpStatus.ERROR, msg, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回错误消息
|
||||||
|
*
|
||||||
|
* @param code 状态码
|
||||||
|
* @param msg 返回内容
|
||||||
|
* @return 错误消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult error(int code, String msg)
|
||||||
|
{
|
||||||
|
return new AjaxResult(code, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为成功消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isSuccess()
|
||||||
|
{
|
||||||
|
return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为警告消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isWarn()
|
||||||
|
{
|
||||||
|
return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为错误消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public boolean isError()
|
||||||
|
{
|
||||||
|
return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方便链式调用
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return 数据对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult put(String key, Object value)
|
||||||
|
{
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package org.lingniu.portal.common.core.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entity基类
|
||||||
|
*
|
||||||
|
* @author lingniu
|
||||||
|
*/
|
||||||
|
public class BaseEntity implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 搜索值 */
|
||||||
|
@JsonIgnore
|
||||||
|
private String searchValue;
|
||||||
|
|
||||||
|
/** 创建者 */
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/** 更新者 */
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/** 更新时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/** 备注 */
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/** 请求参数 */
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
private Map<String, Object> params;
|
||||||
|
|
||||||
|
public String getSearchValue()
|
||||||
|
{
|
||||||
|
return searchValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchValue(String searchValue)
|
||||||
|
{
|
||||||
|
this.searchValue = searchValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateBy()
|
||||||
|
{
|
||||||
|
return createBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateBy(String createBy)
|
||||||
|
{
|
||||||
|
this.createBy = createBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime()
|
||||||
|
{
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime)
|
||||||
|
{
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdateBy()
|
||||||
|
{
|
||||||
|
return updateBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateBy(String updateBy)
|
||||||
|
{
|
||||||
|
this.updateBy = updateBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime()
|
||||||
|
{
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime)
|
||||||
|
{
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark()
|
||||||
|
{
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark)
|
||||||
|
{
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getParams()
|
||||||
|
{
|
||||||
|
if (params == null)
|
||||||
|
{
|
||||||
|
params = new HashMap<>();
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Map<String, Object> params)
|
||||||
|
{
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user