Browse Source

Merge branches 'master' and 'operation-record' of https://github.com/flipped-aurora/gin-vue-admin into operation-record

 Conflicts:
	server/config.yaml
QM303176530 4 years ago
parent
commit
535d8dd96e

+ 1 - 1
server/api/v1/sys_dictionary.go

@@ -78,7 +78,7 @@ func UpdateSysDictionary(c *gin.Context) {
 func FindSysDictionary(c *gin.Context) {
 	var sysDictionary model.SysDictionary
 	_ = c.ShouldBindQuery(&sysDictionary)
-	err, resysDictionary := service.GetSysDictionary(sysDictionary.ID)
+	err, resysDictionary := service.GetSysDictionary(sysDictionary.Type, sysDictionary.ID)
 	if err != nil {
 		response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
 	} else {

+ 4 - 2
server/config.yaml

@@ -11,8 +11,8 @@ jwt:
 # mysql connect configuration
 mysql:
     username: root
-    password: 'xxxxx'
-    path: 'xxxxxx:3306'
+    password: 'Aa@6447985'
+    path: '127.0.0.1:3306'
     db-name: 'qmPlus'
     config: 'charset=utf8&parseTime=True&loc=Local'
     max-idle-conns: 10
@@ -26,6 +26,8 @@ sqlite:
     config: 'loc=Asia/Shanghai'
 
 # oss configuration
+
+# 请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址
 qiniu:
     access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ'
     secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY'

+ 8 - 17
server/db/qmplus.sql

@@ -11,7 +11,7 @@
  Target Server Version : 50640
  File Encoding         : 65001
 
- Date: 24/06/2020 21:52:45
+ Date: 28/06/2020 21:23:47
 */
 
 SET NAMES utf8mb4;
@@ -553,12 +553,8 @@ INSERT INTO `sys_base_menus` VALUES (40, '2020-03-29 21:35:10', '2020-05-03 21:3
 INSERT INTO `sys_base_menus` VALUES (41, '2020-03-29 21:36:26', '2020-05-03 21:38:43', NULL, 0, 38, 'formCreate', 'formCreate', 0, 'view/systemTools/formCreate/index.vue', '表单生成器', 'magic-stick', '表单生成器', 2, 1, 0);
 INSERT INTO `sys_base_menus` VALUES (42, '2020-04-02 14:19:36', '2020-04-24 10:16:43', NULL, 0, 38, 'system', 'system', 0, 'view/systemTools/system/system.vue', '系统配置', 's-operation', '系统配置', 3, 0, 0);
 INSERT INTO `sys_base_menus` VALUES (45, '2020-04-29 17:19:34', '2020-04-30 17:44:44', NULL, 0, 0, 'iconList', 'iconList', 0, 'view/iconList/index.vue', '图标集合', 'star-on', NULL, 2, 0, 0);
-INSERT INTO `sys_base_menus` VALUES (46, '2020-05-03 16:39:57', '2020-05-03 16:39:57', '2020-05-03 21:34:51', 0, 0, 'student', 'student', 0, 'view/student/student.vue', '学生列表', '', NULL, 11, 0, 0);
-INSERT INTO `sys_base_menus` VALUES (47, '2020-05-05 16:36:47', '2020-05-05 16:36:47', '2020-05-07 22:13:51', 0, 0, 'student', 'student', 0, 'view/student/index.vue', '学生列表', '', NULL, 11, 0, 0);
-INSERT INTO `sys_base_menus` VALUES (48, '2020-05-29 20:54:58', '2020-05-29 20:54:58', '2020-05-29 20:55:04', 0, 0, 'test', 'test', 0, 'test', 'test', 'platform-eleme', NULL, 0, 0, 0);
-INSERT INTO `sys_base_menus` VALUES (49, '2020-06-13 16:19:05', '2020-06-13 16:19:05', '2020-06-13 16:23:39', 0, 0, 'test', 'test', 0, 'view/test/test.vue', '演示菜单', 'upload2', NULL, 10, 0, 0);
-INSERT INTO `sys_base_menus` VALUES (50, '2020-06-24 19:49:54', '2020-06-24 19:49:54', NULL, 0, 3, 'dictionary', 'dictionary', 0, 'view/superAdmin/dictionary/sys_dictionary.vue', '字典管理', 'notebook-2', NULL, 5, 0, 0);
-INSERT INTO `sys_base_menus` VALUES (51, '2020-06-24 19:51:33', '2020-06-24 19:51:33', NULL, 0, 3, 'dictionaryDetail/:id', 'dictionaryDetail', 1, 'view/superAdmin/dictionary/sys_dictionary_detail.vue', '字典详情', 's-order', NULL, 1, 0, 0);
+INSERT INTO `sys_base_menus` VALUES (50, '2020-06-24 19:49:54', '2020-06-28 20:34:47', NULL, 0, 3, 'dictionary', 'dictionary', 0, 'view/superAdmin/dictionary/sysDictionary.vue', '字典管理', 'notebook-2', NULL, 5, 0, 0);
+INSERT INTO `sys_base_menus` VALUES (51, '2020-06-24 19:51:33', '2020-06-28 20:35:04', NULL, 0, 3, 'dictionaryDetail/:id', 'dictionaryDetail', 1, 'view/superAdmin/dictionary/sysDictionaryDetail.vue', '字典详情', 's-order', NULL, 1, 0, 0);
 
 -- ----------------------------
 -- Table structure for sys_data_authority_id
@@ -602,7 +598,7 @@ CREATE TABLE `sys_dictionaries`  (
   `desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
   PRIMARY KEY (`id`) USING BTREE,
   INDEX `idx_sys_dictionaries_deleted_at`(`deleted_at`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
 
 -- ----------------------------
 -- Records of sys_dictionaries
@@ -630,8 +626,8 @@ CREATE TABLE `sys_dictionary_details`  (
 -- ----------------------------
 -- Records of sys_dictionary_details
 -- ----------------------------
-INSERT INTO `sys_dictionary_details` VALUES (9, '2020-06-24 20:44:11', '2020-06-24 20:44:11', NULL, '男', 1, 1, 0, 2);
-INSERT INTO `sys_dictionary_details` VALUES (10, '2020-06-24 20:44:20', '2020-06-24 20:52:30', NULL, '女', 0, 1, 1, 2);
+INSERT INTO `sys_dictionary_details` VALUES (9, '2020-06-24 20:44:11', '2020-06-24 20:44:11', '2020-06-28 21:23:18', '男', 1, 1, 0, 2);
+INSERT INTO `sys_dictionary_details` VALUES (10, '2020-06-24 20:44:20', '2020-06-24 20:52:30', '2020-06-28 21:23:18', '女', 0, 1, 1, 2);
 
 -- ----------------------------
 -- Table structure for sys_users
@@ -643,16 +639,11 @@ CREATE TABLE `sys_users`  (
   `updated_at` timestamp(0) NULL DEFAULT NULL,
   `deleted_at` timestamp(0) NULL DEFAULT NULL,
   `uuid` varbinary(255) NULL DEFAULT NULL,
-  `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `pass_word` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
   `nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'QMPlusUser',
   `header_img` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'http://www.henrongyi.top/avatar/lufu.jpg',
   `authority_id` double NULL DEFAULT 888,
-  `authority_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
   `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
   `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `phone_data` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `manager` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
   PRIMARY KEY (`id`) USING BTREE,
   INDEX `idx_users_deleted_at`(`deleted_at`) USING BTREE,
   INDEX `idx_sys_users_deleted_at`(`deleted_at`) USING BTREE
@@ -661,8 +652,8 @@ CREATE TABLE `sys_users`  (
 -- ----------------------------
 -- Records of sys_users
 -- ----------------------------
-INSERT INTO `sys_users` VALUES (10, '2019-09-13 17:23:46', '2019-10-21 11:16:03', NULL, 0x63653064363638352D633135662D343132362D613562342D383930626339643233353664, NULL, NULL, '超级管理员', 'http://qmplusimg.henrongyi.top/1571627762timg.jpg', 888, NULL, 'admin', 'e10adc3949ba59abbe56e057f20f883e', NULL, NULL);
-INSERT INTO `sys_users` VALUES (11, '2019-09-13 17:27:29', '2019-09-13 17:27:29', NULL, 0x66643665663739622D393434632D343838382D383337372D616265326432363038383538, NULL, NULL, 'QMPlusUser', 'http://qmplusimg.henrongyi.top/1572075907logo.png', 9528, NULL, 'a303176530', '3ec063004a6f31642261936a379fde3d', NULL, NULL);
+INSERT INTO `sys_users` VALUES (10, '2019-09-13 17:23:46', '2020-06-26 21:17:50', NULL, 0x63653064363638352D633135662D343132362D613562342D383930626339643233353664, '超级管理员', 'http://qmplusimg.henrongyi.top/1571627762timg.jpg', 888, 'admin', 'e10adc3949ba59abbe56e057f20f883e');
+INSERT INTO `sys_users` VALUES (11, '2019-09-13 17:27:29', '2019-09-13 17:27:29', NULL, 0x66643665663739622D393434632D343838382D383337372D616265326432363038383538, 'QMPlusUser', 'http://qmplusimg.henrongyi.top/1572075907logo.png', 9528, 'a303176530', '3ec063004a6f31642261936a379fde3d');
 
 -- ----------------------------
 -- Table structure for sys_workflow_step_infos

+ 2 - 3
server/go.mod

@@ -32,8 +32,8 @@ require (
 	github.com/pelletier/go-toml v1.6.0 // indirect
 	github.com/piexlmax/gvaplug v0.0.8
 	github.com/pkg/errors v0.9.1 // indirect
-	github.com/qiniu/api.v7 v7.2.5+incompatible
-	github.com/qiniu/x v7.0.8+incompatible // indirect
+	github.com/qiniu/x v1.10.5
+	github.com/qiniu/api.v7/v7 v7.4.1
 	github.com/satori/go.uuid v1.2.0
 	github.com/spf13/afero v1.2.2 // indirect
 	github.com/spf13/cast v1.3.1 // indirect
@@ -51,5 +51,4 @@ require (
 	google.golang.org/protobuf v1.24.0 // indirect
 	gopkg.in/ini.v1 v1.55.0 // indirect
 	gopkg.in/yaml.v2 v2.3.0 // indirect
-	qiniupkg.com/x v7.0.8+incompatible // indirect
 )

+ 16 - 3
server/service/sys_dictionary.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"errors"
 	"gin-vue-admin/global"
 	"gin-vue-admin/model"
 	"gin-vue-admin/model/request"
@@ -13,6 +14,9 @@ import (
 // @return    err             error
 
 func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) {
+	if (!global.GVA_DB.First(&model.SysDictionary{}, "type = ?", sysDictionary.Type).RecordNotFound()) {
+		return errors.New("存在相同的type,不允许创建")
+	}
 	err = global.GVA_DB.Create(&sysDictionary).Error
 	return err
 }
@@ -42,7 +46,16 @@ func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) {
 		"Status": sysDictionary.Status,
 		"Desc":   sysDictionary.Desc,
 	}
-	err = global.GVA_DB.Where("id = ?", sysDictionary.ID).First(&dict).Updates(sysDictionaryMap).Error
+	db := global.GVA_DB.Where("id = ?", sysDictionary.ID).First(&dict)
+	if dict.Type == sysDictionary.Type {
+		err = db.Updates(sysDictionaryMap).Error
+	} else {
+		if (!global.GVA_DB.First(&model.SysDictionary{}, "type = ?", sysDictionary.Type).RecordNotFound()) {
+			return errors.New("存在相同的type,不允许创建")
+		} else {
+			err = db.Updates(sysDictionaryMap).Error
+		}
+	}
 	return err
 }
 
@@ -53,8 +66,8 @@ func UpdateSysDictionary(sysDictionary *model.SysDictionary) (err error) {
 // @return                    error
 // @return    SysDictionary        SysDictionary
 
-func GetSysDictionary(id uint) (err error, sysDictionary model.SysDictionary) {
-	err = global.GVA_DB.Where("id = ?", id).Preload("SysDictionaryDetails").First(&sysDictionary).Error
+func GetSysDictionary(Type string, Id uint) (err error, sysDictionary model.SysDictionary) {
+	err = global.GVA_DB.Where("type = ? OR id = ?", Type, Id).Preload("SysDictionaryDetails").First(&sysDictionary).Error
 	return
 }
 

+ 2 - 2
server/utils/upload.go

@@ -4,8 +4,8 @@ import (
 	"context"
 	"fmt"
 	"gin-vue-admin/global"
-	"github.com/qiniu/api.v7/auth/qbox"
-	"github.com/qiniu/api.v7/storage"
+	"github.com/qiniu/api.v7/v7/auth/qbox"
+	"github.com/qiniu/api.v7/v7/storage"
 	"mime/multipart"
 	"time"
 )

+ 0 - 0
web/src/api/sys_dictionary.js → web/src/api/sysDictionary.js


+ 0 - 0
web/src/api/sys_dictionary_detail.js → web/src/api/sysDictionaryDetail.js


+ 3 - 2
web/src/store/index.js

@@ -4,7 +4,7 @@ import VuexPersistence from 'vuex-persist'
 
 import { user } from "@/store/module/user"
 import { router } from "@/store/module/router"
-
+import { dictionary } from "@/store/module/dictionary"
 Vue.use(Vuex)
 
 
@@ -16,7 +16,8 @@ const vuexLocal = new VuexPersistence({
 export const store = new Vuex.Store({
     modules: {
         user,
-        router
+        router,
+        dictionary
     },
     plugins: [vuexLocal.plugin]
 })

+ 42 - 0
web/src/store/module/dictionary.js

@@ -0,0 +1,42 @@
+import { findSysDictionary } from '@/api/sysDictionary'
+
+export const dictionary = {
+    namespaced: true,
+    state: {
+        dictionaryMap: {},
+    },
+    mutations: {
+        setDictionaryMap(state, dictionaryMap) {
+            state.dictionaryMap = { ...state.dictionaryMap, ...dictionaryMap }
+        },
+
+    },
+    actions: {
+        // 从后台获取动态路由
+        async getDictionary({ commit, state }, type) {
+            if (state.dictionaryMap[type]) {
+                return state.dictionaryMap[type]
+            } else {
+                const res = await findSysDictionary({ type })
+                if (res.code == 0) {
+                    const dictionaryMap = {}
+                    const dict = []
+                    res.data.resysDictionary.sysDictionaryDetails && res.data.resysDictionary.sysDictionaryDetails.map(item => {
+                        dict.push({
+                            label: item.label,
+                            value: item.value
+                        })
+                    })
+                    dictionaryMap[res.data.resysDictionary.type] = dict
+                    commit("setDictionaryMap", dictionaryMap)
+                    return state.dictionaryMap[type]
+                }
+            }
+        }
+    },
+    getters:{
+        getDictionary(state){
+            return state.dictionaryMap
+        }
+    }
+}

+ 6 - 0
web/src/utils/dictionary.js

@@ -0,0 +1,6 @@
+import { store } from '@/store/index'
+//  获取字典方法 使用示例 getDict('sex').then(res)  或者 async函数下 const res = await getDict('sex')
+export const getDict = async (type) => {
+    await store.dispatch("dictionary/getDictionary", type)
+    return store.getters["dictionary/getDictionary"][type]
+}

+ 13 - 10
web/src/view/superAdmin/authority/authority.vue

@@ -57,13 +57,7 @@
           ></el-cascader>
         </el-form-item>
         <el-form-item label="角色ID" prop="authorityId">
-          <el-input-number
-            :disabled="dialogType=='edit'"
-            step-strictly
-            :step="1"
-            autocomplete="off"
-            v-model="form.authorityId"
-          ></el-input-number>
+          <el-input :disabled="dialogType=='edit'" autocomplete="off" v-model="form.authorityId"></el-input>
         </el-form-item>
         <el-form-item label="角色姓名" prop="authorityName">
           <el-input autocomplete="off" v-model="form.authorityName"></el-input>
@@ -111,6 +105,13 @@ export default {
   name: "Authority",
   mixins: [infoList],
   data() {
+    var mustUint = (rule, value, callback) => {
+      if (!(/^[0-9]*[1-9][0-9]*$/).test(value)){
+       return  callback(new Error("请输入正整数"));
+      } 
+      return  callback()
+    };
+
     return {
       AuthorityOption: [
         {
@@ -134,7 +135,8 @@ export default {
       },
       rules: {
         authorityId: [
-          { required: true, message: "请输入角色ID", trigger: "blur" }
+          { required: true, message: "请输入角色ID", trigger: "blur" },
+          {validator: mustUint, trigger: 'blur'  }
         ],
         authorityName: [
           { required: true, message: "请输入角色名", trigger: "blur" }
@@ -296,6 +298,7 @@ export default {
       this.setAuthorityOptions(this.tableData, this.AuthorityOption, false);
     },
     setAuthorityOptions(AuthorityData, optionsData, disabled) {
+      this.form.authorityId = String(this.form.authorityId);
       AuthorityData &&
         AuthorityData.map(item => {
           if (item.children && item.children.length) {
@@ -350,9 +353,9 @@ export default {
 </script>
 <style lang="scss">
 .authority {
-  .el-input-number{
+  .el-input-number {
     margin-left: 15px;
-    span{
+    span {
       display: none;
     }
   }

+ 4 - 3
web/src/view/superAdmin/dictionary/sys_dictionary.vue → web/src/view/superAdmin/dictionary/sysDictionary.vue

@@ -104,6 +104,8 @@
         <el-button @click="enterDialog" type="primary">确 定</el-button>
       </div>
     </el-dialog>
+
+    <div style="margin-top:40px;color:red">获取字典且缓存方法已在前端utils/dictionary 已经封装完成 不必自己书写 使用方法查看文件内注释</div>
   </div>
 </template>
 
@@ -114,10 +116,9 @@ import {
     updateSysDictionary,
     findSysDictionary,
     getSysDictionaryList
-} from "@/api/sys_dictionary";  //  此处请自行替换地址
+} from "@/api/sysDictionary";  //  此处请自行替换地址
 import { formatTimeToStr } from "@/utils/data";
 import infoList from "@/components/mixins/infoList";
-
 export default {
   name: "SysDictionary",
   mixins: [infoList],
@@ -239,7 +240,7 @@ export default {
       this.dialogFormVisible = true;
     }
   },
-  created() {
+  async created() {
     this.getTableData();
   }
 };

+ 1 - 1
web/src/view/superAdmin/dictionary/sys_dictionary_detail.vue → web/src/view/superAdmin/dictionary/sysDictionaryDetail.vue

@@ -113,7 +113,7 @@ import {
   updateSysDictionaryDetail,
   findSysDictionaryDetail,
   getSysDictionaryDetailList
-} from "@/api/sys_dictionary_detail"; //  此处请自行替换地址
+} from "@/api/sysDictionaryDetail"; //  此处请自行替换地址
 import { formatTimeToStr } from "@/utils/data";
 import infoList from "@/components/mixins/infoList";