17 changed files with 352 additions and 7 deletions
@ -0,0 +1,75 @@ |
|||
package matrixapi |
|||
|
|||
import ( |
|||
"appPlatform/models/modelAppPlatform" |
|||
"appPlatform/models/modelshr" |
|||
"appPlatform/overall" |
|||
"appPlatform/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
/* |
|||
* |
|||
@ 作者: 秦东 |
|||
@ 时间: 2023-07-04 13:05:25 |
|||
@ 功能: 获取矩阵列表 |
|||
@ 参数 |
|||
|
|||
# |
|||
|
|||
@ 返回值 |
|||
|
|||
# |
|||
|
|||
@ 方法原型 |
|||
|
|||
# |
|||
*/ |
|||
func (a *ApiMethod) MatrixList(c *gin.Context) { |
|||
var requestData SearchMatrix |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Page == 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 15 |
|||
} |
|||
var matrixInfoList []modelAppPlatform.MatrixContent |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1") |
|||
if requestData.KeyWords != "" { |
|||
gormDb = gormDb.Where("`name` like ?", "%"+requestData.KeyWords+"%") |
|||
} |
|||
if requestData.AdminOrg != 0 { |
|||
var sunOrg publicmethod.GetOrgAllParent |
|||
sunOrg.GetOrgSonAllId(requestData.AdminOrg) |
|||
sunOrg.Id = append(sunOrg.Id, requestData.AdminOrg) |
|||
gormDb = gormDb.Where("`org` IN ?", sunOrg.Id) |
|||
} |
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
|||
err := gormDb.Find(&matrixInfoList).Error |
|||
if err != nil { |
|||
publicmethod.Result(105, err, c) |
|||
return |
|||
} |
|||
var sendList []SendMatrix |
|||
for _, v := range matrixInfoList { |
|||
var sendCont SendMatrix |
|||
sendCont.Id = v.Id |
|||
sendCont.Name = v.Name |
|||
sendCont.Center = v.Center |
|||
sendCont.Org = v.Org |
|||
var orgCont modelshr.AdministrativeOrganization |
|||
orgCont.GetCont(map[string]interface{}{"`id`": v.Org}, "`name`") |
|||
sendCont.OrgName = orgCont.Name |
|||
sendCont.State = v.State |
|||
sendCont.Time = v.Time |
|||
sendList = append(sendList, sendCont) |
|||
} |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c) |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package matrixapi |
|||
|
|||
import ( |
|||
"appPlatform/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 SearchMatrix struct { |
|||
publicmethod.PagesTurn |
|||
KeyWords string `json:"keywords"` |
|||
AdminOrg int64 `json:"adminorg"` |
|||
} |
|||
|
|||
// 输出权限矩阵列表
|
|||
type SendMatrix struct { |
|||
Id int `json:"id"` |
|||
Name string `json:"name"` |
|||
Center string `json:"center"` |
|||
Org int64 `json:"org"` |
|||
OrgName string `json:"orgname"` |
|||
State int `json:"status"` |
|||
Time int64 `json:"time"` |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package matrixrouters |
|||
|
|||
import ( |
|||
"appPlatform/api/version1" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
// 权限矩阵PC端
|
|||
func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) { |
|||
apiRouter := router.Group("matrix") |
|||
|
|||
var methodBinding = version1.AppApiEntry.MatrixApi |
|||
{ |
|||
apiRouter.GET("", methodBinding.Index) //入口
|
|||
apiRouter.POST("", methodBinding.Index) //入口
|
|||
apiRouter.POST("matrixlist", methodBinding.MatrixList) //矩阵列表
|
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
package matrixrouters |
|||
|
|||
//权限矩阵路由
|
|||
type ApiRouter struct{} |
|||
@ -0,0 +1,61 @@ |
|||
package modelAppPlatform |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 权限矩阵基础信息表
|
|||
type MatrixContent struct { |
|||
Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:名称"` |
|||
Center string `json:"center" gorm:"column:center;type:mediumtext;default:'';comment:描述"` |
|||
Org int64 `json:"org" gorm:"column:org;type:bigint(20) unsigned;default:0;not null;comment:归属行政组织"` |
|||
State int `json:"status" gorm:"column:status;type:int(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 (MatrixContent *MatrixContent) TableName() string { |
|||
return "matrix_content" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *MatrixContent) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *MatrixContent) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.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 *MatrixContent) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *MatrixContent) ContMap(whereMap interface{}, field ...string) (countAry []MatrixContent, err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
err = gormDb.Where(whereMap).Find(&countAry).Error |
|||
return |
|||
} |
|||
|
|||
// 删除内容
|
|||
func (cont *MatrixContent) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
package modelAppPlatform |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 权限矩阵基础字段框架表
|
|||
type MatrixFrame struct { |
|||
Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:名称"` |
|||
Types int `json:"type" gorm:"column:type;type:int(1);default:1;not null;comment:骨架类型(1:人力资源;2:行政组织;2:分部;)"` |
|||
Condition int `json:"condition" gorm:"column:condition;type:int(1) unsigned;default:2;not null;comment:骨架取值类型(1:作为条件使用;2:作为取值使用)"` |
|||
State int `json:"status" gorm:"column:status;type:int(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 (MatrixFrame *MatrixFrame) TableName() string { |
|||
return "matrix_frame" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *MatrixFrame) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *MatrixFrame) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.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 *MatrixFrame) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *MatrixFrame) ContMap(whereMap interface{}, field ...string) (countAry []MatrixFrame, err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
err = gormDb.Where(whereMap).Find(&countAry).Error |
|||
return |
|||
} |
|||
|
|||
// 删除内容
|
|||
func (cont *MatrixFrame) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package modelAppPlatform |
|||
|
|||
import ( |
|||
"appPlatform/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 权限矩阵基础字段框架表
|
|||
type MatrixHandler struct { |
|||
Id int `json:"id" gorm:"primaryKey;column:id;type:int(5) unsigned;not null;comment:Id;index"` |
|||
Number int64 `json:"number" gorm:"column:number;type:bigint(20) unsigned;default:0;not null;comment:批号"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:使用者名称"` |
|||
HandId int64 `json:"handid" gorm:"column:hand_id;type:bigint(20) unsigned;default:0;not null;comment:使用者标识符"` |
|||
Types int `json:"types" gorm:"column:types;type:int(1);default:1;not null;comment:骨架类型(1:人力资源;2:行政组织;2:分部;)"` |
|||
McId int64 `json:"mcid" gorm:"column:mc_id;type:bigint(20) unsigned;default:0;not null;comment:矩阵ID"` |
|||
MhId int64 `json:"mhid" gorm:"column:mh_id;type:bigint(20) unsigned;default:0;not null;comment:骨架ID"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
} |
|||
|
|||
func (MatrixHandler *MatrixHandler) TableName() string { |
|||
return "matrix_handler" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *MatrixHandler) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *MatrixHandler) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.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 *MatrixHandler) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *MatrixHandler) ContMap(whereMap interface{}, field ...string) (countAry []MatrixHandler, err error) { |
|||
gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
err = gormDb.Where(whereMap).Find(&countAry).Error |
|||
return |
|||
} |
|||
|
|||
// 删除内容
|
|||
func (cont *MatrixHandler) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
Loading…
Reference in new issue