提交 283be048 编写于 作者: JEECG低代码平台's avatar JEECG低代码平台

Jeecg-Boot 2.1.2版本发布

上级 f0d372d0
......@@ -11,7 +11,7 @@ https://www.oschina.net/p/jeecg-boot
Jeecg-Boot 快速开发平台(前后端分离版本)
===============
当前最新版本: 2.1.1(发布日期:20191021
当前最新版本: 2.1.2(发布日期:20191122
[![AUR](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/zhangdaiscott/jeecg-boot/blob/master/LICENSE)
[![](https://img.shields.io/badge/Author-JEECG团队-orange.svg)](http://www.jeecg.com)
......
Ant Design Jeecg Vue
====
当前最新版本: 2.0.2(发布日期:20190708
当前最新版本: 2.1.2(发布日期:20191122
Overview
----
......
此差异已折叠。
{
"name": "vue-antd-jeecg",
"version": "2.1.1",
"version": "2.1.2",
"private": true,
"scripts": {
"pre": "cnpm install || yarn --registry https://registry.npm.taobao.org || npm install --registry https://registry.npm.taobao.org ",
......@@ -10,7 +10,7 @@
},
"dependencies": {
"@antv/data-set": "^0.10.2",
"@jeecg/antd-online": "1.2.0",
"@jeecg/antd-online": "2.1.2",
"@tinymce/tinymce-vue": "^2.0.0",
"ant-design-vue": "^1.4.0",
"apexcharts": "^3.6.5",
......@@ -34,7 +34,7 @@
"vue-loader": "^15.7.0",
"vue-ls": "^3.2.0",
"vue-photo-preview": "^1.1.3",
"vue-print-nb-jeecg": "^1.0.8",
"vue-print-nb-jeecg": "^1.0.9",
"vue-property-decorator": "^7.3.0",
"vue-router": "^3.0.1",
"vue-splitpane": "^1.0.4",
......@@ -51,6 +51,7 @@
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.1.0",
"html-webpack-plugin": "^4.0.0-beta.11",
"less": "^3.9.0",
"less-loader": "^4.1.0",
"node-sass": "^4.11.0",
......
......@@ -31,6 +31,11 @@
type: Array,
default: () => ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'Jun.', 'Jul.', 'Aug.']
},
// 别名,需要的格式:[{field:'name',alias:'姓名'}, {field:'sex',alias:'性别'}]
aliases:{
type: Array,
default: () => []
},
height: {
type: Number,
default: 254
......@@ -55,13 +60,22 @@
})
// bar 使用不了 - 和 / 所以替换下
return dv.rows.map(row => {
let rows = dv.rows.map(row => {
if (typeof row.x === 'string') {
row.x = row.x.replace(/[-/]/g, '_')
}
return row
})
// 替换别名
rows.forEach(row => {
for (let item of this.aliases) {
if (item.field === row.type) {
row.type = item.alias
break
}
}
})
return rows
}
}
}
......
......@@ -42,6 +42,11 @@
type: Array,
default: () => ['jeecg', 'jeebt']
},
// 别名,需要的格式:[{field:'name',alias:'姓名'}, {field:'sex',alias:'性别'}]
aliases:{
type: Array,
default: () => []
},
height: {
type: Number,
default: 254
......@@ -66,7 +71,17 @@
key: 'x',
value: 'y'
})
return dv.rows
let rows = dv.rows
// 替换别名
rows.forEach(row => {
for (let item of this.aliases) {
if (item.field === row.x) {
row.x = item.alias
break
}
}
})
return rows
}
}
}
......
......@@ -28,13 +28,16 @@ export async function initDictOptions(dictCode) {
* @return String
*/
export function filterDictText(dictOptions, text) {
let re = "";
dictOptions.forEach(function (option) {
if (text === option.value) {
re = option.text;
//--update-begin----author:sunjianlei---date:20191025------for:修复字典替换方法在字典没有加载完成之前报错的问题、修复没有找到字典时返回空值的问题---
if (dictOptions instanceof Array) {
for (let dictItem of dictOptions) {
if (text === dictItem.value) {
return dictItem.text
}
}
});
return re;
}
return text
//--update-end----author:sunjianlei---date:20191025------for:修复字典替换方法在字典没有加载完成之前报错的问题、修复没有找到字典时返回空值的问题---
}
/**
......@@ -58,7 +61,7 @@ export function filterMultiDictText(dictOptions, text) {
}
});
if(re==""){
return "";
return text;
}
return re.substring(0,re.length-1);
}
......
......@@ -181,6 +181,7 @@
:options="col.options"
:getPopupContainer="getParentContainer"
:placeholder="replaceProps(col, col.placeholder)"
:filterOption="(i,o)=>handleSelectFilterOption(i,o,col)"
@change="(v)=>handleChangeSelectCommon(v,id,row,col)"
@search="(v)=>handleSearchSelect(v,id,row,col)"
@blur="(v)=>handleBlurSearch(v,id,row,col)"
......@@ -514,7 +515,7 @@
</div>
<!-- else (normal) -->
<span v-else :key="i" v-bind="buildProps(row,col)" >{{ inputValues[rowIndex][col.key] }}</span>
<span v-else :key="i" v-bind="buildProps(row,col)">{{ inputValues[rowIndex][col.key] }}</span>
</template>
</div>
</div>
......@@ -657,17 +658,6 @@
created() {
// 当前显示的tr
this.visibleTrEls = []
// 用来存储input表单的值
// 数组里的每项都是一个对象,对象里每个key都是input的rowKey,值就是input的值,其中有个id的字段来区分
// 示例:
// [{
// id: "_jet-4sp0iu-15541771111770"
// dbDefaultVal: "aaa",
// dbFieldName: "bbb",
// dbFieldTxt: "ccc",
// dbLength: 32
// }]
this.inputValues = []
this.disabledRowIds = (this.disabledRowIds || [])
},
// 计算属性
......@@ -827,15 +817,18 @@
for (let columnKey in this.disabledRows) {
// 判断是否有该属性
if (this.disabledRows.hasOwnProperty(columnKey) && data.hasOwnProperty(columnKey)) {
// row[columnKey] =
if (disabled !== true) {
disabled = this.disabledRows[columnKey] === data[columnKey]
let temp = this.disabledRows[columnKey]
// 禁用规则可以是一个数组
if (temp instanceof Array) {
disabled = temp.includes(data[columnKey])
} else {
disabled = (temp === data[columnKey])
}
if (disabled) {
disabledRowIds.push(row.id)
}
}
}
}
})
......@@ -870,9 +863,9 @@
column.options = column.options.map(item => {
if (item) {
return {
...item,
text: item.text || item.title,
title: item.text || item.title,
value: item.value
title: item.text || item.title
}
}
return {}
......@@ -925,10 +918,20 @@
/** 初始化列表 */
initialize() {
// inputValues:用来存储input表单的值
// 数组里的每项都是一个对象,对象里每个key都是input的rowKey,值就是input的值,其中有个id的字段来区分
// 示例:
// [{
// id: "_jet-4sp0iu-15541771111770"
// dbDefaultVal: "aaa",
// dbFieldName: "bbb",
// dbFieldTxt: "ccc",
// dbLength: 32
// }]
this.inputValues = []
this.visibleTrEls = []
this.rows = []
this.deleteIds = []
this.inputValues = []
this.selectValues = {}
this.checkboxValues = {}
this.jdateValues = {}
......@@ -1094,16 +1097,17 @@
}
this.rows = rows
let rowValue = this.getValuesSync({
validate: false,
rowIds: [this.removeCaseId(row.id)]
}).values[0]
this.$nextTick(() => {
this.updateFormValues()
})
// 触发add事件
this.$emit('added', {
row: (() => {
let r = Object.assign({}, row)
r.id = this.removeCaseId(r.id)
return r
})(),
row: rowValue,
target: this
})
// 设置滚动条位置
......@@ -1600,9 +1604,16 @@
clearSelection() {
this.selectedRowIds = []
},
/** 用于搜索下拉框中的内容 */
handleSelectFilterOption(input, option, column) {
if (column.allowSearch === true) {
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
return true
},
/** select 搜索时的事件,用于动态添加options */
handleSearchSelect(value, id, row, col) {
if (col.allowInput === true) {
if (col.allowSearch !== true && col.allowInput === true) {
// 是否找到了对应的项,找不到则添加这一项
let flag = false
for (let option of col.options) {
......@@ -1941,7 +1952,7 @@
}
}
// 判断select是否允许输入
if (col.type === FormTypes.select && col.allowInput === true) {
if (col.type === FormTypes.select && (col.allowInput === true || col.allowSearch === true)) {
props['showSearch'] = true
}
......@@ -2022,7 +2033,6 @@
this.elemValueChange(FormTypes.list_multi, row, column, value)
},
handleSearchSelectChange(value, id, row, column) {
console.log(value)
this.searchSelectValues = this.bindValuesChange(value, id, 'searchSelectValues')
this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
this.elemValueChange(FormTypes.sel_search, row, column, value)
......
......@@ -61,6 +61,7 @@
toolbar: this.toolbar,
branding: false,
menubar: false,
toolbar_drawer: false,
images_upload_handler: (blobInfo, success) => {
const img = 'data:image/jpeg;base64,' + blobInfo.base64()
success(img)
......
......@@ -63,7 +63,33 @@
</a-col>
<a-col :span="8">
<j-dict-select-tag v-if="item.dictCode" v-model="item.val" :dictCode="item.dictCode" placeholder="请选择"/>
<template v-if="item.dictCode">
<template v-if="item.type === 'table-dict'">
<j-popup
v-model="item.val"
:code="item.dictTable"
:field="item.dictCode"
:orgFields="item.dictCode"
:destFields="item.dictCode"
></j-popup>
</template>
<j-dict-select-tag v-else v-model="item.val" :dictCode="item.dictCode" placeholder="请选择"/>
</template>
<j-select-multi-user
v-else-if="item.type === 'select-user'"
v-model="item.val"
:buttons="false"
:multiple="false"
placeholder="请选择用户"
:returnKeys="['id', item.customReturnField || 'username']"
/>
<j-select-depart
v-else-if="item.type === 'select-depart'"
v-model="item.val"
:multi="false"
placeholder="请选择部门"
:customReturnField="item.customReturnField || 'id'"
/>
<j-date v-else-if=" item.type=='date' " v-model="item.val" placeholder="请选择日期" style="width: 100%"></j-date>
<j-date v-else-if=" item.type=='datetime' " v-model="item.val" placeholder="请选择时间" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"></j-date>
<a-input-number v-else-if=" item.type=='int'||item.type=='number' " style="width: 100%" placeholder="请输入数值" v-model="item.val"/>
......@@ -86,7 +112,10 @@
<div slot="title">
保存的查询
</div>
<a-empty v-if="treeData.length === 0" class="j-super-query-history-empty" description="没有保存任何查询"/>
<a-tree
v-else
class="j-super-query-history-tree"
showIcon
:treeData="treeData"
......@@ -113,10 +142,12 @@
<script>
import * as utils from '@/utils/util'
import JDate from '@/components/jeecg/JDate.vue'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JSelectMultiUser from '@/components/jeecgbiz/JSelectMultiUser'
export default {
name: 'JSuperQuery',
components: { JDate },
components: { JDate, JSelectDepart, JSelectMultiUser },
props: {
/*
fieldList: [{
......@@ -182,7 +213,6 @@
return item
})
}
console.log({ list })
}
}
},
......@@ -222,9 +252,12 @@
handleSelected(option, item) {
let index = option.data.attrs['data-idx']
let { type, dictCode } = this.fieldList[index]
let { type, dictCode, dictTable, customReturnField } = this.fieldList[index]
item['type'] = type
item['dictCode'] = dictCode
item['dictTable'] = dictTable
item['customReturnField'] = customReturnField
this.$set(item, 'val', '')
},
handleReset() {
this.queryParamsModel = [{}]
......@@ -338,6 +371,24 @@
}
}
.j-super-query-history-empty /deep/ {
.ant-empty-image {
height: 80px;
line-height: 80px;
margin-bottom: 0;
}
img {
width: 80px;
height: 65px;
}
.ant-empty-description {
color: #afafaf;
margin: 8px 0;
}
}
.j-super-query-history-tree /deep/ {
.ant-tree-switcher {
display: none;
......
<template>
<a-row class="j-select-biz-component-box" type="flex" :gutter="8">
<a-col class="left">
<a-col class="left" :class="{'full': !buttons}">
<a-select
mode="multiple"
:placeholder="placeholder"
......@@ -10,10 +10,11 @@
:disabled="disabled"
:open="false"
style="width: 100%;"
@click.native="visible=(buttons?visible:true)"
/>
</a-col>
<a-col class="right">
<a-col v-if="buttons" class="right">
<a-button type="primary" icon="search" :disabled="disabled" @click="visible=true">{{selectButtonText}}</a-button>
</a-col>
......@@ -57,6 +58,11 @@
type: Boolean,
default: true
},
// 是否显示按钮,默认 true
buttons: {
type: Boolean,
default: true
},
/* 可复用属性 */
......@@ -153,5 +159,9 @@
.right {
width: #{$width};
}
.full {
width: 100%;
}
}
</style>
\ No newline at end of file
......@@ -11,7 +11,7 @@
:modal-width="modalWidth"
:multi="multi"
:rootOpened="rootOpened"
:depart-id="value"
:depart-id="departIds"
@ok="handleOK"
@initComp="initComp"/>
</div>
......@@ -48,6 +48,11 @@
type: Boolean,
required: false,
default: false
},
// 自定义返回字段,默认返回 id
customReturnField: {
type: String,
default: 'id'
}
},
data(){
......@@ -63,7 +68,9 @@
},
watch:{
value(val){
this.departIds = val
if (this.customReturnField === 'id') {
this.departIds = val
}
}
},
methods:{
......@@ -73,21 +80,17 @@
openModal(){
this.$refs.innerDepartSelectModal.show()
},
handleOK(rows,idstr){
console.log("当前选中部门",rows)
console.log("当前选中部门ID",idstr)
if(!rows){
handleOK(rows, idstr) {
let value = ''
if (!rows && rows.length <= 0) {
this.departNames = ''
this.departIds=''
}else{
let temp = ''
for(let item of rows){
temp+=','+item.departName
}
this.departNames = temp.substring(1)
this.departIds=idstr
this.departIds = ''
} else {
value = rows.map(row => row[this.customReturnField]).join(',')
this.departNames = rows.map(row => row['departName']).join(',')
this.departIds = idstr
}
this.$emit("change",this.departIds)
this.$emit("change", value)
},
getDepartNames(){
return this.departNames
......
......@@ -5,7 +5,6 @@
name="用户"
displayKey="realname"
:returnKeys="returnKeys"
:listUrl="url.list"
:columns="columns"
queryParamText="账号"
......@@ -24,7 +23,6 @@
props: ['value'],
data() {
return {
returnKeys: ['id', 'username'],
url: { list: '/sys/user/list' },
columns: [
{ title: '姓名', align: 'center', width: 100, dataIndex: 'realname' },
......@@ -33,6 +31,17 @@
{ title: '出生日期', align: 'center', width: 100, dataIndex: 'birthday' }
]
}
},
watch: {
$attrs: {
deep: true,
immediate: true,
handler(val) {
if (!val.returnKeys) {
val.returnKeys = ['id', 'username']
}
}
}
}
}
</script>
......
......@@ -63,7 +63,7 @@
handler() {
if (this.departId) {
this.checkedKeys = this.departId.split(",");
console.log('this.departId', this.departId)
// console.log('this.departId', this.departId)
} else {
this.checkedKeys = [];
}
......@@ -75,7 +75,6 @@
this.visible=true
this.checkedRows=[]
this.checkedKeys=[]
console.log("this.multi",this.multi)
},
loadDepart(){
queryDepartTreeList().then(res=>{
......@@ -133,39 +132,29 @@
},
onCheck (checkedKeys,info) {
if(!this.multi){
let arr = checkedKeys.checked.filter(item=>{
return this.checkedKeys.indexOf(item)<0
})
let arr = checkedKeys.checked.filter(item => this.checkedKeys.indexOf(item) < 0)
this.checkedKeys = [...arr]
this.checkedRows=[info.node.dataRef]
this.checkedRows = (this.checkedKeys.length === 0) ? [] : [info.node.dataRef]
}else{
this.checkedKeys = checkedKeys.checked
this.checkedRows.push(info.node.dataRef)
this.checkedRows = this.getCheckedRows(this.checkedKeys)
}
//this.$emit("input",this.checkedKeys.join(","))
//console.log(this.checkedKeys.join(","))
},
onSelect (selectedKeys,info) {
console.log(selectedKeys)
onSelect(selectedKeys,info) {
let keys = []
keys.push(selectedKeys[0])
if(!this.checkedKeys || this.checkedKeys.length==0 || !this.multi){
if(!this.checkedKeys || this.checkedKeys.length===0 || !this.multi){
this.checkedKeys = [...keys]
this.checkedRows=[info.node.dataRef]
}else{
let currKey = info.node.dataRef.key
if(this.checkedKeys.indexOf(currKey)>=0){
this.checkedKeys = this.checkedKeys.filter(item=>{
return item !=currKey
})
this.checkedRows=this.checkedRows.filter(item=>{
return item.key !=currKey
})
this.checkedKeys = this.checkedKeys.filter(item=> item !==currKey)
}else{
this.checkedRows.push(info.node.dataRef)
this.checkedKeys.push(...keys)
}
}
this.checkedRows = this.getCheckedRows(this.checkedKeys)
},
onExpand (expandedKeys) {
this.expandedKeys = expandedKeys
......@@ -215,6 +204,32 @@
})
},
// 根据 checkedKeys 获取 rows
getCheckedRows(checkedKeys) {
const forChildren = (list, key) => {
for (let item of list) {
if (item.id === key) {
return item
}
if (item.children instanceof Array) {
let value = forChildren(item.children, key)
if (value != null) {
return value
}
}
}
return null
}
let rows = []
for (let key of checkedKeys) {
let row = forChildren(this.treeData, key)
if (row != null) {
rows.push(row)
}
}
return rows
}
}
}
......
......@@ -157,8 +157,9 @@
console.log("props userIds: ", this.userIds)
if (this.userIds) {
let currUserIds = this.userIds
let userIdsArr = currUserIds.split(',');
for (let item of this.dataSource) {
if (currUserIds.indexOf(item.username) >= 0) {
if (userIdsArr.includes(item.username)) {
names += "," + item.realname
}
}
......
......@@ -51,9 +51,12 @@ export const JeecgListMixin = {
}
},
created() {
this.loadData();
//初始化字典配置 在自己页面定义
this.initDictConfig();
if(!this.disableMixinCreated){
console.log(' -- mixin created -- ')
this.loadData();
//初始化字典配置 在自己页面定义
this.initDictConfig();
}
},
methods:{
loadData(arg) {
......@@ -149,6 +152,7 @@ export const JeecgListMixin = {
title: "确认删除",
content: "是否删除选中数据?",
onOk: function () {
that.loading = true;
deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
if (res.success) {
that.$message.success(res.message);
......@@ -157,6 +161,8 @@ export const JeecgListMixin = {
} else {
that.$message.warning(res.message);
}
}).finally(() => {
that.loading = false;
});
}
});
......
......@@ -8,7 +8,7 @@ import { ACCESS_TOKEN } from "@/store/mutation-types"
// 创建 axios 实例
const service = axios.create({
baseURL: '/jeecg-boot', // api base_url
timeout: 15000 // 请求超时时间
timeout: 6000 // 请求超时时间
})
const err = (error) => {
......
import * as api from '@/api/api'
import { isURL } from '@/utils/validate'
export function timeFix() {
......@@ -254,4 +255,25 @@ export function cssExpand(css, id) {
}
// 应用新样式
document.head.appendChild(style)
}
/**
* 重复值验证工具方法
*
* 使用示例:
* { validator: (rule, value, callback) => validateDuplicateValue('sys_fill_rule', 'rule_code', value, this.model.id, callback) }
*
* @param tableName 被验证的表名
* @param fieldName 被验证的字段名
* @param fieldVal 被验证的值
* @param dataId 数据ID,可空
* @param callback
*/
export function validateDuplicateValue(tableName, fieldName, fieldVal, dataId, callback) {
let params = { tableName, fieldName, fieldVal, dataId }
api.duplicateCheck(params).then(res => {
res['success'] ? callback() : callback(res['message'])
}).catch(err => {
callback(err.message || err)
})
}
\ No newline at end of file
......@@ -39,8 +39,8 @@
<!-- 部门选择控件 -->
<a-row :gutter="24">
<a-col :span="12">
<a-form-item label="选择部门">
<j-select-depart v-decorator="['departId']" :trigger-change="true"></j-select-depart>
<a-form-item label="选择部门 自定义返回值">
<j-select-depart v-decorator="['departId']" :trigger-change="true" customReturnField="departName"></j-select-depart>
</a-form-item>
</a-col>
<a-col :span="12">选中的部门ID(v-decorator):{{ getDepartIdValue() }}</a-col>
......@@ -69,7 +69,7 @@
<a-row :gutter="24">
<a-col :span="12">
<a-form-item label="选择用户">
<j-select-multi-user v-model="multiUser"></j-select-multi-user>
<j-select-multi-user v-model="multiUser" ></j-select-multi-user>
</a-form-item>
</a-col>
<a-col :span="12">选中的用户(v-model):{{ multiUser }}</a-col>
......@@ -217,7 +217,7 @@
<a-row :gutter="24">
<a-col :span="12">
<a-form-item label="树字典">
<j-tree-dict parentCode="A01" />
<j-tree-dict parentCode="B01" />
</a-form-item>
</a-col>
<a-col :span="12"></a-col>
......
......@@ -177,13 +177,14 @@
import JDictSelectTag from '../../../../components/dict/JDictSelectTag.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import Clipboard from 'clipboard'
import { filterObj } from '@/utils/util';
export default {
name: 'OnlCgformHeadList',
mixins: [JeecgListMixin],
components: {
JDictSelectTag
JDictSelectTag,
},
data() {
return {
......
......@@ -132,6 +132,7 @@
<j-import-modal ref="importModal" :url="getImportUrl()" @ok="importOk"></j-import-modal>
<process-inst-pic-modal ref="processInstPicModal"></process-inst-pic-modal>
</div>
</a-card>
</template>
......@@ -691,6 +692,12 @@
}
});
},
handlePreviewPic: function(record){
var flowCode = this.flowCodePre+this.currentTableName;
var dataId = record.id;
this.$refs.processInstPicModal.preview(flowCode,dataId);
this.$refs.processInstPicModal.title="流程图";
}
}
}
......
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :md="6" :sm="8">
<a-form-item label="规则名称">
<a-input placeholder="请输入规则名称" v-model="queryParam.ruleName"></a-input>
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<a-form-item label="规则Code">
<a-input placeholder="请输入规则Code" v-model="queryParam.ruleCode"></a-input>
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('填值规则')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload>
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel">
<a-icon type="delete"/>
删除
</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作
<a-icon type="down"/>
</a-button>
</a-dropdown>
</div>
<!-- table区域-begin -->
<a-alert type="info" showIcon style="margin-bottom: 16px;">
<template slot="message">
<span>已选择</span>
<a style="font-weight: 600;padding: 0 4px;">{{ selectedRowKeys.length }}</a>
<span></span>
<template v-if="selectedRowKeys.length>0">
<a-divider type="vertical"/>
<a @click="onClearSelected">清空</a>
</template>
</template>
</a-alert>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical"/>
<a-dropdown>
<a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
<a-menu slot="overlay">
<a-menu-item @click="handleTest(record)">
功能测试
</a-menu-item>
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
<!-- table区域-end -->
<!-- 表单区域 -->
<sys-fill-rule-modal ref="modalForm" @ok="modalFormOk"/>
</a-card>
</template>
<script>
import { getAction } from '@/api/manage'
import SysFillRuleModal from './modules/SysFillRuleModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
name: 'SysFillRuleList',
mixins: [JeecgListMixin],
components: { SysFillRuleModal },
data() {
return {
description: '填值规则管理页面',
// 表头
columns: [
{
title: '#',
dataIndex: '',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: (t, r, index) => 1 + index
},
{
title: '规则名称',
align: 'center',
dataIndex: 'ruleName'
},
{
title: '规则Code',
align: 'center',
dataIndex: 'ruleCode'
},
{
title: '规则实现类',
align: 'center',
dataIndex: 'ruleClass'
},
{
title: '规则参数',
align: 'center',
dataIndex: 'ruleParams'
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
scopedSlots: { customRender: 'action' },
}
],
url: {
list: '/sys/fillRule/list',
test: '/sys/fillRule/testFillRule',
delete: '/sys/fillRule/delete',
deleteBatch: '/sys/fillRule/deleteBatch',
exportXlsUrl: '/sys/fillRule/exportXls',
importExcelUrl: '/sys/fillRule/importExcel',
},
}
},
computed: {
importExcelUrl() {
return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`
}
},
methods: {
handleTest(record) {
let closeLoading = this.$message.loading('生成中...', 0)
getAction(this.url.test, {
ruleCode: record.ruleCode
}).then(res => {
if (res.success) {
this.$info({
title: '填值规则功能测试',
content: '生成结果:' + res.result
})
} else {
this.$message.warn(res.message)
}
}).finally(() => {
closeLoading()
})
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>
\ No newline at end of file
......@@ -19,7 +19,7 @@
<template v-if="toggleSearchStatus">
<a-col :md="6" :sm="8">
<a-form-item label="职级">
<j-dict-select-tag v-model="queryParam.rank" placeholder="请选择职级" dictCode="position_rank"/>
<j-dict-select-tag v-model="queryParam.postRank" placeholder="请选择职级" dictCode="position_rank"/>
</a-form-item>
</a-col>
......@@ -143,7 +143,7 @@
{
title: '职级',
align: 'center',
dataIndex: 'rank_dictText'
dataIndex: 'postRank_dictText'
},
// {
// title: '公司id',
......
......@@ -65,7 +65,7 @@
<!-- 操作按钮区域 -->
<div class="table-operator" style="border-top: 5px">
<a-button @click="handleAdd" v-has="'user:add'" type="primary" icon="plus">添加用户</a-button>
<a-button @click="handleAdd" type="primary" icon="plus" v-has="'user:add'">添加用户</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('用户信息')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
......@@ -119,6 +119,7 @@
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical"/>
<a-dropdown>
......
<template>
<a-modal
:title="title"
:width="800"
:visible="visible"
:maskClosable="false"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则名称">
<a-input placeholder="请输入规则名称" v-decorator="['ruleName', validatorRules.ruleName]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则Code">
<a-input placeholder="请输入规则Code" :disabled="disabledCode" v-decorator="['ruleCode', validatorRules.ruleCode]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则实现类">
<a-input placeholder="请输入规则实现类" v-decorator="['ruleClass', validatorRules.ruleClass]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则参数">
<a-textarea placeholder="请输入规则参数" :rows="5" v-decorator="['ruleParams', validatorRules.ruleParams]"/>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import { httpAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
export default {
name: 'SysFillRuleModal',
components: {},
data() {
return {
title: '操作',
visible: false,
model: {},
labelCol: { xs: { span: 24 }, sm: { span: 5 } },
wrapperCol: { xs: { span: 24 }, sm: { span: 16 } },
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules: {
ruleName: { rules: [{ required: true, message: '规则名称不能为空' }] },
ruleCode: {
rules: [
{ required: true, message: '规则Code不能为空' },
{ validator: (rule, value, callback) => validateDuplicateValue('sys_fill_rule', 'rule_code', value, this.model.id, callback) }
]
},
ruleClass: { rules: [{ required: true, message: '规则实现类不能为空' }] },
ruleParams: {
rules: [{
validator: (rule, value, callback) => {
try {
let json = JSON.parse(value)
if (json instanceof Array) {
callback('只能传递JSON对象,不能传递JSON数组')
} else if (json instanceof Object) {
callback()
} else {
callback('请输入JSON字符串')
}
} catch {
callback('请输入JSON字符串')
}
}
}]
},
},
url: {
add: '/sys/fillRule/add',
edit: '/sys/fillRule/edit',
},
}
},
computed: {
disabledCode() {
return !!this.model.id
}
},
created() {
},
methods: {
add() {
this.edit({})
},
edit(record) {
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'ruleName', 'ruleCode', 'ruleClass', 'ruleParams'))
})
},
close() {
this.$emit('close')
this.visible = false
},
handleOk() {
const that = this
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true
let httpUrl = this.url.add, method = 'post'
if (this.model.id) {
httpUrl = this.url.edit
method = 'put'
}
let formData = Object.assign(this.model, values)
httpAction(httpUrl, formData, method).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
that.close()
})
}
})
},
handleCancel() {
this.close()
}
}
}
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
......@@ -33,7 +33,7 @@
placeholder="请选择职级"
:triggerChange="true"
dictCode="position_rank"
v-decorator="['rank', validatorRules.rank]"
v-decorator="['postRank', validatorRules.postRank]"
/>
</a-form-item>
<!--<a-form-item-->
......@@ -104,7 +104,7 @@
]
},
name: { rules: [{ required: true, message: '请输入职务名称' }] },
rank: { rules: [{ required: true, message: '请选择职级' }] },
postRank: { rules: [{ required: true, message: '请选择职级' }] },
},
url: {
add: '/sys/position/add',
......@@ -126,7 +126,7 @@
this.form.setFieldsValue(pick(this.model,
'code',
'name',
'rank',
'postRank',
// 'companyId'
))
})
......
......@@ -84,7 +84,7 @@
</a-tabs>
<a-form-item>
<a-checkbox v-model="formLogin.rememberMe">自动登陆</a-checkbox>
<a-checkbox v-decorator="['rememberMe', {initialValue: true, valuePropName: 'checked'}]" >自动登陆</a-checkbox>
<router-link :to="{ name: 'alteration'}" class="forge-password" style="float: right;">
忘记密码
</router-link>
......@@ -201,13 +201,6 @@
time: 60,
smsSendBtn: false,
},
formLogin: {
username: "",
password: "",
captcha: "",
mobile: "",
rememberMe: true
},
validatorRules:{
username:{rules: [{ required: true, message: '请输入用户名!',validator: 'click'}]},
password:{rules: [{ required: true, message: '请输入密码!',validator: 'click'}]},
......@@ -251,19 +244,18 @@
},
handleSubmit () {
let that = this
let loginParams = {
remember_me: that.formLogin.rememberMe
};
let loginParams = {};
that.loginBtn = true;
// 使用账户密码登陆
if (that.customActiveKey === 'tab1') {
that.form.validateFields([ 'username', 'password','inputCode' ], { force: true }, (err, values) => {
that.form.validateFields([ 'username', 'password','inputCode', 'rememberMe' ], { force: true }, (err, values) => {
if (!err) {
loginParams.username = values.username
// update-begin- --- author:scott ------ date:20190805 ---- for:密码加密逻辑暂时注释掉,有点问题
//loginParams.password = md5(values.password)
//loginParams.password = encryption(values.password,that.encryptedString.key,that.encryptedString.iv)
loginParams.password = values.password
loginParams.remember_me = values.rememberMe
// update-begin- --- author:scott ------ date:20190805 ---- for:密码加密逻辑暂时注释掉,有点问题
let checkParams = this.$refs.jgraphicCodeRef.getLoginParam()
loginParams.captcha = checkParams.checkCode
......@@ -282,10 +274,11 @@
})
// 使用手机号登陆
} else {
that.form.validateFields([ 'mobile', 'captcha' ], { force: true }, (err, values) => {
that.form.validateFields([ 'mobile', 'captcha', 'rememberMe' ], { force: true }, (err, values) => {
if (!err) {
loginParams.mobile = values.mobile
loginParams.captcha = values.captcha
loginParams.remember_me = values.rememberMe
that.PhoneLogin(loginParams).then((res) => {
console.log(res.result);
this.departConfirm(res)
......
此差异已折叠。
Jeecg-Boot 快速开发平台
===============
当前最新版本: 2.1.1(发布日期:20191021
当前最新版本: 2.1.2(发布日期:20191122
## 后端技术架构
......@@ -39,7 +39,7 @@ Jeecg-Boot 快速开发平台
- 在线演示 : [http://boot.jeecg.org](http://boot.jeecg.org)
- 在线教程[http://doc.jeecg.com/1273753](http://doc.jeecg.com/1273753)
- 在线文档[http://doc.jeecg.com/1273753](http://doc.jeecg.com/1273753)
- 常见问题: [入门常见问题大全](http://www.jeecg.org/forum.php?mod=viewthread&tid=7816&extra=page%3D1)
......
UPDATE `sys_dict_item` SET `item_text` = '可见/可访问(授权后可见/可访问)' WHERE `id` = '83250269359855501ec4e9c0b7e21596';
-- ----------------------------
-- Table structure for oss_file
-- ----------------------------
DROP TABLE IF EXISTS `oss_file`;
CREATE TABLE `oss_file` (
`id` varchar(32) NOT NULL COMMENT '主键id',
`file_name` varchar(255) default NULL COMMENT '文件名称',
`url` varchar(255) default NULL COMMENT '文件地址',
`create_by` varchar(32) default NULL COMMENT '创建人登录名称',
`create_time` datetime default NULL COMMENT '创建日期',
`update_by` varchar(32) default NULL COMMENT '更新人登录名称',
`update_time` datetime default NULL COMMENT '更新日期',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Oss File';
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status) VALUES ('1166535831146504193', '2a470fc0c3954d9dbb61de6d80846549', '对象存储', '/oss/file', 'modules/oss/OSSFileList', null, null, 1, null, '1', 1, 0, '', 1, 1, 0, 0, null, 'admin', '2019-08-28 02:19:50', 'admin', '2019-08-28 02:20:57', 0, 0, '1');
ALTER TABLE sys_permission
add COLUMN internal_or_external tinyint(1)
comment '外链菜单打开方式 0/内部打开 1/外部打开';
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1170592628746878978', 'd7d6e2e4e2934f2c9385a623fd98c6f3', '菜单管理', '/isystem/newPermissionList', 'system/NewPermissionList', NULL, NULL, '1', NULL, '1', '100', '0', NULL, '1', '1', '0', '0', NULL, 'admin', '2019-09-08 15:00:05', 'admin', '2019-09-08 15:02:57', '0', '0', '1', '0');
ALTER TABLE `sys_permission`
ADD INDEX `index_menu_type`(`menu_type`),
ADD INDEX `index_menu_hidden`(`hidden`),
ADD INDEX `index_menu_status`(`status`);
ALTER TABLE `sys_depart`
ADD COLUMN `org_category` varchar(10) NOT NULL DEFAULT 1 COMMENT '机构类别 1组织机构,2岗位' AFTER `description`;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1174511106530525185', '机构类型', 'org_category', '机构类型 1组织机构,2岗位', '0', 'admin', '2019-09-19 10:30:43', NULL, NULL, '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174511197735665665', '1174511106530525185', '组织机构', '1', '组织机构', '1', '1', 'admin', '2019-09-19 10:31:05', NULL, NULL);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174511244036587521', '1174511106530525185', '岗位', '2', '岗位', '1', '1', 'admin', '2019-09-19 10:31:16', NULL, NULL);
ALTER TABLE `sys_user`
ADD COLUMN `work_no` varchar(100) NULL COMMENT '工号,唯一键' AFTER `activiti_sync`,
ADD COLUMN `post` varchar(100) NULL COMMENT '职务,关联职务表' AFTER `work_no`,
ADD COLUMN `telephone` varchar(45) NULL COMMENT '座机号' AFTER `post`,
ADD UNIQUE INDEX `uniq_sys_user_work_no` (`work_no`);
DROP TABLE IF EXISTS `sys_position`;
CREATE TABLE `sys_position` (
`id` varchar(32) NOT NULL,
`code` varchar(100) DEFAULT NULL COMMENT '职务编码',
`name` varchar(100) DEFAULT NULL COMMENT '职务名称',
`rank` varchar(2) DEFAULT NULL COMMENT '职级',
`company_id` varchar(255) DEFAULT NULL COMMENT '公司id',
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(50) DEFAULT NULL COMMENT '修改人',
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
`sys_org_code` varchar(50) DEFAULT NULL COMMENT '组织机构编码',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 职务菜单
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1174506953255182338', 'd7d6e2e4e2934f2c9385a623fd98c6f3', '职务管理', '/isystem/position', 'system/SysPositionList', '1', NULL, NULL, '1', NULL, '1', '2', '0', NULL, '1', '0', '0', NULL, 'admin', '2019-09-19 10:14:13', 'admin', '2019-09-19 10:15:22', '0', '0', '1', '0');
-- 职务职级字典
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1174509082208395266', '职务职级', 'position_rank', '职务表职级字典', '0', 'admin', '2019-09-19 10:22:41', NULL, NULL, '0');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509601047994369', '1174509082208395266', '员工', '1', '', '1', '1', 'admin', '2019-09-19 10:24:45', NULL, NULL);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509667297026049', '1174509082208395266', '小组长', '2', '', '2', '1', 'admin', '2019-09-19 10:25:01', NULL, NULL);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509713568587777', '1174509082208395266', '部门经理', '3', '', '3', '1', 'admin', '2019-09-19 10:25:12', NULL, NULL);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509788361416705', '1174509082208395266', '副总经理', '4', '', '4', '1', 'admin', '2019-09-19 10:25:30', NULL, NULL);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509835803189250', '1174509082208395266', '总经理', '5', '', '5', '1', 'admin', '2019-09-19 10:25:41', NULL, NULL);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509861333917697', '1174509082208395266', '董事长', '6', '', '6', '1', 'admin', '2019-09-19 10:25:47', NULL, NULL);
-- 通讯录菜单
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1174590283938041857', 'd7d6e2e4e2934f2c9385a623fd98c6f3', '通讯录', '/isystem/addressList', 'system/AddressList', '1', NULL, NULL, '1', NULL, '1', '3', '0', NULL, '1', '0', '0', NULL, 'admin', '2019-09-19 15:45:21', NULL, NULL, '0', '0', '1', '0');
DELETE FROM sys_dict_item WHERE dict_id = "1174509082208395266";
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509601047994369', '1174509082208395266', '员级', '1', '', '1', '1', 'admin', '2019-09-19 10:24:45', 'admin', '2019-09-23 11:46:39');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509667297026049', '1174509082208395266', '助级', '2', '', '2', '1', 'admin', '2019-09-19 10:25:01', 'admin', '2019-09-23 11:46:47');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509713568587777', '1174509082208395266', '中级', '3', '', '3', '1', 'admin', '2019-09-19 10:25:12', 'admin', '2019-09-23 11:46:56');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509788361416705', '1174509082208395266', '副高级', '4', '', '4', '1', 'admin', '2019-09-19 10:25:30', 'admin', '2019-09-23 11:47:06');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1174509835803189250', '1174509082208395266', '正高级', '5', '', '5', '1', 'admin', '2019-09-19 10:25:41', 'admin', '2019-09-23 11:47:12');
ALTER TABLE sys_user
MODIFY COLUMN `sex` tinyint(1) NULL COMMENT '性别(0-默认未知,1-男,2-女)' AFTER `birthday`;
ALTER TABLE sys_permission
MODIFY COLUMN `sort_no` double(8, 2) NULL DEFAULT NULL COMMENT '菜单排序' AFTER `perms_type`;
INSERT INTO `sys_dict`(`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1178295274528845826', '表单权限策略', 'form_perms_type', '', 0, 'admin', '2019-09-29 21:07:39', 'admin', '2019-09-29 21:08:26', NULL);
INSERT INTO `sys_dict_item`(`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1178295553450061826', '1178295274528845826', '可编辑(未授权禁用)', '2', '', 2, 1, 'admin', '2019-09-29 21:08:46', 'admin', '2019-09-29 21:09:18');
INSERT INTO `sys_dict_item`(`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1178295639554928641', '1178295274528845826', '可见(未授权不可见)', '1', '', 1, 1, 'admin', '2019-09-29 21:09:06', 'admin', '2019-09-29 21:09:24');
ALTER TABLE `sys_role`
ADD UNIQUE INDEX `uniq_sys_role_role_code` (`role_code`) USING BTREE ;
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`) VALUES ('f2849d3814fc97993bfc519ae6bbf049', 'e41b69c57a941a3bbcce45032fe57605', 'AUTO复制表单', '/online/copyform/:code', 'modules/online/cgform/OnlCgformCopyList', NULL, NULL, '1', NULL, '1', '1', '0', NULL, '1', '1', '0', '1', NULL, 'admin', '2019-08-29 16:05:37', NULL, NULL, '0', '0', '1');
ALTER TABLE `onl_cgform_head`
ADD COLUMN `copy_version` int(11) NULL COMMENT '复制版本号' AFTER `form_template_mobile`,
ADD COLUMN `copy_type` int(3) NULL DEFAULT 0 COMMENT '复制表类型1为复制表 0为原始表' AFTER `copy_version`,
ADD COLUMN `physic_id` varchar(32) NULL COMMENT '原始表ID' AFTER `copy_type`;
ALTER TABLE `onl_cgform_head`
ADD COLUMN `scroll` int(3) NULL DEFAULT 0 COMMENT '是否有横向滚动条' AFTER `form_template_mobile`;
\ No newline at end of file
......@@ -3,12 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jeecg-boot-base-common</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
</parent>
<repositories>
......
......@@ -11,6 +11,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* 关于 ElasticSearch 的一些方法(创建索引、添加数据、查询等)
*
......@@ -20,11 +24,54 @@ import org.springframework.stereotype.Component;
@Component
public class JeecgElasticsearchTemplate {
@Value("${jeecg.elasticsearch.cluster-nodes}")
/**
* 用户配置是否通过,未通过就不走任何方法
*/
private static boolean configIsPassed = true;
/**
* 是否已检测过配置
*/
private static boolean configIsChecked = false;
private String baseUrl;
private final String FORMAT_JSON = "format=json";
public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl) {
log.debug("JeecgElasticsearchTemplate BaseURL:" + baseUrl);
// 未检测过配置,进行检测操作
if (!configIsChecked) {
configIsChecked = true;
// 为空则代表未配置 baseUrl
if (StringUtils.isEmpty(baseUrl)) {
configIsPassed = false;
} else {
this.baseUrl = baseUrl;
// 判断配置的地址是否有效
try {
RestUtil.get(this.getBaseUrl().toString());
} catch (Exception e) {
configIsPassed = false;
}
}
if (configIsPassed) {
log.info("ElasticSearch服务连接成功");
} else {
log.warn("ElasticSearch 服务连接失败,原因:配置未通过。可能是BaseURL未配置或配置有误,也可能是Elasticsearch服务未启动。接下来将会拒绝执行任何方法!");
}
}
}
/**
* 检查配置是否通过,未通过就抛出异常,中断执行
*/
private void checkConfig() {
if (!configIsPassed) {
throw new RuntimeException("配置未通过,拒绝执行该方法");
}
}
public StringBuilder getBaseUrl(String indexName, String typeName) {
typeName = typeName.trim().toLowerCase();
return this.getBaseUrl(indexName).append("/").append(typeName);
......@@ -43,6 +90,7 @@ public class JeecgElasticsearchTemplate {
* cat 查询ElasticSearch系统数据,返回json
*/
public <T> ResponseEntity<T> _cat(String urlAfter, Class<T> responseType) {
this.checkConfig();
String url = this.getBaseUrl().append("/_cat").append(urlAfter).append("?").append(FORMAT_JSON).toString();
return RestUtil.request(url, HttpMethod.GET, null, null, null, responseType);
}
......@@ -53,6 +101,7 @@ public class JeecgElasticsearchTemplate {
* 查询地址:GET http://{baseUrl}/_cat/indices
*/
public JSONArray getIndices() {
this.checkConfig();
return getIndices(null);
}
......@@ -63,6 +112,7 @@ public class JeecgElasticsearchTemplate {
* 查询地址:GET http://{baseUrl}/_cat/indices/{indexName}
*/
public JSONArray getIndices(String indexName) {
this.checkConfig();
StringBuilder urlAfter = new StringBuilder("/indices");
if (!StringUtils.isEmpty(indexName)) {
urlAfter.append("/").append(indexName.trim().toLowerCase());
......@@ -74,6 +124,7 @@ public class JeecgElasticsearchTemplate {
* 索引是否存在
*/
public boolean indexExists(String indexName) {
this.checkConfig();
try {
JSONArray array = getIndices(indexName);
return array != null;
......@@ -92,6 +143,7 @@ public class JeecgElasticsearchTemplate {
* 查询地址:PUT http://{baseUrl}/{indexName}
*/
public boolean createIndex(String indexName) {
this.checkConfig();
String url = this.getBaseUrl(indexName).toString();
/* 返回结果 (仅供参考)
......@@ -119,6 +171,7 @@ public class JeecgElasticsearchTemplate {
* 查询地址:DELETE http://{baseUrl}/{indexName}
*/
public boolean removeIndex(String indexName) {
this.checkConfig();
String url = this.getBaseUrl(indexName).toString();
try {
return RestUtil.delete(url).getBoolean("acknowledged");
......@@ -136,6 +189,7 @@ public class JeecgElasticsearchTemplate {
* 保存数据,详见:saveOrUpdate
*/
public boolean save(String indexName, String typeName, String dataId, JSONObject data) {
this.checkConfig();
return this.saveOrUpdate(indexName, typeName, dataId, data);
}
......@@ -143,6 +197,7 @@ public class JeecgElasticsearchTemplate {
* 更新数据,详见:saveOrUpdate
*/
public boolean update(String indexName, String typeName, String dataId, JSONObject data) {
this.checkConfig();
return this.saveOrUpdate(indexName, typeName, dataId, data);
}
......@@ -158,6 +213,7 @@ public class JeecgElasticsearchTemplate {
* @return
*/
public boolean saveOrUpdate(String indexName, String typeName, String dataId, JSONObject data) {
this.checkConfig();
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
/* 返回结果(仅供参考)
"createIndexA2": {
......@@ -178,12 +234,17 @@ public class JeecgElasticsearchTemplate {
try {
// 去掉 data 中为空的值
for (String key : data.keySet()) {
Set<String> keys = data.keySet();
List<String> emptyKeys = new ArrayList<>(keys.size());
for (String key : keys) {
String value = data.getString(key);
if (StringUtils.isEmpty(value)) {
data.remove(key);
emptyKeys.add(key);
}
}
for (String key : emptyKeys) {
data.remove(key);
}
} catch (Exception e) {
e.printStackTrace();
}
......@@ -198,6 +259,7 @@ public class JeecgElasticsearchTemplate {
* 请求地址:DELETE http://{baseUrl}/{indexName}/{typeName}/{dataId}
*/
public boolean delete(String indexName, String typeName, String dataId) {
this.checkConfig();
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
/* 返回结果(仅供参考)
{
......@@ -235,6 +297,7 @@ public class JeecgElasticsearchTemplate {
* 请求地址:POST http://{baseUrl}/{indexName}/{typeName}/_search
*/
public JSONObject search(String indexName, String typeName, JSONObject queryObject) {
this.checkConfig();
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
log.info("search: " + queryObject.toJSONString());
......
package org.jeecg.common.handler;
import com.alibaba.fastjson.JSONObject;
/**
* 填值规则接口
*
* @author Yan_东
* 如需使用填值规则功能,规则实现类必须实现此接口
*/
public interface IFillRuleHandler {
public Object execute(JSONObject params, JSONObject formData);
}
......@@ -6,6 +6,7 @@ import java.util.List;
import org.jeecg.common.system.vo.ComboModel;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.system.vo.SysDepartModel;
/**
* @Description: 底层共通业务API,提供其他独立模块调用
......@@ -115,12 +116,26 @@ public interface ISysBaseAPI {
*/
public List<ComboModel> queryAllUser();
/**
* 获取所有有效用户 带参
* userIds 默认选中用户
* @return
*/
public List<ComboModel> queryAllUser(String[] userIds);
/**
* 获取所有角色
* @return
*/
public List<ComboModel> queryAllRole();
/**
* 获取所有角色 带参
* roleIds 默认选中角色
* @return
*/
public List<ComboModel> queryAllRole(String[] roleIds );
/**
* 通过用户账号查询角色Id集合
* @param username
......@@ -141,5 +156,11 @@ public interface ISysBaseAPI {
* @return
*/
public DictModel getParentDepartId(String departId);
/**
* 查询所有部门
* @return
*/
public List<SysDepartModel> getAllSysDepart();
}
......@@ -19,9 +19,9 @@ import org.apache.commons.beanutils.PropertyUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.util.JeecgDataAutorUtils;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.util.SqlInjectionUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysPermissionDataRule;
import org.springframework.util.NumberUtils;
import com.alibaba.fastjson.JSON;
......@@ -94,7 +94,7 @@ public class QueryGenerator {
//区间条件组装 模糊查询 高级查询组装 简单排序 权限查询
PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(searchObj);
Map<String,SysPermissionDataRule> ruleMap = getRuleMap();
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap();
//权限规则自定义SQL表达式
for (String c : ruleMap.keySet()) {
......@@ -444,14 +444,14 @@ public class QueryGenerator {
*
* @return
*/
public static Map<String, SysPermissionDataRule> getRuleMap() {
Map<String, SysPermissionDataRule> ruleMap = new HashMap<String, SysPermissionDataRule>();
List<SysPermissionDataRule> list =JeecgDataAutorUtils.loadDataSearchConditon();
public static Map<String, SysPermissionDataRuleModel> getRuleMap() {
Map<String, SysPermissionDataRuleModel> ruleMap = new HashMap<String, SysPermissionDataRuleModel>();
List<SysPermissionDataRuleModel> list =JeecgDataAutorUtils.loadDataSearchConditon();
if(list != null&&list.size()>0){
if(list.get(0)==null){
return ruleMap;
}
for (SysPermissionDataRule rule : list) {
for (SysPermissionDataRuleModel rule : list) {
String column = rule.getRuleColumn();
if(QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) {
column = SQL_RULES_COLUMN+rule.getId();
......@@ -462,7 +462,7 @@ public class QueryGenerator {
return ruleMap;
}
private static void addRuleToQueryWrapper(SysPermissionDataRule dataRule,String name, Class propertyType, QueryWrapper<?> queryWrapper) {
private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) {
QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions());
if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) {
String[] values = dataRule.getRuleValue().split(",");
......@@ -636,7 +636,7 @@ public class QueryGenerator {
public static String installAuthJdbc(Class<?> clazz) {
StringBuffer sb = new StringBuffer();
//权限查询
Map<String,SysPermissionDataRule> ruleMap = getRuleMap();
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap();
PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz);
String sql_and = " and ";
for (String c : ruleMap.keySet()) {
......@@ -651,7 +651,7 @@ public class QueryGenerator {
continue;
}
if(ruleMap.containsKey(name)) {
SysPermissionDataRule dataRule = ruleMap.get(name);
SysPermissionDataRuleModel dataRule = ruleMap.get(name);
QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions());
Class propType = origDescriptors[i].getPropertyType();
boolean isString = propType.equals(String.class);
......@@ -677,7 +677,7 @@ public class QueryGenerator {
*/
public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) {
//权限查询
Map<String,SysPermissionDataRule> ruleMap = getRuleMap();
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap();
PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz);
for (String c : ruleMap.keySet()) {
if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){
......
package org.jeecg.common.system.util;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.system.entity.SysPermissionDataRule;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: JeecgDataAutorUtils
* @Description: 数据权限查询规则容器工具类
......@@ -29,16 +28,16 @@ public class JeecgDataAutorUtils {
* 往链接请求里面,传入数据查询条件
*
* @param request
* @param MENU_DATA_AUTHOR_RULES
* @param dataRules
*/
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRule> dataRules) {
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) {
@SuppressWarnings("unchecked")
List<SysPermissionDataRule> list = (List<SysPermissionDataRule>)loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST
List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST
if (list==null) {
// 2.如果不存在,则new一个list
list = new ArrayList<SysPermissionDataRule>();
list = new ArrayList<SysPermissionDataRuleModel>();
}
for (SysPermissionDataRule tsDataRule : dataRules) {
for (SysPermissionDataRuleModel tsDataRule : dataRules) {
list.add(tsDataRule);
}
request.setAttribute(MENU_DATA_AUTHOR_RULES, list); // 3.往list里面增量存指
......@@ -47,19 +46,17 @@ public class JeecgDataAutorUtils {
/**
* 获取请求对应的数据权限规则
*
* @param request
* @return
*/
@SuppressWarnings("unchecked")
public static synchronized List<SysPermissionDataRule> loadDataSearchConditon() {
return (List<SysPermissionDataRule>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES);
public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() {
return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES);
}
/**
* 获取请求对应的数据权限SQL
*
* @param request
* @return
*/
public static synchronized String loadDataSearchConditonSQLString() {
......@@ -70,7 +67,7 @@ public class JeecgDataAutorUtils {
* 往链接请求里面,传入数据查询条件
*
* @param request
* @param MENU_DATA_AUTHOR_RULE_SQL
* @param sql
*/
public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) {
String ruleSql = (String)loadDataSearchConditonSQLString();
......
......@@ -14,13 +14,19 @@ import java.io.Serializable;
public class ComboModel implements Serializable {
private String id;
private String title;
/**文档管理 表单table默认选中*/
private boolean checked;
/**文档管理 表单table 用户账号*/
private String username;
public ComboModel(){
};
public ComboModel(String id,String title){
public ComboModel(String id,String title,boolean checked,String username){
this.id = id;
this.title = title;
this.checked = false;
this.username = username;
};
}
package org.jeecg.common.system.vo;
/**
* lvdandan 部门机构model
*/
public class SysDepartModel {
/**ID*/
private String id;
/**父机构ID*/
private String parentId;
/**机构/部门名称*/
private String departName;
/**英文名*/
private String departNameEn;
/**缩写*/
private String departNameAbbr;
/**排序*/
private Integer departOrder;
/**描述*/
private Object description;
/**机构类别 1组织机构,2岗位*/
private String orgCategory;
/**机构类型*/
private String orgType;
/**机构编码*/
private String orgCode;
/**手机号*/
private String mobile;
/**传真*/
private String fax;
/**地址*/
private String address;
/**备注*/
private String memo;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getDepartName() {
return departName;
}
public void setDepartName(String departName) {
this.departName = departName;
}
public String getDepartNameEn() {
return departNameEn;
}
public void setDepartNameEn(String departNameEn) {
this.departNameEn = departNameEn;
}
public String getDepartNameAbbr() {
return departNameAbbr;
}
public void setDepartNameAbbr(String departNameAbbr) {
this.departNameAbbr = departNameAbbr;
}
public Integer getDepartOrder() {
return departOrder;
}
public void setDepartOrder(Integer departOrder) {
this.departOrder = departOrder;
}
public Object getDescription() {
return description;
}
public void setDescription(Object description) {
this.description = description;
}
public String getOrgCategory() {
return orgCategory;
}
public void setOrgCategory(String orgCategory) {
this.orgCategory = orgCategory;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
}
package org.jeecg.common.system.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 菜单权限规则表
* </p>
*
* @Author huangzhilin
* @since 2019-03-29
*/
public class SysPermissionDataRuleModel {
/**
* id
*/
private String id;
/**
* 对应的菜单id
*/
private String permissionId;
/**
* 规则名称
*/
private String ruleName;
/**
* 字段
*/
private String ruleColumn;
/**
* 条件
*/
private String ruleConditions;
/**
* 规则值
*/
private String ruleValue;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String createBy;
/**
* 修改时间
*/
private Date updateTime;
/**
* 修改人
*/
private String updateBy;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPermissionId() {
return permissionId;
}
public void setPermissionId(String permissionId) {
this.permissionId = permissionId;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleColumn() {
return ruleColumn;
}
public void setRuleColumn(String ruleColumn) {
this.ruleColumn = ruleColumn;
}
public String getRuleConditions() {
return ruleConditions;
}
public void setRuleConditions(String ruleConditions) {
this.ruleConditions = ruleConditions;
}
public String getRuleValue() {
return ruleValue;
}
public void setRuleValue(String ruleValue) {
this.ruleValue = ruleValue;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
}
package org.jeecg.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.handler.IFillRuleHandler;
/**
* 规则值自动生成工具类
*
* @author qinfeng
* @举例: 自动生成订单号;自动生成当前日期
*/
public class FillRuleUtil {
/**
* @param ruleCode ruleCode
* @return
*/
@SuppressWarnings("unchecked")
public static Object executeRule(String ruleCode, JSONObject formData) {
if (!StringUtils.isEmpty(ruleCode)) {
try {
// 获取 Service
ServiceImpl impl = (ServiceImpl) SpringContextUtils.getBean("sysFillRuleServiceImpl");
// 根据 ruleCode 查询出实体
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("rule_code", ruleCode);
JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
// 获取必要的参数
String ruleClass = entity.getString("ruleClass");
JSONObject params = entity.getJSONObject("ruleParams");
if (params == null) {
params = new JSONObject();
}
if (formData == null) {
formData = new JSONObject();
}
// 通过反射执行配置的类里的方法
IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleClass).newInstance();
return ruleHandler.execute(params, formData);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
}
package org.jeecg.common.util;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.api.vo.Result;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
/**
* 通过 RESTful 风格的接口操纵 desform 里的数据
*
* @author sunjianlei
*/
public class RestDesformUtil {
private static String domain = null;
private static String path = null;
static {
domain = SpringContextUtils.getDomain();
path = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
}
/**
* 查询数据
*
* @param desformCode
* @param dataId
* @param token
* @return
*/
public static Result queryOne(String desformCode, String dataId, String token) {
String url = getBaseUrl(desformCode, dataId).toString();
HttpHeaders headers = getHeaders(token);
ResponseEntity<JSONObject> result = RestUtil.request(url, HttpMethod.GET, headers, null, null, JSONObject.class);
return packageReturn(result);
}
/**
* 新增数据
*
* @param desformCode
* @param formData
* @param token
* @return
*/
public static Result addOne(String desformCode, JSONObject formData, String token) {
return addOrEditOne(desformCode, formData, token, HttpMethod.POST);
}
/**
* 修改数据
*
* @param desformCode
* @param formData
* @param token
* @return
*/
public static Result editOne(String desformCode, JSONObject formData, String token) {
return addOrEditOne(desformCode, formData, token, HttpMethod.PUT);
}
private static Result addOrEditOne(String desformCode, JSONObject formData, String token, HttpMethod method) {
String url = getBaseUrl(desformCode).toString();
HttpHeaders headers = getHeaders(token);
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, formData, JSONObject.class);
return packageReturn(result);
}
/**
* 删除数据
*
* @param desformCode
* @param dataId
* @param token
* @return
*/
public static Result removeOne(String desformCode, String dataId, String token) {
String url = getBaseUrl(desformCode, dataId).toString();
HttpHeaders headers = getHeaders(token);
ResponseEntity<JSONObject> result = RestUtil.request(url, HttpMethod.DELETE, headers, null, null, JSONObject.class);
return packageReturn(result);
}
private static Result packageReturn(ResponseEntity<JSONObject> result) {
if (result.getBody() != null) {
return result.getBody().toJavaObject(Result.class);
}
return Result.error("操作失败");
}
private static StringBuilder getBaseUrl() {
StringBuilder builder = new StringBuilder(domain).append(path);
builder.append("/desform/api");
return builder;
}
private static StringBuilder getBaseUrl(String desformCode, String dataId) {
StringBuilder builder = getBaseUrl();
builder.append("/").append(desformCode);
if (dataId != null) {
builder.append("/").append(dataId);
}
return builder;
}
private static StringBuilder getBaseUrl(String desformCode) {
return getBaseUrl(desformCode, null);
}
private static HttpHeaders getHeaders(String token) {
HttpHeaders headers = new HttpHeaders();
String mediaType = MediaType.APPLICATION_JSON_UTF8_VALUE;
headers.setContentType(MediaType.parseMediaType(mediaType));
headers.set("Accept", mediaType);
headers.set("X-Access-Token", token);
return headers;
}
}
\ No newline at end of file
package org.jeecg.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
......@@ -13,13 +14,29 @@ import javax.servlet.http.HttpServletRequest;
* @Date 2019/9/23 14:12
* @Description: 编程校验token有效性
*/
@Slf4j
public class TokenUtils {
/**
* 获取 request 里传递的 token
*
* @param request
* @return
*/
public static String getTokenByRequest(HttpServletRequest request) {
String token = request.getParameter("token");
if (token == null) {
token = request.getHeader("X-Access-Token");
}
return token;
}
/**
* 验证Token
*/
public static boolean verifyToken(HttpServletRequest request, ISysBaseAPI sysBaseAPI, RedisUtil redisUtil) {
String token = request.getParameter("token");
log.info(" -- url --" + request.getRequestURL());
String token = getTokenByRequest(request);
// 解密获得username,用于和数据库进行对比
String username = JwtUtil.getUsername(token);
......
package org.jeecg.common.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.math.BigDecimal;
......@@ -28,6 +31,7 @@ import javax.servlet.http.HttpServletRequest;
* @Author 张代浩
*
*/
@Slf4j
public class oConvertUtils {
public static boolean isEmpty(Object object) {
if (object == null) {
......@@ -588,4 +592,43 @@ public class oConvertUtils {
}
return select;
}
/**
* 将entityList转换成modelList
* @param fromList
* @param tClass
* @param <F>
* @param <T>
* @return
*/
public static<F,T> List<T> entityListToModelList(List<F> fromList, Class<T> tClass){
if(fromList.isEmpty() || fromList == null){
return null;
}
List<T> tList = new ArrayList<>();
for(F f : fromList){
T t = entityToModel(f, tClass);
tList.add(t);
}
return tList;
}
public static<F,T> T entityToModel(F entity, Class<T> modelClass) {
log.debug("entityToModel : Entity属性的值赋值到Model");
Object model = null;
if (entity == null || modelClass ==null) {
return null;
}
try {
model = modelClass.newInstance();
} catch (InstantiationException e) {
log.error("entityToModel : 实例化异常", e);
} catch (IllegalAccessException e) {
log.error("entityToModel : 安全权限异常", e);
}
BeanUtils.copyProperties(entity, model);
return (T)model;
}
}
package org.jeecg.common.util.oss;
import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.PutObjectResult;
import org.apache.tomcat.util.http.fileupload.FileItemStream;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.UUID;
/**
* @Description: 阿里云 oss 上传工具类(高依赖版)
* @Date: 2019/5/10
*/
public class OssBootUtil {
private static String endPoint;
private static String accessKeyId;
private static String accessKeySecret;
private static String bucketName;
private static String staticDomain;
public static void setEndPoint(String endPoint) {
OssBootUtil.endPoint = endPoint;
}
public static void setAccessKeyId(String accessKeyId) {
OssBootUtil.accessKeyId = accessKeyId;
}
public static void setAccessKeySecret(String accessKeySecret) {
OssBootUtil.accessKeySecret = accessKeySecret;
}
public static void setBucketName(String bucketName) {
OssBootUtil.bucketName = bucketName;
}
public static void setStaticDomain(String staticDomain) {
OssBootUtil.staticDomain = staticDomain;
}
/**
* oss 工具客户端
*/
private static OSSClient ossClient = null;
private static String FILE_URL;
/**
* 上传文件至阿里云 OSS
* 文件上传成功,返回文件完整访问路径
* 文件上传失败,返回 null
*
* @param file 待上传文件
* @param fileDir 文件保存目录
* @return oss 中的相对文件路径
*/
public static String upload(MultipartFile file, String fileDir) {
initOSS(endPoint, accessKeyId, accessKeySecret);
StringBuilder fileUrl = new StringBuilder();
try {
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.'));
String fileName = UUID.randomUUID().toString().replace("-", "") + suffix;
if (!fileDir.endsWith("/")) {
fileDir = fileDir.concat("/");
}
fileUrl = fileUrl.append(fileDir + fileName);
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
//FILE_URL = staticDomain + "/" + fileUrl;
PutObjectResult result = ossClient.putObject(bucketName, fileUrl.toString(), file.getInputStream());
// 设置权限(公开读)
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
if (result != null) {
System.out.println("------OSS文件上传成功------" + fileUrl);
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
return FILE_URL;
}
/**
* 上传文件至阿里云 OSS
* 文件上传成功,返回文件完整访问路径
* 文件上传失败,返回 null
*
* @param file 待上传文件
* @param fileDir 文件保存目录
* @return oss 中的相对文件路径
*/
public static String upload(FileItemStream file, String fileDir) {
initOSS(endPoint, accessKeyId, accessKeySecret);
StringBuilder fileUrl = new StringBuilder();
try {
String suffix = file.getName().substring(file.getName().lastIndexOf('.'));
String fileName = UUID.randomUUID().toString().replace("-", "") + suffix;
if (!fileDir.endsWith("/")) {
fileDir = fileDir.concat("/");
}
fileUrl = fileUrl.append(fileDir + fileName);
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
//FILE_URL = staticDomain + "/" + fileUrl;
PutObjectResult result = ossClient.putObject(bucketName, fileUrl.toString(), file.openStream());
// 设置权限(公开读)
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
if (result != null) {
System.out.println("------OSS文件上传成功------" + fileUrl);
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
return FILE_URL;
}
/**
* 删除文件
* @param url
*/
public static void deleteUrl(String url) {
String bucketUrl = "https://" + bucketName + "." + endPoint + "/";
//String bucketUrl = staticDomain + "/";
url = url.replace(bucketUrl,"");
ossClient.deleteObject(bucketName, url);
}
/**
* 删除文件
* @param fileName
*/
public static void delete(String fileName) {
ossClient.deleteObject(bucketName, fileName);
}
/**
* 初始化 oss 客户端
*
* @return
*/
private static OSSClient initOSS(String endpoint, String accessKeyId, String accessKeySecret) {
if (ossClient == null) {
ossClient = new OSSClient(endpoint,
new DefaultCredentialProvider(accessKeyId, accessKeySecret),
new ClientConfiguration());
}
return ossClient;
}
}
\ No newline at end of file
package org.jeecg.modules.system.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 菜单权限规则表
* </p>
*
* @Author huangzhilin
* @since 2019-03-29
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysPermissionDataRule implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.ID_WORKER_STR)
private String id;
/**
* 对应的菜单id
*/
private String permissionId;
/**
* 规则名称
*/
private String ruleName;
/**
* 字段
*/
private String ruleColumn;
/**
* 条件
*/
private String ruleConditions;
/**
* 规则值
*/
private String ruleValue;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String createBy;
/**
* 修改时间
*/
private Date updateTime;
/**
* 修改人
*/
private String updateBy;
}
......@@ -3,12 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jeecg-boot-module-system</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
</parent>
<repositories>
......
package org.jeecg;
import lombok.extern.slf4j.Slf4j;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.catalina.Context;
import org.apache.tomcat.util.scan.StandardJarScanner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.net.InetAddress;
import java.net.UnknownHostException;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Slf4j
@EnableSwagger2
......@@ -17,19 +22,34 @@ import java.net.UnknownHostException;
@EnableAutoConfiguration
public class JeecgApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
log.info("\n----------------------------------------------------------\n\t" +
"Application Jeecg-Boot is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
public static void main(String[] args) throws UnknownHostException {
//System.setProperty("spring.devtools.restart.enabled", "true");
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
log.info("\n----------------------------------------------------------\n\t" +
"Application Jeecg-Boot is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
/**
* tomcat-embed-jasper引用后提示jar找不到的问题
*/
@Bean
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
}
};
}
}
\ No newline at end of file
......@@ -116,10 +116,13 @@ public class ShiroConfig {
//测试示例
filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
//排除Online请求
filterChainDefinitionMap.put("/auto/cgform/**", "anon");
//websocket排除
filterChainDefinitionMap.put("/websocket/**", "anon");
// 添加自己的过滤器并且取名为jwt
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
filterMap.put("jwt", new JwtFilter());
......@@ -205,7 +208,9 @@ public class ShiroConfig {
public RedisManager redisManager() {
log.info("===============(2)创建RedisManager,连接Redis..URL= " + host + ":" + port);
RedisManager redisManager = new RedisManager();
redisManager.setHost(host + ":" + port);//老版本是分别setHost和setPort,新版本只需要setHost就可以了
redisManager.setHost(host);
redisManager.setPort(oConvertUtils.getInt(port));
redisManager.setTimeout(0);
if (!StringUtils.isEmpty(redisPassword)) {
redisManager.setPassword(redisPassword);
}
......
......@@ -136,35 +136,23 @@ public class MybatisInterceptor implements Interceptor {
log.debug("------field.name------" + field.getName());
try {
if ("updateBy".equals(field.getName())) {
field.setAccessible(true);
Object local_updateBy = field.get(parameter);
field.setAccessible(false);
if (local_updateBy == null || local_updateBy.equals("")) {
String updateBy = "jeecg";
// 获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
// 登录账号
updateBy = sysUser.getUsername();
}
if (oConvertUtils.isNotEmpty(updateBy)) {
field.setAccessible(true);
field.set(parameter, updateBy);
field.setAccessible(false);
}
//获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (sysUser != null) {
// 登录账号
String updateBy = sysUser.getUsername();
field.setAccessible(true);
field.set(parameter, updateBy);
field.setAccessible(false);
}
}
if ("updateTime".equals(field.getName())) {
field.setAccessible(true);
Object local_updateDate = field.get(parameter);
field.set(parameter, new Date());
field.setAccessible(false);
if (local_updateDate == null || local_updateDate.equals("")) {
field.setAccessible(true);
field.set(parameter, new Date());
field.setAccessible(false);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
......
package org.jeecg.config.oss;
import org.jeecg.config.oss.OSSAutoConfiguration.OSSConfigurationImportSelector;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
/**
* Object Storage Service auto configuration.
*/
@Configuration
@EnableConfigurationProperties(OSSProperties.class)
@Import(OSSConfigurationImportSelector.class)
public class OSSAutoConfiguration {
/**
* {@link ImportSelector} to add {@link OSSType} configuration classes.
*/
static class OSSConfigurationImportSelector implements ImportSelector {
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
OSSType[] types = OSSType.values();
String[] imports = new String[types.length];
for (int i = 0; i < types.length; i++) {
imports[i] = OSSConfigurations.getConfigurationClass(types[i]);
}
return imports;
}
}
}
package org.jeecg.config.oss;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.context.properties.bind.BindException;
import org.springframework.boot.context.properties.bind.BindResult;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
/**
* General OSS condition used with all OSS configuration classes.
*/
public class OSSCondition extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
String sourceClass = "";
if (metadata instanceof ClassMetadata) {
sourceClass = ((ClassMetadata) metadata).getClassName();
}
ConditionMessage.Builder message = ConditionMessage.forCondition("OSS", sourceClass);
Environment environment = context.getEnvironment();
try {
BindResult<OSSType> specified = Binder.get(environment).bind("oss.type", OSSType.class);
if (!specified.isBound()) {
return ConditionOutcome.match(message.because("automatic OSS type"));
}
OSSType required = OSSConfigurations.getType(((AnnotationMetadata) metadata).getClassName());
if (specified.get() == required) {
return ConditionOutcome.match(message.because(specified.get() + " OSS type"));
}
}
catch (BindException ex) {
}
return ConditionOutcome.noMatch(message.because("unknown OSS type"));
}
}
package org.jeecg.config.oss;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;
import org.jeecg.config.oss.aliyun.AliYunOSSAutoConfiguration;
import org.jeecg.config.oss.tencent.QcCOSAutoConfiguration;
import org.springframework.util.Assert;
/**
* Mappings between {@link OSSType} and {@code @Configuration}.
*/
final class OSSConfigurations {
private static final Map<OSSType, Class<?>> MAPPINGS;
static {
Map<OSSType, Class<?>> mappings = new EnumMap<>(OSSType.class);
mappings.put(OSSType.ALIYUN, AliYunOSSAutoConfiguration.class);
mappings.put(OSSType.QC, QcCOSAutoConfiguration.class);
MAPPINGS = Collections.unmodifiableMap(mappings);
}
private OSSConfigurations() {
}
public static String getConfigurationClass(OSSType ossType) {
Class<?> configurationClass = MAPPINGS.get(ossType);
Assert.state(configurationClass != null, () -> "Unknown OSS type " + ossType);
return configurationClass.getName();
}
public static OSSType getType(String configurationClassName) {
for (Map.Entry<OSSType, Class<?>> entry : MAPPINGS.entrySet()) {
if (entry.getValue().getName().equals(configurationClassName)) {
return entry.getKey();
}
}
throw new IllegalStateException("Unknown configuration class " + configurationClassName);
}
}
package org.jeecg.config.oss;
import java.io.InputStream;
/**
* 简单上传,删除对象接口.
* 可扩展
*/
public interface OSSManager {
void upload(String fileName, InputStream inputStream);
void delete(String fileName);
}
package org.jeecg.config.oss;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Configuration properties for OSS support.
*/
@Getter
@Setter
@ConfigurationProperties(prefix = "jeecg.oss")
public class OSSProperties {
/**
* OSS type.
*/
private OSSType type;
/**
* OSS Endpoint.
*/
private String endpoint;
/**
* OSS Access key.
*/
private String accessKey;
/**
* OSS Secret key.
*/
private String secretKey;
/**
* OSS Bucket Name.
*/
private String bucketName;
/**
* Additional OSS properties.
*/
private Map<String, String> properties = new HashMap<>();
}
package org.jeecg.config.oss;
/**
* Supported OSS types.
*/
public enum OSSType {
ALIYUN, QC
}
package org.jeecg.config.oss;
import org.jeecg.common.util.oss.OssBootUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OssBootConfiguration {
@Value("${jeecg.oss.endpoint}")
private String endpoint;
@Value("${jeecg.oss.accessKey}")
private String accessKeyId;
@Value("${jeecg.oss.secretKey}")
private String accessKeySecret;
@Value("${jeecg.oss.bucketName}")
private String bucketName;
@Value("${jeecg.oss.staticDomain}")
private String staticDomain;
@Bean
public void initOssBootConfiguration() {
OssBootUtil.setEndPoint(endpoint);
OssBootUtil.setAccessKeyId(accessKeyId);
OssBootUtil.setAccessKeySecret(accessKeySecret);
OssBootUtil.setBucketName(bucketName);
OssBootUtil.setStaticDomain(staticDomain);
}
}
\ No newline at end of file
package org.jeecg.config.oss.aliyun;
import java.util.Map;
import java.util.Properties;
import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.comm.Protocol;
import org.jeecg.config.oss.OSSCondition;
import org.jeecg.config.oss.OSSManager;
import org.jeecg.config.oss.OSSProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
/**
* AliYun OSS configuration.
*/
@Configuration
@ConditionalOnClass({ OSS.class })
@ConditionalOnProperty(prefix = "jeecg.oss", name = "type",havingValue = "aliyun")
@Conditional(OSSCondition.class)
public class AliYunOSSAutoConfiguration {
private final OSSProperties properties;
public AliYunOSSAutoConfiguration(OSSProperties ossProperties) {
this.properties = ossProperties;
}
@Bean
@ConditionalOnMissingBean
public ClientBuilderConfiguration clientConfiguration(OSSProperties ossProperties) {
Properties properties = asProperties(ossProperties.getProperties());
ClientBuilderConfiguration configuration = new ClientBuilderConfiguration();
configuration.setMaxConnections(Integer.parseInt(properties.getProperty("aliyun.maxConnections", "5")));
configuration.setSocketTimeout(Integer.parseInt(properties.getProperty("aliyun.socketTimeout", "50000")));
configuration
.setConnectionTimeout(Integer.parseInt(properties.getProperty("aliyun.connectionTimeout", "50000")));
configuration.setConnectionRequestTimeout(
Integer.parseInt(properties.getProperty("aliyun.connectionRequestTimeout", "-1")));
configuration
.setIdleConnectionTime(Integer.parseInt(properties.getProperty("aliyun.idleConnectionTime", "60000")));
configuration.setMaxErrorRetry(Integer.parseInt(properties.getProperty("aliyun.maxErrorRetry", "3")));
configuration.setSupportCname(Boolean.parseBoolean(properties.getProperty("aliyun.supportCname", "false")));
configuration.setSLDEnabled(Boolean.parseBoolean(properties.getProperty("aliyun.sldEnabled", "false")));
configuration.setProtocol(Protocol.HTTP);
if (Protocol.HTTPS.toString().equals(properties.getProperty("aliyun.protocol"))) {
configuration.setProtocol(Protocol.HTTPS);
}
if (properties.getProperty("aliyun.userAgent") != null) {
configuration.setUserAgent(properties.getProperty("aliyun.userAgent"));
}
return configuration;
}
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean
public OSS ossClient(ClientBuilderConfiguration clientConfiguration) {
return new OSSClientBuilder().build(this.properties.getEndpoint(), this.properties.getAccessKey(),
this.properties.getSecretKey(), clientConfiguration);
}
@Bean
@ConditionalOnMissingBean
public OSSManager ossManager(OSS ossClient) {
return new AliYunOSSManager(ossClient, this.properties);
}
private Properties asProperties(Map<String, String> source) {
Properties properties = new Properties();
properties.putAll(source);
return properties;
}
}
package org.jeecg.config.oss.aliyun;
import java.io.InputStream;
import com.aliyun.oss.OSS;
import org.jeecg.config.oss.OSSManager;
import org.jeecg.config.oss.OSSProperties;
/**
* Object Storage Service of AliYun.
*/
public class AliYunOSSManager implements OSSManager {
private OSS client;
private OSSProperties properties;
AliYunOSSManager(OSS client, OSSProperties properties) {
this.client = client;
this.properties = properties;
}
@Override
public void upload(String fileName, InputStream inputStream) {
this.client.putObject(this.properties.getBucketName(), fileName, inputStream);
}
@Override
public void delete(String fileName) {
this.client.deleteObject(this.properties.getBucketName(), fileName);
}
}
package org.jeecg.config.oss.tencent;
import java.util.Map;
import java.util.Properties;
import com.qcloud.cos.COS;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import org.jeecg.config.oss.OSSCondition;
import org.jeecg.config.oss.OSSManager;
import org.jeecg.config.oss.OSSProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnClass({ COS.class })
@ConditionalOnProperty(prefix = "jeecg.oss", name = "type",havingValue = "qc")
@Conditional(OSSCondition.class)
public class QcCOSAutoConfiguration {
private final OSSProperties properties;
public QcCOSAutoConfiguration(OSSProperties ossProperties) {
this.properties = ossProperties;
}
@Bean
@ConditionalOnMissingBean
public ClientConfig clientConfiguration(OSSProperties ossProperties) {
Properties properties = asProperties(ossProperties.getProperties());
ClientConfig configuration = new ClientConfig();
configuration.setMaxConnectionsCount(Integer.parseInt(properties.getProperty("qc.maxConnectionsCount", "5")));
configuration.setSocketTimeout(Integer.parseInt(properties.getProperty("qc.socketTimeout", "50000")));
configuration.setConnectionTimeout(Integer.parseInt(properties.getProperty("qc.connectionTimeout", "50000")));
configuration.setConnectionRequestTimeout(
Integer.parseInt(properties.getProperty("qc.connectionRequestTimeout", "-1")));
configuration.setRegion(new Region(properties.getProperty("qc.region")));
if (properties.getProperty("qc.userAgent") != null) {
configuration.setUserAgent(properties.getProperty("qc.userAgent"));
}
return configuration;
}
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean
public COS ossClient(ClientConfig clientConfig) {
COSCredentials cred = new BasicCOSCredentials(this.properties.getAccessKey(), this.properties.getSecretKey());
return new COSClient(cred, clientConfig);
}
@Bean
@ConditionalOnMissingBean
public OSSManager ossManager(COS client) {
return new QcCOSManager(client, this.properties);
}
private Properties asProperties(Map<String, String> source) {
Properties properties = new Properties();
properties.putAll(source);
return properties;
}
}
package org.jeecg.config.oss.tencent;
import java.io.InputStream;
import com.qcloud.cos.COS;
import com.qcloud.cos.model.ObjectMetadata;
import org.jeecg.config.oss.OSSManager;
import org.jeecg.config.oss.OSSProperties;
/**
* Object Storage Service of Tencent cloud.
*/
public class QcCOSManager implements OSSManager {
private COS client;
private OSSProperties properties;
QcCOSManager(COS client, OSSProperties properties) {
this.client = client;
this.properties = properties;
}
@Override
public void upload(String fileName, InputStream inputStream) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(10);
objectMetadata.setContentType("application/octet-stream");
this.client.putObject(this.properties.getBucketName(),
this.properties.getProperties().get("qc.prefix") + "/" + fileName, inputStream, objectMetadata);
}
@Override
public void delete(String fileName) {
this.client.deleteObject(this.properties.getBucketName(),
this.properties.getProperties().get("qc.prefix") + "/" + fileName);
}
}
package org.jeecg.modules.oss.service.impl;
import java.io.IOException;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.config.oss.OSSManager;
import org.jeecg.config.oss.OSSProperties;
import org.jeecg.common.util.oss.OssBootUtil;
import org.jeecg.modules.oss.entity.OSSFile;
import org.jeecg.modules.oss.mapper.OSSFileMapper;
import org.jeecg.modules.oss.service.IOSSFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@Service("ossFileService")
public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> implements IOSSFileService {
@Autowired
private OSSManager ossManager;
@Autowired
private OSSProperties properties;
@Override
public void upload(MultipartFile multipartFile) throws IOException {
String fileName = multipartFile.getOriginalFilename();
OSSFile ossFile = new OSSFile();
ossFile.setFileName(fileName);
ossFile.setUrl("https://" + properties.getBucketName() + "." + properties.getEndpoint() + "/" + fileName);
String url = OssBootUtil.upload(multipartFile,"upload/test");
ossFile.setUrl(url);
this.save(ossFile);
ossManager.upload(fileName, multipartFile.getInputStream());
}
@Override
public boolean delete(OSSFile ossFile) {
try {
this.removeById(ossFile.getId());
ossManager.delete(ossFile.getFileName());
OssBootUtil.deleteUrl(ossFile.getUrl());
}
catch (Exception ex) {
return false;
......
......@@ -14,6 +14,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.system.util.JeecgDataAutorUtils;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
......@@ -92,12 +93,15 @@ public class PermissionDataAspect {
//3.通过用户名+菜单ID 找到权限配置信息 放到request中去
if(currentSyspermission!=null && currentSyspermission.size()>0) {
String username = JwtUtil.getUserNameByToken(request);
List<SysPermissionDataRule> dataRules = new ArrayList<SysPermissionDataRule>();
List<SysPermissionDataRuleModel> dataRules = new ArrayList<SysPermissionDataRuleModel>();
for (SysPermission sysPermission : currentSyspermission) {
// update-begin--Author:scott Date:20191119 for:数据权限规则编码不规范,项目存在相同包名和类名 #722
List<SysPermissionDataRule> temp = sysPermissionDataRuleService.queryPermissionDataRules(username, sysPermission.getId());
if(temp!=null && temp.size()>0) {
dataRules.addAll(temp);
//dataRules.addAll(temp);
dataRules = oConvertUtils.entityListToModelList(temp,SysPermissionDataRuleModel.class);
}
// update-end--Author:scott Date:20191119 for:数据权限规则编码不规范,项目存在相同包名和类名 #722
}
if(dataRules!=null && dataRules.size()>0) {
JeecgDataAutorUtils.installDataSearchConditon(request, dataRules);
......
......@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.util.JwtUtil;
......@@ -117,7 +118,11 @@ public class LoginController {
//清空用户登录Token缓存
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
//清空用户登录Shiro权限缓存
redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId());
redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId());
//清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username>
redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername()));
//调用shiro的logout
SecurityUtils.getSubject().logout();
return Result.ok("退出登录成功!");
}else {
return Result.error("Token无效!");
......
package org.jeecg.modules.system.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.FillRuleUtil;
import org.jeecg.modules.system.entity.SysFillRule;
import org.jeecg.modules.system.service.ISysFillRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
/**
* @Description: 填值规则
* @Author: jeecg-boot
* @Date: 2019-11-07
* @Version: V1.0
*/
@Slf4j
@Api(tags = "填值规则")
@RestController
@RequestMapping("/sys/fillRule")
public class SysFillRuleController extends JeecgController<SysFillRule, ISysFillRuleService> {
@Autowired
private ISysFillRuleService sysFillRuleService;
/**
* 分页列表查询
*
* @param sysFillRule
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "填值规则-分页列表查询")
@ApiOperation(value = "填值规则-分页列表查询", notes = "填值规则-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysFillRule sysFillRule,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<SysFillRule> queryWrapper = QueryGenerator.initQueryWrapper(sysFillRule, req.getParameterMap());
Page<SysFillRule> page = new Page<>(pageNo, pageSize);
IPage<SysFillRule> pageList = sysFillRuleService.page(page, queryWrapper);
return Result.ok(pageList);
}
/**
* 测试 ruleCode
*
* @param ruleCode
* @return
*/
@GetMapping(value = "/testFillRule")
public Result testFillRule(@RequestParam("ruleCode") String ruleCode) {
Object result = FillRuleUtil.executeRule(ruleCode, new JSONObject());
return Result.ok(result);
}
/**
* 添加
*
* @param sysFillRule
* @return
*/
@AutoLog(value = "填值规则-添加")
@ApiOperation(value = "填值规则-添加", notes = "填值规则-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysFillRule sysFillRule) {
sysFillRuleService.save(sysFillRule);
return Result.ok("添加成功!");
}
/**
* 编辑
*
* @param sysFillRule
* @return
*/
@AutoLog(value = "填值规则-编辑")
@ApiOperation(value = "填值规则-编辑", notes = "填值规则-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysFillRule sysFillRule) {
sysFillRuleService.updateById(sysFillRule);
return Result.ok("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "填值规则-通过id删除")
@ApiOperation(value = "填值规则-通过id删除", notes = "填值规则-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
sysFillRuleService.removeById(id);
return Result.ok("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "填值规则-批量删除")
@ApiOperation(value = "填值规则-批量删除", notes = "填值规则-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.sysFillRuleService.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "填值规则-通过id查询")
@ApiOperation(value = "填值规则-通过id查询", notes = "填值规则-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
SysFillRule sysFillRule = sysFillRuleService.getById(id);
return Result.ok(sysFillRule);
}
/**
* 导出excel
*
* @param request
* @param sysFillRule
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysFillRule sysFillRule) {
return super.exportXls(request, sysFillRule, SysFillRule.class, "填值规则");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, SysFillRule.class);
}
/**
* 通过 ruleCode 执行自定义填值规则
*
* @param ruleCode 要执行的填值规则编码
* @param formData 表单数据,可根据表单数据的不同生成不同的填值结果
* @return 运行后的结果
*/
@PutMapping("/executeRuleByCode/{ruleCode}")
public Result executeByRuleCode(@PathVariable("ruleCode") String ruleCode, @RequestBody JSONObject formData) {
Object result = FillRuleUtil.executeRule(ruleCode, formData);
return Result.ok(result);
}
/**
* 批量通过 ruleCode 执行自定义填值规则
*
* @param ruleData 要执行的填值规则JSON数组:
* 示例: { "commonFormData": {}, rules: [ { "ruleCode": "xxx", "formData": null } ] }
* @return 运行后的结果,返回示例: [{"ruleCode": "order_num_rule", "result": "CN2019111117212984"}]
*
*/
@PutMapping("/executeRuleByCodeBatch")
public Result executeByRuleCodeBatch(@RequestBody JSONObject ruleData) {
JSONObject commonFormData = ruleData.getJSONObject("commonFormData");
JSONArray rules = ruleData.getJSONArray("rules");
// 遍历 rules ,批量执行规则
JSONArray results = new JSONArray(rules.size());
for (int i = 0; i < rules.size(); i++) {
JSONObject rule = rules.getJSONObject(i);
String ruleCode = rule.getString("ruleCode");
JSONObject formData = rule.getJSONObject("formData");
// 如果没有传递 formData,就用common的
if (formData == null) {
formData = commonFormData;
}
// 执行填值规则
Object result = FillRuleUtil.executeRule(ruleCode, formData);
JSONObject obj = new JSONObject(rules.size());
obj.put("ruleCode", ruleCode);
obj.put("result", result);
results.add(obj);
}
return Result.ok(results);
}
}
\ No newline at end of file
......@@ -182,6 +182,7 @@ public class SysPermissionController {
log.info(" ------ 通过令牌获取用户拥有的访问菜单 ---- TOKEN ------ " + token);
String username = JwtUtil.getUsername(token);
List<SysPermission> metaList = sysPermissionService.queryByUser(username);
//添加首页路由
PermissionDataUtil.addIndexPage(metaList);
JSONObject json = new JSONObject();
JSONArray menujsonArray = new JSONArray();
......@@ -196,8 +197,11 @@ public class SysPermissionController {
List<SysPermission> allAuthList = sysPermissionService.list(query);
JSONArray allauthjsonArray = new JSONArray();
this.getAllAuthJsonArray(allauthjsonArray, allAuthList);
//路由菜单
json.put("menu", menujsonArray);
//按钮权限
json.put("auth", authjsonArray);
//全部权限配置(按钮权限,访问权限)
json.put("allAuth", allauthjsonArray);
result.setResult(json);
result.success("查询成功");
......@@ -517,7 +521,12 @@ public class SysPermissionController {
}
}
private JSONObject getPermissionJsonObject(SysPermission permission) {
/**
* 根据菜单配置生成路由json
* @param permission
* @return
*/
private JSONObject getPermissionJsonObject(SysPermission permission) {
JSONObject json = new JSONObject();
// 类型(0:一级菜单 1:子菜单 2:按钮)
if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
......
package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @Description: 填值规则
* @Author: jeecg-boot
* @Date: 2019-11-07
* @Version: V1.0
*/
@Data
@TableName("sys_fill_rule")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "sys_fill_rule对象", description = "填值规则")
public class SysFillRule {
/**
* 主键ID
*/
@TableId(type = IdType.ID_WORKER_STR)
@ApiModelProperty(value = "主键ID")
private java.lang.String id;
/**
* 规则名称
*/
@Excel(name = "规则名称", width = 15)
@ApiModelProperty(value = "规则名称")
private java.lang.String ruleName;
/**
* 规则Code
*/
@Excel(name = "规则Code", width = 15)
@ApiModelProperty(value = "规则Code")
private java.lang.String ruleCode;
/**
* 规则实现类
*/
@Excel(name = "规则实现类", width = 15)
@ApiModelProperty(value = "规则实现类")
private java.lang.String ruleClass;
/**
* 规则参数
*/
@Excel(name = "规则参数", width = 15)
@ApiModelProperty(value = "规则参数")
private java.lang.String ruleParams;
/**
* 修改人
*/
@Excel(name = "修改人", width = 15)
@ApiModelProperty(value = "修改人")
private java.lang.String updateBy;
/**
* 修改时间
*/
@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "修改时间")
private java.util.Date updateTime;
/**
* 创建人
*/
@Excel(name = "创建人", width = 15)
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**
* 创建时间
*/
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
}
......@@ -47,10 +47,10 @@ public class SysPosition {
/**
* 职级
*/
@Excel(name = "职级", width = 15)
@Excel(name = "职级", width = 15,dicCode ="position_rank")
@ApiModelProperty(value = "职级")
@Dict(dicCode = "position_rank")
private java.lang.String rank;
private java.lang.String postRank;
/**
* 公司id
*/
......
package org.jeecg.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.system.entity.SysFillRule;
/**
* @Description: 填值规则
* @Author: jeecg-boot
* @Date: 2019-11-07
* @Version: V1.0
*/
public interface SysFillRuleMapper extends BaseMapper<SysFillRule> {
}
......@@ -58,9 +58,9 @@
select id as "value",depart_name as "text" from sys_depart where del_flag = '0'
</select>
<!-- 查询部门信息 作为字典数据 -->
<!-- 查询用户信息 作为字典数据 -->
<select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
select username as "value",realname as "text" from sys_depart where del_flag = '0'
select username as "value",realname as "text" from sys_user where del_flag = '0'
</select>
<!--通过查询指定table的 text code 获取字典数据,且支持关键字查询 -->
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.system.mapper.SysFillRuleMapper">
</mapper>
\ No newline at end of file
package org.jeecg.modules.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.system.entity.SysFillRule;
/**
* @Description: 填值规则
* @Author: jeecg-boot
* @Date: 2019-11-07
* @Version: V1.0
*/
public interface ISysFillRuleService extends IService<SysFillRule> {
}
......@@ -21,6 +21,7 @@ import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.ComboModel;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.system.vo.SysDepartModel;
import org.jeecg.common.util.IPUtils;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
......@@ -283,6 +284,27 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return list;
}
@Override
public List<ComboModel> queryAllUser(String[] userIds) {
List<ComboModel> list = new ArrayList<ComboModel>();
List<SysUser> userList = userMapper.selectList(new QueryWrapper<SysUser>().eq("status","1").eq("del_flag","0"));
for(SysUser user : userList){
ComboModel model = new ComboModel();
model.setUsername(user.getUsername());
model.setTitle(user.getRealname());
model.setId(user.getId());
if(oConvertUtils.isNotEmpty(userIds)){
for(int i = 0; i<userIds.length;i++){
if(userIds[i].equals(user.getId())){
model.setChecked(true);
}
}
}
list.add(model);
}
return list;
}
@Override
public List<ComboModel> queryAllRole() {
List<ComboModel> list = new ArrayList<ComboModel>();
......@@ -296,6 +318,26 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return list;
}
@Override
public List<ComboModel> queryAllRole(String[] roleIds) {
List<ComboModel> list = new ArrayList<ComboModel>();
List<SysRole> roleList = roleMapper.selectList(new QueryWrapper<SysRole>());
for(SysRole role : roleList){
ComboModel model = new ComboModel();
model.setTitle(role.getRoleName());
model.setId(role.getId());
if(oConvertUtils.isNotEmpty(roleIds)) {
for (int i = 0; i < roleIds.length; i++) {
if (roleIds[i].equals(role.getId())) {
model.setChecked(true);
}
}
}
list.add(model);
}
return list;
}
@Override
public List<String> getRoleIdsByUsername(String username) {
return sysUserRoleMapper.getRoleIdByUserName(username);
......@@ -312,4 +354,16 @@ public class SysBaseApiImpl implements ISysBaseAPI {
DictModel model = new DictModel(depart.getId(),depart.getParentId());
return model;
}
@Override
public List<SysDepartModel> getAllSysDepart() {
List<SysDepartModel> departModelList = new ArrayList<SysDepartModel>();
List<SysDepart> departList = departMapper.selectList(new QueryWrapper<SysDepart>().eq("del_flag","0"));
for(SysDepart depart : departList){
SysDepartModel model = new SysDepartModel();
BeanUtils.copyProperties(depart,model);
departModelList.add(model);
}
return departModelList;
}
}
package org.jeecg.modules.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.system.entity.SysFillRule;
import org.jeecg.modules.system.mapper.SysFillRuleMapper;
import org.jeecg.modules.system.service.ISysFillRuleService;
import org.springframework.stereotype.Service;
/**
* @Description: 填值规则
* @Author: jeecg-boot
* @Date: 2019-11-07
* @Version: V1.0
*/
@Service("sysFillRuleServiceImpl")
public class SysFillRuleServiceImpl extends ServiceImpl<SysFillRuleMapper, SysFillRule> implements ISysFillRuleService {
}
......@@ -60,12 +60,14 @@ public class SysPermissionDataRuleImpl extends ServiceImpl<SysPermissionDataRule
@Override
public List<SysPermissionDataRule> queryPermissionDataRules(String username,String permissionId) {
List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId);
if(idsList==null || idsList.size()==0 || idsList.get(0)==null ) {
//update-begin--Author:scott Date:20191119 for:数据权限失效问题处理--------------------
if(idsList==null || idsList.size()==0) {
return null;
}
//update-end--Author:scott Date:20191119 for:数据权限失效问题处理--------------------
Set<String> set = new HashSet<String>();
for (String ids : idsList) {
if(ids==null) {
if(oConvertUtils.isEmpty(ids)) {
continue;
}
String[] arr = ids.split(",");
......
......@@ -260,6 +260,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
@CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, key="#username")
public void updateUserDepart(String username,String orgCode) {
baseMapper.updateUserDepart(username, orgCode);
}
......
......@@ -4,9 +4,10 @@ server:
max-swallow-size: -1
servlet:
context-path: /jeecg-boot
compression:
enabled: true
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
compression:
enabled: true
min-response-size: 1024
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
management:
endpoints:
......@@ -95,7 +96,7 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot-os?characterEncoding=UTF-8&useUnicode=true&useSSL=false
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
......@@ -147,33 +148,15 @@ jeecg :
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**
#阿里云oss存储配置
oss:
type: aliyun
endpoint: oss-cn-beijing.aliyuncs.com
accessKey: ??
accessKey: WegDpuKzOuPK6D3N
secretKey: ??
bucketName: jeecgos
properties:
aliyun:
protocol: https
staticDomain: ??
# ElasticSearch 设置
elasticsearch:
cluster-name: my-application
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
# #腾讯云cos存储配置
# oss:
# type: qc
# #跟地区有关
# endpoint: cos.ap-beijing-1.myqcloud.com
# accessKey: ??
# secretKey: ??
# bucketName: jeecg-1251108935
# properties:
# qc:
# #地区
# region: ap-beijing-1
# #存储路径
# prefix: jeecgboot
#Mybatis输出sql日志
logging:
level:
......
......@@ -4,9 +4,10 @@ server:
max-swallow-size: -1
servlet:
context-path: /jeecg-boot
compression:
enabled: true
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
compression:
enabled: true
min-response-size: 1024
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
management:
endpoints:
......@@ -138,38 +139,21 @@ jeecg :
webapp: /opt/jeecg-boot/webapp
#短信秘钥
sms:
accessKeyId: ??
accessKeyId: LTAIpW4gUG7xYDNI
accessKeySecret: ??
shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**
#阿里云oss存储配置
oss:
type: aliyun
endpoint: oss-cn-beijing.aliyuncs.com
accessKey: ???
secretKey: ???
bucketName: ???
properties:
aliyun:
protocol: https
accessKey: WegDpuKzOuPK6D3N
secretKey: ??
bucketName: jeecgos
staticDomain: ??
# ElasticSearch 设置
elasticsearch:
cluster-name: my-application
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
# #腾讯云cos存储配置
# oss:
# type: qc
# #跟地区有关
# endpoint: cos.ap-beijing.myqcloud.com
# accessKey: yourSecretKeyId
# secretKey: yourSecretKey
# bucketName: yourBucketName
# properties:
# qc:
# #地区
# region: ap-beijing
# #存储路径
# prefix: project
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
......
server:
port: 8080
tomcat:
max-swallow-size: -1
servlet:
context-path: /jeecg-boot
compression:
enabled: true
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
port: 8080
tomcat:
max-swallow-size: -1
servlet:
context-path: /jeecg-boot
compression:
enabled: true
min-response-size: 1024
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
management:
endpoints:
......@@ -141,39 +142,21 @@ jeecg :
webapp: D://webapp
#短信秘钥
sms:
accessKeyId: ??
accessKeyId: LTAIpW4gUG7xYDNI
accessKeySecret: ??
shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**
#阿里云oss存储配置
oss:
type: aliyun
endpoint: oss-cn-beijing.aliyuncs.com
accessKey: ???
secretKey: ???
bucketName: ???
properties:
aliyun:
protocol: https
accessKey: WegDpuKzOuPK6D3N
secretKey: ??
bucketName: jeecgos
staticDomain: ??
# ElasticSearch 设置
elasticsearch:
cluster-name: my-application
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
# #腾讯云cos存储配置
# oss:
# type: qc
# #跟地区有关
# endpoint: cos.ap-beijing.myqcloud.com
# accessKey: yourSecretKeyId
# secretKey: yourSecretKey
# bucketName: yourBucketName
# properties:
# qc:
# #地区
# region: ap-beijing
# #存储路径
# prefix: project
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
\ No newline at end of file
......@@ -9,6 +9,6 @@ ${AnsiColor.BRIGHT_BLUE}
${AnsiColor.BRIGHT_GREEN}
Jeecg Boot Version: 2.1.1
Jeecg Boot Version: 2.1.2
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
${AnsiColor.BLACK}
#code_generate_project_path
project_path=E:\\eclipse2018-workspace\\jeecg-boot
project_path=E:\\workspace-ui\\jeecg-boot-framework\\jeecg-boot-module-system
#bussi_package[User defined]
bussi_package=org.jeecg.modules.demo
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<packaging>pom</packaging>
<parent>
......@@ -16,7 +16,7 @@
<modules>
<module>jeecg-boot-base-common</module>
<module>jeecg-boot-module-system</module>
</modules>
</modules>
<distributionManagement>
<repository>
......@@ -51,7 +51,7 @@
</repositories>
<properties>
<jeecgboot.common.version>2.1.1</jeecgboot.common.version>
<jeecgboot.common.version>2.1.2</jeecgboot.common.version>
<java.version>1.8</java.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......@@ -62,7 +62,6 @@
<aliyun-java-sdk-core.version>3.2.3</aliyun-java-sdk-core.version>
<aliyun-java-sdk-dysmsapi.version>1.0.0</aliyun-java-sdk-dysmsapi.version>
<aliyun.oss.version>3.6.0</aliyun.oss.version>
<qc.cos.version>5.6.5</qc.cos.version>
</properties>
<dependencies>
......@@ -105,7 +104,7 @@
<artifactId>commons-lang</artifactId>
<version>${commons.version}</version>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -131,7 +130,7 @@
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
......@@ -168,12 +167,12 @@
<scope>runtime</scope>
</dependency>
<!-- postgresql驱动 -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.6</version>
<scope>runtime</scope>
</dependency>
<!-- Quartz定时任务 -->
<dependency>
......@@ -187,30 +186,14 @@
<artifactId>java-jwt</artifactId>
<version>3.7.0</version>
</dependency>
<!-- online form-->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>online-form</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--shiro-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-starter</artifactId>
<version>1.4.0</version>
</dependency>
<!-- shiro-redis -->
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
......@@ -222,7 +205,7 @@
</exclusion>
</exclusions>
</dependency>
<!-- Swagger API文档 -->
<dependency>
<groupId>io.springfox</groupId>
......@@ -272,7 +255,7 @@
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>codegenerate</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
</dependency>
<!-- AutoPoi Excel工具类-->
......@@ -305,7 +288,23 @@
<artifactId>aliyun-java-sdk-core</artifactId>
<version>${aliyun-java-sdk-core.version}</version>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>online-form</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--HttpClient-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
......@@ -319,16 +318,12 @@
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- aliyun oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>${aliyun.oss.version}</version>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api</artifactId>
<version>${qc.cos.version}</version>
</dependency>
</dependencies>
......@@ -353,8 +348,8 @@
<!--<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> -->
<!--指定JDK编译版本 -->
</plugin>
指定JDK编译版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册