Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98830dfdc7 | ||
|
|
1c10dc2ce2 | ||
|
|
65699dcab4 | ||
|
|
b0a57c778b | ||
|
|
8a38e532e2 | ||
|
|
df43cd2333 | ||
|
|
65e94a204c | ||
|
|
da255fa7e0 | ||
|
|
d413ea4469 | ||
|
|
4eaa383717 | ||
|
|
d113ebfa2f | ||
|
|
f2898da525 | ||
|
|
462abff607 | ||
|
|
89803b3908 | ||
|
|
df6dc89b96 | ||
|
|
5989b8bc78 | ||
|
|
d41333c766 | ||
|
|
83c4e28527 | ||
|
|
1053669077 | ||
|
|
96647a055b | ||
|
|
02bff29f94 |
@@ -0,0 +1,12 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function listMetadata(query) {
|
||||||
|
return request({
|
||||||
|
url: 'api/component/CuteDeptTree/listMetadata',
|
||||||
|
method: 'post',
|
||||||
|
data: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { listMetadata }
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function listMetadata() {
|
||||||
|
return request({
|
||||||
|
url: 'api/component/CuteProductLineSelectPro/listMetadata',
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function listMetadata() {
|
||||||
|
return request({
|
||||||
|
url: 'api/component/CuteProductLineSelect/listMetadata',
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function listMetadata(query) {
|
||||||
|
return request({
|
||||||
|
url: 'api/component/CuteUserSelect/listMetadata',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
blurry: query
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listMetadataByUsernames(usernameList = []) {
|
||||||
|
return request({
|
||||||
|
url: 'api/component/CuteUserSelect/listMetadataByUsernames',
|
||||||
|
method: 'post',
|
||||||
|
data: usernameList
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { listMetadata, listMetadataByUsernames }
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import request from '@/utils/request'
|
|
||||||
|
|
||||||
export function listDeptSelectDataSource() {
|
|
||||||
return request({
|
|
||||||
url: 'api/component/listDeptSelectDataSource',
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function listDeptSelectProDataSource() {
|
|
||||||
return request({
|
|
||||||
url: 'api/component/listDeptSelectProDataSource',
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -68,20 +68,5 @@ export function updateUserEmailByUsername(form) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function queryUserMetadataOptions(query) {
|
export default { add, edit, del, resetUserPasswordByIds }
|
||||||
const params = {
|
|
||||||
page: 1,
|
|
||||||
size: 50,
|
|
||||||
args: {
|
|
||||||
blurry: query
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request({
|
|
||||||
url: 'api/user/queryUserMetadataOptions',
|
|
||||||
method: 'post',
|
|
||||||
data: params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default { add, edit, del, resetUserPasswordByIds, queryUserMetadataOptions }
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import { get as getDictDetail } from '@/api/system/dictDetail'
|
import { get as getDictDetail } from '@/api/system/dict-detail'
|
||||||
|
|
||||||
export default class Dict {
|
export default class Dict {
|
||||||
constructor(dict) {
|
constructor(dict) {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
* @type {any}
|
* @type {any}
|
||||||
*/
|
*/
|
||||||
const getters = {
|
const getters = {
|
||||||
deployUploadApi: state => state.api.deployUploadApi,
|
|
||||||
databaseUploadApi: state => state.api.databaseUploadApi,
|
|
||||||
size: state => state.app.size,
|
size: state => state.app.size,
|
||||||
sidebar: state => state.app.sidebar,
|
sidebar: state => state.app.sidebar,
|
||||||
device: state => state.app.device,
|
device: state => state.app.device,
|
||||||
@@ -24,6 +22,9 @@ const getters = {
|
|||||||
swaggerApi: state => state.api.swaggerApi,
|
swaggerApi: state => state.api.swaggerApi,
|
||||||
websocketApi: state => state.api.websocketApi,
|
websocketApi: state => state.api.websocketApi,
|
||||||
sidebarRouters: state => state.permission.sidebarRouters,
|
sidebarRouters: state => state.permission.sidebarRouters,
|
||||||
statusConst: state => state.pipeline.statusConst
|
statusConst: state => state.pipeline.statusConst,
|
||||||
|
// 上传组件专用
|
||||||
|
fileUploadApplicationApi: state => state.api.fileUploadApplicationApi,
|
||||||
|
ossUploadApplicationApi: state => state.api.ossUploadApplicationApi
|
||||||
}
|
}
|
||||||
export default getters
|
export default getters
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ const api = {
|
|||||||
fileUploadApi: baseUrl + '/api/localStorage/uploadFile',
|
fileUploadApi: baseUrl + '/api/localStorage/uploadFile',
|
||||||
// oss上传
|
// oss上传
|
||||||
ossUploadApi: baseUrl + '/api/ossStorage/uploadFile',
|
ossUploadApi: baseUrl + '/api/ossStorage/uploadFile',
|
||||||
|
// 上传组件专用
|
||||||
|
fileUploadApplicationApi: baseUrl + '/api/component/CuteFileUpload/uploadLocal',
|
||||||
|
ossUploadApplicationApi: baseUrl + '/api/component/CuteFileUpload/uploadOSS',
|
||||||
// baseUrl,
|
// baseUrl,
|
||||||
baseApi: baseUrl
|
baseApi: baseUrl
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { searchDept } from '@/api/system/dept'
|
import CuteDeptTreeApi from '@/api/application/cute-dept-tree'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CuteDeptTree',
|
name: 'CuteDeptTree',
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [Number, String],
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
@@ -61,15 +61,11 @@ export default {
|
|||||||
params['pid'] = node.data.id
|
params['pid'] = node.data.id
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
searchDept({
|
CuteDeptTreeApi.listMetadata(params).then(res => {
|
||||||
page: 1,
|
|
||||||
size: 9999999,
|
|
||||||
args: params
|
|
||||||
}).then(res => {
|
|
||||||
if (resolve) {
|
if (resolve) {
|
||||||
resolve(res.content)
|
resolve(res)
|
||||||
} else {
|
} else {
|
||||||
this.deptData = res.content
|
this.deptData = res
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
:headers="headers"
|
:headers="headers"
|
||||||
:on-success="handleSuccess"
|
:on-success="handleSuccess"
|
||||||
:on-error="handleError"
|
:on-error="handleError"
|
||||||
:action="ossUploadApi"
|
:action="mode === 'oss' ? ossUploadApplicationApi: fileUploadApplicationApi"
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload" />
|
<i class="el-icon-upload" />
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
@@ -34,6 +34,14 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上传方式:local、oss
|
||||||
|
*/
|
||||||
|
mode: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
default: 'oss'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -44,7 +52,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'baseApi',
|
'baseApi',
|
||||||
'ossUploadApi'
|
'fileUploadApplicationApi',
|
||||||
|
'ossUploadApplicationApi'
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
:headers="headers"
|
:headers="headers"
|
||||||
:on-success="handleSuccess"
|
:on-success="handleSuccess"
|
||||||
:on-error="handleError"
|
:on-error="handleError"
|
||||||
:action="ossUploadApi"
|
:action="mode === 'oss' ? ossUploadApplicationApi: fileUploadApplicationApi"
|
||||||
>
|
>
|
||||||
<el-button size="small" type="primary">点击上传</el-button>
|
<el-button size="small" type="primary">点击上传</el-button>
|
||||||
<div slot="tip" class="el-upload__tip">只能上传不超过100MB的文件</div>
|
<div slot="tip" class="el-upload__tip">只能上传不超过100MB的文件</div>
|
||||||
@@ -32,6 +32,14 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上传方式:local、oss
|
||||||
|
*/
|
||||||
|
mode: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
default: 'oss'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -42,7 +50,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'baseApi',
|
'baseApi',
|
||||||
'ossUploadApi'
|
'fileUploadApplicationApi',
|
||||||
|
'ossUploadApplicationApi'
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { listDeptSelectDataSource } from '@/api/system/component'
|
import { listMetadata } from '@/api/application/cute-product-line-select'
|
||||||
import CsMessage from '@/utils/elementui/CsMessage'
|
import CsMessage from '@/utils/elementui/CsMessage'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CuteProductLineSelect',
|
name: 'CuteProductLineSelect',
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [Number, String],
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
@@ -56,7 +56,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchDeptData() {
|
fetchDeptData() {
|
||||||
listDeptSelectDataSource().then(data => {
|
listMetadata().then(data => {
|
||||||
this.deptOptions = data
|
this.deptOptions = data
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('获取部门数据失败:', error)
|
console.error('获取部门数据失败:', error)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { listDeptSelectProDataSource } from '@/api/system/component'
|
import { listMetadata } from '@/api/application/cute-product-line-select-pro'
|
||||||
import CsMessage from '@/utils/elementui/CsMessage'
|
import CsMessage from '@/utils/elementui/CsMessage'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -62,7 +62,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchDeptData() {
|
fetchDeptData() {
|
||||||
listDeptSelectProDataSource().then(data => {
|
listMetadata().then(data => {
|
||||||
this.deptOptions = this.cleanEmptyChildren(data)
|
this.deptOptions = this.cleanEmptyChildren(data)
|
||||||
// console.error('deptOptions', this.deptOptions)
|
// console.error('deptOptions', this.deptOptions)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import UserService from '@/api/system/user'
|
import CuteUserSelectApi from '@/api/application/cute-user-select'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CuteSingleUserSelect',
|
name: 'CuteSingleUserSelect',
|
||||||
@@ -41,7 +41,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: this.value,
|
user: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
options: []
|
options: []
|
||||||
}
|
}
|
||||||
@@ -51,21 +51,28 @@ export default {
|
|||||||
this.user = newVal
|
this.user = newVal
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async mounted() {
|
||||||
|
const that = this
|
||||||
|
if (that.value && that.value.length > 0) {
|
||||||
|
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value)
|
||||||
|
that.users = that.value
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
remoteMethod(query) {
|
remoteMethod(query) {
|
||||||
if (query !== '') {
|
if (query !== '') {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.queryUserMetadataOptions(query)
|
this.listMetadata(query)
|
||||||
}, 200)
|
}, 200)
|
||||||
} else {
|
} else {
|
||||||
this.options = []
|
this.options = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryUserMetadataOptions(query, options) {
|
listMetadata(query, options) {
|
||||||
const that = this
|
const that = this
|
||||||
UserService.queryUserMetadataOptions(query).then(res => {
|
CuteUserSelectApi.listMetadata(query).then(res => {
|
||||||
that.options = res
|
that.options = res
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import UserService from '@/api/system/user'
|
import CuteUserSelectApi from '@/api/application/cute-user-select'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CuteUserSelect',
|
name: 'CuteUserSelect',
|
||||||
@@ -37,16 +37,11 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: false,
|
required: false,
|
||||||
default: null
|
default: null
|
||||||
},
|
|
||||||
dataSource: {
|
|
||||||
type: Array,
|
|
||||||
required: false,
|
|
||||||
default: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
users: this.value,
|
users: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
options: []
|
options: []
|
||||||
}
|
}
|
||||||
@@ -56,9 +51,11 @@ export default {
|
|||||||
this.users = newVal
|
this.users = newVal
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
if (this.dataSource && this.dataSource.length > 0) {
|
const that = this
|
||||||
this.options = this.dataSource
|
if (that.value && that.value.length > 0) {
|
||||||
|
that.options = await CuteUserSelectApi.listMetadataByUsernames(that.value)
|
||||||
|
that.users = that.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -67,15 +64,15 @@ export default {
|
|||||||
this.loading = true
|
this.loading = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.queryUserMetadataOptions(query)
|
this.listMetadata(query)
|
||||||
}, 200)
|
}, 200)
|
||||||
} else {
|
} else {
|
||||||
this.options = []
|
this.options = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
queryUserMetadataOptions(query, options) {
|
listMetadata(query, options) {
|
||||||
const that = this
|
const that = this
|
||||||
UserService.queryUserMetadataOptions(query).then(res => {
|
CuteUserSelectApi.listMetadata(query).then(res => {
|
||||||
that.options = res
|
that.options = res
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
user: null,
|
user: [],
|
||||||
dept: null,
|
dept: null,
|
||||||
productLine: null,
|
productLine: null,
|
||||||
productLinePro: null
|
productLinePro: null
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="文件上传" prop="fileUrl">
|
<el-form-item label="文件上传" prop="fileUrl">
|
||||||
<cute-file-drag-upload v-model="form" />
|
<cute-file-drag-upload v-model="form" mode="local" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('form')">提 交</el-button>
|
<el-button type="primary" @click="submitForm('form')">提 交</el-button>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="文件上传" prop="fileUrl">
|
<el-form-item label="文件上传" prop="fileUrl">
|
||||||
<cute-file-upload v-model="form" />
|
<cute-file-upload v-model="form" mode="local" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('form')">提 交</el-button>
|
<el-button type="primary" @click="submitForm('form')">提 交</el-button>
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import crudDictDetail from '@/api/system/dictDetail'
|
import crudDictDetail from '@/api/system/dict-detail'
|
||||||
import CRUD, { form, header, presenter } from '@crud/crud'
|
import CRUD, { form, header, presenter } from '@crud/crud'
|
||||||
import pagination from '@crud/Pagination'
|
import pagination from '@crud/Pagination'
|
||||||
import udOperation from '@crud/UD.operation'
|
import udOperation from '@crud/UD.operation'
|
||||||
|
|||||||
@@ -167,7 +167,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import crudJob from '@/api/system/quartzJob'
|
import crudJob from '@/api/system/quartz-job'
|
||||||
import Log from './log'
|
import Log from './log'
|
||||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||||
import rrOperation from '@crud/RR.operation'
|
import rrOperation from '@crud/RR.operation'
|
||||||
|
|||||||
@@ -125,7 +125,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import crudFile from '@/api/system/localStorage'
|
import crudFile from '@/api/system/local-storage'
|
||||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||||
import rrOperation from '@crud/RR.operation'
|
import rrOperation from '@crud/RR.operation'
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import crudFile from '@/api/system/ossStorage'
|
import crudFile from '@/api/system/oss-storage'
|
||||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||||
import rrOperation from '@crud/RR.operation'
|
import rrOperation from '@crud/RR.operation'
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>cutejava-framework</artifactId>
|
<artifactId>cutejava-framework</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>cutejava-module-system</artifactId>
|
<artifactId>cutejava-module-system</artifactId>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<artifactId>cutejava-framework</artifactId>
|
<artifactId>cutejava-framework</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
import cn.odboy.system.application.service.CuteDeptTreeService;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteDeptTree")
|
||||||
|
@RequestMapping("/api/component/CuteDeptTree")
|
||||||
|
public class CuteDeptTreeApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteDeptTreeService cuteDeptTreeService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
public ResponseEntity<List<CuteDeptTreeVo>> listMetadata(@Validated @RequestBody SystemQueryDeptArgs args) throws Exception {
|
||||||
|
List<CuteDeptTreeVo> depts = cuteDeptTreeService.listMetadata(args);
|
||||||
|
return ResponseEntity.ok(depts);
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteFileUploadService;
|
||||||
|
import cn.odboy.system.framework.operalog.OperationLog;
|
||||||
|
import cn.odboy.system.service.SystemOssStorageService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteFileUpload")
|
||||||
|
@RequestMapping("/api/component/CuteFileUpload")
|
||||||
|
public class CuteFileUploadApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteFileUploadService cuteFileUploadService;
|
||||||
|
@Autowired
|
||||||
|
private SystemOssStorageService systemOssStorageService;
|
||||||
|
|
||||||
|
@OperationLog
|
||||||
|
@ApiOperation("上传文件到服务器本地")
|
||||||
|
@PostMapping(value = "/uploadLocal")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<String> uploadLocal(@RequestParam("file") MultipartFile file) {
|
||||||
|
String fileUrl = cuteFileUploadService.uploadLocal(file);
|
||||||
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperationLog
|
||||||
|
@ApiOperation("上传文件到OSS")
|
||||||
|
@PostMapping(value = "/uploadOSS")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<String> uploadOSS(@RequestParam("file") MultipartFile file) {
|
||||||
|
String fileUrl = systemOssStorageService.uploadFile(file);
|
||||||
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteProductLineSelect")
|
||||||
|
@RequestMapping("/api/component/CuteProductLineSelect")
|
||||||
|
public class CuteProductLineSelectApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteProductLineSelectService cuteProductLineSelectService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择数据源")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> listMetadata() {
|
||||||
|
return ResponseEntity.ok(cuteProductLineSelectService.listMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteProductLineSelectPro")
|
||||||
|
@RequestMapping("/api/component/CuteProductLineSelectPro")
|
||||||
|
public class CuteProductLineSelectProApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteProductLineSelectProService cuteProductLineSelectProService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择Pro数据源")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> listMetadata() {
|
||||||
|
return ResponseEntity.ok(cuteProductLineSelectProService.listMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
import cn.odboy.system.application.service.CuteUserSelectService;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteUserSelect")
|
||||||
|
@RequestMapping("/api/component/CuteUserSelect")
|
||||||
|
public class CuteUserSelectApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteUserSelectService cuteUserSelectService;
|
||||||
|
|
||||||
|
@ApiOperation("查询用户基础数据")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<List<CuteUserSelectVo>> listMetadata(@Validated @RequestBody SystemQueryUserArgs args) {
|
||||||
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadata(args);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("根据用户名称集合查询用户基础数据")
|
||||||
|
@PostMapping(value = "/listMetadataByUsernames")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<List<CuteUserSelectVo>> listMetadataByUsernames(@RequestBody List<String> usernameList) {
|
||||||
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadataByUsernames(usernameList);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CuteDeptTreeVo extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 上级部门ID
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
/**
|
||||||
|
* 子节点数目
|
||||||
|
*/
|
||||||
|
private Integer subCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有子节点
|
||||||
|
*/
|
||||||
|
public Boolean getHasChildren() {
|
||||||
|
return subCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为叶子
|
||||||
|
*/
|
||||||
|
public Boolean getLeaf() {
|
||||||
|
return subCount <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签名称
|
||||||
|
*/
|
||||||
|
public String getLabel() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-4
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -22,9 +22,14 @@ import java.util.List;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SystemProductLineTreeVo extends KitObject {
|
public class CuteProductLineSelectProVo extends KitObject {
|
||||||
|
/**
|
||||||
|
* 部门ID(select的value)
|
||||||
|
*/
|
||||||
private String value;
|
private String value;
|
||||||
|
/**
|
||||||
|
* 产品线,如"研发部/华南分部/devops组"
|
||||||
|
*/
|
||||||
private String label;
|
private String label;
|
||||||
private List<SystemProductLineTreeVo> children;
|
private List<CuteProductLineSelectProVo> children;
|
||||||
}
|
}
|
||||||
+3
-3
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -21,12 +21,12 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SystemProductLineVo extends KitObject {
|
public class CuteProductLineSelectVo extends KitObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID(select的value)
|
* 部门ID(select的value)
|
||||||
*/
|
*/
|
||||||
private Long value;
|
private String value;
|
||||||
/**
|
/**
|
||||||
* 产品线,如"研发部/华南分部/devops组"
|
* 产品线,如"研发部/华南分部/devops组"
|
||||||
*/
|
*/
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CuteUserSelectVo extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* username
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
/**
|
||||||
|
* nickname
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private String deptId;
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CuteBaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptMapper systemDeptMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询启用的所有部门集合
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> listEnabledDept() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
|
import cn.odboy.system.service.SystemDeptService;
|
||||||
|
import cn.odboy.util.KitClassUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteDeptTreeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptService systemDeptService;
|
||||||
|
|
||||||
|
public List<CuteDeptTreeVo> listMetadata(SystemQueryDeptArgs args) throws Exception {
|
||||||
|
String dataScopeType = KitSecurityHelper.getDataScopeType();
|
||||||
|
if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) {
|
||||||
|
args.setPidIsNull(true);
|
||||||
|
}
|
||||||
|
List<Field> fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>());
|
||||||
|
List<String> fieldNames = new ArrayList<>() {{
|
||||||
|
add("pidIsNull");
|
||||||
|
add("enabled");
|
||||||
|
}};
|
||||||
|
for (Field field : fields) {
|
||||||
|
// 设置对象的访问权限, 保证对private的属性的访问
|
||||||
|
field.setAccessible(true);
|
||||||
|
Object val = field.get(args);
|
||||||
|
if (fieldNames.contains(field.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(val)) {
|
||||||
|
args.setPidIsNull(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 数据权限
|
||||||
|
args.setIds(KitSecurityHelper.getCurrentUserDataScope());
|
||||||
|
List<SystemDeptTb> list = systemDeptService.queryDeptByArgs(args);
|
||||||
|
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
||||||
|
if (StrUtil.isBlank(dataScopeType)) {
|
||||||
|
return systemDeptService.filterRootDeptList(list).stream().map(this::convertToVo).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return list.stream().map(this::convertToVo).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private CuteDeptTreeVo convertToVo(SystemDeptTb record) {
|
||||||
|
CuteDeptTreeVo treeVo = new CuteDeptTreeVo();
|
||||||
|
treeVo.setId(Long.toString(record.getId()));
|
||||||
|
treeVo.setName(record.getName());
|
||||||
|
treeVo.setPid(record.getPid() == null ? null : Long.toString(record.getPid()));
|
||||||
|
treeVo.setSubCount(record.getSubCount());
|
||||||
|
return treeVo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.odboy.framework.context.KitRequestHolder;
|
||||||
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
|
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemLocalStorageTb;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemLocalStorageMapper;
|
||||||
|
import cn.odboy.util.KitFileUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class CuteFileUploadService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemLocalStorageMapper systemLocalStorageMapper;
|
||||||
|
@Autowired
|
||||||
|
private KitFileLocalUploadHelper fileUploadPathHelper;
|
||||||
|
@Autowired
|
||||||
|
private AppProperties properties;
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String uploadLocal(MultipartFile multipartFile) {
|
||||||
|
long size = multipartFile.getSize();
|
||||||
|
KitFileUtil.checkSize(properties.getOss().getMaxSize(), size);
|
||||||
|
String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename());
|
||||||
|
String type = KitFileUtil.getFileType(suffix);
|
||||||
|
String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
|
||||||
|
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator);
|
||||||
|
if (file == null) {
|
||||||
|
throw new BadRequestException("上传失败");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String formatSize = KitFileUtil.getSize(size);
|
||||||
|
String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), null);
|
||||||
|
SystemLocalStorageTb localStorage = new SystemLocalStorageTb();
|
||||||
|
localStorage.setRealName(file.getName());
|
||||||
|
localStorage.setName(prefixName);
|
||||||
|
localStorage.setSuffix(suffix);
|
||||||
|
localStorage.setPath(file.getPath());
|
||||||
|
localStorage.setType(type);
|
||||||
|
localStorage.setSize(formatSize);
|
||||||
|
localStorage.setDateGroup(uploadDateStr);
|
||||||
|
systemLocalStorageMapper.insert(localStorage);
|
||||||
|
// 构建上传路径 /file/20260117/odboycn-20260117055246428.png
|
||||||
|
HttpServletRequest httpServletRequest = KitRequestHolder.getHttpServletRequest();
|
||||||
|
StringBuffer requestURL = httpServletRequest.getRequestURL();
|
||||||
|
String[] splits = requestURL.toString().split("/api/component/CuteFileUpload");
|
||||||
|
String requestAddress = splits[0];
|
||||||
|
return String.format("%s/file/%s/%s", requestAddress, uploadDateStr, localStorage.getRealName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("上传文件失败", e);
|
||||||
|
KitFileUtil.del(file);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteProductLineSelectProService extends CuteBaseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件Pro版 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteProductLineSelectProVo> listMetadata() {
|
||||||
|
List<SystemDeptTb> depts = this.listEnabledDept();
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<CuteProductLineSelectProVo> options = new ArrayList<>();
|
||||||
|
// 构建树形结构
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 只处理顶级部门(pid为null或0的部门)
|
||||||
|
if (dept.getPid() == null || dept.getPid() == 0) {
|
||||||
|
CuteProductLineSelectProVo vo = this.buildDeptTreePro(dept, deptMap);
|
||||||
|
options.add(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 按排序字段排序
|
||||||
|
options.sort(Comparator.comparingInt(o -> {
|
||||||
|
Long id = Long.valueOf(o.getValue());
|
||||||
|
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
||||||
|
}));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归构建部门树
|
||||||
|
*
|
||||||
|
* @param dept 当前部门
|
||||||
|
* @param deptMap 部门映射
|
||||||
|
* @return CuteProductLineSelectProVo 树节点
|
||||||
|
*/
|
||||||
|
private CuteProductLineSelectProVo buildDeptTreePro(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
CuteProductLineSelectProVo vo = new CuteProductLineSelectProVo();
|
||||||
|
vo.setValue(String.valueOf(dept.getId()));
|
||||||
|
vo.setLabel(dept.getName());
|
||||||
|
// 查找子部门
|
||||||
|
List<CuteProductLineSelectProVo> children = new ArrayList<>();
|
||||||
|
for (SystemDeptTb childDept : deptMap.values()) {
|
||||||
|
if (dept.getId().equals(childDept.getPid())) {
|
||||||
|
children.add(this.buildDeptTreePro(childDept, deptMap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 子部门按排序字段排序
|
||||||
|
children.sort(Comparator.comparingInt(o -> {
|
||||||
|
Long id = Long.valueOf(o.getValue());
|
||||||
|
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
||||||
|
}));
|
||||||
|
vo.setChildren(children);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteProductLineSelectVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteProductLineSelectService extends CuteBaseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteProductLineSelectVo> listMetadata() {
|
||||||
|
List<SystemDeptTb> depts = this.listEnabledDept();
|
||||||
|
return this.buildDeptMetadata(depts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CuteProductLineSelectVo> buildDeptMetadata(List<SystemDeptTb> depts) {
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<CuteProductLineSelectVo> options = new ArrayList<>();
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 构建部门ID路径
|
||||||
|
List<Long> pathIds = new ArrayList<>();
|
||||||
|
this.buildDeptIdPath(dept, deptMap, pathIds);
|
||||||
|
// 反转路径,从顶级部门到当前部门
|
||||||
|
Collections.reverse(pathIds);
|
||||||
|
CuteProductLineSelectVo dto = new CuteProductLineSelectVo();
|
||||||
|
dto.setValue(Long.toString(dept.getId()));
|
||||||
|
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
||||||
|
// 保留名称路径用于显示
|
||||||
|
dto.setLabel(this.buildNamePath(dept, deptMap));
|
||||||
|
options.add(dto);
|
||||||
|
}
|
||||||
|
// 按部门名称路径排序
|
||||||
|
options.sort(Comparator.comparing(CuteProductLineSelectVo::getLabel));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
||||||
|
pathIds.add(dept.getId());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
List<String> pathNames = new ArrayList<>();
|
||||||
|
this.buildDeptNamePath(dept, deptMap, pathNames);
|
||||||
|
Collections.reverse(pathNames);
|
||||||
|
return String.join(" / ", pathNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
||||||
|
pathNames.add(dept.getName());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteUserSelectService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemUserMapper systemUserMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询用户基础信息,限制返回的条数
|
||||||
|
*
|
||||||
|
* @param args 查询参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteUserSelectVo> listMetadata(SystemQueryUserArgs args) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
|
wrapper.and(c -> {
|
||||||
|
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.eq(SystemUserTb::getEmail, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.like(SystemUserTb::getUsername, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.like(SystemUserTb::getNickName, args.getBlurry());
|
||||||
|
});
|
||||||
|
return systemUserMapper.selectPage(new Page<>(1, 50), wrapper).convert(m -> {
|
||||||
|
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||||
|
selectVo.setValue(m.getUsername());
|
||||||
|
selectVo.setLabel(m.getNickName());
|
||||||
|
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||||
|
selectVo.setEmail(m.getEmail());
|
||||||
|
selectVo.setPhone(m.getPhone());
|
||||||
|
return selectVo;
|
||||||
|
}).getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CuteUserSelectVo> listMetadataByUsernames(List<String> usernameList) {
|
||||||
|
if (CollUtil.isEmpty(usernameList)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
|
wrapper.in(SystemUserTb::getUsername, usernameList);
|
||||||
|
return systemUserMapper.selectList(wrapper).stream().map(m -> {
|
||||||
|
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||||
|
selectVo.setValue(m.getUsername());
|
||||||
|
selectVo.setLabel(m.getNickName());
|
||||||
|
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||||
|
selectVo.setEmail(m.getEmail());
|
||||||
|
selectVo.setPhone(m.getPhone());
|
||||||
|
return selectVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-1
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.redis;
|
package cn.odboy.system.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关于缓存的Key集合
|
* 关于缓存的Key集合
|
||||||
@@ -28,4 +28,8 @@ public interface SystemCacheKey {
|
|||||||
* 登录验证码
|
* 登录验证码
|
||||||
*/
|
*/
|
||||||
String CAPTCHA_LOGIN = "captcha::login:";
|
String CAPTCHA_LOGIN = "captcha::login:";
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*/
|
||||||
|
String USER_INFO = "user::info:";
|
||||||
}
|
}
|
||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.controller;
|
|
||||||
|
|
||||||
import cn.odboy.system.service.SystemDeptService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Api(tags = "系统:组件数据源")
|
|
||||||
@RequestMapping("/api/component")
|
|
||||||
public class SystemComponentController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SystemDeptService systemDeptService;
|
|
||||||
|
|
||||||
@ApiOperation("查询部门下拉选择数据源")
|
|
||||||
@PostMapping(value = "/listDeptSelectDataSource")
|
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> listDeptSelectDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.listDeptSelectDataSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("查询部门下拉选择Pro数据源")
|
|
||||||
@PostMapping(value = "/listDeptSelectProDataSource")
|
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> listDeptSelectProDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.listDeptSelectProDataSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -68,7 +68,7 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/listMenuByPid")
|
@PostMapping(value = "/listMenuByPid")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
||||||
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid);
|
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid, false);
|
||||||
return ResponseEntity.ok(systemMenuTbs);
|
return ResponseEntity.ok(systemMenuTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-9
@@ -17,7 +17,6 @@ package cn.odboy.system.controller;
|
|||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
import cn.odboy.system.dal.model.request.SystemUpdateUserPasswordArgs;
|
import cn.odboy.system.dal.model.request.SystemUpdateUserPasswordArgs;
|
||||||
@@ -43,7 +42,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Api(tags = "系统:用户管理")
|
@Api(tags = "系统:用户管理")
|
||||||
@@ -141,13 +139,6 @@ public class SystemUserController {
|
|||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询用户基础数据")
|
|
||||||
@PostMapping(value = "/queryUserMetadataOptions")
|
|
||||||
@PreAuthorize("@el.check('user:list')")
|
|
||||||
public ResponseEntity<List<KitSelectOptionVo>> queryUserMetadataOptions(@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
|
||||||
List<KitSelectOptionVo> collect = systemUserService.queryUserMetadataOptions(args);
|
|
||||||
return ResponseEntity.ok(collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户信息")
|
@ApiOperation("获取用户信息")
|
||||||
@PostMapping(value = "/getCurrentUserInfo")
|
@PostMapping(value = "/getCurrentUserInfo")
|
||||||
|
|||||||
+11
@@ -43,31 +43,42 @@ public class SystemUserTb extends KitBaseUserTimeTb {
|
|||||||
private Long deptId;
|
private Long deptId;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "用户名称")
|
@ApiModelProperty(value = "用户名称")
|
||||||
|
@TableField(value = "username")
|
||||||
private String username;
|
private String username;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "用户昵称")
|
@ApiModelProperty(value = "用户昵称")
|
||||||
|
@TableField(value = "nick_name")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
@Email
|
@Email
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "邮箱")
|
@ApiModelProperty(value = "邮箱")
|
||||||
|
@TableField(value = "email")
|
||||||
private String email;
|
private String email;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "电话号码")
|
@ApiModelProperty(value = "电话号码")
|
||||||
|
@TableField(value = "phone")
|
||||||
private String phone;
|
private String phone;
|
||||||
@ApiModelProperty(value = "用户性别")
|
@ApiModelProperty(value = "用户性别")
|
||||||
|
@TableField(value = "gender")
|
||||||
private String gender;
|
private String gender;
|
||||||
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
||||||
|
@TableField(value = "avatar_name")
|
||||||
private String avatarName;
|
private String avatarName;
|
||||||
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
||||||
|
@TableField(value = "avatar_path")
|
||||||
private String avatarPath;
|
private String avatarPath;
|
||||||
@ApiModelProperty(value = "密码")
|
@ApiModelProperty(value = "密码")
|
||||||
|
@TableField(value = "password")
|
||||||
private String password;
|
private String password;
|
||||||
@NotNull
|
@NotNull
|
||||||
@ApiModelProperty(value = "是否启用")
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
@TableField(value = "enabled")
|
||||||
private Boolean enabled;
|
private Boolean enabled;
|
||||||
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
||||||
|
@TableField(value = "is_admin")
|
||||||
private Boolean isAdmin = false;
|
private Boolean isAdmin = false;
|
||||||
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
||||||
|
@TableField(value = "pwd_reset_time")
|
||||||
private Date pwdResetTime;
|
private Date pwdResetTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-1
@@ -16,6 +16,7 @@
|
|||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.dal.model.response;
|
||||||
|
|
||||||
import cn.odboy.base.KitBaseUserTimeTb;
|
import cn.odboy.base.KitBaseUserTimeTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@@ -60,7 +61,7 @@ public class SystemUserVo extends KitBaseUserTimeTb {
|
|||||||
* 扩展字段
|
* 扩展字段
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户部门")
|
@ApiModelProperty(value = "用户部门")
|
||||||
private SystemDeptVo dept;
|
private SystemDeptTb dept;
|
||||||
@ApiModelProperty(value = "用户角色")
|
@ApiModelProperty(value = "用户角色")
|
||||||
private Set<SystemRoleTb> roles;
|
private Set<SystemRoleTb> roles;
|
||||||
@ApiModelProperty(value = "用户岗位")
|
@ApiModelProperty(value = "用户岗位")
|
||||||
|
|||||||
-69
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.dal.redis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关于缓存的Key集合
|
|
||||||
*/
|
|
||||||
public interface SystemRedisKey {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*/
|
|
||||||
String USER_ID = "user::id:";
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
String DATA_USER = "data::user:";
|
|
||||||
/**
|
|
||||||
* 菜单
|
|
||||||
*/
|
|
||||||
String MENU_ID = "menu::id:";
|
|
||||||
String MENU_USER = "menu::user:";
|
|
||||||
/**
|
|
||||||
* 角色授权
|
|
||||||
*/
|
|
||||||
String ROLE_AUTH = "role::auth:";
|
|
||||||
String ROLE_USER = "role::user:";
|
|
||||||
/**
|
|
||||||
* 角色信息
|
|
||||||
*/
|
|
||||||
String ROLE_ID = "role::id:";
|
|
||||||
/**
|
|
||||||
* 部门
|
|
||||||
*/
|
|
||||||
String DEPT_ID = "dept::id:";
|
|
||||||
/**
|
|
||||||
* 岗位
|
|
||||||
*/
|
|
||||||
String JOB_ID = "job::id:";
|
|
||||||
/**
|
|
||||||
* 数据字典
|
|
||||||
*/
|
|
||||||
String DICT_NAME = "dict::name:";
|
|
||||||
/**
|
|
||||||
* 在线用户
|
|
||||||
*/
|
|
||||||
String ONLINE_USER = "online::token:";
|
|
||||||
/**
|
|
||||||
* 登录验证码
|
|
||||||
*/
|
|
||||||
String CAPTCHA_LOGIN = "captcha::login:";
|
|
||||||
/**
|
|
||||||
* 用户信息
|
|
||||||
*/
|
|
||||||
String USER_INFO = "user::info:";
|
|
||||||
}
|
|
||||||
+4
-3
@@ -18,6 +18,7 @@ package cn.odboy.system.dal.redis;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@@ -42,7 +43,7 @@ public class SystemUserInfoDAO {
|
|||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 添加数据, 避免数据同时过期(2小时左右)
|
// 添加数据, 避免数据同时过期(2小时左右)
|
||||||
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
||||||
redisHelper.set(SystemRedisKey.USER_INFO + userName, user, time);
|
redisHelper.set(SystemCacheKey.USER_INFO + userName, user, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class SystemUserInfoDAO {
|
|||||||
public void deleteUserLoginInfoByUserName(String userName) {
|
public void deleteUserLoginInfoByUserName(String userName) {
|
||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 清除数据
|
// 清除数据
|
||||||
redisHelper.del(SystemRedisKey.USER_INFO + userName);
|
redisHelper.del(SystemCacheKey.USER_INFO + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class SystemUserInfoDAO {
|
|||||||
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
||||||
if (StrUtil.isNotEmpty(username)) {
|
if (StrUtil.isNotEmpty(username)) {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
return redisHelper.get(SystemRedisKey.USER_INFO + username, SystemUserJwtVo.class);
|
return redisHelper.get(SystemCacheKey.USER_INFO + username, SystemUserJwtVo.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -19,6 +19,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo;
|
import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserOnlineVo;
|
import cn.odboy.system.dal.model.response.SystemUserOnlineVo;
|
||||||
@@ -122,7 +123,7 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @param username /
|
* @param username /
|
||||||
*/
|
*/
|
||||||
public void kickOutByUsername(String username) {
|
public void kickOutByUsername(String username) {
|
||||||
String loginKey = SystemRedisKey.ONLINE_USER + username + "*";
|
String loginKey = SystemCacheKey.ONLINE_USER + username + "*";
|
||||||
redisHelper.scanDel(loginKey);
|
redisHelper.scanDel(loginKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,15 +134,13 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @param pageable /
|
* @param pageable /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo,
|
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo, IPage<SystemUserOnlineVo> pageable) {
|
||||||
IPage<SystemUserOnlineVo> pageable) {
|
|
||||||
String username = null;
|
String username = null;
|
||||||
if (onlineVo != null) {
|
if (onlineVo != null) {
|
||||||
username = onlineVo.getUserName();
|
username = onlineVo.getUserName();
|
||||||
}
|
}
|
||||||
List<SystemUserOnlineVo> onlineUserList = queryUserOnlineModelListByUsername(username);
|
List<SystemUserOnlineVo> onlineUserList = this.queryUserOnlineModelListByUsername(username);
|
||||||
List<SystemUserOnlineVo> paging =
|
List<SystemUserOnlineVo> paging = KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
||||||
KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
|
||||||
return KitPageUtil.toPage(paging, onlineUserList.size());
|
return KitPageUtil.toPage(paging, onlineUserList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +151,7 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
||||||
String loginKey = SystemRedisKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
String loginKey = SystemCacheKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
||||||
List<String> keys = redisHelper.scan(loginKey + "*");
|
List<String> keys = redisHelper.scan(loginKey + "*");
|
||||||
Collections.reverse(keys);
|
Collections.reverse(keys);
|
||||||
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import cn.odboy.constant.SystemConst;
|
|||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import cn.odboy.system.dal.redis.SystemCacheKey;
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.JwtParser;
|
import io.jsonwebtoken.JwtParser;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
|
|||||||
+1
-1
@@ -22,8 +22,8 @@ import cn.odboy.constant.SystemConst;
|
|||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.response.SystemCaptchaVo;
|
import cn.odboy.system.dal.model.response.SystemCaptchaVo;
|
||||||
import cn.odboy.system.dal.redis.SystemCacheKey;
|
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
+150
-223
@@ -27,8 +27,6 @@ import cn.odboy.system.dal.model.export.SystemDeptExportRowVo;
|
|||||||
import cn.odboy.system.dal.model.request.SystemCreateDeptArgs;
|
import cn.odboy.system.dal.model.request.SystemCreateDeptArgs;
|
||||||
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
import cn.odboy.system.dal.model.response.SystemDeptVo;
|
import cn.odboy.system.dal.model.response.SystemDeptVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemProductLineTreeVo;
|
|
||||||
import cn.odboy.system.dal.model.response.SystemProductLineVo;
|
|
||||||
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.util.KitBeanUtil;
|
import cn.odboy.util.KitBeanUtil;
|
||||||
@@ -42,14 +40,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -99,16 +94,6 @@ public class SystemDeptService {
|
|||||||
this.updateDeptSubCnt(newPid);
|
this.updateDeptSubCnt(newPid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门id查询部门信息 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param id 部门id
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private SystemDeptTb getDeptById(Long id) {
|
|
||||||
return systemDeptMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*
|
*
|
||||||
@@ -117,10 +102,10 @@ public class SystemDeptService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteDeptByIds(Set<Long> ids) {
|
public void deleteDeptByIds(Set<Long> ids) {
|
||||||
// 查询部门, 和其所有子部门
|
// 查询部门, 和其所有子部门
|
||||||
Set<SystemDeptVo> depts = this.traverseDeptByIdWithPids(ids);
|
Set<SystemDeptTb> depts = this.traverseDeptByIdWithPids(ids);
|
||||||
// 验证是否被角色或用户关联
|
// 验证是否被角色或用户关联
|
||||||
this.verifyBindRelationByIds(depts);
|
this.verifyBindRelationByIds(depts);
|
||||||
for (SystemDeptVo dept : depts) {
|
for (SystemDeptTb dept : depts) {
|
||||||
systemDeptMapper.deleteById(dept.getId());
|
systemDeptMapper.deleteById(dept.getId());
|
||||||
this.updateDeptSubCnt(dept.getPid());
|
this.updateDeptSubCnt(dept.getPid());
|
||||||
}
|
}
|
||||||
@@ -139,43 +124,6 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countDeptByPid(Long pid) {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemDeptTb::getPid, pid);
|
|
||||||
return systemDeptMapper.selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
|
||||||
*/
|
|
||||||
private List<SystemDeptTb> deduplication(List<SystemDeptTb> list) {
|
|
||||||
List<SystemDeptTb> deptList = new ArrayList<>();
|
|
||||||
// 使用 Set 存储所有部门的 id
|
|
||||||
Set<Long> idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
|
||||||
// 遍历部门列表, 筛选出没有父部门的部门
|
|
||||||
for (SystemDeptTb dept : list) {
|
|
||||||
if (!idSet.contains(dept.getPid())) {
|
|
||||||
deptList.add(dept);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return deptList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
|
|
||||||
KitValidUtil.notNull(args);
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
|
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName());
|
|
||||||
wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled());
|
|
||||||
wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid());
|
|
||||||
wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid);
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemDeptTb::getDeptSort);
|
|
||||||
return systemDeptMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据
|
* 查询所有数据
|
||||||
*
|
*
|
||||||
@@ -213,41 +161,17 @@ public class SystemDeptService {
|
|||||||
List<SystemDeptTb> list = this.queryDeptByArgs(args);
|
List<SystemDeptTb> list = this.queryDeptByArgs(args);
|
||||||
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
||||||
if (StrUtil.isBlank(dataScopeType)) {
|
if (StrUtil.isBlank(dataScopeType)) {
|
||||||
return this.deduplication(list);
|
return this.filterRootDeptList(list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询
|
* 根据部门id遍历所有部门和子部门id集合
|
||||||
*
|
*
|
||||||
* @param id /
|
* @param deptList 部门集合
|
||||||
* @return /
|
* @param deptPidMap 父部门id和子部门集合的映射关系
|
||||||
*/
|
*/
|
||||||
public SystemDeptVo getDeptVoById(Long id) {
|
|
||||||
return KitBeanUtil.copyToClass(systemDeptMapper.selectById(id), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询部门下所有关联的部门
|
|
||||||
*
|
|
||||||
* @param deptTbList /
|
|
||||||
* @param depts /
|
|
||||||
*/
|
|
||||||
private void queryRelationDeptByArgs(List<SystemDeptVo> deptTbList, Set<SystemDeptVo> depts) {
|
|
||||||
for (SystemDeptVo dept : deptTbList) {
|
|
||||||
depts.add(dept);
|
|
||||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(dept.getId());
|
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
|
||||||
queryRelationDeptByArgs(deptList, depts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemDeptVo> listDeptVoByPid(Long pid) {
|
|
||||||
return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Long> queryChildDeptIdByDeptIds(List<SystemDeptTb> deptList, Map<Long, List<SystemDeptTb>> deptPidMap) {
|
public List<Long> queryChildDeptIdByDeptIds(List<SystemDeptTb> deptList, Map<Long, List<SystemDeptTb>> deptPidMap) {
|
||||||
List<Long> list = new ArrayList<>();
|
List<Long> list = new ArrayList<>();
|
||||||
for (SystemDeptTb systemDeptTb : deptList) {
|
for (SystemDeptTb systemDeptTb : deptList) {
|
||||||
@@ -262,42 +186,21 @@ public class SystemDeptService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID查询同级与上级数据
|
|
||||||
*
|
|
||||||
* @param dept /
|
|
||||||
* @param deptList /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private List<SystemDeptVo> querySuperiorDeptByPid(SystemDeptVo dept, List<SystemDeptVo> deptList) {
|
|
||||||
if (dept.getPid() == null) {
|
|
||||||
deptList.addAll(this.listRootDept());
|
|
||||||
return deptList;
|
|
||||||
}
|
|
||||||
deptList.addAll(this.listDeptVoByPid(dept.getPid()));
|
|
||||||
return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemDeptVo> listRootDept() {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(SystemDeptTb::getPid);
|
|
||||||
return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建树形数据
|
* 构建树形数据
|
||||||
*
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDeptVo> searchDeptTree(List<Long> ids, Boolean exclude) {
|
public KitPageResult<SystemDeptVo> searchDeptTree(List<Long> ids, Boolean exclude) {
|
||||||
Set<SystemDeptVo> deptSet1 = new LinkedHashSet<>();
|
Map<Long, SystemDeptTb> allDeptMap = this.getAllDeptMap();
|
||||||
|
Set<SystemDeptTb> deptSet1 = new LinkedHashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
// 同级数据
|
// 同级数据
|
||||||
SystemDeptVo dept = this.getDeptVoById(id);
|
SystemDeptTb dept = allDeptMap.get(id);
|
||||||
// 上级数据
|
// 上级数据
|
||||||
List<SystemDeptVo> depts = this.querySuperiorDeptByPid(dept, new ArrayList<>());
|
List<SystemDeptTb> depts = this.querySuperiorDeptByPid(dept, new ArrayList<>(), allDeptMap);
|
||||||
if (exclude) {
|
if (exclude) {
|
||||||
for (SystemDeptVo data : depts) {
|
for (SystemDeptTb data : depts) {
|
||||||
if (data.getId().equals(dept.getPid())) {
|
if (data.getId().equals(dept.getPid())) {
|
||||||
data.setSubCount(data.getSubCount() - 1);
|
data.setSubCount(data.getSubCount() - 1);
|
||||||
}
|
}
|
||||||
@@ -307,18 +210,20 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
deptSet1.addAll(depts);
|
deptSet1.addAll(depts);
|
||||||
}
|
}
|
||||||
List<SystemDeptVo> deptList = new ArrayList<>(deptSet1);
|
List<SystemDeptTb> deptList = new ArrayList<>(deptSet1);
|
||||||
// 构建部门树
|
// 构建部门树
|
||||||
Set<SystemDeptVo> trees = new LinkedHashSet<>();
|
Set<SystemDeptVo> trees = new LinkedHashSet<>();
|
||||||
Set<SystemDeptVo> deptSet = new LinkedHashSet<>();
|
Set<SystemDeptVo> deptSet = new LinkedHashSet<>();
|
||||||
List<String> deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList());
|
List<String> deptNames = deptList.stream().map(SystemDeptTb::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
boolean isChild;
|
boolean isChild;
|
||||||
for (SystemDeptVo dept : deptList) {
|
List<SystemDeptVo> systemDeptVos = KitBeanUtil.copyToList(deptList, SystemDeptVo.class);
|
||||||
|
for (SystemDeptVo dept : systemDeptVos) {
|
||||||
isChild = false;
|
isChild = false;
|
||||||
if (dept.getPid() == null) {
|
if (dept.getPid() == null) {
|
||||||
trees.add(dept);
|
trees.add(dept);
|
||||||
}
|
}
|
||||||
for (SystemDeptVo it : deptList) {
|
for (SystemDeptVo it : systemDeptVos) {
|
||||||
if (it.getPid() != null && dept.getId().equals(it.getPid())) {
|
if (it.getPid() != null && dept.getId().equals(it.getPid())) {
|
||||||
isChild = true;
|
isChild = true;
|
||||||
if (dept.getChildren() == null) {
|
if (dept.getChildren() == null) {
|
||||||
@@ -329,7 +234,7 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
if (isChild) {
|
if (isChild) {
|
||||||
deptSet.add(dept);
|
deptSet.add(dept);
|
||||||
} else if (dept.getPid() != null && !deptNames.contains(this.getDeptVoById(dept.getPid()).getName())) {
|
} else if (dept.getPid() != null && !deptNames.contains(allDeptMap.get(dept.getPid()).getName())) {
|
||||||
deptSet.add(dept);
|
deptSet.add(dept);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,13 +247,18 @@ public class SystemDeptService {
|
|||||||
return baseResult;
|
return baseResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<Long, SystemDeptTb> getAllDeptMap() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
return systemDeptMapper.selectList(wrapper).stream().collect(Collectors.toMap(SystemDeptTb::getId, i -> i, (m, n) -> m));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证是否被角色或用户关联
|
* 验证是否被角色或用户关联
|
||||||
*
|
*
|
||||||
* @param deptSet /
|
* @param deptSet /
|
||||||
*/
|
*/
|
||||||
public void verifyBindRelationByIds(Set<SystemDeptVo> deptSet) {
|
public void verifyBindRelationByIds(Set<SystemDeptTb> deptSet) {
|
||||||
Set<Long> deptIds = deptSet.stream().map(SystemDeptVo::getId).collect(Collectors.toSet());
|
Set<Long> deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) {
|
if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) {
|
||||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||||
}
|
}
|
||||||
@@ -357,135 +267,43 @@ public class SystemDeptService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SystemDeptTb> listEnabledDepts() {
|
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
|
||||||
return systemDeptMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 遍历所有部门和子部门
|
* 根据部门id遍历所有部门和子部门
|
||||||
*
|
*
|
||||||
* @param ids /
|
* @param ids 部门id集合
|
||||||
*/
|
*/
|
||||||
public Set<SystemDeptVo> traverseDeptByIdWithPids(Set<Long> ids) {
|
public Set<SystemDeptTb> traverseDeptByIdWithPids(Set<Long> ids) {
|
||||||
Set<SystemDeptVo> depts = new HashSet<>();
|
Set<SystemDeptTb> depts = new HashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
// 根部门
|
// 根部门
|
||||||
depts.add(this.getDeptVoById(id));
|
depts.add(systemDeptMapper.selectById(id));
|
||||||
// 子部门
|
// 子部门
|
||||||
List<SystemDeptVo> deptList = this.listDeptVoByPid(id);
|
List<SystemDeptTb> deptList = this.listDeptByPid(id);
|
||||||
if (CollUtil.isNotEmpty(deptList)) {
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
queryRelationDeptByArgs(deptList, depts);
|
this.queryRelationDeptByArgs(deptList, depts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemProductLineVo> listDeptSelectDataSource() {
|
|
||||||
List<SystemDeptTb> depts = this.listEnabledDepts();
|
|
||||||
return buildDeptSelectOptions(depts);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemProductLineVo> buildDeptSelectOptions(List<SystemDeptTb> depts) {
|
|
||||||
// 查询所有部门并按父子关系组织
|
|
||||||
Map<Long, SystemDeptTb> deptMap =
|
|
||||||
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
|
||||||
List<SystemProductLineVo> options = new ArrayList<>();
|
|
||||||
for (SystemDeptTb dept : depts) {
|
|
||||||
// 构建部门ID路径
|
|
||||||
List<Long> pathIds = new ArrayList<>();
|
|
||||||
buildDeptIdPath(dept, deptMap, pathIds);
|
|
||||||
// 反转路径,从顶级部门到当前部门
|
|
||||||
Collections.reverse(pathIds);
|
|
||||||
SystemProductLineVo dto = new SystemProductLineVo();
|
|
||||||
dto.setValue(dept.getId());
|
|
||||||
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
|
||||||
// 保留名称路径用于显示
|
|
||||||
dto.setLabel(buildNamePath(dept, deptMap));
|
|
||||||
options.add(dto);
|
|
||||||
}
|
|
||||||
// 按部门名称路径排序
|
|
||||||
options.sort(Comparator.comparing(SystemProductLineVo::getLabel));
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
|
||||||
pathIds.add(dept.getId());
|
|
||||||
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
|
||||||
buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
|
||||||
List<String> pathNames = new ArrayList<>();
|
|
||||||
buildDeptNamePath(dept, deptMap, pathNames);
|
|
||||||
Collections.reverse(pathNames);
|
|
||||||
return String.join(" / ", pathNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
|
||||||
pathNames.add(dept.getName());
|
|
||||||
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
|
||||||
buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SystemProductLineTreeVo> listDeptSelectProDataSource() {
|
|
||||||
List<SystemDeptTb> depts = this.listEnabledDepts();
|
|
||||||
// 查询所有部门并按父子关系组织
|
|
||||||
Map<Long, SystemDeptTb> deptMap =
|
|
||||||
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
|
||||||
List<SystemProductLineTreeVo> options = new ArrayList<>();
|
|
||||||
// 构建树形结构
|
|
||||||
for (SystemDeptTb dept : depts) {
|
|
||||||
// 只处理顶级部门(pid为null或0的部门)
|
|
||||||
if (dept.getPid() == null || dept.getPid() == 0) {
|
|
||||||
SystemProductLineTreeVo vo = buildDeptTreePro(dept, deptMap);
|
|
||||||
options.add(vo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 按排序字段排序
|
|
||||||
options.sort(Comparator.comparingInt(o -> {
|
|
||||||
Long id = Long.valueOf(o.getValue());
|
|
||||||
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
|
||||||
}));
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归构建部门树
|
* 根据父部门id查询部门集合
|
||||||
*
|
*
|
||||||
* @param dept 当前部门
|
* @param pid 父部门id
|
||||||
* @param deptMap 部门映射
|
* @return /
|
||||||
* @return SystemProductLineTreeVo 树节点
|
|
||||||
*/
|
*/
|
||||||
private SystemProductLineTreeVo buildDeptTreePro(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
|
||||||
SystemProductLineTreeVo vo = new SystemProductLineTreeVo();
|
|
||||||
vo.setValue(String.valueOf(dept.getId()));
|
|
||||||
vo.setLabel(dept.getName());
|
|
||||||
// 查找子部门
|
|
||||||
List<SystemProductLineTreeVo> children = new ArrayList<>();
|
|
||||||
for (SystemDeptTb childDept : deptMap.values()) {
|
|
||||||
if (dept.getId().equals(childDept.getPid())) {
|
|
||||||
children.add(buildDeptTreePro(childDept, deptMap));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 子部门按排序字段排序
|
|
||||||
children.sort(Comparator.comparingInt(o -> {
|
|
||||||
Long id = Long.valueOf(o.getValue());
|
|
||||||
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
|
||||||
}));
|
|
||||||
vo.setChildren(children);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SystemDeptTb> listDeptByPid(long pid) {
|
public List<SystemDeptTb> listDeptByPid(long pid) {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDeptTb::getPid, pid);
|
wrapper.eq(SystemDeptTb::getPid, pid);
|
||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出部门数据
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args /
|
||||||
|
*/
|
||||||
public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
|
public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
|
||||||
List<SystemDeptTb> systemDeptTbs = this.queryAllDeptByArgs(args, false);
|
List<SystemDeptTb> systemDeptTbs = this.queryAllDeptByArgs(args, false);
|
||||||
List<SystemDeptExportRowVo> rowVos = new ArrayList<>();
|
List<SystemDeptExportRowVo> rowVos = new ArrayList<>();
|
||||||
@@ -499,10 +317,119 @@ public class SystemDeptService {
|
|||||||
KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询父部门非空且启用的部门数据
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public List<SystemDeptTb> listPidNonNull() {
|
public List<SystemDeptTb> listPidNonNull() {
|
||||||
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
wrapper.isNotNull(SystemDeptTb::getPid);
|
wrapper.isNotNull(SystemDeptTb::getPid);
|
||||||
return systemDeptMapper.selectList(wrapper);
|
return systemDeptMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询部门下所有关联的部门
|
||||||
|
*
|
||||||
|
* @param deptTbList /
|
||||||
|
* @param depts /
|
||||||
|
*/
|
||||||
|
private void queryRelationDeptByArgs(List<SystemDeptTb> deptTbList, Set<SystemDeptTb> depts) {
|
||||||
|
for (SystemDeptTb dept : deptTbList) {
|
||||||
|
depts.add(dept);
|
||||||
|
List<SystemDeptTb> deptList = this.listDeptByPid(dept.getId());
|
||||||
|
if (CollUtil.isNotEmpty(deptList)) {
|
||||||
|
this.queryRelationDeptByArgs(deptList, depts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询同级与上级数据
|
||||||
|
*
|
||||||
|
* @param dept /
|
||||||
|
* @param deptList /
|
||||||
|
* @param allDeptMap
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemDeptTb> querySuperiorDeptByPid(SystemDeptTb dept, List<SystemDeptTb> deptList, Map<Long, SystemDeptTb> allDeptMap) {
|
||||||
|
if (dept.getPid() == null) {
|
||||||
|
deptList.addAll(this.listRootDept());
|
||||||
|
return deptList;
|
||||||
|
}
|
||||||
|
deptList.addAll(this.listDeptByPid(dept.getPid()));
|
||||||
|
return querySuperiorDeptByPid(allDeptMap.get(dept.getPid()), deptList, allDeptMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有根部门
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private List<SystemDeptTb> listRootDept() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(SystemDeptTb::getPid);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门id查询部门信息 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param id 部门id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public SystemDeptTb getDeptById(Long id) {
|
||||||
|
return systemDeptMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父部门id统计数量
|
||||||
|
*
|
||||||
|
* @param pid 父部门id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private long countDeptByPid(Long pid) {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getPid, pid);
|
||||||
|
return systemDeptMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> filterRootDeptList(List<SystemDeptTb> list) {
|
||||||
|
List<SystemDeptTb> deptList = new ArrayList<>();
|
||||||
|
// 使用 Set 存储所有部门的 id
|
||||||
|
Set<Long> idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet());
|
||||||
|
// 遍历部门列表, 筛选出没有父部门的部门
|
||||||
|
for (SystemDeptTb dept : list) {
|
||||||
|
if (!idSet.contains(dept.getPid())) {
|
||||||
|
deptList.add(dept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deptList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据复杂条件查询部门集合
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> queryDeptByArgs(SystemQueryDeptArgs args) {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds());
|
||||||
|
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName());
|
||||||
|
wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled());
|
||||||
|
wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid());
|
||||||
|
wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid);
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemDeptTb::getDeptSort);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -84,6 +84,11 @@ public class SystemDictDetailService {
|
|||||||
systemDictDetailMapper.deleteById(id);
|
systemDictDetailMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典id集合删除字典明细
|
||||||
|
*
|
||||||
|
* @param ids 字典id集合
|
||||||
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteDictDetailByDictIds(Set<Long> ids) {
|
public void deleteDictDetailByDictIds(Set<Long> ids) {
|
||||||
if (CollUtil.isNotEmpty(ids)) {
|
if (CollUtil.isNotEmpty(ids)) {
|
||||||
@@ -100,8 +105,10 @@ public class SystemDictDetailService {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemDictDetailVo> searchDictDetail(SystemQueryDictDetailArgs args,
|
public KitPageResult<SystemDictDetailVo> searchDictDetail(
|
||||||
Page<SystemDictDetailTb> page) {
|
SystemQueryDictDetailArgs args,
|
||||||
|
Page<SystemDictDetailTb> page
|
||||||
|
) {
|
||||||
IPage<SystemDictDetailVo> iPage = systemDictDetailMapper.selectPageByArgs(page, args);
|
IPage<SystemDictDetailVo> iPage = systemDictDetailMapper.selectPageByArgs(page, args);
|
||||||
List<Long> dictIds =
|
List<Long> dictIds =
|
||||||
iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList());
|
iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList());
|
||||||
|
|||||||
+25
-7
@@ -96,19 +96,24 @@ public class SystemDictService {
|
|||||||
return KitPageUtil.toPage(selectPage);
|
return KitPageUtil.toPage(selectPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
/**
|
||||||
if (args != null) {
|
* 复杂条件查询字典列表
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
*
|
||||||
.like(SystemDictTb::getDescription, args.getBlurry()));
|
* @param args /
|
||||||
}
|
* @return /
|
||||||
}
|
*/
|
||||||
|
|
||||||
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
public List<SystemDictTb> queryDictByArgs(SystemQueryDictArgs args) {
|
||||||
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemDictTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
this.injectQueryParams(args, wrapper);
|
this.injectQueryParams(args, wrapper);
|
||||||
return systemDictMapper.selectList(wrapper);
|
return systemDictMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出字典数据
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args /
|
||||||
|
*/
|
||||||
public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) {
|
public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) {
|
||||||
List<SystemDictTb> systemDictTbs = this.queryDictByArgs(args);
|
List<SystemDictTb> systemDictTbs = this.queryDictByArgs(args);
|
||||||
List<SystemDictExportRowVo> rowVos = new ArrayList<>();
|
List<SystemDictExportRowVo> rowVos = new ArrayList<>();
|
||||||
@@ -136,4 +141,17 @@ public class SystemDictService {
|
|||||||
}
|
}
|
||||||
KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper<SystemDictTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or()
|
||||||
|
.like(SystemDictTb::getDescription, args.getBlurry()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-13
@@ -108,19 +108,6 @@ public class SystemEmailService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验邮箱验证码 -> TestPassed
|
|
||||||
*/
|
|
||||||
public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) {
|
|
||||||
String redisKey = biEnum.getRedisKey() + email;
|
|
||||||
String value = redisHelper.get(redisKey, String.class);
|
|
||||||
if (value == null || !value.equals(code)) {
|
|
||||||
throw new BadRequestException("无效验证码");
|
|
||||||
} else {
|
|
||||||
redisHelper.del(redisKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送给邮箱验证码
|
* 发送给邮箱验证码
|
||||||
*/
|
*/
|
||||||
@@ -148,11 +135,19 @@ public class SystemEmailService {
|
|||||||
sendEmail(sendEmailRequest);
|
sendEmail(sendEmailRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮箱配置
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemEmailConfigTb getLastEmailConfig() {
|
public SystemEmailConfigTb getLastEmailConfig() {
|
||||||
SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L);
|
SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L);
|
||||||
return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb;
|
return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验邮箱验证码 -> TestPassed
|
||||||
|
*/
|
||||||
public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) {
|
public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) {
|
||||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
||||||
if (biEnum == null) {
|
if (biEnum == null) {
|
||||||
@@ -160,4 +155,14 @@ public class SystemEmailService {
|
|||||||
}
|
}
|
||||||
this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode());
|
this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) {
|
||||||
|
String redisKey = biEnum.getRedisKey() + email;
|
||||||
|
String value = redisHelper.get(redisKey, String.class);
|
||||||
|
if (value == null || !value.equals(code)) {
|
||||||
|
throw new BadRequestException("无效验证码");
|
||||||
|
} else {
|
||||||
|
redisHelper.del(redisKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-16
@@ -119,6 +119,22 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出岗位数据 -> TestPassed
|
||||||
|
*/
|
||||||
|
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
|
||||||
|
List<SystemJobTb> systemJobTbs = this.queryJobByArgs(args);
|
||||||
|
List<SystemJobExportRowVo> rowVos = new ArrayList<>();
|
||||||
|
for (SystemJobTb dataObject : systemJobTbs) {
|
||||||
|
SystemJobExportRowVo rowVo = new SystemJobExportRowVo();
|
||||||
|
rowVo.setName(dataObject.getName());
|
||||||
|
rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用");
|
||||||
|
rowVo.setCreateTime(dataObject.getCreateTime());
|
||||||
|
rowVos.add(rowVo);
|
||||||
|
}
|
||||||
|
KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据岗位名称查询岗位是否存在 -> TestPassed
|
* 根据岗位名称查询岗位是否存在 -> TestPassed
|
||||||
*/
|
*/
|
||||||
@@ -138,6 +154,12 @@ public class SystemJobService {
|
|||||||
return systemJobMapper.exists(wrapper);
|
return systemJobMapper.exists(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
|
private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper<SystemJobTb> wrapper) {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
|
wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName());
|
||||||
@@ -148,20 +170,4 @@ public class SystemJobService {
|
|||||||
}
|
}
|
||||||
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
|
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出岗位数据 -> TestPassed
|
|
||||||
*/
|
|
||||||
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
|
|
||||||
List<SystemJobTb> systemJobTbs = this.queryJobByArgs(args);
|
|
||||||
List<SystemJobExportRowVo> rowVos = new ArrayList<>();
|
|
||||||
for (SystemJobTb dataObject : systemJobTbs) {
|
|
||||||
SystemJobExportRowVo rowVo = new SystemJobExportRowVo();
|
|
||||||
rowVo.setName(dataObject.getName());
|
|
||||||
rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用");
|
|
||||||
rowVo.setCreateTime(dataObject.getCreateTime());
|
|
||||||
rowVos.add(rowVo);
|
|
||||||
}
|
|
||||||
KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-17
@@ -133,29 +133,13 @@ public class SystemLocalStorageService {
|
|||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemLocalStorageTb> searchLocalStorage(SystemQueryStorageArgs args,
|
public KitPageResult<SystemLocalStorageTb> searchLocalStorage(SystemQueryStorageArgs args, Page<SystemLocalStorageTb> page) {
|
||||||
Page<SystemLocalStorageTb> page) {
|
|
||||||
LambdaQueryWrapper<SystemLocalStorageTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemLocalStorageTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
this.injectQueryParams(args, wrapper);
|
this.injectQueryParams(args, wrapper);
|
||||||
Page<SystemLocalStorageTb> selectPage = systemLocalStorageMapper.selectPage(page, wrapper);
|
Page<SystemLocalStorageTb> selectPage = systemLocalStorageMapper.selectPage(page, wrapper);
|
||||||
return KitPageUtil.toPage(selectPage);
|
return KitPageUtil.toPage(selectPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
|
|
||||||
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
|
|
||||||
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
|
|
||||||
.like(SystemLocalStorageTb::getType, args.getBlurry()).or()
|
|
||||||
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
|
||||||
args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemLocalStorageTb::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询文件上传记录 -> TestPassed
|
* 查询文件上传记录 -> TestPassed
|
||||||
*/
|
*/
|
||||||
@@ -186,4 +170,28 @@ public class SystemLocalStorageService {
|
|||||||
List<SystemLocalStorageExportRowVo> rowVos = KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class);
|
List<SystemLocalStorageExportRowVo> rowVos = KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class);
|
||||||
KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper<SystemLocalStorageTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.and(
|
||||||
|
StrUtil.isNotBlank(args.getBlurry()),
|
||||||
|
c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or()
|
||||||
|
.like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or()
|
||||||
|
.like(SystemLocalStorageTb::getType, args.getBlurry()).or()
|
||||||
|
.like(SystemLocalStorageTb::getCreateBy, args.getBlurry())
|
||||||
|
);
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
||||||
|
args.getCreateTime().get(1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemLocalStorageTb::getId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+182
-178
@@ -95,56 +95,6 @@ public class SystemMenuService {
|
|||||||
this.updateMenuSubCnt(args.getPid());
|
this.updateMenuSubCnt(args.getPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据组件名称查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param componentName 组件名称
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithComponentName(String componentName) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据组件名称查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param componentName 组件名称
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithComponentNameNeSelf(String componentName, Long currentMenuId) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
|
||||||
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param title 菜单标题
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithTitle(String title) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getTitle, title);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param title 菜单标题
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private boolean existMenuWithTitleNeSelf(String title, Long currentMenuId) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getTitle, title);
|
|
||||||
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
|
||||||
return systemMenuMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑 -> TestPassed
|
* 编辑 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -222,7 +172,7 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
// 查询所有菜单数据
|
// 查询所有菜单数据
|
||||||
List<SystemMenuTb> allMenus = systemMenuMapper.listAll();
|
List<SystemMenuTb> allMenus = systemMenuMapper.listAll();
|
||||||
// 根据ID集合获取当前菜单和其子菜单
|
// 根据ID集合查询当前菜单和其子菜单
|
||||||
Set<Long> allMenuIds = this.getAllMenuIdsWithChildren(ids, allMenus);
|
Set<Long> allMenuIds = this.getAllMenuIdsWithChildren(ids, allMenus);
|
||||||
if (CollUtil.isNotEmpty(allMenuIds)) {
|
if (CollUtil.isNotEmpty(allMenuIds)) {
|
||||||
// 删除角色菜单关联
|
// 删除角色菜单关联
|
||||||
@@ -234,60 +184,6 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 从所有菜单中找出指定ID及其子菜单ID
|
|
||||||
*
|
|
||||||
* @param rootIds 要删除的根菜单ID集合
|
|
||||||
* @param allMenus 所有菜单数据
|
|
||||||
* @return 包含根菜单及其所有子菜单的ID集合
|
|
||||||
*/
|
|
||||||
private Set<Long> getAllMenuIdsWithChildren(Set<Long> rootIds, List<SystemMenuTb> allMenus) {
|
|
||||||
Set<Long> result = new HashSet<>(rootIds);
|
|
||||||
Set<Long> currentLevelIds = new HashSet<>(rootIds);
|
|
||||||
// 构建父ID到子菜单的映射
|
|
||||||
Map<Long, List<SystemMenuTb>> parentToChildrenMap = allMenus.stream().filter(menu -> menu.getPid() != null)
|
|
||||||
.collect(Collectors.groupingBy(SystemMenuTb::getPid));
|
|
||||||
while (!currentLevelIds.isEmpty()) {
|
|
||||||
Set<Long> nextLevelIds = new HashSet<>();
|
|
||||||
// 对于当前层级的每个菜单ID,查找其子菜单
|
|
||||||
for (Long parentId : currentLevelIds) {
|
|
||||||
List<SystemMenuTb> children = parentToChildrenMap.get(parentId);
|
|
||||||
if (children != null && !children.isEmpty()) {
|
|
||||||
for (SystemMenuTb child : children) {
|
|
||||||
if (result.add(child.getId())) { // 如果成功添加(之前不存在),则继续查找其子菜单
|
|
||||||
nextLevelIds.add(child.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentLevelIds = nextLevelIds;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新被删除菜单的父菜单子节点计数
|
|
||||||
*/
|
|
||||||
private void updateParentMenuCounts(Set<Long> deletedMenuIds, List<SystemMenuTb> allMenus) {
|
|
||||||
// 获取被删除菜单的父ID
|
|
||||||
Set<Long> parentIds =
|
|
||||||
allMenus.stream().filter(menu -> deletedMenuIds.contains(menu.getId()) && menu.getPid() != null)
|
|
||||||
.map(SystemMenuTb::getPid).collect(Collectors.toSet());
|
|
||||||
// 更新每个父菜单的子节点计数
|
|
||||||
for (Long parentId : parentIds) {
|
|
||||||
proxyService.updateMenuSubCnt(parentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据菜单id查询目录 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param id 菜单id
|
|
||||||
*/
|
|
||||||
private SystemMenuTb getMenuById(Long id) {
|
|
||||||
return systemMenuMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateMenuSubCnt(Long menuId) {
|
public void updateMenuSubCnt(Long menuId) {
|
||||||
if (menuId != null) {
|
if (menuId != null) {
|
||||||
@@ -341,35 +237,21 @@ public class SystemMenuService {
|
|||||||
return systemRoleMenuService.listMenuByRoleIds(roleIds, false);
|
return systemRoleMenuService.listMenuByRoleIds(roleIds, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 查询所有子节点, 包含自身ID
|
|
||||||
// *
|
|
||||||
// * @param menuList /
|
|
||||||
// * @param menuSet /
|
|
||||||
// * @return /
|
|
||||||
// */
|
|
||||||
// public Set<SystemMenuTb> queryChildMenuByArgs(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
|
||||||
// for (SystemMenuTb menu : menuList) {
|
|
||||||
// menuSet.add(menu);
|
|
||||||
// List<SystemMenuTb> menus = this.listMenuByPid(menu.getId());
|
|
||||||
// if (CollUtil.isNotEmpty(menus)) {
|
|
||||||
// queryChildMenuByArgs(menus, menuSet);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return menuSet;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 懒加载菜单数据
|
* 懒加载菜单数据
|
||||||
*
|
*
|
||||||
* @param pid /
|
* @param pid /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemMenuTb> listMenuByPid(Long pid) {
|
public List<SystemMenuTb> listMenuByPid(Long pid, boolean includeButton) {
|
||||||
List<SystemMenuTb> menus;
|
List<SystemMenuTb> menus;
|
||||||
if (pid != null && !pid.equals(0L)) {
|
if (pid != null && !pid.equals(0L)) {
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
if (!includeButton) {
|
||||||
|
// 是否剔除按钮
|
||||||
|
wrapper.ne(SystemMenuTb::getType, 2);
|
||||||
|
}
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
return systemMenuMapper.selectList(wrapper);
|
return systemMenuMapper.selectList(wrapper);
|
||||||
} else {
|
} else {
|
||||||
@@ -390,7 +272,7 @@ public class SystemMenuService {
|
|||||||
menus.addAll(this.listRootMenu());
|
menus.addAll(this.listRootMenu());
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
menus.addAll(this.listMenuByPid(menu.getPid()));
|
menus.addAll(this.listMenuByPid(menu.getPid(), true));
|
||||||
return querySuperiorMenuByArgs(this.getMenuById(menu.getPid()), menus);
|
return querySuperiorMenuByArgs(this.getMenuById(menu.getPid()), menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,62 +355,10 @@ public class SystemMenuService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询 MenuResponse
|
|
||||||
*
|
|
||||||
* @param menu /
|
|
||||||
* @param menuVo /
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) {
|
|
||||||
SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo();
|
|
||||||
menuVo1.setMeta(menuVo.getMeta());
|
|
||||||
// 非外链
|
|
||||||
if (!menu.getIFrame()) {
|
|
||||||
menuVo1.setPath("index");
|
|
||||||
menuVo1.setName(menuVo.getName());
|
|
||||||
menuVo1.setComponent(menuVo.getComponent());
|
|
||||||
} else {
|
|
||||||
menuVo1.setPath(menu.getPath());
|
|
||||||
}
|
|
||||||
return menuVo1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SystemMenuTb> listMenuByIds(List<Long> ids) {
|
public List<SystemMenuTb> listMenuByIds(List<Long> ids) {
|
||||||
return systemMenuMapper.selectByIds(ids);
|
return systemMenuMapper.selectByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long countMenuByPid(Long pid) {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
|
||||||
return systemMenuMapper.selectCount(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
|
|
||||||
KitValidUtil.notNull(args);
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
|
|
||||||
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
|
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or()
|
|
||||||
.like(SystemMenuTb::getComponentName, args.getBlurry()).or()
|
|
||||||
.like(SystemMenuTb::getPermission, args.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return systemMenuMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询根目录 -> TestPassed
|
|
||||||
*/
|
|
||||||
private List<SystemMenuTb> listRootMenu() {
|
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.isNull(SystemMenuTb::getPid);
|
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
|
||||||
return systemMenuMapper.selectList(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SystemMenuRouterVo> buildFrontMenus() {
|
public List<SystemMenuRouterVo> buildFrontMenus() {
|
||||||
List<SystemMenuTb> originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId());
|
List<SystemMenuTb> originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId());
|
||||||
List<SystemMenuVo> targetMenus = this.buildMenuTree(originMenus);
|
List<SystemMenuVo> targetMenus = this.buildMenuTree(originMenus);
|
||||||
@@ -563,7 +393,7 @@ public class SystemMenuService {
|
|||||||
List<SystemMenuTb> newMenuList = new ArrayList<>(menus);
|
List<SystemMenuTb> newMenuList = new ArrayList<>(menus);
|
||||||
return this.buildMenuTree(newMenuList);
|
return this.buildMenuTree(newMenuList);
|
||||||
} else {
|
} else {
|
||||||
List<SystemMenuTb> records = this.listMenuByPid(null);
|
List<SystemMenuTb> records = this.listMenuByPid(null, true);
|
||||||
return KitBeanUtil.copyToList(records, SystemMenuVo.class);
|
return KitBeanUtil.copyToList(records, SystemMenuVo.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -584,4 +414,178 @@ public class SystemMenuService {
|
|||||||
}
|
}
|
||||||
KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos);
|
KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询 MenuResponse
|
||||||
|
*
|
||||||
|
* @param menu /
|
||||||
|
* @param menuVo /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) {
|
||||||
|
SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo();
|
||||||
|
menuVo1.setMeta(menuVo.getMeta());
|
||||||
|
// 非外链
|
||||||
|
if (!menu.getIFrame()) {
|
||||||
|
menuVo1.setPath("index");
|
||||||
|
menuVo1.setName(menuVo.getName());
|
||||||
|
menuVo1.setComponent(menuVo.getComponent());
|
||||||
|
} else {
|
||||||
|
menuVo1.setPath(menu.getPath());
|
||||||
|
}
|
||||||
|
return menuVo1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long countMenuByPid(Long pid) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
return systemMenuMapper.selectCount(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SystemMenuTb> queryMenuByArgs(SystemQueryMenuArgs args) {
|
||||||
|
KitValidUtil.notNull(args);
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid);
|
||||||
|
wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid());
|
||||||
|
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or()
|
||||||
|
.like(SystemMenuTb::getComponentName, args.getBlurry()).or()
|
||||||
|
.like(SystemMenuTb::getPermission, args.getBlurry()));
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询根目录 -> TestPassed
|
||||||
|
*/
|
||||||
|
private List<SystemMenuTb> listRootMenu() {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.isNull(SystemMenuTb::getPid);
|
||||||
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
|
return systemMenuMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据组件名称查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param componentName 组件名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithComponentName(String componentName) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据组件名称查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param componentName 组件名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithComponentNameNeSelf(String componentName, Long currentMenuId) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getComponentName, componentName);
|
||||||
|
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param title 菜单标题
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithTitle(String title) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getTitle, title);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单标题查询菜单是否存在 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param title 菜单标题
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existMenuWithTitleNeSelf(String title, Long currentMenuId) {
|
||||||
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemMenuTb::getTitle, title);
|
||||||
|
wrapper.ne(SystemMenuTb::getId, currentMenuId);
|
||||||
|
return systemMenuMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从所有菜单中找出指定ID及其子菜单ID
|
||||||
|
*
|
||||||
|
* @param rootIds 要删除的根菜单ID集合
|
||||||
|
* @param allMenus 所有菜单数据
|
||||||
|
* @return 包含根菜单及其所有子菜单的ID集合
|
||||||
|
*/
|
||||||
|
private Set<Long> getAllMenuIdsWithChildren(Set<Long> rootIds, List<SystemMenuTb> allMenus) {
|
||||||
|
Set<Long> result = new HashSet<>(rootIds);
|
||||||
|
Set<Long> currentLevelIds = new HashSet<>(rootIds);
|
||||||
|
// 构建父ID到子菜单的映射
|
||||||
|
Map<Long, List<SystemMenuTb>> parentToChildrenMap = allMenus.stream().filter(menu -> menu.getPid() != null)
|
||||||
|
.collect(Collectors.groupingBy(SystemMenuTb::getPid));
|
||||||
|
while (!currentLevelIds.isEmpty()) {
|
||||||
|
Set<Long> nextLevelIds = new HashSet<>();
|
||||||
|
// 对于当前层级的每个菜单ID,查找其子菜单
|
||||||
|
for (Long parentId : currentLevelIds) {
|
||||||
|
List<SystemMenuTb> children = parentToChildrenMap.get(parentId);
|
||||||
|
if (children != null && !children.isEmpty()) {
|
||||||
|
for (SystemMenuTb child : children) {
|
||||||
|
if (result.add(child.getId())) { // 如果成功添加(之前不存在),则继续查找其子菜单
|
||||||
|
nextLevelIds.add(child.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentLevelIds = nextLevelIds;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新被删除菜单的父菜单子节点计数
|
||||||
|
*/
|
||||||
|
private void updateParentMenuCounts(Set<Long> deletedMenuIds, List<SystemMenuTb> allMenus) {
|
||||||
|
// 查询被删除菜单的父ID
|
||||||
|
Set<Long> parentIds =
|
||||||
|
allMenus.stream().filter(menu -> deletedMenuIds.contains(menu.getId()) && menu.getPid() != null)
|
||||||
|
.map(SystemMenuTb::getPid).collect(Collectors.toSet());
|
||||||
|
// 更新每个父菜单的子节点计数
|
||||||
|
for (Long parentId : parentIds) {
|
||||||
|
proxyService.updateMenuSubCnt(parentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据菜单id查询目录 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param id 菜单id
|
||||||
|
*/
|
||||||
|
private SystemMenuTb getMenuById(Long id) {
|
||||||
|
return systemMenuMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有子节点, 包含自身ID
|
||||||
|
*
|
||||||
|
* @param menuList /
|
||||||
|
* @param menuSet /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private Set<SystemMenuTb> queryChildMenuByArgs(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
||||||
|
for (SystemMenuTb menu : menuList) {
|
||||||
|
menuSet.add(menu);
|
||||||
|
List<SystemMenuTb> menus = this.listMenuByPid(menu.getId(), true);
|
||||||
|
if (CollUtil.isNotEmpty(menus)) {
|
||||||
|
queryChildMenuByArgs(menus, menuSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuSet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -141,8 +141,10 @@ public class SystemMonitorService {
|
|||||||
memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal()));
|
memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal()));
|
||||||
memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable()));
|
memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable()));
|
||||||
memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable()));
|
memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable()));
|
||||||
memoryInfo.put("usageRate",
|
memoryInfo.put(
|
||||||
df.format((memory.getTotal() - memory.getAvailable()) / (double) memory.getTotal() * 100));
|
"usageRate",
|
||||||
|
df.format((memory.getTotal() - memory.getAvailable()) / (double) memory.getTotal() * 100)
|
||||||
|
);
|
||||||
return memoryInfo;
|
return memoryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
@@ -35,13 +35,43 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface SystemOssStorageService extends IService<SystemOssStorageTb> {
|
public interface SystemOssStorageService extends IService<SystemOssStorageTb> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*
|
||||||
|
* @param args 查询条件
|
||||||
|
* @param page 分页参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page);
|
KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args, Page<SystemOssStorageTb> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂条件查询
|
||||||
|
*
|
||||||
|
* @param args 查询条件
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
List<SystemOssStorageVo> queryOssStorage(SystemQueryStorageArgs args);
|
List<SystemOssStorageVo> queryOssStorage(SystemQueryStorageArgs args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param file /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
String uploadFile(MultipartFile file);
|
String uploadFile(MultipartFile file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除文件
|
||||||
|
*
|
||||||
|
* @param ids 文件记录id
|
||||||
|
*/
|
||||||
void deleteFileByIds(Long[] ids);
|
void deleteFileByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出文件上传记录
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args 查询条件
|
||||||
|
*/
|
||||||
void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args);
|
void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args);
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-35
@@ -59,19 +59,6 @@ public class SystemQuartzJobService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private KitRedisHelper redisHelper;
|
private KitRedisHelper redisHelper;
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
|
||||||
*
|
|
||||||
* @param beanName Bean名称
|
|
||||||
*/
|
|
||||||
private void checkBean(String beanName) {
|
|
||||||
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
|
||||||
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
|
||||||
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
|
||||||
throw new BadRequestException("非法的 Bean,请重新输入!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建 -> TestPassed
|
* 创建 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -207,28 +194,6 @@ public class SystemQuartzJobService {
|
|||||||
return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper));
|
return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzJobTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName());
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemQuartzJobTb::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
|
|
||||||
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0),
|
|
||||||
args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemQuartzLogTb::getId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询日志 -> TestPassed
|
* 分页查询日志 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -324,4 +289,52 @@ public class SystemQuartzJobService {
|
|||||||
public SystemQuartzJobTb getQuartzJobById(Long id) {
|
public SystemQuartzJobTb getQuartzJobById(Long id) {
|
||||||
return systemQuartzJobMapper.selectById(id);
|
return systemQuartzJobMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzJobTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName());
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemQuartzJobTb::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper<SystemQuartzLogTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName());
|
||||||
|
wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess());
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0),
|
||||||
|
args.getCreateTime().get(1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemQuartzLogTb::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
|
*
|
||||||
|
* @param beanName Bean名称
|
||||||
|
*/
|
||||||
|
private void checkBean(String beanName) {
|
||||||
|
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
||||||
|
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
||||||
|
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
||||||
|
throw new BadRequestException("非法的 Bean,请重新输入!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ public class SystemRoleMenuService {
|
|||||||
// menuWrapper.ne(SystemMenuTb::getType, 2);
|
// menuWrapper.ne(SystemMenuTb::getType, 2);
|
||||||
// menuWrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
// menuWrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
// return systemMenuMapper.selectList(menuWrapper);
|
// return systemMenuMapper.selectList(menuWrapper);
|
||||||
if (hasButton){
|
if (hasButton) {
|
||||||
return systemRoleMenuMapper.listMenuWithRoleIds(roleIds);
|
return systemRoleMenuMapper.listMenuWithRoleIds(roleIds);
|
||||||
}
|
}
|
||||||
return systemRoleMenuMapper.listMenuWithRoleIdsNeButton(roleIds);
|
return systemRoleMenuMapper.listMenuWithRoleIdsNeButton(roleIds);
|
||||||
|
|||||||
+64
-29
@@ -66,7 +66,7 @@ public class SystemRoleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveRole(SystemCreateRoleArgs args) {
|
public void saveRole(SystemCreateRoleArgs args) {
|
||||||
checkRoleLevels(args.getLevel());
|
this.checkRoleLevels(args.getLevel());
|
||||||
if (this.existRoleWithName(args.getName())) {
|
if (this.existRoleWithName(args.getName())) {
|
||||||
throw new BadRequestException("角色名称已存在");
|
throw new BadRequestException("角色名称已存在");
|
||||||
}
|
}
|
||||||
@@ -78,19 +78,6 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean existRoleWithName(String name) {
|
|
||||||
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemRoleTb::getName, name);
|
|
||||||
return systemRoleMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existRoleWithNameNeSelf(String name, Long roleId) {
|
|
||||||
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemRoleTb::getName, name);
|
|
||||||
wrapper.eq(SystemRoleTb::getId, roleId);
|
|
||||||
return systemRoleMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改 -> TestPassed
|
* 修改 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -98,7 +85,7 @@ public class SystemRoleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateRoleById(SystemRoleVo args) {
|
public void updateRoleById(SystemRoleVo args) {
|
||||||
checkRoleLevels(args.getLevel());
|
this.checkRoleLevels(args.getLevel());
|
||||||
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
||||||
if (this.existRoleWithNameNeSelf(args.getName(), role.getId())) {
|
if (this.existRoleWithNameNeSelf(args.getName(), role.getId())) {
|
||||||
throw new BadRequestException("角色名称已存在");
|
throw new BadRequestException("角色名称已存在");
|
||||||
@@ -125,7 +112,7 @@ public class SystemRoleService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateBindMenuById(SystemRoleVo args) {
|
public void updateBindMenuById(SystemRoleVo args) {
|
||||||
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
SystemRoleTb role = systemRoleMapper.selectById(args.getId());
|
||||||
checkRoleLevels(role.getLevel());
|
this.checkRoleLevels(role.getLevel());
|
||||||
// 更新菜单
|
// 更新菜单
|
||||||
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
systemRoleMenuService.deleteRoleMenuByRoleId(role.getId());
|
||||||
Set<SystemMenuTb> menus = args.getMenus();
|
Set<SystemMenuTb> menus = args.getMenus();
|
||||||
@@ -143,7 +130,7 @@ public class SystemRoleService {
|
|||||||
public void deleteRoleByIds(Set<Long> ids) {
|
public void deleteRoleByIds(Set<Long> ids) {
|
||||||
List<Integer> roleLevels = systemRoleMapper.listRoleLevelByRoleIds(new ArrayList<>(ids));
|
List<Integer> roleLevels = systemRoleMapper.listRoleLevelByRoleIds(new ArrayList<>(ids));
|
||||||
for (Integer roleLevel : roleLevels) {
|
for (Integer roleLevel : roleLevels) {
|
||||||
checkRoleLevels(roleLevel);
|
this.checkRoleLevels(roleLevel);
|
||||||
}
|
}
|
||||||
// 验证是否被用户关联
|
// 验证是否被用户关联
|
||||||
this.verifyBindRelationByIds(ids);
|
this.verifyBindRelationByIds(ids);
|
||||||
@@ -176,17 +163,6 @@ public class SystemRoleService {
|
|||||||
return systemRoleMapper.selectList(wrapper);
|
return systemRoleMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void injectQueryParams(SystemQueryRoleArgs args, LambdaQueryWrapper<SystemRoleTb> wrapper) {
|
|
||||||
if (args != null) {
|
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
|
|
||||||
.like(SystemRoleTb::getDescription, args.getBlurry()));
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByAsc(SystemRoleTb::getLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询角色 -> TestPassed
|
* 分页查询角色 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -239,6 +215,12 @@ public class SystemRoleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色id查询用户可访问的部门和菜单信息
|
||||||
|
*
|
||||||
|
* @param id 角色id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemRoleVo getRoleVoById(Long id) {
|
public SystemRoleVo getRoleVoById(Long id) {
|
||||||
SystemRoleTb roleTb = systemRoleMapper.selectById(id);
|
SystemRoleTb roleTb = systemRoleMapper.selectById(id);
|
||||||
if (roleTb == null) {
|
if (roleTb == null) {
|
||||||
@@ -247,8 +229,55 @@ public class SystemRoleService {
|
|||||||
return systemUserRoleService.convertToRoleVo(roleTb);
|
return systemUserRoleService.convertToRoleVo(roleTb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前用户角色级别
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public Dict getCurrentUserRoleLevel() {
|
public Dict getCurrentUserRoleLevel() {
|
||||||
return Dict.create().set("level", checkRoleLevels(null));
|
return Dict.create().set("level", this.checkRoleLevels(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryRoleArgs args, LambdaQueryWrapper<SystemRoleTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or()
|
||||||
|
.like(SystemRoleTb::getDescription, args.getBlurry()));
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(SystemRoleTb::getLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询角色名称是否存在
|
||||||
|
*
|
||||||
|
* @param name 角色名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existRoleWithName(String name) {
|
||||||
|
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemRoleTb::getName, name);
|
||||||
|
return systemRoleMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询角色名称是否存在(排除本身)
|
||||||
|
*
|
||||||
|
* @param name 角色名称
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existRoleWithNameNeSelf(String name, Long roleId) {
|
||||||
|
LambdaQueryWrapper<SystemRoleTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemRoleTb::getName, name);
|
||||||
|
wrapper.eq(SystemRoleTb::getId, roleId);
|
||||||
|
return systemRoleMapper.exists(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,6 +296,12 @@ public class SystemRoleService {
|
|||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出部门数据
|
||||||
|
*
|
||||||
|
* @param response /
|
||||||
|
* @param args /
|
||||||
|
*/
|
||||||
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
|
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
|
||||||
List<SystemRoleTb> systemRoleVos = this.queryRoleByArgs(args, null);
|
List<SystemRoleTb> systemRoleVos = this.queryRoleByArgs(args, null);
|
||||||
List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
|
List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
|
||||||
|
|||||||
+164
-126
@@ -17,9 +17,7 @@ package cn.odboy.system.service;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.base.KitPageArgs;
|
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
||||||
@@ -117,27 +115,6 @@ public class SystemUserService {
|
|||||||
systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId());
|
systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean existUserWithPhone(String phone) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getPhone, phone);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithEmail(String email) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getEmail, email);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithUsername(String username) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, 1);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑用户 -> TestPassed
|
* 编辑用户 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -178,27 +155,6 @@ public class SystemUserService {
|
|||||||
systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId());
|
systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean existUserWithPhoneNeSelf(String phone, Long currentUserId) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getPhone, phone);
|
|
||||||
wrapper.ne(SystemUserTb::getId, currentUserId);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithEmailNeSelf(String email, Long currentUserId) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getEmail, email);
|
|
||||||
wrapper.ne(SystemUserTb::getId, currentUserId);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean existUserWithUsernameNeSelf(String username, Long currentUserId) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
|
||||||
wrapper.ne(SystemUserTb::getId, currentUserId);
|
|
||||||
return systemUserMapper.exists(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户自助修改资料 -> TestPassed
|
* 用户自助修改资料 -> TestPassed
|
||||||
*
|
*
|
||||||
@@ -354,8 +310,8 @@ public class SystemUserService {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserVo> searchUserByArgs(SystemQueryUserArgs args, Page<SystemUserTb> page) {
|
public KitPageResult<SystemUserVo> searchUserByArgs(SystemQueryUserArgs args, Page<SystemUserTb> page) {
|
||||||
// 查询用户基本信息
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = this.buildUserQueryWrapper(args);
|
this.injectQueryParams(args, wrapper);
|
||||||
IPage<SystemUserTb> userPage = systemUserMapper.selectPage(page, wrapper);
|
IPage<SystemUserTb> userPage = systemUserMapper.selectPage(page, wrapper);
|
||||||
List<SystemUserTb> users = userPage.getRecords();
|
List<SystemUserTb> users = userPage.getRecords();
|
||||||
// 转换为SystemUserVo并关联查询
|
// 转换为SystemUserVo并关联查询
|
||||||
@@ -363,91 +319,24 @@ public class SystemUserService {
|
|||||||
return KitPageUtil.toPage(userVos, userPage.getTotal());
|
return KitPageUtil.toPage(userVos, userPage.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂条件统计用户数量
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public long countUserByArgs(SystemQueryUserArgs args) {
|
public long countUserByArgs(SystemQueryUserArgs args) {
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = this.buildUserQueryWrapper(args);
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
this.injectQueryParams(args, wrapper);
|
||||||
return systemUserMapper.selectCount(wrapper);
|
return systemUserMapper.selectCount(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<KitSelectOptionVo> queryUserMetadataOptions(KitPageArgs<SystemQueryUserArgs> pageArgs) {
|
|
||||||
SystemQueryUserArgs args = pageArgs.getArgs();
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
|
||||||
wrapper.and(c -> {
|
|
||||||
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
|
||||||
c.or();
|
|
||||||
c.eq(SystemUserTb::getEmail, args.getBlurry());
|
|
||||||
c.or();
|
|
||||||
c.like(SystemUserTb::getUsername, args.getBlurry());
|
|
||||||
c.or();
|
|
||||||
c.like(SystemUserTb::getNickName, args.getBlurry());
|
|
||||||
});
|
|
||||||
return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> {
|
|
||||||
Map<String, Object> ext = new HashMap<>(1);
|
|
||||||
ext.put("id", m.getId());
|
|
||||||
ext.put("deptId", m.getDeptId());
|
|
||||||
ext.put("email", m.getEmail());
|
|
||||||
ext.put("phone", m.getPhone());
|
|
||||||
return KitSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build();
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建用户查询条件 -> TestPassed
|
* 根据用户名查询启用的用户信息
|
||||||
*
|
*
|
||||||
* @param args 查询条件
|
* @param username 用户名
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
private LambdaQueryWrapper<SystemUserTb> buildUserQueryWrapper(SystemQueryUserArgs args) {
|
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (args != null) {
|
|
||||||
if (args.getId() != null) {
|
|
||||||
wrapper.eq(SystemUserTb::getId, args.getId());
|
|
||||||
}
|
|
||||||
if (args.getEnabled() != null) {
|
|
||||||
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(args.getDeptIds())) {
|
|
||||||
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
|
|
||||||
}
|
|
||||||
if (StrUtil.isNotBlank(args.getBlurry())) {
|
|
||||||
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or()
|
|
||||||
.like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry()));
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
|
||||||
wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(SystemUserTb::getCreateTime);
|
|
||||||
return wrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed
|
|
||||||
*
|
|
||||||
* @param user 用户基本信息
|
|
||||||
* @param includePassword 是否包含用户密码
|
|
||||||
* @return 包含关联信息的SystemUserVo
|
|
||||||
*/
|
|
||||||
private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) {
|
|
||||||
if (user == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!includePassword) {
|
|
||||||
// 查询用户时,清空密码
|
|
||||||
user.setPassword(null);
|
|
||||||
}
|
|
||||||
SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class);
|
|
||||||
// 查询关联的部门信息
|
|
||||||
if (user.getDeptId() != null) {
|
|
||||||
userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId()));
|
|
||||||
}
|
|
||||||
// 查询关联的岗位信息
|
|
||||||
userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId()));
|
|
||||||
// 查询关联的角色信息
|
|
||||||
userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId()));
|
|
||||||
return userVo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemUserTb getUserByUsername(String username) {
|
public SystemUserTb getUserByUsername(String username) {
|
||||||
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemUserTb::getUsername, username);
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
@@ -455,10 +344,22 @@ public class SystemUserService {
|
|||||||
return systemUserMapper.selectOne(wrapper);
|
return systemUserMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户名查询用户的部门、岗位和角色信息,用户信息中有密码数据
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemUserVo getUserVoWithPasswordByUsername(String username) {
|
public SystemUserVo getUserVoWithPasswordByUsername(String username) {
|
||||||
return this.convertToUserVo(this.getUserByUsername(username), true);
|
return this.convertToUserVo(this.getUserByUsername(username), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户名查询用户的部门、岗位和角色信息,用户信息中无密码数据
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
public SystemUserVo getUserVoByUsername(String username) {
|
public SystemUserVo getUserVoByUsername(String username) {
|
||||||
return this.convertToUserVo(this.getUserByUsername(username), false);
|
return this.convertToUserVo(this.getUserByUsername(username), false);
|
||||||
}
|
}
|
||||||
@@ -466,8 +367,7 @@ public class SystemUserService {
|
|||||||
/**
|
/**
|
||||||
* 聚合查询 -> TestPassed
|
* 聚合查询 -> TestPassed
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(Page<SystemUserTb> page, SystemQueryUserArgs args,
|
public KitPageResult<SystemUserVo> aggregationSearchUserByArgs(Page<SystemUserTb> page, SystemQueryUserArgs args, String currentUsername) {
|
||||||
String currentUsername) {
|
|
||||||
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
if (!ObjectUtils.isEmpty(args.getDeptId())) {
|
||||||
args.getDeptIds().add(args.getDeptId());
|
args.getDeptIds().add(args.getDeptId());
|
||||||
// 先查找是否存在子节点
|
// 先查找是否存在子节点
|
||||||
@@ -518,6 +418,144 @@ public class SystemUserService {
|
|||||||
rowVos.add(rowVo);
|
rowVos.add(rowVo);
|
||||||
}
|
}
|
||||||
return rowVos;
|
return rowVos;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号是否存在
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithPhone(String phone) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getPhone, phone);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮箱是否存在
|
||||||
|
*
|
||||||
|
* @param email 邮箱
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithEmail(String email) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getEmail, email);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户名是否存在
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithUsername(String username) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, 1);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号是否存在(排除指定用户)
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param currentUserId 指定用户id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithPhoneNeSelf(String phone, Long currentUserId) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getPhone, phone);
|
||||||
|
wrapper.ne(SystemUserTb::getId, currentUserId);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询邮箱是否存在(排除指定用户)
|
||||||
|
*
|
||||||
|
* @param email 邮箱
|
||||||
|
* @param currentUserId 指定用户id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithEmailNeSelf(String email, Long currentUserId) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getEmail, email);
|
||||||
|
wrapper.ne(SystemUserTb::getId, currentUserId);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户名是否存在(排除指定用户)
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param currentUserId 指定用户id
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private boolean existUserWithUsernameNeSelf(String username, Long currentUserId) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemUserTb::getUsername, username);
|
||||||
|
wrapper.ne(SystemUserTb::getId, currentUserId);
|
||||||
|
return systemUserMapper.exists(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询条件
|
||||||
|
*
|
||||||
|
* @param args /
|
||||||
|
* @param wrapper /
|
||||||
|
*/
|
||||||
|
private void injectQueryParams(SystemQueryUserArgs args, LambdaQueryWrapper<SystemUserTb> wrapper) {
|
||||||
|
if (args != null) {
|
||||||
|
if (args.getId() != null) {
|
||||||
|
wrapper.eq(SystemUserTb::getId, args.getId());
|
||||||
|
}
|
||||||
|
if (args.getEnabled() != null) {
|
||||||
|
wrapper.eq(SystemUserTb::getEnabled, args.getEnabled());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(args.getDeptIds())) {
|
||||||
|
wrapper.in(SystemUserTb::getDeptId, args.getDeptIds());
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(args.getBlurry())) {
|
||||||
|
wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or()
|
||||||
|
.like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry()));
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
|
wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.orderByDesc(SystemUserTb::getCreateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed
|
||||||
|
*
|
||||||
|
* @param user 用户基本信息
|
||||||
|
* @param includePassword 是否包含用户密码
|
||||||
|
* @return 包含关联信息的SystemUserVo
|
||||||
|
*/
|
||||||
|
private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) {
|
||||||
|
if (user == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!includePassword) {
|
||||||
|
// 查询用户时,清空密码
|
||||||
|
user.setPassword(null);
|
||||||
|
}
|
||||||
|
SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class);
|
||||||
|
// 查询关联的部门信息
|
||||||
|
if (user.getDeptId() != null) {
|
||||||
|
userVo.setDept(systemDeptService.getDeptById(user.getDeptId()));
|
||||||
|
}
|
||||||
|
// 查询关联的岗位信息
|
||||||
|
userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId()));
|
||||||
|
// 查询关联的角色信息
|
||||||
|
userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId()));
|
||||||
|
return userVo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-7
@@ -69,8 +69,10 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
|
|||||||
private SystemOssStorageMapper systemOssStorageMapper;
|
private SystemOssStorageMapper systemOssStorageMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KitPageResult<SystemOssStorageVo> searchOssStorage(SystemQueryStorageArgs args,
|
public KitPageResult<SystemOssStorageVo> searchOssStorage(
|
||||||
Page<SystemOssStorageTb> page) {
|
SystemQueryStorageArgs args,
|
||||||
|
Page<SystemOssStorageTb> page
|
||||||
|
) {
|
||||||
IPage<SystemOssStorageVo> ossStorageTbs = this.selectOssStorageByArgs(args, page);
|
IPage<SystemOssStorageVo> ossStorageTbs = this.selectOssStorageByArgs(args, page);
|
||||||
for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) {
|
for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) {
|
||||||
storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize()));
|
storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize()));
|
||||||
@@ -78,18 +80,23 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
|
|||||||
return KitPageUtil.toPage(ossStorageTbs);
|
return KitPageUtil.toPage(ossStorageTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPage<SystemOssStorageVo> selectOssStorageByArgs(SystemQueryStorageArgs args,
|
private IPage<SystemOssStorageVo> selectOssStorageByArgs(
|
||||||
Page<SystemOssStorageTb> page) {
|
SystemQueryStorageArgs args,
|
||||||
|
Page<SystemOssStorageTb> page
|
||||||
|
) {
|
||||||
KitValidUtil.notNull(args);
|
KitValidUtil.notNull(args);
|
||||||
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemOssStorageTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.and(StrUtil.isNotBlank(args.getBlurry()),
|
wrapper.and(
|
||||||
|
StrUtil.isNotBlank(args.getBlurry()),
|
||||||
c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or()
|
c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or()
|
||||||
.like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or()
|
.like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or()
|
||||||
.like(SystemOssStorageTb::getFileMime, args.getBlurry()).or()
|
.like(SystemOssStorageTb::getFileMime, args.getBlurry()).or()
|
||||||
.like(SystemOssStorageTb::getFileMd5, args.getBlurry()));
|
.like(SystemOssStorageTb::getFileMd5, args.getBlurry())
|
||||||
|
);
|
||||||
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) {
|
||||||
wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0),
|
||||||
args.getCreateTime().get(1));
|
args.getCreateTime().get(1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
wrapper.orderByAsc(SystemOssStorageTb::getId);
|
wrapper.orderByAsc(SystemOssStorageTb::getId);
|
||||||
return systemOssStorageMapper.selectPage(page, wrapper)
|
return systemOssStorageMapper.selectPage(page, wrapper)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<artifactId>cutejava-module-system</artifactId>
|
<artifactId>cutejava-module-system</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
| |___ | |_| | | | | |___ | |_| | / / | | | |/ / / / | |
|
| |___ | |_| | | | | |___ | |_| | / / | | | |/ / / / | |
|
||||||
\_____| \_____/ |_| |_____| \_____/ /_/ |_| |___/ /_/ |_|
|
\_____| \_____/ |_| |_____| \_____/ /_/ |_| |___/ /_/ |_|
|
||||||
|
|
||||||
Spring Boot Version: (${spring-boot.version}),CuteJava Version: (1.5.0)
|
Spring Boot Version: (${spring-boot.version}),CuteJava Version: (1.5.2)
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<!-- 基础设施 -->
|
<!-- 基础设施 -->
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>cutejava-framework</artifactId>
|
<artifactId>cutejava-framework</artifactId>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class SwaggerConfig {
|
|||||||
|
|
||||||
private ApiInfo apiInfo() {
|
private ApiInfo apiInfo() {
|
||||||
return new ApiInfoBuilder().description("一个简单且易上手的自动化运维平台").title("CuteJava 接口文档")
|
return new ApiInfoBuilder().description("一个简单且易上手的自动化运维平台").title("CuteJava 接口文档")
|
||||||
.version("1.5.0").build();
|
.version("1.5.2").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SecurityScheme> securitySchemes() {
|
private List<SecurityScheme> securitySchemes() {
|
||||||
|
|||||||
+3
-3
@@ -61,12 +61,12 @@ public class KitWsServer {
|
|||||||
* @param message 客户端发送过来的消息
|
* @param message 客户端发送过来的消息
|
||||||
*/
|
*/
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(String message, Session session) {
|
public void onMessage(String message, Session session) throws IOException {
|
||||||
KitWsMessage wsMessage = JSON.parseObject(message, KitWsMessage.class);
|
KitWsMessage wsMessage = JSON.parseObject(message, KitWsMessage.class);
|
||||||
String bizCode = wsMessage.getBizCode();
|
String bizCode = wsMessage.getBizCode();
|
||||||
Object data = wsMessage.getData();
|
Object data = wsMessage.getData();
|
||||||
log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode,
|
log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode, JSON.toJSONString(data));
|
||||||
JSON.toJSONString(data));
|
session.getBasicRemote().sendText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>cutejava-module-system</artifactId>
|
<artifactId>cutejava-module-system</artifactId>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<artifactId>cutejava-framework</artifactId>
|
<artifactId>cutejava-framework</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
import cn.odboy.system.application.service.CuteDeptTreeService;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteDeptTree")
|
||||||
|
@RequestMapping("/api/component/CuteDeptTree")
|
||||||
|
public class CuteDeptTreeApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteDeptTreeService cuteDeptTreeService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
public ResponseEntity<List<CuteDeptTreeVo>> listMetadata(@Validated @RequestBody SystemQueryDeptArgs args) throws Exception {
|
||||||
|
List<CuteDeptTreeVo> depts = cuteDeptTreeService.listMetadata(args);
|
||||||
|
return ResponseEntity.ok(depts);
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteFileUploadService;
|
||||||
|
import cn.odboy.system.framework.operalog.OperationLog;
|
||||||
|
import cn.odboy.system.service.SystemLocalStorageService;
|
||||||
|
import cn.odboy.system.service.SystemOssStorageService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteFileUpload")
|
||||||
|
@RequestMapping("/api/component/CuteFileUpload")
|
||||||
|
public class CuteFileUploadApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteFileUploadService cuteFileUploadService;
|
||||||
|
@Autowired
|
||||||
|
private SystemOssStorageService systemOssStorageService;
|
||||||
|
|
||||||
|
@OperationLog
|
||||||
|
@ApiOperation("上传文件到服务器本地")
|
||||||
|
@PostMapping(value = "/uploadLocal")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<String> uploadLocal(@RequestParam("file") MultipartFile file) {
|
||||||
|
String fileUrl = cuteFileUploadService.uploadLocal(file);
|
||||||
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperationLog
|
||||||
|
@ApiOperation("上传文件到OSS")
|
||||||
|
@PostMapping(value = "/uploadOSS")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<String> uploadOSS(@RequestParam("file") MultipartFile file) {
|
||||||
|
String fileUrl = systemOssStorageService.uploadFile(file);
|
||||||
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteProductLineSelectService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteProductLineSelect")
|
||||||
|
@RequestMapping("/api/component/CuteProductLineSelect")
|
||||||
|
public class CuteProductLineSelectApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteProductLineSelectService cuteProductLineSelectService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择数据源")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> listMetadata() {
|
||||||
|
return ResponseEntity.ok(cuteProductLineSelectService.listMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.service.CuteProductLineSelectProService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteProductLineSelectPro")
|
||||||
|
@RequestMapping("/api/component/CuteProductLineSelectPro")
|
||||||
|
public class CuteProductLineSelectProApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteProductLineSelectProService cuteProductLineSelectProService;
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择Pro数据源")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> listMetadata() {
|
||||||
|
return ResponseEntity.ok(cuteProductLineSelectProService.listMetadata());
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package cn.odboy.system.application;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
import cn.odboy.system.application.service.CuteUserSelectService;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "系统组件:CuteUserSelect")
|
||||||
|
@RequestMapping("/api/component/CuteUserSelect")
|
||||||
|
public class CuteUserSelectApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CuteUserSelectService cuteUserSelectService;
|
||||||
|
|
||||||
|
@ApiOperation("查询用户基础数据")
|
||||||
|
@PostMapping(value = "/listMetadata")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<List<CuteUserSelectVo>> listMetadata(@Validated @RequestBody SystemQueryUserArgs args) {
|
||||||
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadata(args);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("根据用户名称集合查询用户基础数据")
|
||||||
|
@PostMapping(value = "/listMetadataByUsernames")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<List<CuteUserSelectVo>> listMetadataByUsernames(@RequestBody List<String> usernameList) {
|
||||||
|
List<CuteUserSelectVo> collect = cuteUserSelectService.listMetadataByUsernames(usernameList);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CuteDeptTreeVo extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 上级部门ID
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
/**
|
||||||
|
* 子节点数目
|
||||||
|
*/
|
||||||
|
private Integer subCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有子节点
|
||||||
|
*/
|
||||||
|
public Boolean getHasChildren() {
|
||||||
|
return subCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为叶子
|
||||||
|
*/
|
||||||
|
public Boolean getLeaf() {
|
||||||
|
return subCount <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签名称
|
||||||
|
*/
|
||||||
|
public String getLabel() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-4
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,9 +22,14 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SystemProductLineTreeVo extends KitObject {
|
public class CuteProductLineSelectProVo extends KitObject {
|
||||||
|
/**
|
||||||
|
* 部门ID(select的value)
|
||||||
|
*/
|
||||||
private String value;
|
private String value;
|
||||||
|
/**
|
||||||
|
* 产品线,如"研发部/华南分部/devops组"
|
||||||
|
*/
|
||||||
private String label;
|
private String label;
|
||||||
private List<SystemProductLineTreeVo> children;
|
private List<CuteProductLineSelectProVo> children;
|
||||||
}
|
}
|
||||||
+3
-3
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -21,12 +21,12 @@ import lombok.Setter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SystemProductLineVo extends KitObject {
|
public class CuteProductLineSelectVo extends KitObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID(select的value)
|
* 部门ID(select的value)
|
||||||
*/
|
*/
|
||||||
private Long value;
|
private String value;
|
||||||
/**
|
/**
|
||||||
* 产品线,如"研发部/华南分部/devops组"
|
* 产品线,如"研发部/华南分部/devops组"
|
||||||
*/
|
*/
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.odboy.system.application.model;
|
||||||
|
|
||||||
|
import cn.odboy.base.KitObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CuteUserSelectVo extends KitObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* username
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
/**
|
||||||
|
* nickname
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
/**
|
||||||
|
* 部门ID
|
||||||
|
*/
|
||||||
|
private String deptId;
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemDeptMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CuteBaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptMapper systemDeptMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询启用的所有部门集合
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<SystemDeptTb> listEnabledDept() {
|
||||||
|
LambdaQueryWrapper<SystemDeptTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SystemDeptTb::getEnabled, 1);
|
||||||
|
return systemDeptMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.odboy.system.application.model.CuteDeptTreeVo;
|
||||||
|
import cn.odboy.system.constant.SystemDataScopeEnum;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryDeptArgs;
|
||||||
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
|
import cn.odboy.system.service.SystemDeptService;
|
||||||
|
import cn.odboy.util.KitClassUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteDeptTreeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptService systemDeptService;
|
||||||
|
|
||||||
|
public List<CuteDeptTreeVo> listMetadata(SystemQueryDeptArgs args) throws Exception {
|
||||||
|
String dataScopeType = KitSecurityHelper.getDataScopeType();
|
||||||
|
if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) {
|
||||||
|
args.setPidIsNull(true);
|
||||||
|
}
|
||||||
|
List<Field> fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>());
|
||||||
|
List<String> fieldNames = new ArrayList<>() {{
|
||||||
|
add("pidIsNull");
|
||||||
|
add("enabled");
|
||||||
|
}};
|
||||||
|
for (Field field : fields) {
|
||||||
|
// 设置对象的访问权限, 保证对private的属性的访问
|
||||||
|
field.setAccessible(true);
|
||||||
|
Object val = field.get(args);
|
||||||
|
if (fieldNames.contains(field.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(val)) {
|
||||||
|
args.setPidIsNull(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 数据权限
|
||||||
|
args.setIds(KitSecurityHelper.getCurrentUserDataScope());
|
||||||
|
List<SystemDeptTb> list = systemDeptService.queryDeptByArgs(args);
|
||||||
|
// 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果
|
||||||
|
if (StrUtil.isBlank(dataScopeType)) {
|
||||||
|
return systemDeptService.filterRootDeptList(list).stream().map(this::convertToVo).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return list.stream().map(this::convertToVo).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private CuteDeptTreeVo convertToVo(SystemDeptTb record) {
|
||||||
|
CuteDeptTreeVo treeVo = new CuteDeptTreeVo();
|
||||||
|
treeVo.setId(Long.toString(record.getId()));
|
||||||
|
treeVo.setName(record.getName());
|
||||||
|
treeVo.setPid(record.getPid() == null ? null : Long.toString(record.getPid()));
|
||||||
|
treeVo.setSubCount(record.getSubCount());
|
||||||
|
return treeVo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.odboy.framework.context.KitRequestHolder;
|
||||||
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
|
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemLocalStorageTb;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemLocalStorageMapper;
|
||||||
|
import cn.odboy.util.KitFileUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class CuteFileUploadService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemLocalStorageMapper systemLocalStorageMapper;
|
||||||
|
@Autowired
|
||||||
|
private KitFileLocalUploadHelper fileUploadPathHelper;
|
||||||
|
@Autowired
|
||||||
|
private AppProperties properties;
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String uploadLocal(MultipartFile multipartFile) {
|
||||||
|
long size = multipartFile.getSize();
|
||||||
|
KitFileUtil.checkSize(properties.getOss().getMaxSize(), size);
|
||||||
|
String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename());
|
||||||
|
String type = KitFileUtil.getFileType(suffix);
|
||||||
|
String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT);
|
||||||
|
File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator);
|
||||||
|
if (file == null) {
|
||||||
|
throw new BadRequestException("上传失败");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String formatSize = KitFileUtil.getSize(size);
|
||||||
|
String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), null);
|
||||||
|
SystemLocalStorageTb localStorage = new SystemLocalStorageTb();
|
||||||
|
localStorage.setRealName(file.getName());
|
||||||
|
localStorage.setName(prefixName);
|
||||||
|
localStorage.setSuffix(suffix);
|
||||||
|
localStorage.setPath(file.getPath());
|
||||||
|
localStorage.setType(type);
|
||||||
|
localStorage.setSize(formatSize);
|
||||||
|
localStorage.setDateGroup(uploadDateStr);
|
||||||
|
systemLocalStorageMapper.insert(localStorage);
|
||||||
|
// 构建上传路径 /file/20260117/odboycn-20260117055246428.png
|
||||||
|
HttpServletRequest httpServletRequest = KitRequestHolder.getHttpServletRequest();
|
||||||
|
StringBuffer requestURL = httpServletRequest.getRequestURL();
|
||||||
|
String[] splits = requestURL.toString().split("/api/component/CuteFileUpload");
|
||||||
|
String requestAddress = splits[0];
|
||||||
|
return String.format("%s/file/%s/%s", requestAddress, uploadDateStr, localStorage.getRealName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("上传文件失败", e);
|
||||||
|
KitFileUtil.del(file);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.application.model.CuteProductLineSelectProVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteProductLineSelectProService extends CuteBaseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件Pro版 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteProductLineSelectProVo> listMetadata() {
|
||||||
|
List<SystemDeptTb> depts = this.listEnabledDept();
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<CuteProductLineSelectProVo> options = new ArrayList<>();
|
||||||
|
// 构建树形结构
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 只处理顶级部门(pid为null或0的部门)
|
||||||
|
if (dept.getPid() == null || dept.getPid() == 0) {
|
||||||
|
CuteProductLineSelectProVo vo = this.buildDeptTreePro(dept, deptMap);
|
||||||
|
options.add(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 按排序字段排序
|
||||||
|
options.sort(Comparator.comparingInt(o -> {
|
||||||
|
Long id = Long.valueOf(o.getValue());
|
||||||
|
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
||||||
|
}));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归构建部门树
|
||||||
|
*
|
||||||
|
* @param dept 当前部门
|
||||||
|
* @param deptMap 部门映射
|
||||||
|
* @return CuteProductLineSelectProVo 树节点
|
||||||
|
*/
|
||||||
|
private CuteProductLineSelectProVo buildDeptTreePro(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
CuteProductLineSelectProVo vo = new CuteProductLineSelectProVo();
|
||||||
|
vo.setValue(String.valueOf(dept.getId()));
|
||||||
|
vo.setLabel(dept.getName());
|
||||||
|
// 查找子部门
|
||||||
|
List<CuteProductLineSelectProVo> children = new ArrayList<>();
|
||||||
|
for (SystemDeptTb childDept : deptMap.values()) {
|
||||||
|
if (dept.getId().equals(childDept.getPid())) {
|
||||||
|
children.add(this.buildDeptTreePro(childDept, deptMap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 子部门按排序字段排序
|
||||||
|
children.sort(Comparator.comparingInt(o -> {
|
||||||
|
Long id = Long.valueOf(o.getValue());
|
||||||
|
return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0;
|
||||||
|
}));
|
||||||
|
vo.setChildren(children);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
|
import cn.odboy.system.application.model.CuteProductLineSelectVo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteProductLineSelectService extends CuteBaseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品线选择组件 数据源
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteProductLineSelectVo> listMetadata() {
|
||||||
|
List<SystemDeptTb> depts = this.listEnabledDept();
|
||||||
|
return this.buildDeptMetadata(depts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CuteProductLineSelectVo> buildDeptMetadata(List<SystemDeptTb> depts) {
|
||||||
|
// 查询所有部门并按父子关系组织
|
||||||
|
Map<Long, SystemDeptTb> deptMap =
|
||||||
|
depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity()));
|
||||||
|
List<CuteProductLineSelectVo> options = new ArrayList<>();
|
||||||
|
for (SystemDeptTb dept : depts) {
|
||||||
|
// 构建部门ID路径
|
||||||
|
List<Long> pathIds = new ArrayList<>();
|
||||||
|
this.buildDeptIdPath(dept, deptMap, pathIds);
|
||||||
|
// 反转路径,从顶级部门到当前部门
|
||||||
|
Collections.reverse(pathIds);
|
||||||
|
CuteProductLineSelectVo dto = new CuteProductLineSelectVo();
|
||||||
|
dto.setValue(Long.toString(dept.getId()));
|
||||||
|
dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-")));
|
||||||
|
// 保留名称路径用于显示
|
||||||
|
dto.setLabel(this.buildNamePath(dept, deptMap));
|
||||||
|
options.add(dto);
|
||||||
|
}
|
||||||
|
// 按部门名称路径排序
|
||||||
|
options.sort(Comparator.comparing(CuteProductLineSelectVo::getLabel));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDeptIdPath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<Long> pathIds) {
|
||||||
|
pathIds.add(dept.getId());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap) {
|
||||||
|
List<String> pathNames = new ArrayList<>();
|
||||||
|
this.buildDeptNamePath(dept, deptMap, pathNames);
|
||||||
|
Collections.reverse(pathNames);
|
||||||
|
return String.join(" / ", pathNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDeptNamePath(SystemDeptTb dept, Map<Long, SystemDeptTb> deptMap, List<String> pathNames) {
|
||||||
|
pathNames.add(dept.getName());
|
||||||
|
if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) {
|
||||||
|
this.buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package cn.odboy.system.application.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.odboy.system.application.model.CuteUserSelectVo;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
|
import cn.odboy.system.dal.model.request.SystemQueryUserArgs;
|
||||||
|
import cn.odboy.system.dal.mysql.SystemUserMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CuteUserSelectService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemUserMapper systemUserMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模糊查询用户基础信息,限制返回的条数
|
||||||
|
*
|
||||||
|
* @param args 查询参数
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
public List<CuteUserSelectVo> listMetadata(SystemQueryUserArgs args) {
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
|
wrapper.and(c -> {
|
||||||
|
c.eq(SystemUserTb::getPhone, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.eq(SystemUserTb::getEmail, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.like(SystemUserTb::getUsername, args.getBlurry());
|
||||||
|
c.or();
|
||||||
|
c.like(SystemUserTb::getNickName, args.getBlurry());
|
||||||
|
});
|
||||||
|
return systemUserMapper.selectPage(new Page<>(1, 50), wrapper).convert(m -> {
|
||||||
|
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||||
|
selectVo.setValue(m.getUsername());
|
||||||
|
selectVo.setLabel(m.getNickName());
|
||||||
|
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||||
|
selectVo.setEmail(m.getEmail());
|
||||||
|
selectVo.setPhone(m.getPhone());
|
||||||
|
return selectVo;
|
||||||
|
}).getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CuteUserSelectVo> listMetadataByUsernames(List<String> usernameList) {
|
||||||
|
if (CollUtil.isEmpty(usernameList)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<SystemUserTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SystemUserTb::getUsername, SystemUserTb::getNickName, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone);
|
||||||
|
wrapper.in(SystemUserTb::getUsername, usernameList);
|
||||||
|
return systemUserMapper.selectList(wrapper).stream().map(m -> {
|
||||||
|
CuteUserSelectVo selectVo = new CuteUserSelectVo();
|
||||||
|
selectVo.setValue(m.getUsername());
|
||||||
|
selectVo.setLabel(m.getNickName());
|
||||||
|
selectVo.setDeptId(Long.toString(m.getDeptId()));
|
||||||
|
selectVo.setEmail(m.getEmail());
|
||||||
|
selectVo.setPhone(m.getPhone());
|
||||||
|
return selectVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-1
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package cn.odboy.system.dal.redis;
|
package cn.odboy.system.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关于缓存的Key集合
|
* 关于缓存的Key集合
|
||||||
@@ -28,4 +28,8 @@ public interface SystemCacheKey {
|
|||||||
* 登录验证码
|
* 登录验证码
|
||||||
*/
|
*/
|
||||||
String CAPTCHA_LOGIN = "captcha::login:";
|
String CAPTCHA_LOGIN = "captcha::login:";
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*/
|
||||||
|
String USER_INFO = "user::info:";
|
||||||
}
|
}
|
||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.controller;
|
|
||||||
|
|
||||||
import cn.odboy.system.service.SystemDeptService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Api(tags = "系统:组件数据源")
|
|
||||||
@RequestMapping("/api/component")
|
|
||||||
public class SystemComponentController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SystemDeptService systemDeptService;
|
|
||||||
|
|
||||||
@ApiOperation("查询部门下拉选择数据源")
|
|
||||||
@PostMapping(value = "/listDeptSelectDataSource")
|
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> listDeptSelectDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.listDeptSelectDataSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("查询部门下拉选择Pro数据源")
|
|
||||||
@PostMapping(value = "/listDeptSelectProDataSource")
|
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> listDeptSelectProDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.listDeptSelectProDataSource());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -68,7 +68,7 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/listMenuByPid")
|
@PostMapping(value = "/listMenuByPid")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
||||||
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid);
|
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid, false);
|
||||||
return ResponseEntity.ok(systemMenuTbs);
|
return ResponseEntity.ok(systemMenuTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-7
@@ -141,13 +141,6 @@ public class SystemUserController {
|
|||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询用户基础数据")
|
|
||||||
@PostMapping(value = "/queryUserMetadataOptions")
|
|
||||||
@PreAuthorize("@el.check('user:list')")
|
|
||||||
public ResponseEntity<List<KitSelectOptionVo>> queryUserMetadataOptions(@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
|
||||||
List<KitSelectOptionVo> collect = systemUserService.queryUserMetadataOptions(args);
|
|
||||||
return ResponseEntity.ok(collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户信息")
|
@ApiOperation("获取用户信息")
|
||||||
@PostMapping(value = "/getCurrentUserInfo")
|
@PostMapping(value = "/getCurrentUserInfo")
|
||||||
|
|||||||
+11
@@ -43,31 +43,42 @@ public class SystemUserTb extends KitBaseUserTimeTb {
|
|||||||
private Long deptId;
|
private Long deptId;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "用户名称")
|
@ApiModelProperty(value = "用户名称")
|
||||||
|
@TableField(value = "username")
|
||||||
private String username;
|
private String username;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "用户昵称")
|
@ApiModelProperty(value = "用户昵称")
|
||||||
|
@TableField(value = "nick_name")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
@Email
|
@Email
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "邮箱")
|
@ApiModelProperty(value = "邮箱")
|
||||||
|
@TableField(value = "email")
|
||||||
private String email;
|
private String email;
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "电话号码")
|
@ApiModelProperty(value = "电话号码")
|
||||||
|
@TableField(value = "phone")
|
||||||
private String phone;
|
private String phone;
|
||||||
@ApiModelProperty(value = "用户性别")
|
@ApiModelProperty(value = "用户性别")
|
||||||
|
@TableField(value = "gender")
|
||||||
private String gender;
|
private String gender;
|
||||||
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
@ApiModelProperty(value = "头像真实名称", hidden = true)
|
||||||
|
@TableField(value = "avatar_name")
|
||||||
private String avatarName;
|
private String avatarName;
|
||||||
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
@ApiModelProperty(value = "头像存储的路径", hidden = true)
|
||||||
|
@TableField(value = "avatar_path")
|
||||||
private String avatarPath;
|
private String avatarPath;
|
||||||
@ApiModelProperty(value = "密码")
|
@ApiModelProperty(value = "密码")
|
||||||
|
@TableField(value = "password")
|
||||||
private String password;
|
private String password;
|
||||||
@NotNull
|
@NotNull
|
||||||
@ApiModelProperty(value = "是否启用")
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
@TableField(value = "enabled")
|
||||||
private Boolean enabled;
|
private Boolean enabled;
|
||||||
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
@ApiModelProperty(value = "是否为admin账号", hidden = true)
|
||||||
|
@TableField(value = "is_admin")
|
||||||
private Boolean isAdmin = false;
|
private Boolean isAdmin = false;
|
||||||
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
||||||
|
@TableField(value = "pwd_reset_time")
|
||||||
private Date pwdResetTime;
|
private Date pwdResetTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-3
@@ -16,14 +16,15 @@
|
|||||||
package cn.odboy.system.dal.model.response;
|
package cn.odboy.system.dal.model.response;
|
||||||
|
|
||||||
import cn.odboy.base.KitBaseUserTimeTb;
|
import cn.odboy.base.KitBaseUserTimeTb;
|
||||||
|
import cn.odboy.system.dal.dataobject.SystemDeptTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
import cn.odboy.system.dal.dataobject.SystemJobTb;
|
||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -60,7 +61,7 @@ public class SystemUserVo extends KitBaseUserTimeTb {
|
|||||||
* 扩展字段
|
* 扩展字段
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户部门")
|
@ApiModelProperty(value = "用户部门")
|
||||||
private SystemDeptVo dept;
|
private SystemDeptTb dept;
|
||||||
@ApiModelProperty(value = "用户角色")
|
@ApiModelProperty(value = "用户角色")
|
||||||
private Set<SystemRoleTb> roles;
|
private Set<SystemRoleTb> roles;
|
||||||
@ApiModelProperty(value = "用户岗位")
|
@ApiModelProperty(value = "用户岗位")
|
||||||
|
|||||||
-69
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021-2026 Odboy
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.odboy.system.dal.redis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关于缓存的Key集合
|
|
||||||
*/
|
|
||||||
public interface SystemRedisKey {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户
|
|
||||||
*/
|
|
||||||
String USER_ID = "user::id:";
|
|
||||||
/**
|
|
||||||
* 数据
|
|
||||||
*/
|
|
||||||
String DATA_USER = "data::user:";
|
|
||||||
/**
|
|
||||||
* 菜单
|
|
||||||
*/
|
|
||||||
String MENU_ID = "menu::id:";
|
|
||||||
String MENU_USER = "menu::user:";
|
|
||||||
/**
|
|
||||||
* 角色授权
|
|
||||||
*/
|
|
||||||
String ROLE_AUTH = "role::auth:";
|
|
||||||
String ROLE_USER = "role::user:";
|
|
||||||
/**
|
|
||||||
* 角色信息
|
|
||||||
*/
|
|
||||||
String ROLE_ID = "role::id:";
|
|
||||||
/**
|
|
||||||
* 部门
|
|
||||||
*/
|
|
||||||
String DEPT_ID = "dept::id:";
|
|
||||||
/**
|
|
||||||
* 岗位
|
|
||||||
*/
|
|
||||||
String JOB_ID = "job::id:";
|
|
||||||
/**
|
|
||||||
* 数据字典
|
|
||||||
*/
|
|
||||||
String DICT_NAME = "dict::name:";
|
|
||||||
/**
|
|
||||||
* 在线用户
|
|
||||||
*/
|
|
||||||
String ONLINE_USER = "online::token:";
|
|
||||||
/**
|
|
||||||
* 登录验证码
|
|
||||||
*/
|
|
||||||
String CAPTCHA_LOGIN = "captcha::login:";
|
|
||||||
/**
|
|
||||||
* 用户信息
|
|
||||||
*/
|
|
||||||
String USER_INFO = "user::info:";
|
|
||||||
}
|
|
||||||
+4
-3
@@ -18,6 +18,7 @@ package cn.odboy.system.dal.redis;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@@ -42,7 +43,7 @@ public class SystemUserInfoDAO {
|
|||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 添加数据, 避免数据同时过期(2小时左右)
|
// 添加数据, 避免数据同时过期(2小时左右)
|
||||||
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
long time = 7200 + RandomUtil.randomInt(900, 1800);
|
||||||
redisHelper.set(SystemRedisKey.USER_INFO + userName, user, time);
|
redisHelper.set(SystemCacheKey.USER_INFO + userName, user, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class SystemUserInfoDAO {
|
|||||||
public void deleteUserLoginInfoByUserName(String userName) {
|
public void deleteUserLoginInfoByUserName(String userName) {
|
||||||
if (StrUtil.isNotEmpty(userName)) {
|
if (StrUtil.isNotEmpty(userName)) {
|
||||||
// 清除数据
|
// 清除数据
|
||||||
redisHelper.del(SystemRedisKey.USER_INFO + userName);
|
redisHelper.del(SystemCacheKey.USER_INFO + userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class SystemUserInfoDAO {
|
|||||||
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
public SystemUserJwtVo getUserLoginInfoByUserName(String username) {
|
||||||
if (StrUtil.isNotEmpty(username)) {
|
if (StrUtil.isNotEmpty(username)) {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
return redisHelper.get(SystemRedisKey.USER_INFO + username, SystemUserJwtVo.class);
|
return redisHelper.get(SystemCacheKey.USER_INFO + username, SystemUserJwtVo.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -19,6 +19,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.redis.KitRedisHelper;
|
import cn.odboy.framework.redis.KitRedisHelper;
|
||||||
|
import cn.odboy.system.constant.SystemCacheKey;
|
||||||
import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo;
|
import cn.odboy.system.dal.model.export.SystemUserOnlineExportRowVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
import cn.odboy.system.dal.model.response.SystemUserJwtVo;
|
||||||
import cn.odboy.system.dal.model.response.SystemUserOnlineVo;
|
import cn.odboy.system.dal.model.response.SystemUserOnlineVo;
|
||||||
@@ -122,7 +123,7 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @param username /
|
* @param username /
|
||||||
*/
|
*/
|
||||||
public void kickOutByUsername(String username) {
|
public void kickOutByUsername(String username) {
|
||||||
String loginKey = SystemRedisKey.ONLINE_USER + username + "*";
|
String loginKey = SystemCacheKey.ONLINE_USER + username + "*";
|
||||||
redisHelper.scanDel(loginKey);
|
redisHelper.scanDel(loginKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,15 +134,13 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @param pageable /
|
* @param pageable /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo,
|
public KitPageResult<SystemUserOnlineVo> searchOnlineUser(SystemUserOnlineVo onlineVo, IPage<SystemUserOnlineVo> pageable) {
|
||||||
IPage<SystemUserOnlineVo> pageable) {
|
|
||||||
String username = null;
|
String username = null;
|
||||||
if (onlineVo != null) {
|
if (onlineVo != null) {
|
||||||
username = onlineVo.getUserName();
|
username = onlineVo.getUserName();
|
||||||
}
|
}
|
||||||
List<SystemUserOnlineVo> onlineUserList = queryUserOnlineModelListByUsername(username);
|
List<SystemUserOnlineVo> onlineUserList = this.queryUserOnlineModelListByUsername(username);
|
||||||
List<SystemUserOnlineVo> paging =
|
List<SystemUserOnlineVo> paging = KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
||||||
KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList);
|
|
||||||
return KitPageUtil.toPage(paging, onlineUserList.size());
|
return KitPageUtil.toPage(paging, onlineUserList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +151,7 @@ public class SystemUserOnlineInfoDAO {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
public List<SystemUserOnlineVo> queryUserOnlineModelListByUsername(String username) {
|
||||||
String loginKey = SystemRedisKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
String loginKey = SystemCacheKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username);
|
||||||
List<String> keys = redisHelper.scan(loginKey + "*");
|
List<String> keys = redisHelper.scan(loginKey + "*");
|
||||||
Collections.reverse(keys);
|
Collections.reverse(keys);
|
||||||
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
List<SystemUserOnlineVo> onlineUserList = new ArrayList<>();
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user