From cdf23283cbe1717e9aab39992caeec0de5d05a40 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 5 Sep 2022 09:49:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 48 ++++++++ api/version1/entry.go | 14 ++- .../jurisdiction/jurisdictionpc/power.go | 91 ++++++++++++++++ .../jurisdiction/jurisdictionpc/type.go | 24 ++++ api/version1/postseting/postpc/targetpost.go | 103 ++++++++++++++++++ api/version1/postseting/postpc/type.go | 19 ++++ apirouter/entry.go | 2 + apirouter/v1/postseting/pc.go | 2 + apirouter/v1/systempower/pc.go | 19 ++++ apirouter/v1/systempower/type.go | 4 + config/configDatabase/database.go | 1 + config/configDatabase/database.yaml | 16 ++- identification/interceptor/identity.go | 9 ++ initialization/databaseinit/mysql.go | 7 ++ initialization/route/initRoute.go | 4 + models/modelssystempermission/empower.go | 61 +++++++++++ models/systempermission/empower.go | 60 ++++++++++ overall/appConfig.go | 33 +++--- 18 files changed, 494 insertions(+), 23 deletions(-) create mode 100644 api/version1/jurisdiction/jurisdictionpc/power.go create mode 100644 api/version1/jurisdiction/jurisdictionpc/type.go create mode 100644 apirouter/v1/systempower/pc.go create mode 100644 apirouter/v1/systempower/type.go create mode 100644 models/modelssystempermission/empower.go create mode 100644 models/systempermission/empower.go diff --git a/README.md b/README.md index 20510bd..94ac8a6 100644 --- a/README.md +++ b/README.md @@ -272,4 +272,52 @@ CREATE TABLE `post_metering_flow` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='岗位定量考核流水'; +``` + + + +Time:2022-09-04
+增加权限配置管理相关模块 +
+ +## database.yaml添加权限数据库配置 + +``` +1、文件地址:config\configDatabase\database.yaml +2、系统权限配置数据库 + +systemPermission: + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + charset: 'utf8mb4' #数据库编码方式 + parseTime: 'True' #是否自动转换时间 + loc: 'Local' #时区 + name: 'system_permission' #数据库名称 + username: 'root' #数据库用户民 + password: 'root' #数据库密码 + max_idle_conns: 100 #最大空闲数量 + max_open_conns: 1500 #最大打开数量 + gorm_log: true #是否开启gorm日志 + +``` + +## 增加系统权限系统参数 + +1、config\configDatabase\database.go + + SystemPermission MasterMysqlSetUp `mapstructure:"systempermission" json:"systempermission" yaml:"systempermission"` //系统权限配置数据库 + +2、overall\appConfig.go + CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库 + +3、initialization\databaseinit\mysql.go + +``` +//系统权限配置数据库 + overall.CONSTANT_DB_System_Permission = sqlConfig.SystemPermission.OpenSql() + if overall.CONSTANT_DB_System_Permission == nil { + fmt.Printf("%v数据库开启失败!\n", sqlConfig.SystemPermission.Name) + } else { + fmt.Printf("%v数据库开启成功!\n", sqlConfig.SystemPermission.Name) + } ``` \ No newline at end of file diff --git a/api/version1/entry.go b/api/version1/entry.go index 68ee77b..82dfd02 100644 --- a/api/version1/entry.go +++ b/api/version1/entry.go @@ -5,17 +5,19 @@ import ( "key_performance_indicators/api/version1/departmentseting/departmentpc" "key_performance_indicators/api/version1/departmentseting/departmentweb" "key_performance_indicators/api/version1/honoraryArchives" + "key_performance_indicators/api/version1/jurisdiction/jurisdictionpc" "key_performance_indicators/api/version1/postseting/postpc" "key_performance_indicators/api/version1/postseting/postweb" ) type ApiEntry struct { - HonorsApi honoraryArchives.ApiMethod - PostPcApi postpc.ApiMethod - PostWebApi postweb.ApiMethod - DeparmentPcApi departmentpc.ApiMethod - DeparmentWebApi departmentweb.ApiMethod - BookImg bookimg.ApiMethod + HonorsApi honoraryArchives.ApiMethod //荣誉 + PostPcApi postpc.ApiMethod //岗位pc端 + PostWebApi postweb.ApiMethod //岗位web端 + DeparmentPcApi departmentpc.ApiMethod //部门PC端 + DeparmentWebApi departmentweb.ApiMethod //部门web端 + BookImg bookimg.ApiMethod //图文信息管理 + JurisdictionpcApi jurisdictionpc.ApiMethod //权限模块PC端 } var AppApiEntry = new(ApiEntry) diff --git a/api/version1/jurisdiction/jurisdictionpc/power.go b/api/version1/jurisdiction/jurisdictionpc/power.go new file mode 100644 index 0000000..1192774 --- /dev/null +++ b/api/version1/jurisdiction/jurisdictionpc/power.go @@ -0,0 +1,91 @@ +package jurisdictionpc + +import ( + "key_performance_indicators/models/modelssystempermission" + "key_performance_indicators/overall" + "key_performance_indicators/overall/publicmethod" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" +) + +// 编辑权限 +func (a *ApiMethod) EditPower(c *gin.Context) { + var receivedValue appPowerStruct + err := c.ShouldBindJSON(&receivedValue) + if err != nil { + publicmethod.Result(100, err, c) + return + } + if receivedValue.OrdId == "" { + publicmethod.Result(1, receivedValue, c, "请指定要配置的行政组织!") + return + } + if receivedValue.PostId == "" { + publicmethod.Result(1, receivedValue, c, "请指定要配置的岗位!") + return + } + if receivedValue.SystemName == "" { + publicmethod.Result(1, err, c, "请提交系统识别符!") + return + } + if len(receivedValue.PointId) < 1 { + publicmethod.Result(1, err, c, "请至少指定一项权限!") + return + } + var empowerCont modelssystempermission.Empower + err = empowerCont.GetCont(map[string]interface{}{"`ordid`": receivedValue.OrdId, "`post_id`": receivedValue.PostId, "`system`": receivedValue.SystemName}, "`id`") + postIdStr := strings.Join(receivedValue.PointId, ",") + if err == nil { + + err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`state`": 1, "`point_id`": postIdStr, "`time`": time.Now().Unix()}) + } else { + ordIdInt64, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64) + empowerCont.OrdId = ordIdInt64 //行政组织"` + postIdInt64, _ := strconv.ParseInt(receivedValue.PostId, 10, 64) + empowerCont.PostId = postIdInt64 //岗位ID"` + empowerCont.System = receivedValue.SystemName //系统"` + empowerCont.PointId = postIdStr //权限点位"` + empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + empowerCont.Time = time.Now().Unix() //创建时间"` + err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error + } + if err != nil { + publicmethod.Result(104, err, c) + return + } + publicmethod.Result(0, err, c) + // for i := 0; i < len(receivedValue.PointId); i++ { + // var empowerCont modelssystempermission.Empower + // err = empowerCont.GetCont(map[string]interface{}{"`post_id`": receivedValue.PostId, "`system`": receivedValue.SystemName, "`point_id`": receivedValue.PointId[i]}) + // if err == nil { + // if empowerCont.State != 1 { + // empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()}) + // } + // } else { + // postIdInt64, _ := strconv.ParseInt(receivedValue.PostId, 10, 64) + // empowerCont.PostId = postIdInt64 //岗位ID"` + // empowerCont.System = receivedValue.SystemName //系统"` + // poinIdInt64, _ := strconv.ParseInt(receivedValue.PointId[i], 10, 64) + // empowerCont.PointId = poinIdInt64 //权限点位"` + // empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + // empowerCont.Time = time.Now().Unix() //创建时间"` + // saveData = append(saveData, empowerCont) + // } + // } + // if len(saveData) > 0 { + // err = overall.CONSTANT_DB_System_Permission.Create(&saveData).Error + // } + // if err != nil { + // publicmethod.Result(104, err, c) + // return + // } + // //清除其他权限 + // otherSaveData := publicmethod.MapOut[string]() + // otherSaveData["`state`"] = 2 + // otherSaveData["`time`"] = time.Now().Unix() + // overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Where("`state` = 1 AND `post_id` = ? AND `system` = ?", receivedValue.PostId, receivedValue.SystemName).Not(map[string]interface{}{"point_id": receivedValue.PointId}).Updates(&otherSaveData) + // publicmethod.Result(0, saveData, c) +} diff --git a/api/version1/jurisdiction/jurisdictionpc/type.go b/api/version1/jurisdiction/jurisdictionpc/type.go new file mode 100644 index 0000000..4ba1e8a --- /dev/null +++ b/api/version1/jurisdiction/jurisdictionpc/type.go @@ -0,0 +1,24 @@ +package jurisdictionpc + +import ( + "key_performance_indicators/overall/publicmethod" + + "github.com/gin-gonic/gin" +) + +type ApiMethod struct{} + +// 权限配置 +func (a *ApiMethod) Index(c *gin.Context) { + outputCont := publicmethod.MapOut[string]() + outputCont["index"] = "权限配置" + publicmethod.Result(0, outputCont, c) +} + +// 添加权限参数 +type appPowerStruct struct { + OrdId string `json:"ordid"` //岗位 + PostId string `json:"postid"` //岗位 + SystemName string `json:"systemname"` //系统识别符 + PointId []string `json:"pointid"` //权限点位 +} diff --git a/api/version1/postseting/postpc/targetpost.go b/api/version1/postseting/postpc/targetpost.go index 77968d3..934e988 100644 --- a/api/version1/postseting/postpc/targetpost.go +++ b/api/version1/postseting/postpc/targetpost.go @@ -656,3 +656,106 @@ func addDetaonsCont(saveCont modelskpi.PostTargetDetails, postMan, targetPostMan } syncSetinges.Wait() } + +// 根据指标获取岗位定性指标细则列表 +func (a *ApiMethod) PostTargetSunList(c *gin.Context) { + var requestData lookPostTargetDeta + c.ShouldBindJSON(&requestData) + if requestData.Page == 0 { + requestData.Page = 1 + } + if requestData.PageSize == 0 { + requestData.Page = 10 + } + var postDetails []modelskpi.PostTargetDetails + gormDb := overall.CONSTANT_DB_KPI.Model(&modelskpi.PostTargetDetails{}).Where("`state` BETWEEN 1 AND 2") + if requestData.Title != "" { + gormDb = gormDb.Where("`title` LIKE ?", "%"+requestData.Title+"%") + } + if requestData.DepartmentId != "" { + gormDb = gormDb.Where("`paretment` = ?", requestData.DepartmentId) + } + if requestData.TargetId != "" { + gormDb = gormDb.Where("`parentid` = ?", requestData.TargetId) + } + if requestData.Cycle != 0 { + gormDb = gormDb.Where("`cycle` = ?", requestData.Cycle) + } + if len(requestData.PostId) > 0 { + var findInSet []string + for _, ctv := range requestData.PostId { + findWher := fmt.Sprintf("FIND_IN_SET(%v,`paretment_post`)", ctv) + if publicmethod.IsInTrue[string](findWher, findInSet) == false { + findInSet = append(findInSet, findWher) + } + } + if len(findInSet) > 0 { + gormDb = gormDb.Where(strings.Join(findInSet, " OR ")) + } + } + if len(requestData.PostId) > 0 { + var findInSetType []string + for _, ctvt := range requestData.Inspect { + findWherType := fmt.Sprintf("FIND_IN_SET(%v,`censor_type`)", ctvt) + if publicmethod.IsInTrue[string](findWherType, findInSetType) == false { + findInSetType = append(findInSetType, findWherType) + } + } + if len(findInSetType) > 0 { + gormDb = gormDb.Where(strings.Join(findInSetType, " OR ")) + } + } + gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) + err := gormDb.Order("`parentid_sun` asc").Order("`id` desc").Find(&postDetails).Error + if err != nil { + publicmethod.Result(107, err.Error(), c) + return + } + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + var sendDataAry []sendNaitonTargetDeiment + for _, v := range postDetails { + var sendDataCont sendNaitonTargetDeiment + sendDataCont.Id = v.Id + sendDataCont.Title = v.Title //指标细则"` + sendDataCont.Content = v.Content //指标说明"` + sendDataCont.ParentId = v.ParentId //归属指标栏目"` + sendDataCont.ParentIdSun = v.ParentIdSun //归属指标子栏目"` + sendDataCont.State = v.State //状态(1:启用;2:禁用;3:删除)"` + sendDataCont.AddTime = v.AddTime //制定时间"` + sendDataCont.MinScore = v.MinScore //最小分*100保存"` + sendDataCont.MaxScore = v.MaxScore //最大分*100保存"` + sendDataCont.Company = v.Company //单位"` + sendDataCont.AddReduce = v.AddReduce //1:减少;2:增加;3:无属性,现场确认加或减"` + sendDataCont.CensorType = v.CensorType //检查方式"` + sendDataCont.CensorCont = v.CensorCont //检查依据"` + sendDataCont.CensorRate = v.CensorRate // 检查频次"` + sendDataCont.Cycles = v.Cycles // 1:班;2:天;3:周;4:月;5:季度;6:年"` + sendDataCont.CycleAttres = v.CycleAttres //辅助计数"` + sendDataCont.Paretment = v.Paretment //接受考核的部门"` + sendDataCont.ParetmentPost = v.ParetmentPost //接受考核的部门岗位"` + sendDataCont.Reportary = v.Reportary //提报人"` + sendDataCont.Punishmode = v.Punishmode //处罚方式 1:扣分;2:现金处罚;3:扣分加现金"` + sendDataCont.Maxmoney = v.Maxmoney //最高罚款"` + sendDataCont.Minmoney = v.Minmoney //最低罚款"` + var sonTargetCont modelskpi.PostSonTarget + sonTargetCont.GetCont(map[string]interface{}{"`id`": v.ParentIdSun}, "`title`") + sendDataCont.SonTargetTitle = sonTargetCont.Title + if v.MinScore != 0 { + sendDataCont.ReferenceScore = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(float64(v.MinScore)/100, 2), publicmethod.DecimalEs(float64(v.MaxScore)/100, 2)) + } else { + sendDataCont.ReferenceScore = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(v.MaxScore)/100, 2)) + } + if v.Minmoney != 0 { + sendDataCont.CashStandard = fmt.Sprintf("%v-%v", publicmethod.DecimalEs(float64(v.Minmoney)/100, 2), publicmethod.DecimalEs(float64(v.Maxmoney)/100, 2)) + } else { + sendDataCont.CashStandard = fmt.Sprintf("%v", publicmethod.DecimalEs(float64(v.Maxmoney)/100, 2)) + } + + sendDataAry = append(sendDataAry, sendDataCont) + } + publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendDataAry)), sendDataAry, c) +} diff --git a/api/version1/postseting/postpc/type.go b/api/version1/postseting/postpc/type.go index b718f0f..e8b5a80 100644 --- a/api/version1/postseting/postpc/type.go +++ b/api/version1/postseting/postpc/type.go @@ -200,3 +200,22 @@ type postContList struct { PunishMode int `json:"punishmode"` //处罚方式 1:扣分;2:现金处罚;3:扣分加现金 CashStandard string `json:"cashstandard"` //现金标准 } + +// 查看岗位定性考核细则列表 +type lookPostTargetDeta struct { + publicmethod.PagesTurn + Title string `json:"title"` //名称 + DepartmentId string `json:"departmentid"` //行政组织 + PostId []string `json:"postid"` //岗位 + TargetId string `json:"targetid"` //指标 + Inspect []string `json:"inspect"` //检查方式(1:现场检查;2:资料检查;3:事件触发) + Cycle int `json:"cycle"` //1:班;2:天;3:周;4:月;5:季度;6:年 +} + +// 输出岗位定性指标详细列表 +type sendNaitonTargetDeiment struct { + modelskpi.PostTargetDetails + SonTargetTitle string `sontargettitle` //指标名称 + ReferenceScore string `json:"referencescore"` //考核标准 + CashStandard string `json:"cashstandard"` //现金标准 +} diff --git a/apirouter/entry.go b/apirouter/entry.go index 558bb18..b92e577 100644 --- a/apirouter/entry.go +++ b/apirouter/entry.go @@ -7,6 +7,7 @@ import ( "key_performance_indicators/apirouter/v1/departmentseting" honorsRoute "key_performance_indicators/apirouter/v1/honorsRoute" "key_performance_indicators/apirouter/v1/postseting" + "key_performance_indicators/apirouter/v1/systempower" "key_performance_indicators/apirouter/verifyLogin" // "key_performance_indicators/v1" ) @@ -20,6 +21,7 @@ type RouterGroup struct { PostRouter postseting.ApiRouter DepartmentRouter departmentseting.ApiRouter BookImg bookimg.ApiRouter + SystemPowerRouter systempower.ApiRouter } var RouterGroupEntry = new(RouterGroup) diff --git a/apirouter/v1/postseting/pc.go b/apirouter/v1/postseting/pc.go index 32d86b1..aef1fb5 100644 --- a/apirouter/v1/postseting/pc.go +++ b/apirouter/v1/postseting/pc.go @@ -24,5 +24,7 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { apiRouter.POST("dit_post_target", methodBinding.EditPostTarget) //编辑岗位指标 apiRouter.POST("get_target_about_depart_to_post_man", methodBinding.GetTargetAboutDepartToPostMan) //获取岗位指标关联部门相关岗位及提报人 apiRouter.POST("add_post_target_cont", methodBinding.AddPostTargetCont) //根据指标添加岗位细则 + + apiRouter.POST("posttargetsunlist", methodBinding.PostTargetSunList) //根据指标获取岗位定性指标细则列表 } } diff --git a/apirouter/v1/systempower/pc.go b/apirouter/v1/systempower/pc.go new file mode 100644 index 0000000..72558c2 --- /dev/null +++ b/apirouter/v1/systempower/pc.go @@ -0,0 +1,19 @@ +package systempower + +import ( + "key_performance_indicators/api/version1" + + "github.com/gin-gonic/gin" +) + +// 权限管理PC端 +func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { + apiRouter := router.Group("powerpc") + + var methodBinding = version1.AppApiEntry.JurisdictionpcApi + { + apiRouter.GET("", methodBinding.Index) //入口 + apiRouter.POST("", methodBinding.Index) //入口 + apiRouter.POST("edit_power", methodBinding.EditPower) //编辑权限 + } +} diff --git a/apirouter/v1/systempower/type.go b/apirouter/v1/systempower/type.go new file mode 100644 index 0000000..e0536ac --- /dev/null +++ b/apirouter/v1/systempower/type.go @@ -0,0 +1,4 @@ +package systempower + +//系统权限 +type ApiRouter struct{} diff --git a/config/configDatabase/database.go b/config/configDatabase/database.go index 03e714f..cb80c86 100644 --- a/config/configDatabase/database.go +++ b/config/configDatabase/database.go @@ -24,6 +24,7 @@ type MysqlSetUp struct { KpiDate MasterMysqlSetUp `mapstructure:"kpiDate" json:"kpiDate" yaml:"kpiDate"` //绩效考核数据库 WechatCallBackLogDate MasterMysqlSetUp `mapstructure:"wechatCallBackLogDate" json:"wechatCallBackLogDate" yaml:"wechatCallBackLogDate"` //企业微信回调记录 Managearchives MasterMysqlSetUp `mapstructure:"managearchives" json:"managearchives" yaml:"managearchives"` //管理档案 + SystemPermission MasterMysqlSetUp `mapstructure:"systempermission" json:"systempermission" yaml:"systempermission"` //系统权限配置数据库 } type MasterMysqlSetUp struct { diff --git a/config/configDatabase/database.yaml b/config/configDatabase/database.yaml index 7b47f28..1aebcef 100644 --- a/config/configDatabase/database.yaml +++ b/config/configDatabase/database.yaml @@ -189,4 +189,18 @@ managearchives: password: 'root' #数据库密码 max_idle_conns: 100 #最大空闲数量1 max_open_conns: 1500 #最大打开数量 - gorm_log: true #是否开启gorm日志2 \ No newline at end of file + gorm_log: true #是否开启gorm日志2 + +#系统权限配置数据库 +systemPermission: + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + charset: 'utf8mb4' #数据库编码方式 + parseTime: 'True' #是否自动转换时间 + loc: 'Local' #时区 + name: 'system_permission' #数据库名称 + username: 'root' #数据库用户民 + password: 'root' #数据库密码 + max_idle_conns: 100 #最大空闲数量 + max_open_conns: 1500 #最大打开数量 + gorm_log: true #是否开启gorm日志 \ No newline at end of file diff --git a/identification/interceptor/identity.go b/identification/interceptor/identity.go index bdd1176..505aea8 100644 --- a/identification/interceptor/identity.go +++ b/identification/interceptor/identity.go @@ -3,6 +3,7 @@ package interceptor import ( "fmt" "key_performance_indicators/middleware/grocerystore" + "key_performance_indicators/models/modelssystempermission" "key_performance_indicators/overall" "key_performance_indicators/overall/publicmethod" @@ -125,3 +126,11 @@ func VerifyUrl() gin.HandlerFunc { c.Next() } } + +// 获取岗位权限 +func GetPostPower(postid int64, system string) { + var ponitId string + err := overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Select("`point_id`").Where("`state` = 1 AND `post_id` = ? AND `system` = ?", postid, system).Find(&ponitId).Error + if err == nil { + } +} diff --git a/initialization/databaseinit/mysql.go b/initialization/databaseinit/mysql.go index 6065bfc..87f2b08 100644 --- a/initialization/databaseinit/mysql.go +++ b/initialization/databaseinit/mysql.go @@ -107,4 +107,11 @@ func LoadDatabase() { } else { fmt.Printf("%v数据库开启成功!\n", sqlConfig.Managearchives.Name) } + //系统权限配置数据库 + overall.CONSTANT_DB_System_Permission = sqlConfig.SystemPermission.OpenSql() + if overall.CONSTANT_DB_System_Permission == nil { + fmt.Printf("%v数据库开启失败!\n", sqlConfig.SystemPermission.Name) + } else { + fmt.Printf("%v数据库开启成功!\n", sqlConfig.SystemPermission.Name) + } } diff --git a/initialization/route/initRoute.go b/initialization/route/initRoute.go index 398f894..2a281fb 100644 --- a/initialization/route/initRoute.go +++ b/initialization/route/initRoute.go @@ -79,6 +79,10 @@ func InitialRouter() *gin.Engine { //部门考核 departmentRouterApiWeb := apirouter.RouterGroupEntry.DepartmentRouter departmentRouterApiWeb.RouterGroupWeb(VerifyIdentityWeb) //web端 + + //系统权限设置 + systemPowerPcApi := apirouter.RouterGroupEntry.SystemPowerRouter + systemPowerPcApi.RouterGroupPc(VerifyIdentityWeb) //web端 } //Token身份验证 VerifyIdentityToken := router.Group("") diff --git a/models/modelssystempermission/empower.go b/models/modelssystempermission/empower.go new file mode 100644 index 0000000..309dfc5 --- /dev/null +++ b/models/modelssystempermission/empower.go @@ -0,0 +1,61 @@ +package modelssystempermission + +import ( + "key_performance_indicators/overall" + "strings" +) + +type Empower struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + OrdId int64 `json:"ordid" gorm:"column:ordid;type:bigint(20) unsigned;default:0;not null;comment:行政组织"` + PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` + System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"` + PointId string `json:"pointid" gorm:"column:point_id;type:longtext;comment:权限点位"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (Empower *Empower) TableName() string { + return "Empower" +} + +// 编辑内容 +func (cont *Empower) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Empower) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *Empower) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Empower) ContMap(whereMap interface{}, field ...string) (countAry []Empower, err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Empower) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/systempermission/empower.go b/models/systempermission/empower.go new file mode 100644 index 0000000..fbce540 --- /dev/null +++ b/models/systempermission/empower.go @@ -0,0 +1,60 @@ +package systempermission + +import ( + "key_performance_indicators/overall" + "strings" +) + +type Empower struct { + Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` + PostId int64 `json:"postid" gorm:"column:post_id;type:bigint(20) unsigned;default:0;not null;comment:岗位ID"` + System string `json:"system" gorm:"column:system;type:varchar(255) ;comment:系统"` + PointId int64 `json:"pointid" gorm:"column:point_id;type:bigint(20) unsigned;default:0;not null;comment:权限点位"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (Empower *Empower) TableName() string { + return "Empower" +} + +// 编辑内容 +func (cont *Empower) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *Empower) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *Empower) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_System_Permission.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *Empower) ContMap(whereMap interface{}, field ...string) (countAry []Empower, err error) { + gormDb := overall.CONSTANT_DB_System_Permission.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *Empower) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_System_Permission.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/appConfig.go b/overall/appConfig.go index 45f0b68..beb5585 100644 --- a/overall/appConfig.go +++ b/overall/appConfig.go @@ -7,7 +7,7 @@ import ( "gorm.io/gorm" ) -//常量 +// 常量 var ( ConfigFilePathConstant = "./config/configApp/appConfig.yaml" //服务基础配置 ConfigDatabaseConstant = "./config/configDatabase/database.yaml" @@ -18,25 +18,26 @@ var ( MyContJwt = "mycontjwt" ) -//全局配置 +// 全局配置 var ( //服务常量 CONSTANT_CONFIG configApp.Server // - CONSTANT_DB_Master *gorm.DB //主数据库 - CONSTANT_DB_Wechat *gorm.DB //微信数据库 - CONSTANT_DB_HR *gorm.DB //HR数据库 - CONSTANT_DB_FILE_BOOK *gorm.DB //文档属性数据库 - CONSTANT_DB_ERROR_SUBJECT *gorm.DB //错题库 - CONSTANT_DB_MY_TEST *gorm.DB //自我测验 - CONSTANT_DB_IMAGES_TEST *gorm.DB //图文信息数据库 - CONSTANT_DB_SCORING *gorm.DB //计分明细数据库 - CONSTANT_DB_QA *gorm.DB //趣味问答 - CONSTANT_DB_BILLBOARD *gorm.DB //风云榜统计数据库 - CONSTANT_DB_HEALTH *gorm.DB //健康上报数据库 - CONSTANT_DB_KPI *gorm.DB //绩效考核数据库 - CONSTANT_DB_WECHAT_LOG *gorm.DB //企业微信回调记录 - CONSTANT_DB_MANAGE_ARCHIVES *gorm.DB //管理档案 + CONSTANT_DB_Master *gorm.DB //主数据库 + CONSTANT_DB_Wechat *gorm.DB //微信数据库 + CONSTANT_DB_HR *gorm.DB //HR数据库 + CONSTANT_DB_FILE_BOOK *gorm.DB //文档属性数据库 + CONSTANT_DB_ERROR_SUBJECT *gorm.DB //错题库 + CONSTANT_DB_MY_TEST *gorm.DB //自我测验 + CONSTANT_DB_IMAGES_TEST *gorm.DB //图文信息数据库 + CONSTANT_DB_SCORING *gorm.DB //计分明细数据库 + CONSTANT_DB_QA *gorm.DB //趣味问答 + CONSTANT_DB_BILLBOARD *gorm.DB //风云榜统计数据库 + CONSTANT_DB_HEALTH *gorm.DB //健康上报数据库 + CONSTANT_DB_KPI *gorm.DB //绩效考核数据库 + CONSTANT_DB_WECHAT_LOG *gorm.DB //企业微信回调记录 + CONSTANT_DB_MANAGE_ARCHIVES *gorm.DB //管理档案 + CONSTANT_DB_System_Permission *gorm.DB //系统权限配置数据库 //Redis CONSTANT_REDIS0 *redis.Client CONSTANT_REDIS1 *redis.Client