houyaf 3 سال پیش
والد
کامیت
1ae979bc74

+ 0 - 1
datamodels/ent.go

@@ -5,7 +5,6 @@ import "time"
 type Ent struct {
     OcId                int64       `json:"ocId"        xorm:"'oc_id'             bigint        not null pk comment('组织ID:公司或机构或单位ID')"`
     EntName             string      `json:"entName"     xorm:"'ent_qymc'          varchar(255)  comment('企业名称')"`
-    EntCatId            int64       `json:"entCatId"    xorm:"'ent_cat_id'        bigint        comment('组织ID:公司或机构或单位ID')"`
     EntZch              string      `json:"entZch"      xorm:"'ent_zch'           varchar(255)  comment('注册号')"`
     EntTyshxydm         string      `json:"entTyshxydm" xorm:"'ent_tyshxydm'      varchar(255)  comment('统一社会信用代码')"`
     EntClrq             string      `json:"entClrq"     xorm:"'ent_clrq'          date          comment('成立日期')"`

+ 0 - 21
datamodels/ent_cat.go

@@ -1,21 +0,0 @@
-package datamodels
-
-import "time"
-
-type EntCat struct {
-	EntCatId    int64     `json:"entCatId"        xorm:"'ent_cat_id'      bigint     pk comment('主键ID')          "`
-	EntCatTitle string    `json:"entCatTitle"     xorm:"'ent_cat_title'   varchar(50)   comment('单位类型名称')     "`
-	EntCatDesc  string    `json:"entCatDesc"      xorm:"'ent_cat_desc'    varchar(50)   comment('描述')            "`
-	IsFixed     int64     `json:"isFixed"         xorm:"'is_fixed'        int           comment('是否可修改')       "`
-	CreatedBy   int64     `json:"createdBy"       xorm:"'created_by'"`
-	CreatedAt   time.Time `json:"createdAt"       xorm:"'created_at'"`
-	UpdatedBy   int64     `json:"updatedBy"       xorm:"'updated_by'"`
-	UpdatedAt   time.Time `json:"updatedAt"       xorm:"'updated_at'"`
-	DeletedFlag int64     `json:"deletedFlag"     xorm:"'deleted_flag'"`
-	DeletedBy   int64     `json:"deletedBy"       xorm:"'deleted_by'"`
-	DeletedAt   time.Time `json:"deletedAt"       xorm:"'deleted_at'"`
-}
-
-func (t *EntCat) TableName() string {
-	return "ent_cat"
-}

+ 23 - 22
datamodels/oc.go

@@ -2,29 +2,30 @@ package datamodels
 
 import "time"
 
-// Oc
 type Oc struct {
-	OcId      int64  `json:"ocId"          form:"ocTypeId"        xorm:"'oc_id'       bigint    pk  comment('主键ID')     " `
-	OcName    string `json:"ocName"        form:"ocName"          xorm:"'oc_name'     varchar(127)  comment('ENT类型名称') " `
-	OcTypeId  int64  `json:"ocTypeId"      form:"ocTypeId"        xorm:"'oc_type_id'  bigint        comment('Type ID')    " `
-	RootId    int64  `json:"rootId"        form:"rootId"          xorm:"'root_id'     bigint        comment('Root ID')     " `
-	ParentId  int64  `json:"parentId"      form:"parentId"        xorm:"'parent_id'   bigint        comment('Parent ID')   " `
-	AdminId   int64  `json:"adminId"       form:"adminId"         xorm:"'admin_id'    bigint        comment('Admin ID')    " `
-	AdminName string `json:"adminName"     form:"adminName"       xorm:"'admin_name'  varchar(127)  comment('Admin Name')  " `
-	GroupId   int64  `json:"groupId"       form:"groupId"         xorm:"'group_id'    bigint        comment('Root Group Id')" `
-	ifLic     int    `json:"ifLic"         form:"ifLic"           xorm:"'if_lic'      int           comment('Admin ID')    " `
+	OcId        int64       `json:"ocId"          form:"ocTypeId"      xorm:"'oc_id'       bigint    pk  comment('主键ID')     " `
+	OcName      string      `json:"ocName"        form:"ocName"        xorm:"'oc_name'     varchar(127)  comment('ENT类型名称') " `
+	OcTypeId    int64       `json:"ocTypeId"      form:"ocTypeId"      xorm:"'oc_type_id'  bigint        comment('Type ID')    " `
+	OcCatId     int64       `json:"ocCatId"       form:"ocCatId"       xorm:"'oc_cat_id'   bigint        comment('Cat ID')     " `
+	
+	RootId      int64       `json:"rootId"        form:"rootId"        xorm:"'root_id'     bigint        comment('Root ID')     " `
+	ParentId    int64       `json:"parentId"      form:"parentId"      xorm:"'parent_id'   bigint        comment('Parent ID')   " `
+	AdminId     int64       `json:"adminId"       form:"adminId"       xorm:"'admin_id'    bigint        comment('Admin ID')    " `
+	AdminName   string      `json:"adminName"     form:"adminName"     xorm:"'admin_name'  varchar(127)  comment('Admin Name')  " `
+	GroupId     int64       `json:"groupId"       form:"groupId"       xorm:"'group_id'    bigint        comment('Root Group Id')" `
+	IfLic       int         `json:"ifLic"         form:"ifLic"         xorm:"'if_lic'      int           comment('Admin ID')    " `
 
-	NodeLeft  int `json:"nodeLeft"      form:"nodeLeft"        xorm:"'node_left'   int           comment('Admin ID')    " `
-	NodeRight int `json:"nodeRight"     form:"nodeRight"       xorm:"'node_right'  int           comment('Admin ID')    " `
-	IsLeaf    int `json:"isLeaf"        form:"isLeaf"          xorm:"'is_leaf'     int           comment('Admin ID')    " `
-	NodeLevel int `json:"nodeLevel"     form:"nodeLevel"       xorm:"'node_level'  int           comment('Admin ID')    " `
-	Status    int `json:"status"         form:"status"         xorm:"'status'      int           comment('OC Status')   " `
+	NodeLeft    int         `json:"nodeLeft"      form:"nodeLeft"      xorm:"'node_left'   int           comment('Admin ID')    " `
+	NodeRight   int         `json:"nodeRight"     form:"nodeRight"     xorm:"'node_right'  int           comment('Admin ID')    " `
+	IsLeaf      int         `json:"isLeaf"        form:"isLeaf"        xorm:"'is_leaf'     int           comment('Admin ID')    " `
+	NodeLevel   int         `json:"nodeLevel"     form:"nodeLevel"     xorm:"'node_level'  int           comment('Admin ID')    " `
+	Status      int         `json:"status"        form:"status"        xorm:"'status'      int           comment('OC Status')   " `
 
-	CreatedBy   int64     `json:"createdBy"     xorm:"'created_by'"`
-	CreatedAt   time.Time `json:"createdAt"     xorm:"'created_at'"`
-	UpdatedBy   int64     `json:"updatedBy"     xorm:"'updated_by'"`
-	UpdatedAt   time.Time `json:"updatedAt"     xorm:"'updated_at'"`
-	DeletedFlag int64     `json:"deletedFlag"   xorm:"'deleted_flag'"`
-	DeletedBy   int64     `json:"deletedBy"     xorm:"'deleted_by'"`
-	DeletedAt   time.Time `json:"deletedAt"     xorm:"'deleted_at'"`
+	CreatedBy   int64       `json:"createdBy"     xorm:"'created_by'"`
+	CreatedAt   time.Time   `json:"createdAt"     xorm:"'created_at'"`
+	UpdatedBy   int64       `json:"updatedBy"     xorm:"'updated_by'"`
+	UpdatedAt   time.Time   `json:"updatedAt"     xorm:"'updated_at'"`
+	DeletedFlag int64       `json:"deletedFlag"   xorm:"'deleted_flag'"`
+	DeletedBy   int64       `json:"deletedBy"     xorm:"'deleted_by'"`
+	DeletedAt   time.Time   `json:"deletedAt"     xorm:"'deleted_at'"`
 }

+ 22 - 0
datamodels/oc_cat.go

@@ -0,0 +1,22 @@
+package datamodels
+
+import "time"
+
+type OcCat struct {
+    OcTypeId        int64     `json:"ocTypeId"      xorm:"'oc_type_id'     bigint     pk comment('主键ID')         "`
+    OcCatId         int64     `json:"ocCatId"       xorm:"'oc_cat_id'      bigint     pk comment('主键ID')         "`
+    OcCatTitle      string    `json:"ocCatTitle"    xorm:"'oc_cat_title'   varchar(50)   comment('群组类型名称')     "`
+    OcCatDesc       string    `json:"ocCatDesc"     xorm:"'oc_cat_desc'    varchar(50)   comment('描述')            "`
+    IsFixed         int64     `json:"isFixed"       xorm:"'is_fixed'        int          comment('是否可修改')         "`
+    CreatedBy       int64     `json:"createdBy"     xorm:"'created_by'"`
+    CreatedAt       time.Time `json:"createdAt"     xorm:"'created_at'"`
+    UpdatedBy       int64     `json:"updatedBy"     xorm:"'updated_by'"`
+    UpdatedAt       time.Time `json:"updatedAt"     xorm:"'updated_at'"`
+    DeletedFlag     int64     `json:"deletedFlag"   xorm:"'deleted_flag'"`
+    DeletedBy       int64     `json:"deletedBy"     xorm:"'deleted_by'"`
+    DeletedAt       time.Time `json:"deletedAt"     xorm:"'deleted_at'"`
+}
+
+func (t *OcCat) TableName() string {
+    return "oc_cat"
+}

+ 1 - 0
datamodels/oc_license.go

@@ -0,0 +1 @@
+package datamodels

+ 21 - 0
datamodels/oc_type.go

@@ -0,0 +1,21 @@
+package datamodels
+
+import "time"
+
+type OcType struct {
+    OcTypeId        int64       `json:"ocTypeId"      xorm:"'oc_type_id'      bigint     pk comment('主键ID')         "`
+    OcTypeTitle     string      `json:"ocTypeTitle"   xorm:"'oc_type_title'   varchar(50)   comment('OC类型名称')     "`
+    OcTypeDesc      string      `json:"ocTypeDesc"    xorm:"'oc_type_desc'    varchar(50)   comment('描述')            "`
+    IsFixed         int64       `json:"isFixed"       xorm:"'is_fixed'        int           comment('是否可修改')         "`
+    CreatedBy       int64       `json:"createdBy"     xorm:"'created_by'"`
+    CreatedAt       time.Time   `json:"createdAt"     xorm:"'created_at'"`
+    UpdatedBy       int64       `json:"updatedBy"     xorm:"'updated_by'"`
+    UpdatedAt       time.Time   `json:"updatedAt"     xorm:"'updated_at'"`
+    DeletedFlag     int64       `json:"deletedFlag"   xorm:"'deleted_flag'"`
+    DeletedBy       int64       `json:"deletedBy"     xorm:"'deleted_by'"`
+    DeletedAt       time.Time   `json:"deletedAt"     xorm:"'deleted_at'"`
+}
+
+func (t *OcType) TableName() string {
+    return "oc_type"
+}

+ 0 - 1
datamodels/partner.go

@@ -5,7 +5,6 @@ import "time"
 type Partner struct {
     OcId             int64       `json:"ocId"             xorm:"'oc_id'            bigint    pk  comment('主键ID')       " `
     PartnerName      string      `json:"partnerName"      xorm:"'partner_name'     varchar(127)  comment('Partner名称')  " `
-    PartTypeId       int64       `json:"partnerTypeId"    xorm:"'partner_type_id'  bigint        comment('主键ID')       " `
     
     PartnerDesc      string      `json:"partnerDesc"      xorm:"'partner_desc'     varchar(127)  comment('PartnerDesc')  " `
     PartnerLxr       string      `json:"partnerLxr"       xorm:"'partner_lxr'      varchar(127)  comment('Partner ren')  " `

+ 0 - 21
datamodels/partner_cat.go

@@ -1,21 +0,0 @@
-package datamodels
-
-import "time"
-
-type PartnerCat struct {
-	PartnerCatId    int64     `json:"partnerCatId"        xorm:"'partner_cat_id'      bigint     pk comment('主键ID')         "`
-	PartnerCatTitle string    `json:"partnerCatTitle"     xorm:"'partner_cat_title'   varchar(50)   comment('群组类型名称')     "`
-	PartnerCatDesc  string    `json:"partnerCatDesc"      xorm:"'partner_cat_desc'    varchar(50)   comment('描述')            "`
-	IsFixed         int64     `json:"isFixed"         xorm:"'is_fixed'        int           comment('是否可修改')         "`
-	CreatedBy       int64     `json:"createdBy"       xorm:"'created_by'"`
-	CreatedAt       time.Time `json:"createdAt"       xorm:"'created_at'"`
-	UpdatedBy       int64     `json:"updatedBy"       xorm:"'updated_by'"`
-	UpdatedAt       time.Time `json:"updatedAt"       xorm:"'updated_at'"`
-	DeletedFlag     int64     `json:"deletedFlag"     xorm:"'deleted_flag'"`
-	DeletedBy       int64     `json:"deletedBy"       xorm:"'deleted_by'"`
-	DeletedAt       time.Time `json:"deletedAt"       xorm:"'deleted_at'"`
-}
-
-func (t *PartnerCat) TableName() string {
-	return "partner_cat"
-}

+ 7 - 3
repositories/biz_repo.go

@@ -83,11 +83,15 @@ func (d *BizRepo) GetAll() ([]viewmodels.BizInfo, error) {
     return datalist, nil
 }
 
-
 func (d *BizRepo) GetById(bizId int64) (*viewmodels.BizInfo, error) {
+    sqlSelect  := ` SELECT A.*               `
+    sqlFrom    := ` FROM  biz   AS A    `
+    sqlWhere   := ` WHERE A.deleted_flag = 0 `
+    sqlWhere   += fmt.Sprintf(" A.biz_id = %d ", bizId)
+    
     data := &viewmodels.BizInfo{}
-    ok, err := d.engine.Where("biz_id = ?", bizId).Get(data)
-    if !ok && err == nil {
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
         return nil, err
     } else {
         return data, nil

+ 7 - 2
repositories/biz_rule_repo.go

@@ -71,9 +71,14 @@ func (d *BizRuleRepo) GetList(m map[string]interface{}) ([]viewmodels.BizRuleInf
 }
 
 func (d *BizRuleRepo) GetById(ruleId int64) (*viewmodels.BizRuleInfo, error) {
+    sqlSelect := ` SELECT A.*               `
+    sqlFrom   := ` FROM  biz_rule   AS A    `
+    sqlWhere  := ` WHERE A.deleted_flag = 0 `
+    sqlWhere  += fmt.Sprintf(" AND A.rule_id = %d ", ruleId)
+    
     data := &viewmodels.BizRuleInfo{}
-    ok, err := d.engine.Where("rule_id = ?", ruleId).Get(data)
-    if !ok && err == nil {
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
         return nil, err
     } else {
         return data, nil

+ 7 - 2
repositories/db_type_repo.go

@@ -72,9 +72,14 @@ func (d *DbTypeRepo) GetList(m map[string]interface{}) ([]viewmodels.DbTypeInfo,
 }
 
 func (d *DbTypeRepo) GetById(dbTypeId int64) (*viewmodels.DbTypeInfo, error) {
+    sqlSelect := ` SELECT A.*               `
+    sqlFrom   := ` FROM  ds_db_type   AS A    `
+    sqlWhere  := ` WHERE A.deleted_flag = 0 `
+    sqlWhere  += fmt.Sprintf(" AND A.db_type_id = %d ", dbTypeId)
+    
     data := &viewmodels.DbTypeInfo{}
-    ok, err := d.engine.Where("db_type_id = ?", dbTypeId).Get(data)
-    if !ok && err == nil {
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
         return nil, err
     } else {
         return data, nil

+ 0 - 112
repositories/ent_cat_repo.go

@@ -1,112 +0,0 @@
-package repositories
-
-import (
-	"fmt"
-	"time"
-	"xorm.io/xorm"
-	"xps/datamodels"
-	"xps/viewmodels"
-)
-
-type EntCatRepo struct {
-	engine *xorm.Engine
-}
-
-func NewEntCatRepo(engine *xorm.Engine) *EntCatRepo {
-	return &EntCatRepo{
-		engine: engine,
-	}
-}
-
-func (d *EntCatRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
-	limit := m["limit"].(int)
-	page  := m["page"].(int)
-
-	sqlSelect := ` SELECT A.*               `
-	sqlFrom   := ` FROM   ent_cat AS A      `
-	sqlWhere  := ` WHERE A.deleted_flag = 0 `
-	if keywords, ok:= m["keywords"]; ok {
-		sqlWhere += " AND A.ent_cat_title like '%" + fmt.Sprintf("%s", keywords) + "%'"
-	}
-
-	sqlCount := ` SELECT COUNT(*)          `
-	total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.EntCat))
-	if err1 != nil {
-		return nil, err1
-	}
-
-	sqlOrderBy := " ORDER BY ent_cat_id DESC "
-	pageStart  := (page - 1) * limit
-	sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
-
-	datalist := make([]datamodels.EntCat, 0)
-	err2 := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy + sqlLimit).Find(&datalist)
-	if err2 != nil {
-		return nil, err2
-	}
-
-	pageResult := &viewmodels.PageResult{}
-	pageResult.Data     = datalist
-	pageResult.Total    = total
-	pageResult.PageSize = limit
-	pageResult.Page     = page
-	return pageResult, nil
-}
-
-func (d *EntCatRepo) GetList(m map[string]interface{}) ([]viewmodels.EntCatInfo, error) {
-	sqlSelect := ` SELECT A.*               `
-	sqlFrom   := ` FROM  ent_cat   AS A     `
-	sqlWhere  := ` WHERE A.deleted_flag = 0 `
-	if keywords, ok := m["keywords"]; ok {
-		sqlWhere += " AND A.ent_cat_title like " + "'%" + fmt.Sprintf("%s", keywords) + "%'"
-	}
-	sqlOrderBy := " ORDER BY ent_cat_id DESC "
-	
-	datalist := make([]viewmodels.EntCatInfo, 0)
-	err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
-	if err != nil {
-		return nil, err
-	} else {
-		return datalist, nil
-	}
-}
-
-func (d *EntCatRepo) GetById(entCatId int64) (*viewmodels.EntCatInfo, error) {
-	data := &viewmodels.EntCatInfo{}
-	ok, err := d.engine.Where("ent_cat_id = ?", entCatId).Get(data)
-	if !ok || err != nil {
-		return nil, err
-	} else {
-		return data, nil
-	}
-}
-
-func (d *EntCatRepo) Create(data *datamodels.EntCat) error {
-	data.CreatedAt = time.Now()
-	_, err := d.engine.Insert(data)
-	return err
-}
-
-func (d *EntCatRepo) Update(data *datamodels.EntCat) error {
-	entCatId := data.EntCatId
-
-	data.UpdatedAt = time.Now()
-	_, err := d.engine.
-		Where("ent_cat_id = ?", entCatId).
-		Update(data)
-	return err
-}
-
-func (d *EntCatRepo) Delete(m map[string]interface{}) error {
-	entCatId := m["entCatId"].(int64)
-	deletedBy := m["deletedBy"].(int64)
-
-	data := &datamodels.EntCat{}
-	data.DeletedFlag = 1
-	data.DeletedBy = deletedBy
-	data.DeletedAt = time.Now()
-	_, err := d.engine.
-		Where("ent_cat_id = ?", entCatId).
-		Update(data)
-	return err
-}

+ 8 - 2
repositories/group_cat_repo.go

@@ -77,9 +77,15 @@ func (d *GroupCatRepo) GetList(m map[string]interface{})([]viewmodels.GroupCatIn
 }
 
 func (d *GroupCatRepo) GetById(ocId int64, groupCatId int64)(*viewmodels.GroupCatInfo, error){
+	sqlSelect := ` SELECT A.*                 `
+	sqlFrom   := ` FROM   s_group_cat   AS A  `
+	sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+	sqlWhere  +=  fmt.Sprintf("AND A.oc_id = %d ", ocId)
+	sqlWhere  +=  fmt.Sprintf("AND A.group_cat_id = %d ", groupCatId)
+	
 	data := &viewmodels.GroupCatInfo{}
-	ok, err := d.engine.Where("oc_id = ?", ocId).Where("group_cat_id = ?", groupCatId).Get(data)
-	if !ok && err == nil {
+	has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+	if !has || err != nil {
 		return nil, err
 	} else {
 		return data, nil

+ 7 - 2
repositories/model_repo.go

@@ -84,9 +84,14 @@ func (d *ModelRepo) GetAll() ([]viewmodels.ModelInfo, error) {
 }
 
 func (d *ModelRepo) GetById(modelId int64) (*viewmodels.ModelInfo, error) {
+	sqlSelect  := ` SELECT A.*               `
+	sqlFrom    := ` FROM  ds_model   AS A    `
+	sqlWhere   := ` WHERE A.deleted_flag = 0 `
+	sqlWhere   += fmt.Sprintf(" AND A.model_id = %d ", modelId)
+	
 	data := &viewmodels.ModelInfo{}
-	ok, err := d.engine.Where("model_id = ?", modelId).Get(data)
-	if !ok && err == nil {
+	has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+	if !has || err != nil {
 		return nil, err
 	} else {
 		return data, nil

+ 149 - 0
repositories/oc_cat_repo.go

@@ -0,0 +1,149 @@
+package repositories
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type OcCatRepo struct {
+    engine *xorm.Engine
+}
+
+func NewOcCatRepo(engine *xorm.Engine) *OcCatRepo {
+    return &OcCatRepo{
+        engine: engine,
+    }
+}
+
+func (d *OcCatRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit     := m["limit"].(int)
+    page      := m["page"].(int)
+    
+    sqlSelect := ` SELECT A.*                `
+    sqlFrom   := ` FROM   oc_cat   AS A     `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    
+    if ocTypeId, ok := m["ocTypeId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_type_id = %d ", ocTypeId)
+    }
+    
+    if ocCatId, ok := m["ocCatId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_cat_id = %d ", ocCatId)
+    }
+    
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.oc_cat_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlCount := ` SELECT COUNT(*)            `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.OcCat))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_type_id, A.oc_cat_id "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.OcCat, 0)
+    err2 := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy + sqlLimit).Find(&datalist)
+    if err2 != nil {
+        return nil, err2
+    }
+    
+    pageResult := &viewmodels.PageResult{}
+    pageResult.Data     = datalist
+    pageResult.Total    = total
+    pageResult.PageSize = limit
+    pageResult.Page     = page
+    return pageResult, nil
+}
+
+func (d *OcCatRepo) GetList(m map[string]interface{}) ([]viewmodels.OcCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  oc_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    
+    if ocTypeId, ok := m["ocTypeId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_type_id = %d ", ocTypeId)
+    }
+    
+    if ocCatId, ok := m["ocCatId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_cat_id = %d ", ocCatId)
+    }
+    
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += ` AND   A.oc_cat_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_type_id, A.oc_cat_id "
+    datalist   := make([]viewmodels.OcCatInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+func (d *OcCatRepo) GetById(ocTypeId, ocCatId int64) (*viewmodels.OcCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  oc_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_type_id = %d ", ocTypeId)
+    sqlWhere   += fmt.Sprintf(" AND A.oc_cat_id  = %d ", ocCatId)
+    data := &viewmodels.OcCatInfo{}
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *OcCatRepo) GetListById(ocTypeId int64) ([]viewmodels.OcCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  oc_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_type_id = %d ", ocTypeId)
+    sqlOrderBy := " ORDER BY A.oc_type_id, A.oc_cat_id "
+    datalist   := make([]viewmodels.OcCatInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+
+func (d *OcCatRepo) Create(data *datamodels.OcCat) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *OcCatRepo) Update(data *datamodels.OcCat) error {
+    ocCatId := data.OcCatId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.Where("oc_cat_id = ?", ocCatId).Update(data)
+    return err
+}
+
+func (d *OcCatRepo) Delete(m map[string]interface{}) error {
+    ocCatId   := m["ocCatId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.OcCat{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_cat_id = ?", ocCatId).
+        Update(data)
+    return err
+}

+ 1 - 1
repositories/oc_repo.go

@@ -19,7 +19,7 @@ func NewOcRepo(engine *xorm.Engine) *OcRepo {
 }
 
 func (d *OcRepo) GetById(ocId int64) (*viewmodels.OcInfo, error) {
-	sqlSelect := ` SELECT  A.oc_id,
+	sqlSelect := ` SELECT   A.oc_id,
 							A.oc_name,
 							A.oc_type_id,
 							A.root_id,

+ 112 - 0
repositories/oc_type_repo.go

@@ -0,0 +1,112 @@
+package repositories
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type OcTypeRepo struct {
+    engine *xorm.Engine
+}
+
+func NewOcTypeRepo(engine *xorm.Engine) *OcTypeRepo {
+    return &OcTypeRepo{
+        engine: engine,
+    }
+}
+
+func (d *OcTypeRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit := m["limit"].(int)
+    page  := m["page"].(int)
+    
+    sqlSelect := ` SELECT A.*               `
+    sqlFrom   := ` FROM   oc_type AS A      `
+    sqlWhere  := ` WHERE A.deleted_flag = 0 `
+    if keywords, ok:= m["keywords"]; ok {
+        sqlWhere += " AND A.oc_type_title like '%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    
+    sqlCount := ` SELECT COUNT(*)          `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.OcType))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY oc_type_id DESC "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.OcType, 0)
+    err2 := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy + sqlLimit).Find(&datalist)
+    if err2 != nil {
+        return nil, err2
+    }
+    
+    pageResult := &viewmodels.PageResult{}
+    pageResult.Data     = datalist
+    pageResult.Total    = total
+    pageResult.PageSize = limit
+    pageResult.Page     = page
+    return pageResult, nil
+}
+
+func (d *OcTypeRepo) GetList(m map[string]interface{}) ([]viewmodels.OcTypeInfo, error) {
+    sqlSelect := ` SELECT  A.*              `
+    sqlFrom   := ` FROM  oc_type   AS A     `
+    sqlWhere  := ` WHERE A.deleted_flag = 0 `
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.oc_type_title like " + "'%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    sqlOrderBy := " ORDER BY oc_type_id DESC "
+    
+    datalist := make([]viewmodels.OcTypeInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+func (d *OcTypeRepo) GetById(ocTypeId int64) (*viewmodels.OcTypeInfo, error) {
+    data := &viewmodels.OcTypeInfo{}
+    ok, err := d.engine.Where("oc_type_id = ?", ocTypeId).Get(data)
+    if !ok || err != nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *OcTypeRepo) Create(data *datamodels.OcType) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *OcTypeRepo) Update(data *datamodels.OcType) error {
+    ocTypeId := data.OcTypeId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_type_id = ?", ocTypeId).
+        Update(data)
+    return err
+}
+
+func (d *OcTypeRepo) Delete(m map[string]interface{}) error {
+    ocTypeId  := m["ocTypeId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.OcType{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_type_id = ?", ocTypeId).
+        Update(data)
+    return err
+}

+ 0 - 108
repositories/partner_cat_repo.go

@@ -1,108 +0,0 @@
-package repositories
-
-import (
-	"fmt"
-	"time"
-	"xorm.io/xorm"
-	"xps/datamodels"
-	"xps/viewmodels"
-)
-
-type PartnerCatRepo struct {
-	engine *xorm.Engine
-}
-
-func NewPartnerCatRepo(engine *xorm.Engine) *PartnerCatRepo {
-	return &PartnerCatRepo{
-		engine: engine,
-	}
-}
-
-func (d *PartnerCatRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
-	limit := m["limit"].(int)
-	page  := m["page"].(int)
-
-	sqlSelect := ` SELECT A.*`
-	sqlFrom   := ` FROM   partner_cat   AS A `
-	sqlWhere  := ` WHERE  A.deleted_flag = 0 `
-	if keywords, ok := m["keywords"]; ok {
-		sqlWhere += ` AND A.partner_cat_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
-	}
-
-	sqlCount := `SELECT COUNT(*) `
-	total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.PartnerCat))
-	if err1 != nil {
-		return nil, err1
-	}
-
-	sqlOrderBy := " ORDER BY partner_cat_id DESC "
-	pageStart := (page - 1) * limit
-	sqlLimit := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
-
-	datalist := make([]datamodels.PartnerCat, 0)
-	err2 := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy + sqlLimit).Find(&datalist)
-	if err2 != nil {
-		return nil, err2
-	}
-
-	pageResult := &viewmodels.PageResult{}
-	pageResult.Data     = datalist
-	pageResult.Total    = total
-	pageResult.PageSize = limit
-	pageResult.Page     = page
-	return pageResult, nil
-}
-
-func (d *PartnerCatRepo) GetList(m map[string]interface{}) ([]viewmodels.PartnerCatInfo, error) {
-	sqlSelect := ` SELECT A.*                  `
-	sqlFrom   := ` FROM   partner_cat   AS A   `
-	sqlWhere  := ` WHERE A.deleted_flag = 0    `
-	if keywords, ok := m["keywords"]; ok {
-		sqlWhere += ` AND   A.partner_cat_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
-	}
-
-	sqlOrderBy := " ORDER BY partner_cat_id DESC "
-	datalist := make([]viewmodels.PartnerCatInfo, 0)
-	err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
-	if err != nil {
-		return nil, err
-	} else {
-		return datalist, nil
-	}
-}
-
-func (d *PartnerCatRepo) GetById(partnerCatId int64) (*viewmodels.PartnerCatInfo, error) {
-	data := &viewmodels.PartnerCatInfo{}
-	ok, err := d.engine.Where("partner_cat_id = ?", partnerCatId).Get(data)
-	if !ok && err == nil {
-		return nil, err
-	} else {
-		return data, nil
-	}
-}
-
-func (d *PartnerCatRepo) Create(data *datamodels.PartnerCat) error {
-	data.CreatedAt = time.Now()
-	_, err := d.engine.Insert(data)
-	return err
-}
-
-func (d *PartnerCatRepo) Update(data *datamodels.PartnerCat) error {
-	partnerCatId := data.PartnerCatId
-
-	data.UpdatedAt = time.Now()
-	_, err := d.engine.Where("partner_cat_id = ?", partnerCatId).Update(data)
-	return err
-}
-
-func (d *PartnerCatRepo) Delete(m map[string]interface{}) error {
-	partnerCatId := m["partnerCatId"].(int64)
-	deletedBy := m["deletedBy"].(int64)
-
-	data := &datamodels.PartnerCat{}
-	data.DeletedFlag = 1
-	data.DeletedBy   = deletedBy
-	data.DeletedAt   = time.Now()
-	_, err := d.engine.Where("partner_cat_id = ?", partnerCatId).Update(data)
-	return err
-}

+ 0 - 52
service/ent_cat_service.go

@@ -1,52 +0,0 @@
-package service
-
-import (
-    "xps/datamodels"
-    "xps/datasource"
-    "xps/repositories"
-    "xps/viewmodels"
-)
-
-type EntCatService interface {
-	GetList(m map[string]interface{}) ([]viewmodels.EntCatInfo, error)
-	GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
-	GetById(entCatId int64) (*viewmodels.EntCatInfo, error)
-	Create(d *datamodels.EntCat) error
-	Update(d *datamodels.EntCat) error
-	Delete(m map[string]interface{}) error
-}
-
-type entCatService struct {
-	repo *repositories.EntCatRepo
-}
-
-func NewEntCatService() EntCatService {
-	return &entCatService{
-		repo: repositories.NewEntCatRepo(datasource.InstanceMaster()),
-	}
-}
-
-func (s *entCatService) GetList(m map[string]interface{}) ([]viewmodels.EntCatInfo, error) {
-	return s.repo.GetList(m)
-}
-
-func (s *entCatService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
-	return s.repo.GetPage(m)
-}
-
-func (s *entCatService) GetById(entCatId int64) (*viewmodels.EntCatInfo, error) {
-	return s.repo.GetById(entCatId)
-}
-
-func (s *entCatService) Create(EntCat *datamodels.EntCat) error {
-	EntCat.EntCatId = NewID()
-	return s.repo.Create(EntCat)
-}
-
-func (s *entCatService) Update(EntCat *datamodels.EntCat) error {
-	return s.repo.Update(EntCat)
-}
-
-func (s *entCatService) Delete(m map[string]interface{}) error {
-	return s.repo.Delete(m)
-}

+ 57 - 0
service/oc_cat_service.go

@@ -0,0 +1,57 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type OcCatService interface {
+	GetList(m map[string]interface{}) ([]viewmodels.OcCatInfo, error)
+	GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+	GetById(ocTypeId, ocCatId int64) (*viewmodels.OcCatInfo, error)
+	GetListById(ocTypeId int64) ([]viewmodels.OcCatInfo, error)
+	Create(d *datamodels.OcCat) error
+	Update(d *datamodels.OcCat) error
+	Delete(m map[string]interface{}) error
+}
+
+type ocCatService struct {
+	repo *repositories.OcCatRepo
+}
+
+func NewOcCatService() OcCatService {
+	return &ocCatService{
+		repo: repositories.NewOcCatRepo(datasource.InstanceMaster()),
+	}
+}
+
+func (s *ocCatService) GetList(m map[string]interface{}) ([]viewmodels.OcCatInfo, error) {
+	return s.repo.GetList(m)
+}
+
+func (s *ocCatService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+	return s.repo.GetPage(m)
+}
+
+func (s *ocCatService) GetById(ocTypeId, ocCatId int64) (*viewmodels.OcCatInfo, error) {
+	return s.repo.GetById(ocTypeId, ocCatId)
+}
+
+func (s *ocCatService)  GetListById(ocTypeId int64) ([]viewmodels.OcCatInfo, error) {
+	return s.repo.GetListById(ocTypeId)
+}
+
+func (s *ocCatService) Create(OcCat *datamodels.OcCat) error {
+	OcCat.OcCatId = NewID()
+	return s.repo.Create(OcCat)
+}
+
+func (s *ocCatService) Update(OcCat *datamodels.OcCat) error {
+	return s.repo.Update(OcCat)
+}
+
+func (s *ocCatService) Delete(m map[string]interface{}) error {
+	return s.repo.Delete(m)
+}

+ 52 - 0
service/oc_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type OcService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.OcInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocId int64) (*viewmodels.OcInfo, error)
+    Create(d *datamodels.Oc) error
+    Update(d *datamodels.Oc) error
+    Delete(m map[string]interface{}) error
+}
+
+type ocService struct {
+    repo *repositories.OcRepo
+}
+
+func NewOcService() OcService {
+    return &ocService{
+        repo: repositories.NewOcRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *ocService) GetList(m map[string]interface{}) ([]viewmodels.OcInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *ocService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *ocService) GetById(ocId int64) (*viewmodels.OcInfo, error) {
+    return s.repo.GetById(ocId)
+}
+
+func (s *ocService) Create(Oc *datamodels.Oc) error {
+    Oc.OcId = NewID()
+    return s.repo.Create(Oc)
+}
+
+func (s *ocService) Update(Oc *datamodels.Oc) error {
+    return s.repo.Update(Oc)
+}
+
+func (s *ocService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 52 - 0
service/oc_type_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+"xps/datamodels"
+"xps/datasource"
+"xps/repositories"
+"xps/viewmodels"
+)
+
+type OcTypeService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.OcTypeInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocTypeId int64) (*viewmodels.OcTypeInfo, error)
+    Create(d *datamodels.OcType) error
+    Update(d *datamodels.OcType) error
+    Delete(m map[string]interface{}) error
+}
+
+type ocTypeService struct {
+    repo *repositories.OcTypeRepo
+}
+
+func NewOcTypeService() OcTypeService {
+    return &ocTypeService{
+        repo: repositories.NewOcTypeRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *ocTypeService) GetList(m map[string]interface{}) ([]viewmodels.OcTypeInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *ocTypeService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *ocTypeService) GetById(ocTypeId int64) (*viewmodels.OcTypeInfo, error) {
+    return s.repo.GetById(ocTypeId)
+}
+
+func (s *ocTypeService) Create(OcType *datamodels.OcType) error {
+    OcType.OcTypeId = NewID()
+    return s.repo.Create(OcType)
+}
+
+func (s *ocTypeService) Update(OcType *datamodels.OcType) error {
+    return s.repo.Update(OcType)
+}
+
+func (s *ocTypeService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 13 - 0
viewmodels/oc_cat_info.go

@@ -0,0 +1,13 @@
+package viewmodels
+
+type OcCatInfo struct {
+    OcTypeId        int64     `json:"ocTypeId"      xorm:"'oc_type_id'     bigint     pk comment('主键ID')          "`
+    OcCatId         int64     `json:"ocCatId"       xorm:"'oc_cat_id'      bigint     pk comment('主键ID')          "`
+    OcCatTitle      string    `json:"ocCatTitle"    xorm:"'oc_cat_title'   varchar(50)   comment('群组类型名称')     "`
+    OcCatDesc       string    `json:"ocCatDesc"     xorm:"'oc_cat_desc'    varchar(50)   comment('描述')            "`
+    IsFixed         int64     `json:"isFixed"       xorm:"'is_fixed'        int          comment('是否可修改')       "`
+}
+
+func (t *OcCatInfo) TableName() string {
+    return "oc_cat"
+}

+ 16 - 14
viewmodels/oc_info.go

@@ -1,20 +1,22 @@
 package viewmodels
 
-// OcInfo
+// OcInfo Oc Info
 type OcInfo struct {
-	OcId      int64  `json:"ocId"          form:"ocTypeId"        xorm:"'oc_id'       bigint    pk  comment('主键ID')     " `
-	OcName    string `json:"ocName"        form:"ocName"          xorm:"'oc_name'     varchar(127)  comment('ENT类型名称') " `
-	OcTypeId  int64  `json:"ocTypeId"      form:"ocTypeId"        xorm:"'oc_type_id'  bigint        comment('Type ID')    " `
-	RootId    int64  `json:"rootId"        form:"rootId"          xorm:"'root_id'     bigint        comment('Root ID')     " `
-	ParentId  int64  `json:"parentId"      form:"parentId"        xorm:"'parent_id'   bigint        comment('Parent ID')   " `
-	AdminId   int64  `json:"adminId"       form:"adminId"         xorm:"'admin_id'    bigint        comment('Admin ID')    " `
-	AdminName string `json:"adminName"     form:"adminName"       xorm:"'admin_name'  varchar(127)  comment('Admin Name')  " `
+	OcId      int64  `json:"ocId"          form:"ocTypeId"        xorm:"'oc_id'       bigint    pk  comment('主键ID')       " `
+	OcName    string `json:"ocName"        form:"ocName"          xorm:"'oc_name'     varchar(127)  comment('ENT类型名称')   " `
+	OcTypeId  int64  `json:"ocTypeId"      form:"ocTypeId"        xorm:"'oc_type_id'  bigint        comment('Type ID')      " `
+	OcCatId   int64  `json:"ocCatId"       form:"ocCatId"         xorm:"'oc_cat_id'   bigint        comment('Cat ID')       " `
+	
+	RootId    int64  `json:"rootId"        form:"rootId"          xorm:"'root_id'     bigint        comment('Root ID')      " `
+	ParentId  int64  `json:"parentId"      form:"parentId"        xorm:"'parent_id'   bigint        comment('Parent ID')    " `
+	AdminId   int64  `json:"adminId"       form:"adminId"         xorm:"'admin_id'    bigint        comment('Admin ID')     " `
+	AdminName string `json:"adminName"     form:"adminName"       xorm:"'admin_name'  varchar(127)  comment('Admin Name')   " `
 	GroupId   int64  `json:"groupId"       form:"groupId"         xorm:"'group_id'    bigint        comment('Root Group Id')" `
-	IfLic     int    `json:"ifLic"         form:"ifLic"           xorm:"'if_lic'      int           comment('Admin ID')    " `
+	IfLic     int    `json:"ifLic"         form:"ifLic"           xorm:"'if_lic'      int           comment('Admin ID')     " `
 
-	NodeLeft  int `json:"nodeLeft"      form:"nodeLeft"        xorm:"'node_left'   int           comment('Admin ID')    " `
-	NodeRight int `json:"nodeRight"     form:"nodeRight"       xorm:"'node_right'  int           comment('Admin ID')    " `
-	IsLeaf    int `json:"isLeaf"        form:"isLeaf"          xorm:"'is_leaf'     int           comment('Admin ID')    " `
-	NodeLevel int `json:"nodeLevel"     form:"nodeLevel"       xorm:"'node_level'  int           comment('Admin ID')    " `
-	Status    int `json:"status"         form:"status"         xorm:"'status'      int           comment('OC Status')   " `
+	NodeLeft  int   `json:"nodeLeft"       form:"nodeLeft"        xorm:"'node_left'   int           comment('Admin ID')     " `
+	NodeRight int   `json:"nodeRight"      form:"nodeRight"       xorm:"'node_right'  int           comment('Admin ID')     " `
+	IsLeaf    int   `json:"isLeaf"         form:"isLeaf"          xorm:"'is_leaf'     int           comment('Admin ID')     " `
+	NodeLevel int   `json:"nodeLevel"      form:"nodeLevel"       xorm:"'node_level'  int           comment('Admin ID')     " `
+	Status    int   `json:"status"         form:"status"          xorm:"'status'      int           comment('OC Status')    " `
 }

+ 12 - 0
viewmodels/oc_type_info.go

@@ -0,0 +1,12 @@
+package viewmodels
+
+type OcTypeInfo struct {
+    OcTypeId        int64   `json:"ocTypeId"      xorm:"'oc_type_id'      bigint     pk comment('主键ID')        "`
+    OcTypeTitle     string  `json:"ocTypeTitle"   xorm:"'oc_type_title'   varchar(50)   comment('群组类型名称')   "`
+    OcTypeDesc      string  `json:"ocTypeDesc"    xorm:"'oc_type_desc'    varchar(50)   comment('描述')          "`
+    IsFixed         int64   `json:"isFixed"       xorm:"'is_fixed'        int           comment('是否可修改')     "`
+}
+
+func (t *OcTypeInfo) TableName() string {
+    return "oc_type"
+}

+ 106 - 0
web/controllers/oc_cat_controller.go

@@ -0,0 +1,106 @@
+package controllers
+
+import (
+    "github.com/kataras/iris/v12/mvc"
+    "xps/datamodels"
+    "xps/service"
+)
+
+type OcCatController struct {
+    Base
+    Service service.OcCatService
+}
+
+func (c *OcCatController) BeforeActivation(b mvc.BeforeActivation) {
+    b.Handle("GET",         "/",                                    "GetList"       )
+    b.Handle("GET",         "/page",                                "GetPage"       )
+    b.Handle("GET",         "/{ocTypeId:int64}/{ocCatId:int64}",    "GetById"       )
+    b.Handle("GET",         "/{ocTypeId:int64}",                    "GetListById"   )
+    b.Handle("POST",        "/add",                                 "Create"        )
+    b.Handle("PUT",         "/update",                              "Update"        )
+    b.Handle("DELETE",      "/{ocTypeId:int64}/{ocCatId:int64}",    "DeleteByID"    )
+}
+
+func (c *OcCatController) GetList() *JsonResult {
+    params    := c.buildParams()
+    data, err := c.Service.GetList(params)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcCatController) GetPage() *JsonResult {
+    params    := c.buildParams()
+    data, err := c.Service.GetPage(params)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcCatController) GetById(ocTypeId, ocCatId int64) *JsonResult {
+    data, err := c.Service.GetById(ocTypeId, ocCatId)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcCatController) GetListById(ocTypeId int64) *JsonResult {
+    dataList, err := c.Service.GetListById(ocTypeId)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", dataList)
+    }
+}
+
+func (c *OcCatController) Create() *JsonResult {
+    userId := c.GetCurUserId()
+    
+    mod := datamodels.OcCat{}
+    mod.CreatedBy = userId
+    if err := c.Ctx.ReadJSON(&mod); err != nil {
+        return ResultErr("读取数据失败", nil)
+    }
+    
+    if err := c.Service.Create(&mod); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("新增成功", nil)
+    }
+}
+
+func (c *OcCatController) Update() *JsonResult {
+    userId := c.GetCurUserId()
+    
+    mod  := datamodels.OcCat{}
+    if err := c.Ctx.ReadJSON(&mod); err != nil {
+        return ResultErr("读取数据失败", nil)
+    }
+    
+    mod.UpdatedBy = userId
+    if err := c.Service.Update(&mod); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("更新成功", nil)
+    }
+}
+
+func (c *OcCatController) DeleteByID(ocTypeId, ocCatId int64) *JsonResult {
+    userId := c.GetCurUserId()
+    
+    m := make(map[string]interface{})
+    m["ocTypeId"]  = ocTypeId
+    m["ocCatId"]   = ocCatId
+    m["deletedBy"] = userId
+    if err := c.Service.Delete(m); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("删除成功", nil)
+    }
+}

+ 95 - 0
web/controllers/oc_controller.go

@@ -0,0 +1,95 @@
+package controllers
+
+import (
+    "github.com/kataras/iris/v12/mvc"
+    "xps/datamodels"
+    "xps/service"
+)
+
+type OcController struct {
+    Base
+    Service service.OcService
+}
+
+func (c *OcController) BeforeActivation(b mvc.BeforeActivation) {
+    b.Handle("GET",         "/",                                "GetList"       )
+    b.Handle("GET",         "/page",                            "GetPage"       )
+    b.Handle("GET",         "/{ocId:int64}",                    "GetById"       )
+    b.Handle("POST",        "/add",                             "Create"        )
+    b.Handle("PUT",         "/update",                          "Update"        )
+    b.Handle("DELETE",      "/{ocId:int64}",                    "DeleteByID"    )
+}
+
+func (c *OcController) GetList() *JsonResult {
+    params    := c.buildParams()
+    data, err := c.Service.GetList(params)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcController) GetPage() *JsonResult {
+    params    := c.buildParams()
+    data, err := c.Service.GetPage(params)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcController) GetById(ocId int64) *JsonResult {
+    data, err := c.Service.GetById(ocId)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcController) Create() *JsonResult {
+    userId := c.GetCurUserId()
+    
+    o := datamodels.Oc{}
+    o.CreatedBy = userId
+    if err := c.Ctx.ReadJSON(&o); err != nil {
+        return ResultErr("读取数据失败", nil)
+    }
+    
+    if err := c.Service.Create(&o); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("新增成功", nil)
+    }
+}
+
+func (c *OcController) Update() *JsonResult {
+    userId := c.GetCurUserId()
+    
+    o  := datamodels.Oc{}
+    if err := c.Ctx.ReadJSON(&o); err != nil {
+        return ResultErr("读取数据失败", nil)
+    }
+    
+    o.UpdatedBy = userId
+    if err := c.Service.Update(&o); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("更新成功", nil)
+    }
+}
+
+func (c *OcController) DeleteByID(ocId int64) *JsonResult {
+    userId := c.GetCurUserId()
+    
+    m := make(map[string]interface{})
+    m["ocId"]  = ocId
+    m["deletedBy"] = userId
+    if err := c.Service.Delete(m); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("删除成功", nil)
+    }
+}

+ 95 - 0
web/controllers/oc_type_controller.go

@@ -0,0 +1,95 @@
+package controllers
+
+import (
+"github.com/kataras/iris/v12/mvc"
+"xps/datamodels"
+"xps/service"
+)
+
+type OcTypeController struct {
+    Base
+    Service service.OcTypeService
+}
+
+func (c *OcTypeController) BeforeActivation(b mvc.BeforeActivation) {
+    b.Handle("GET",         "/",                                    "GetList"       )
+    b.Handle("GET",         "/page",                                "GetPage"       )
+    b.Handle("GET",         "/{ocTypeId:int64}",                    "GetById"       )
+    b.Handle("POST",        "/add",                                 "Create"        )
+    b.Handle("PUT",         "/update",                              "Update"        )
+    b.Handle("DELETE",      "/{ocTypeId:int64}",                    "DeleteByID"    )
+}
+
+func (c *OcTypeController) GetList() *JsonResult {
+    params    := c.buildParams()
+    data, err := c.Service.GetList(params)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcTypeController) GetPage() *JsonResult {
+    params    := c.buildParams()
+    data, err := c.Service.GetPage(params)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcTypeController) GetById(ocTypeId int64) *JsonResult {
+    data, err := c.Service.GetById(ocTypeId)
+    if err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("获取成功", data)
+    }
+}
+
+func (c *OcTypeController) Create() *JsonResult {
+    userId := c.GetCurUserId()
+    
+    mod := datamodels.OcType{}
+    mod.CreatedBy = userId
+    if err := c.Ctx.ReadJSON(&mod); err != nil {
+        return ResultErr("读取数据失败", nil)
+    }
+    
+    if err := c.Service.Create(&mod); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("新增成功", nil)
+    }
+}
+
+func (c *OcTypeController) Update() *JsonResult {
+    userId := c.GetCurUserId()
+    
+    mod  := datamodels.OcType{}
+    if err := c.Ctx.ReadJSON(&mod); err != nil {
+        return ResultErr("读取数据失败", nil)
+    }
+    
+    mod.UpdatedBy = userId
+    if err := c.Service.Update(&mod); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("更新成功", nil)
+    }
+}
+
+func (c *OcTypeController) DeleteByID(ocTypeId int64) *JsonResult {
+    userId := c.GetCurUserId()
+    
+    m := make(map[string]interface{})
+    m["ocTypeId"]  = ocTypeId
+    m["deletedBy"] = userId
+    if err := c.Service.Delete(m); err != nil {
+        return ResultErr(err.Error(), nil)
+    } else {
+        return ResultOk("删除成功", nil)
+    }
+}