You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
539 lines
13 KiB
539 lines
13 KiB
package customerApp
|
|
|
|
import (
|
|
"appPlatform/models/customerForm"
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"fmt"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-29 16:34:23
|
|
@ 功能: 鉴定当权人员是否有权限使用
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AppJwtPower(c *gin.Context) {
|
|
var requestData JwtPower
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
if userCont.Role != "" {
|
|
roleAry := strings.Split(userCont.Role, ",")
|
|
if len(roleAry) > 0 {
|
|
if publicmethod.IsInTrue[string]("1", roleAry) {
|
|
publicmethod.Result(0, true, c)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
var custFormInfo modelAppPlatform.CustomerForm
|
|
err = custFormInfo.GetCont(map[string]interface{}{"`signCode`": requestData.Id}, "`id`", "`appManager`", "`appRoleManager`", "`appOrgMan`", "`userpermit`", "`postpermit`", "`orgpermit`")
|
|
if err != nil {
|
|
publicmethod.Result(0, false, c)
|
|
return
|
|
}
|
|
if requestData.Types == 2 {
|
|
//操作权限
|
|
var jwtIsTrue TreeJwtPower
|
|
if custFormInfo.AppRoleManager != "" {
|
|
syncSeting.Add(1)
|
|
go jwtIsTrue.JwtRoleViewsIsTrue(custFormInfo.AppRoleManager, userCont.Role)
|
|
}
|
|
if custFormInfo.AppOrgMan != "" {
|
|
syncSeting.Add(1)
|
|
go jwtIsTrue.JwtOrgViewsIsTrue(custFormInfo.OrgPermit, userCont.AdminOrg)
|
|
}
|
|
if custFormInfo.AppManager != "" {
|
|
userKey := strconv.FormatInt(userCont.Key, 10)
|
|
syncSeting.Add(1)
|
|
go jwtIsTrue.JwtPeopleViewsIsTrue(custFormInfo.AppManager, userKey)
|
|
}
|
|
syncSeting.Wait()
|
|
if jwtIsTrue.Role || jwtIsTrue.Org || jwtIsTrue.People {
|
|
publicmethod.Result(0, true, c)
|
|
return
|
|
} else {
|
|
publicmethod.Result(0, false, c)
|
|
return
|
|
}
|
|
} else {
|
|
//可见范围
|
|
var jwtIsTrue TreeJwtPower
|
|
if custFormInfo.PostPermit != "" {
|
|
syncSeting.Add(1)
|
|
go jwtIsTrue.JwtRoleViewsIsTrue(custFormInfo.PostPermit, userCont.Role)
|
|
}
|
|
if custFormInfo.OrgPermit != "" {
|
|
syncSeting.Add(1)
|
|
go jwtIsTrue.JwtOrgViewsIsTrue(custFormInfo.OrgPermit, userCont.AdminOrg)
|
|
}
|
|
if custFormInfo.UserPermit != "" {
|
|
userKey := strconv.FormatInt(userCont.Key, 10)
|
|
syncSeting.Add(1)
|
|
go jwtIsTrue.JwtPeopleViewsIsTrue(custFormInfo.UserPermit, userKey)
|
|
}
|
|
syncSeting.Wait()
|
|
if jwtIsTrue.Role || jwtIsTrue.Org || jwtIsTrue.People {
|
|
publicmethod.Result(0, true, c)
|
|
return
|
|
} else {
|
|
publicmethod.Result(0, false, c)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-30 08:10:32
|
|
@ 功能: 使用人鉴权
|
|
@ 参数
|
|
|
|
#jwpUser 使用人员
|
|
#userKEy 个人权限
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (t *TreeJwtPower) JwtPeopleViewsIsTrue(jwpUser, userKEy string) {
|
|
defer syncSeting.Done()
|
|
if jwpUser == "" {
|
|
t.People = true
|
|
} else {
|
|
if userKEy == "" {
|
|
t.People = false
|
|
} else {
|
|
jwtRoleAry := strings.Split(jwpUser, ",")
|
|
if publicmethod.IsInTrue[string](userKEy, jwtRoleAry) {
|
|
t.People = true
|
|
} else {
|
|
t.People = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-30 08:24:55
|
|
@ 功能: 鉴定行政组织授权
|
|
@ 参数
|
|
|
|
#jwpRoel 应用行政组织
|
|
#userRole 个人行政组织
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (t *TreeJwtPower) JwtOrgViewsIsTrue(jwpOrg string, userOrg int64) {
|
|
if jwpOrg == "" {
|
|
t.Org = true
|
|
} else {
|
|
if userOrg == 0 {
|
|
t.Org = false
|
|
} else {
|
|
var allOrg []int64
|
|
jwtOrgAry := strings.Split(jwpOrg, ",")
|
|
for _, v := range jwtOrgAry {
|
|
orgId, _ := strconv.ParseInt(v, 10, 64)
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSonAllId(orgId)
|
|
allOrg = append(allOrg, orgId)
|
|
allOrg = append(allOrg, sunOrg.Id...)
|
|
}
|
|
if publicmethod.IsInTrue[int64](userOrg, allOrg) {
|
|
t.Org = true
|
|
} else {
|
|
t.Org = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-05-30 08:10:32
|
|
@ 功能: 角色鉴权
|
|
@ 参数
|
|
|
|
#jwpRoel 应用权限
|
|
#userRole 个人权限
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (t *TreeJwtPower) JwtRoleViewsIsTrue(jwpRoel, userRole string) {
|
|
defer syncSeting.Done()
|
|
if jwpRoel == "" {
|
|
t.Role = true
|
|
} else {
|
|
if userRole == "" {
|
|
t.Role = false
|
|
} else {
|
|
jwtRoleAry := strings.Split(jwpRoel, ",")
|
|
userRoleAry := strings.Split(userRole, ",")
|
|
t.Role = false
|
|
for _, v := range userRoleAry {
|
|
if publicmethod.IsInTrue[string](v, jwtRoleAry) {
|
|
t.Role = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-10-31 13:33:16
|
|
@ 功能: 获取此应用的所有表单
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetAllAppTableForm(c *gin.Context) {
|
|
var requestData GainAppForm
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, requestData, c)
|
|
return
|
|
}
|
|
if requestData.Types == 0 {
|
|
requestData.Types = 1
|
|
}
|
|
if requestData.Page == 0 {
|
|
requestData.Page = 1
|
|
}
|
|
if requestData.PageSize == 0 {
|
|
if requestData.Types != 2 {
|
|
requestData.PageSize = 20
|
|
} else {
|
|
requestData.PageSize = 6
|
|
}
|
|
}
|
|
var appMenusList []SendAppForm
|
|
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Where("`state` = 1 AND `type` = 2 AND `isLock` = 2 AND `appkey` = ?", requestData.Id)
|
|
if requestData.Types == 2 {
|
|
gormDb = gormDb.Where("`wapIsShow` = ?", 1)
|
|
} else {
|
|
gormDb = gormDb.Where("`pcIsShow` = ?", 1)
|
|
}
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
gormDb.Order("`sort` DESC").Find(&appMenusList)
|
|
for i, v := range appMenusList {
|
|
|
|
appMenusList[i].IdStr = strconv.FormatInt(v.Id, 10)
|
|
appMenusList[i].AppkStr = strconv.FormatInt(v.Appkey, 10)
|
|
appMenusList[i].ParentStr = strconv.FormatInt(v.Parent, 10)
|
|
appMenusList[i].CreaterStr = strconv.FormatInt(v.Creater, 10)
|
|
|
|
var tableFormInfo modelAppPlatform.CustomerFormView
|
|
err := tableFormInfo.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": v.Id}, "`id`", "`cfid`", "`time`", "`icon`", "`listjson`")
|
|
if err == nil {
|
|
if tableFormInfo.ListJson != "" {
|
|
appMenusList[i].IsList = true
|
|
} else {
|
|
appMenusList[i].IsList = false
|
|
}
|
|
appMenusList[i].VersionId = strconv.FormatInt(tableFormInfo.Id, 10)
|
|
appMenusList[i].TableId = strconv.FormatInt(tableFormInfo.CfId, 10)
|
|
var usInfo modelshr.PersonArchives //获取创建人
|
|
usInfo.GetCont(map[string]interface{}{"`key`": v.Creater}, "`name`", "`number`")
|
|
appMenusList[i].Founder = fmt.Sprintf("%v(%v)", usInfo.Name, usInfo.Number)
|
|
appMenusList[i].CreateDate = publicmethod.UnixTimeToDay(tableFormInfo.CreaterTime, 14)
|
|
appMenusList[i].Icon = tableFormInfo.Icon
|
|
}
|
|
}
|
|
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(appMenusList)), appMenusList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-10-31 15:38:32
|
|
@ 功能: 计算待办事宜,已办事宜,我创建的,抄送我的数量
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) CalculateQuantityOption(c *gin.Context) {
|
|
var requestData AppIdType
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var userCont modelshr.ManCont
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
var taskItem []modelAppPlatform.Appmenus
|
|
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.Appmenus{}).Where("`isLock` = 1 AND `type` = 2 AND `state` = 1 AND `appkey` = ?", requestData.Id)
|
|
if requestData.Types == 2 {
|
|
gormDb = gormDb.Where("`wapIsShow` = 1")
|
|
} else {
|
|
gormDb = gormDb.Where("`pcIsShow` = 1")
|
|
}
|
|
gormDb.Order("`sort` ASC").Find(&taskItem)
|
|
var StatisTaskPage StatisTaskCount
|
|
StatisTaskPage.userCont = userCont
|
|
for _, v := range taskItem {
|
|
StatisTaskPage.Types = v.IsMain
|
|
syncSeting.Add(1)
|
|
go StatisTaskPage.GetTotalPAge(requestData.Id, v.IsMain)
|
|
}
|
|
syncSeting.Wait()
|
|
var sendData []SendStatisInfo
|
|
for i, v := range taskItem {
|
|
var sendInfo SendStatisInfo
|
|
sendInfo.Lable = v.Label
|
|
sendInfo.Icon = v.Svg
|
|
sendInfo.Sort = v.IsMain
|
|
switch v.IsMain {
|
|
case 1: //待办事宜
|
|
sendInfo.Count = StatisTaskPage.ToDoCount
|
|
case 2: //已办事宜
|
|
sendInfo.Count = StatisTaskPage.AlreadyDoneCount
|
|
case 5: //草稿箱
|
|
sendInfo.Count = StatisTaskPage.DraftsCount
|
|
case 3: //抄送我的
|
|
sendInfo.Count = StatisTaskPage.CopyForCount
|
|
default: //我的请求
|
|
sendInfo.Count = StatisTaskPage.MyCreateCount
|
|
}
|
|
if i < 4 {
|
|
sendData = append(sendData, sendInfo)
|
|
}
|
|
|
|
}
|
|
sort.Slice(sendData, func(i, j int) bool {
|
|
return sendData[i].Sort < sendData[j].Sort
|
|
})
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-10-31 15:48:44
|
|
@ 功能: 协程处理数据
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (s *StatisTaskCount) GetTotalPAge(appk string, types int) {
|
|
defer syncSeting.Done()
|
|
// fmt.Printf("s.Types:%v\n", types)
|
|
gormDb := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.RunFlowTask{}).Select("`id`").Where("appKey = ?", appk)
|
|
gormDbEs := overall.CONSTANT_DB_CustomerForm.Model(&customerForm.TaskRecord{}).Select("`id`").Where("appKey = ?", appk)
|
|
switch types {
|
|
case 1: //待办事宜
|
|
gormDb = gormDb.Where("`status` = 3 AND FIND_IN_SET(?,`next_executor`)", s.userCont.Key)
|
|
case 2: //已办事宜
|
|
gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`participants`) AND NOT FIND_IN_SET(?,`next_executor`) AND `creater` <> ?", s.userCont.Key, s.userCont.Key, s.userCont.Key)
|
|
case 5: //草稿箱
|
|
gormDb = gormDb.Where("`status` = 1 AND `creater` = ?", s.userCont.Key)
|
|
gormDbEs = gormDbEs.Where("`status` = 1 AND `creater` = ?", s.userCont.Key)
|
|
case 3: //抄送我的
|
|
// gormDb = gormDb.Where("`status` IN (2,3,4) AND FIND_IN_SET(?,`makeCopy`)", s.userCont.Key)
|
|
default: //我的请求
|
|
// gormDb = gormDb.Where("`status` IN (1,2,3,4) AND `creater` = ?", s.userCont.Key)
|
|
gormDbEs = gormDbEs.Where("`status` IN (1,2,3,4) AND `creater` = ?", s.userCont.Key)
|
|
}
|
|
var total int64
|
|
var totales int64
|
|
gormDb.Count(&total)
|
|
gormDbEs.Count(&totales)
|
|
switch types {
|
|
case 1: //待办事宜
|
|
s.ToDoCount = total
|
|
case 2: //已办事宜
|
|
s.AlreadyDoneCount = total
|
|
case 5: //草稿箱
|
|
s.DraftsCount = totales
|
|
case 3: //抄送我的
|
|
s.CopyForCount = total
|
|
default: //我的请求
|
|
s.MyCreateCount = totales
|
|
}
|
|
} /**
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-11-08 13:34:24
|
|
@ 功能: 根据分组获取App列表
|
|
@ 参数
|
|
#
|
|
@ 返回值
|
|
#
|
|
@ 方法原型
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetAppList(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var list []SendAppInfo
|
|
overall.CONSTANT_DB_AppPlatform.Where("`classify` = 3 AND `groupid` = ?", requestData.Id).Limit(10).Order("`creater_time` DESC").Find(&list)
|
|
for i, v := range list {
|
|
list[i].SignCodeStr = strconv.FormatInt(v.SignCode, 10)
|
|
list[i].GroupIdStr = strconv.FormatInt(v.Groupid, 10)
|
|
list[i].FlowkeyStr = strconv.FormatInt(v.FlowKey, 10)
|
|
}
|
|
publicmethod.Result(0, list, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-11-12 13:46:28
|
|
@ 功能: 获取分组及App
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GetGroupAndApp(c *gin.Context) {
|
|
var appGroup []modelAppPlatform.CustomerFormGroup
|
|
overall.CONSTANT_DB_AppPlatform.Where("`state` = 1").Find(&appGroup)
|
|
var sendList []SendGroupAppList
|
|
if len(appGroup) < 1 {
|
|
publicmethod.Result(0, sendList, c)
|
|
return
|
|
}
|
|
var xieChengchuli XiechengApp
|
|
for _, v := range appGroup {
|
|
syncSeting.Add(1)
|
|
go xieChengchuli.GainAppList(v.Id)
|
|
}
|
|
syncSeting.Wait()
|
|
for _, v := range appGroup {
|
|
var sendInfo SendGroupAppList
|
|
sendInfo.Id = v.Id //
|
|
sendInfo.Title = v.Title //分组名称
|
|
sendInfo.Superior = v.Superior //父级
|
|
sendInfo.Sort = v.Sort //排序
|
|
sendInfo.Ordid = v.Ordid //归属行政组织
|
|
sendInfo.State = v.State //显示状态(1:启用;2:禁用,3:删除)
|
|
sendInfo.Time = v.Time //创建时间"`
|
|
sendInfo.Icon = v.Icon //图标
|
|
for _, vv := range xieChengchuli.Child {
|
|
if v.Id == vv.GroupKey {
|
|
sendInfo.Child = vv.List
|
|
}
|
|
}
|
|
sendList = append(sendList, sendInfo)
|
|
}
|
|
sort.Slice(sendList, func(i, j int) bool {
|
|
return sendList[i].Sort < sendList[j].Sort
|
|
})
|
|
publicmethod.Result(0, sendList, c)
|
|
}
|
|
|
|
func (x *XiechengApp) GainAppList(id int64) {
|
|
defer syncSeting.Done()
|
|
var appList []AppListCont
|
|
overall.CONSTANT_DB_AppPlatform.Where("`classify` = 3 AND `states` = 1 AND `groupid` = ?", id).Find(&appList)
|
|
if len(appList) > 0 {
|
|
for i, v := range appList {
|
|
appList[i].SignCodeStr = strconv.FormatInt(v.SignCode, 10)
|
|
}
|
|
var childInfo XiechengAppEs
|
|
childInfo.GroupKey = id
|
|
childInfo.List = appList
|
|
// for _,v := range appList {}
|
|
x.Child = append(x.Child, childInfo)
|
|
}
|
|
|
|
}
|
|
|