houyaf vor 3 Jahren
Ursprung
Commit
3d26ace745

+ 2 - 1
datamodels/art.go

@@ -9,7 +9,8 @@ type Art struct {
     ArtTitle    string    `json:"artTitle"     xorm:"'art_title'     varchar(127)   comment('ArtTitle') "`
     ArtContent  string    `json:"artContent"   xorm:"'art_content'   varchar(127)   comment('Content')  "`
     ArtAuthor   string    `json:"artAuthor"    xorm:"'art_author'    varchar(127)   comment('Content')  "`
-
+    ArtSource   string    `json:"artSource"    xorm:"'art_source'    varchar(127)   comment('Content')  "`
+    
     Status      int64     `json:"status"       xorm:"'status'        bigint         comment('Status')    "`
     EditorId    int64     `json:"editorId"     xorm:"'editor_id'     bigint         comment('EditorId')  "`
     IssuedAt    time.Time `json:"issuedAt"     xorm:"'issued_at'     datetime       comment('Datetime')  "`

+ 21 - 0
datamodels/art_attach.go

@@ -0,0 +1,21 @@
+package datamodels
+
+import "time"
+
+type ArtAttach struct {
+    OcId            int64     `json:"ocId"            xorm:"'oc_id'             bigint    pk comment('OC Id')       " `
+    ArtId           int64     `json:"artId"           xorm:"'art_id'            bigint    pk comment('主键ID')       " `
+    FileId          int64     `json:"fileId"          xorm:"'file_id'           bigint    pk comment('主键ID')       " `
+    
+    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 (m *ArtAttach) TableName() string {
+    return "wf_ins_attach"
+}

+ 22 - 0
datamodels/doc_cat.go

@@ -0,0 +1,22 @@
+package datamodels
+
+import "time"
+
+type DocCat struct {
+    OcId          int64     `json:"ocId"            xorm:"'oc_id'           bigint     pk comment('OC ID')          "`
+    DocCatId      int64     `json:"docCatId"        xorm:"'doc_cat_id'      bigint     pk comment('DOC CAT ID')     "`
+    DocCatTitle   string    `json:"docCatTitle"     xorm:"'doc_cat_title'   varchar(127)  comment('群组类型名称')     "`
+    DocCatDesc    string    `json:"docCatDesc"      xorm:"'doc_cat_desc'    varchar(127)  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 *DocCat) TableName() string {
+    return "doc_cat"
+}

+ 31 - 0
datamodels/doc_dir.go

@@ -0,0 +1,31 @@
+package datamodels
+
+import "time"
+
+type DocDir struct {
+    OcId          int64     `json:"ocId"         xorm:"'oc_id'       bigint     pk  comment('OC ID')    "`
+    
+    DirId         int64     `json:"dirId"        xorm:"'dir_id'      bigint        pk  comment('主键ID')       "`
+    DirTitle      string    `json:"dirTitle"     xorm:"'dir_title'   varchar(50)       comment('群组类型名称')  "`
+    DirDesc       string    `json:"dirDesc"      xorm:"'dir_desc'    varchar(50)       comment('描述')         "`
+    
+    RootId        int64     `json:"rootId"       xorm:"'root_id'     bigint not null   comment('Order')      " `
+    ParentId      int64     `json:"parentId"     xorm:"'parent_id'   bigint not null   comment('父群组ID')    " `
+    NodeLeft      int64     `json:"nodeLeft"     xorm:"'node_left'   bigint not null   comment('群组LEFT')    " `
+    NodeRight     int64     `json:"nodeRight"    xorm:"'node_right'  bigint not null   comment('群组RIGHT')   " `
+    NodeLevel     int64     `json:"nodeLevel"    xorm:"'node_level'  bigint not null   comment('群组LEVEL')   " `
+    IsLeaf        int64     `json:"isLeaf"       xorm:"'is_leaf'     bigint not null   comment('LEAF群组')    " `
+    IsFixed       int64     `json:"isFixed"      xorm:"'is_fixed'    bigint not null   comment('群组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'"`
+}
+
+func (t *DocDir) TableName() string {
+    return "doc_dir"
+}

+ 33 - 0
datamodels/doc_file.go

@@ -0,0 +1,33 @@
+package datamodels
+
+import "time"
+
+type DocFile struct {
+    OcId            int64     `json:"ocId"             xorm:"'oc_id'            bigint     pk comment('OC Id')       " `
+    
+    FileId          int64     `json:"fileId"           xorm:"'file_id'          bigint     pk comment('主键ID')       " `
+    FileTitle       string    `json:"fileTitle"        xorm:"'file_title'       varchar(50)   comment('File Title')  "`
+    FileIcon        string    `json:"fileIcon"         xorm:"'file_icon'        varchar(50)   comment('File Url')    "`
+    FileExt         string    `json:"fileExt"          xorm:"'file_ext'         varchar(50)   comment('File Url')    "`
+    
+    DirId           int64     `json:"dirId"            xorm:"'dir_id'           bigint        comment('Dir ID')      "`
+    
+    FileUrl         string    `json:"fileUrl"          xorm:"'file_url'         varchar(50)   comment('File Url')    "`
+    FileSize        int64     `json:"fileSize"         xorm:"'file_size'        bigint        comment('File Size')   "`
+    
+    FileAuthor      string    `json:"fileAuthor"       xorm:"'file_author'      varchar(50)   comment('File Url')    "`
+    FileMimeType    string    `json:"fileMimeType"     xorm:"'file_mime_type'   varchar(50)   comment('File Url')    "`
+    
+    FileDesc        string    `json:"fileDesc"         xorm:"'file_desc'        varchar(50)   comment('File Desc')   "`
+    
+    UploadedAt      time.Time `json:"uploadedAt"       xorm:"'uploaded_at'    "`
+    UploadedBy      int64     `json:"uploadedBy"       xorm:"'uploaded_by'    "`
+    
+    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'"`
+}

+ 25 - 26
datamodels/wf_ins.go

@@ -3,36 +3,35 @@ package datamodels
 import "time"
 
 type WfIns struct {
-    OcId            int64     `json:"ocId"            xorm:"'oc_id'             bigint    pk comment('OC Id')       " `
-    WfDefId         int64     `json:"wfDefId"         xorm:"'wf_def_id'         bigint    pk comment('主键ID')       " `
-    WfInsId         int64     `json:"wfInsId"         xorm:"'wf_ins_id'         bigint    pk comment('主键ID')       " `
-    WfInsTitle      string    `json:"wfInsTitle"      xorm:"'wf_ins_title'      varchar(127) comment('描述')         " `
-    BeginTime       time.Time `json:"beginTime"       xorm:"'begin_time'        datetime     comment('描述')         " `
-    FinishTime      time.Time `json:"finishTime"      xorm:"'finish_time'       datetime     comment('描述')         " `
-    Status          int64     `json:"status"          xorm:"'status'            bigint       comment('Status')      " `
-    CurGroupId      int64     `json:"curGroupId"      xorm:"'cur_group_id'      bigint       comment('CurGroupId')  " `
-    CurGroupName    string    `json:"curGroupName"    xorm:"'cur_group_name'    varchar(127) comment('描述')         " `
-    CurPositionId   int64     `json:"curPositionId"   xorm:"'cur_position_id'   bigint       comment('CurGroupId')  " `
-    CurPositionName string    `json:"curPositionName" xorm:"'cur_position_name' varchar(127) comment('描述')         " `
-    CurAccountId    int64     `json:"curAccountId"    xorm:"'cur_account_id'    bigint       comment('CurGroupId')  " `
-    CurAccountName  string    `json:"curAccountName"  xorm:"'cur_account_name'  varchar(127) comment('描述')         " `
+    OcId                int64       `json:"ocId"                    xorm:"'oc_id'                   bigint    pk comment('OC Id')       " `
+    WfDefId             int64       `json:"wfDefId"                 xorm:"'wf_def_id'               bigint    pk comment('主键ID')       " `
+    WfInsId             int64       `json:"wfInsId"                 xorm:"'wf_ins_id'               bigint    pk comment('主键ID')       " `
+    WfInsTitle          string      `json:"wfInsTitle"              xorm:"'wf_ins_title'            varchar(127) comment('描述')         " `
+    BeginTime           time.Time   `json:"beginTime"               xorm:"'begin_time'              datetime     comment('描述')         " `
+    FinishTime          time.Time   `json:"finishTime"              xorm:"'finish_time'             datetime     comment('描述')         " `
+    Status              int64       `json:"status"                  xorm:"'status'                  bigint       comment('Status')      " `
+    CurGroupId          int64       `json:"curGroupId"              xorm:"'cur_group_id'            bigint       comment('CurGroupId')  " `
+    CurGroupName        string      `json:"curGroupName"            xorm:"'cur_group_name'          varchar(127) comment('描述')         " `
+    CurPositionId       int64       `json:"curPositionId"           xorm:"'cur_position_id'         bigint       comment('CurGroupId')  " `
+    CurPositionName     string      `json:"curPositionName"         xorm:"'cur_position_name'       varchar(127) comment('描述')         " `
+    CurAccountId        int64       `json:"curAccountId"            xorm:"'cur_account_id'          bigint       comment('CurGroupId')  " `
+    CurAccountName      string      `json:"curAccountName"          xorm:"'cur_account_name'        varchar(127) comment('描述')         " `
     
-    CurActivityInsId     int64     `json:"curActivityInsId"      xorm:"'cur_activity_ins_id'      bigint       comment('CurGroupId')  " `
-    CurActivityBeginTime time.Time `json:"curActivityBeginTime"  xorm:"'cur_activity_begin_name'  varchar(127) comment('描述')         " `
+    CurActivityInsId     int64      `json:"curActivityInsId"        xorm:"'cur_activity_ins_id'     bigint       comment('CurGroupId')  " `
+    CurActivityBeginTime time.Time  `json:"curActivityBeginTime"    xorm:"'cur_activity_begin_name' varchar(127) comment('描述')         " `
     
-    CurActivityCode  string    `json:"curActivityCode"  xorm:"'cur_activity_code'  varchar(127) comment('描述')         " `
-    CurActivityTitle string    `json:"curActivityTitle" xorm:"'cur_activity_title'  varchar(127) comment('描述')         " `
+    CurActivityCode     string      `json:"curActivityCode"         xorm:"'cur_activity_code'       varchar(127) comment('描述')         " `
+    CurActivityTitle    string      `json:"curActivityTitle"        xorm:"'cur_activity_title'      varchar(127) comment('描述')         " `
     
-    CurFormCode  string    `json:"curFormCode"     xorm:"'cur_form_code'  varchar(127) comment('描述')         " `
+    CurFormCode         string      `json:"curFormCode"             xorm:"'cur_form_code'           varchar(127) 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'  " `
+    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 (m *WfIns) TableName() string {

+ 7 - 7
datamodels/wf_ins_attach.go

@@ -10,13 +10,13 @@ type WfInsAttach struct {
     
     FileId          int64     `json:"fileId"          xorm:"'file_id'           bigint    pk comment('主键ID')       " `
     
-    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'  " `
 }
 
 func (m *WfInsAttach) TableName() string {

+ 2 - 2
repositories/app_repo.go

@@ -37,7 +37,7 @@ func (d *AppRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, err
 		return nil, err1
 	}
 
-	sqlOrderBy := " ORDER BY app_id DESC "
+	sqlOrderBy := " ORDER BY A.app_id "
 	pageStart  := (page - 1) * limit
 	sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
 
@@ -65,7 +65,7 @@ func (d *AppRepo) GetList(m map[string]interface{}) ([]viewmodels.AppInfo, error
 		sqlWhere += " AND   A.app_title like '%" + fmt.Sprintf("%s", keywords) + "%'"
 	}
 
-	sqlOrderBy := " ORDER BY app_id DESC "
+	sqlOrderBy := " ORDER BY A.app_id "
 	datalist   := make([]viewmodels.AppInfo, 0)
 	err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
 	if err != nil {

+ 89 - 0
repositories/art_attach_repo.go

@@ -0,0 +1,89 @@
+package repositories
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type ArtAttachRepo struct {
+    engine *xorm.Engine
+}
+
+func NewArtAttachRepo(engine *xorm.Engine) *ArtCatRepo {
+    return &ArtCatRepo{
+        engine: engine,
+    }
+}
+
+func (d *ArtRepo) GetListById(ocId, artId int64) ([]viewmodels.AttachInfo, error) {
+    sqlSelect := ` SELECT
+                        A.file_id,
+                        B.file_title,
+                        B.dir_id,
+                        B.file_icon,
+                        B.file_url,
+                        B.file_ext,
+                        B.file_size,
+                        B.file_author,
+                        B.file_desc,
+                        B.uploaded_by  AS uploader_id,
+                        C.account_name AS uploader_name,
+                        B.uploaded_at  `
+    sqlFrom   := ` FROM        art_attach  AS A
+                   LEFT JOIN   doc_file    AS B ON(A.oc_id = B.oc_id AND A.file_id     = B.file_id)
+                   LEFT JOIN   account     AS C ON(B.oc_id = C.oc_id AND B.uploaded_by = C.account_id)  `
+    sqlWhere  := ` WHERE B.deleted_flag = 0 `
+    sqlWhere  += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlWhere  += fmt.Sprintf(" AND A.art_id = %d ", artId)
+    
+    sqlOrderBy := " ORDER BY A.issued_at DESC "
+    datalist   := make([]viewmodels.AttachInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    }
+    return datalist, nil
+}
+
+func (d *ArtAttachRepo) Create(data *datamodels.ArtAttach) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *ArtAttachRepo) Delete(m map[string]interface{}) error {
+    ocId      := m["ocId"].(int64)
+    artId     := m["artId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.ArtAttach{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("art_id = ?", artId).
+        Update(data)
+    return err
+}
+
+func (d *ArtAttachRepo) DeleteById(m map[string]interface{}) error {
+    ocId      := m["ocId"].(int64)
+    artId     := m["artId"].(int64)
+    fileId    := m["fileId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.ArtAttach{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("art_id = ?", artId).
+        Where("file_id = ?", fileId).
+        Update(data)
+    return err
+}

+ 173 - 0
repositories/art_cat_repo.go

@@ -0,0 +1,173 @@
+package repositories
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type ArtCatRepo struct {
+    engine *xorm.Engine
+}
+
+func NewArtCatRepo(engine *xorm.Engine) *ArtCatRepo {
+    return &ArtCatRepo{
+        engine: engine,
+    }
+}
+
+func (d *ArtCatRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit     := m["limit"].(int)
+    page      := m["page"].(int)
+    
+    sqlSelect := ` SELECT A.*                `
+    sqlFrom   := ` FROM   art_cat   AS A     `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    if artCatId, ok := m["artCatId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.art_cat_id = %d ", artCatId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.art_cat_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlCount := ` SELECT COUNT(*)            `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.ArtCat))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.art_cat_id "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.ArtCat, 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 *ArtCatRepo) GetList(m map[string]interface{}) ([]viewmodels.ArtCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  art_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    if ocId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if artCatId, ok := m["artCatId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.art_cat_id = %d ", artCatId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += ` AND   A.art_cat_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.art_cat_id "
+    datalist   := make([]viewmodels.ArtCatInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+func (d *ArtCatRepo) GetById(ocId, artCatId int64) (*viewmodels.ArtCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  art_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlWhere   += fmt.Sprintf(" AND A.art_cat_id  = %d ", artCatId)
+    data := &viewmodels.ArtCatInfo{}
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *ArtCatRepo) GetListById(ocId int64) ([]viewmodels.ArtCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  art_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlOrderBy := " ORDER BY A.oc_id, A.art_cat_id "
+    datalist   := make([]viewmodels.ArtCatInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+
+func (d *ArtCatRepo) Create(data *datamodels.ArtCat) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *ArtCatRepo) Update(data *datamodels.ArtCat) error {
+    artCatId := data.ArtCatId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.Where("art_cat_id = ?", artCatId).Update(data)
+    return err
+}
+
+func (d *ArtCatRepo) Delete(m map[string]interface{}) error {
+    ocId      := m["ocId"].(int64)
+    artCatId  := m["artCatId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.ArtCat{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("art_cat_id = ?", artCatId).
+        Update(data)
+    return err
+}
+
+func (d *ArtCatRepo) IncrementLeft(ocId int64 ,steps int64 ,nodeLeft int64) error {
+    sql  := fmt.Sprintf("UPDATE art_cat SET node_left = node_left + %d  WHERE oc_id =%d AND node_left >= %d AND deleted_flag = 0" ,steps ,ocId ,nodeLeft)
+    _, err :=d.engine.Exec(sql)
+    
+    return err
+}
+
+func (d *ArtCatRepo) IncrementRight(ocId int64 ,steps int64 ,nodeRight int64) error {
+    sql  := fmt.Sprintf("UPDATE art_cat SET node_right = node_right + %d WHERE oc_id =%d AND node_right >= %d AND deleted_flag = 0" ,steps ,ocId ,nodeRight)
+    _, err :=d.engine.Exec(sql)
+    return err
+}
+
+func (d *ArtCatRepo) DecrementLeft(ocId int64 ,steps int64 ,nodeLeft int64) error {
+    sql  := fmt.Sprintf("UPDATE art_cat SET node_left = node_left - %d  WHERE oc_id =%d AND node_left > %d AND deleted_flag = 0" ,steps ,ocId ,nodeLeft)
+    _, err :=d.engine.Exec(sql)
+    return err
+}
+
+func (d *ArtCatRepo) DecrementRight(ocId int64 ,steps int64 ,nodeRight int64) error {
+    sql  := fmt.Sprintf("UPDATE art_cat SET node_right = node_right - %d WHERE oc_id =%d AND node_right > %d AND deleted_flag = 0" ,steps ,ocId ,nodeRight)
+    _, err :=d.engine.Exec(sql)
+    return err
+}
+
+func (d *ArtCatRepo) BatchDelete(ocId ,nodeLeft ,nodeRight int64) error {
+    sql := fmt.Sprintf("DELETE FROM art_cat WHERE oc_id = %d AND node_left >= %d AND node_right <= %d " ,ocId ,nodeLeft ,nodeRight)
+    _ ,err := d.engine.Exec(sql)
+    return err
+}

+ 156 - 0
repositories/art_repo.go

@@ -0,0 +1,156 @@
+package repositories
+
+import (
+    "errors"
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type ArtRepo struct {
+    engine *xorm.Engine
+}
+
+func NewArtRepo(engine *xorm.Engine) *ArtRepo {
+    return &ArtRepo{
+        engine: engine,
+    }
+}
+
+func (d *ArtRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit, ok1     := m["limit"].(int)
+    page, ok2      := m["page"].(int)
+    if !ok1 || !ok2 {
+        return nil, errors.New("分页参数不完整")
+    }
+    
+    sqlSelect := ` SELECT A.* ,
+                          B.art_cat_title `
+    sqlFrom   := ` FROM       art     AS A
+                   LEFT  JOIN art_cat AS B ON (A.oc_id = B.oc_id AND A.art_cat_id = B.art_cat_id)
+                   LEFT  JOIN account AS C ON (A.oc_id = C.oc_id AND A.editor_id  = C.account_id)  `
+    sqlWhere  := ` WHERE A.deleted_flag = 0 `
+    if ocId, ok:= m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if status, ok:= m["status"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.status = %d ", status)
+    }
+    if editorId, ok:= m["editorId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.editor_id = %d ", editorId)
+    }
+    nodeLeft, ok1 := m["nodeLeft"]
+    nodeRight, ok2 := m["nodeRight"]
+    if ok1 && ok2 {
+        sqlWhere += fmt.Sprintf(" AND B.node_left >= %d", nodeLeft)
+        sqlWhere += fmt.Sprintf(" AND B.node_right <= %d", nodeRight)
+    }
+    if keywords, ok:= m["keywords"]; ok {
+        sqlWhere += " AND A.art_title like '%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    
+    sqlCount    := ` SELECT COUNT(*) `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.Art))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY A.issued_at DESC "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.Art, 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 *ArtRepo) GetList(m map[string]interface{}) ([]viewmodels.ArtInfo, error) {
+    sqlSelect := ` SELECT A.* ,
+                          B.art_cat_title `
+    sqlFrom   := ` FROM       art     AS A
+                   LEFT  JOIN art_cat AS B ON (A.oc_id = B.oc_id AND A.art_cat_id = B.art_cat_id)
+                   LEFT  JOIN account AS C ON (A.oc_id = C.oc_id AND A.editor_id  = C.account_id)  `
+    sqlWhere  := ` WHERE A.deleted_flag = 0 `
+    if ocId, ok:= m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if status, ok:= m["status"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.status = %d ", status)
+    }
+    if editorId, ok:= m["editorId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.editor_id = %d ", editorId)
+    }
+    nodeLeft, ok1 := m["nodeLeft"]
+    nodeRight, ok2 := m["nodeRight"]
+    if ok1 && ok2 {
+        sqlWhere += fmt.Sprintf(" AND B.node_left >= %d", nodeLeft)
+        sqlWhere += fmt.Sprintf(" AND B.node_right <= %d", nodeRight)
+    }
+    if keywords, ok:= m["keywords"]; ok {
+        sqlWhere += " AND A.art_title like '%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    
+    sqlOrderBy := " ORDER BY A.issued_at DESC "
+    datalist   := make([]viewmodels.ArtInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    }
+    return datalist, nil
+}
+
+func (d *ArtRepo) GetById(ocId, artId int64) (*viewmodels.ArtInfo, error) {
+    sqlSelect := ` SELECT A.* ,
+                          B.art_cat_title `
+    sqlFrom   := ` FROM       art     AS A
+                   LEFT  JOIN art_cat AS B ON (A.oc_id = B.oc_id AND A.art_cat_id = B.art_cat_id)
+                   LEFT  JOIN account AS C ON (A.oc_id = C.oc_id AND A.editor_id  = C.account_id)  `
+    sqlWhere  := ` WHERE A.deleted_flag = 0`
+    sqlWhere  += fmt.Sprintf(" AND A.oc_id = %d", ocId)
+    sqlWhere  += fmt.Sprintf(" AND A.art_id = %d", artId)
+    
+    data      := &viewmodels.ArtInfo{}
+    ok, err   := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Limit(1).Get(data)
+    if !ok && err == nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *ArtRepo) Create(data *datamodels.Art) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *ArtRepo) Update(data *datamodels.Art) error {
+    artId := data.ArtId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.Where("art_id = ?", artId).Update(data)
+    return err
+}
+
+func (d *ArtRepo) Delete(m map[string]interface{}) error {
+    artId     := m["artId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.Art{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.Where("art_id = ?", artId).Update(data)
+    return err
+}

+ 143 - 0
repositories/doc_cat_repo.go

@@ -0,0 +1,143 @@
+package repositories
+
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type DocCatRepo struct {
+    engine *xorm.Engine
+}
+
+func NewDocCatRepo(engine *xorm.Engine) *DocCatRepo {
+    return &DocCatRepo{
+        engine: engine,
+    }
+}
+
+func (d *DocCatRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit     := m["limit"].(int)
+    page      := m["page"].(int)
+    
+    sqlSelect := ` SELECT A.*                `
+    sqlFrom   := ` FROM   doc_cat   AS A     `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    if docCatId, ok := m["docCatId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.doc_cat_id = %d ", docCatId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.doc_cat_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlCount := ` SELECT COUNT(*)            `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.DocCat))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.doc_cat_id "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.DocCat, 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 *DocCatRepo) GetList(m map[string]interface{}) ([]viewmodels.DocCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  doc_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    if ocId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if docCatId, ok := m["docCatId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.doc_cat_id = %d ", docCatId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += ` AND   A.doc_cat_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.doc_cat_id "
+    datalist   := make([]viewmodels.DocCatInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+func (d *DocCatRepo) GetById(ocId, docCatId int64) (*viewmodels.DocCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  doc_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlWhere   += fmt.Sprintf(" AND A.doc_cat_id  = %d ", docCatId)
+    data := &viewmodels.DocCatInfo{}
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *DocCatRepo) GetListById(ocId int64) ([]viewmodels.DocCatInfo, error) {
+    sqlSelect  := ` SELECT A.*                `
+    sqlFrom    := ` FROM  doc_cat AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlOrderBy := " ORDER BY A.oc_id, A.doc_cat_id "
+    datalist   := make([]viewmodels.DocCatInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+
+func (d *DocCatRepo) Create(data *datamodels.DocCat) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *DocCatRepo) Update(data *datamodels.DocCat) error {
+    docCatId := data.DocCatId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.Where("doc_cat_id = ?", docCatId).Update(data)
+    return err
+}
+
+func (d *DocCatRepo) Delete(m map[string]interface{}) error {
+    ocId      := m["ocId"].(int64)
+    docCatId  := m["docCatId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.DocCat{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("doc_cat_id = ?", docCatId).
+        Update(data)
+    return err
+}

+ 206 - 0
repositories/doc_dir_repo.go

@@ -0,0 +1,206 @@
+package repositories
+
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type DocDirRepo struct {
+    engine *xorm.Engine
+}
+
+func NewDocDirRepo(engine *xorm.Engine) *DocDirRepo {
+    return &DocDirRepo{
+        engine: engine,
+    }
+}
+
+func (d *DocDirRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit     := m["limit"].(int)
+    page      := m["page"].(int)
+    
+    sqlSelect := ` SELECT   A.oc_id,
+                            A.dir_id,
+                            A.dir_title,
+                            A.dir_desc,
+                            A.parent_id,
+                            A.is_fixed,
+                            A.node_left,
+                            A.node_right,
+                            A.node_level,
+                            A.is_leaf                `
+    sqlFrom   := ` FROM   doc_dir   AS A     `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    if ocId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if dirId, ok := m["dirId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.dir_id = %d ", dirId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.dir_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlCount := ` SELECT COUNT(*)            `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.DocDir))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.dir_id "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.DocDir, 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 *DocDirRepo) GetList(m map[string]interface{}) ([]viewmodels.DocDirInfo, error) {
+    sqlSelect  := ` SELECT  A.oc_id,
+                            A.dir_id,
+                            A.dir_title,
+                            A.dir_desc,
+                            A.parent_id,
+                            A.is_fixed,
+                            A.node_left,
+                            A.node_right,
+                            A.node_level,
+                            A.is_leaf                            `
+    sqlFrom    := ` FROM  doc_dir AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    if ocId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if dirId, ok := m["dirId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.dir_id = %d ", dirId)
+    }
+    nodeLeft, ok1 := m["nodeLeft"]
+    nodeRight, ok2 := m["nodeRight"]
+    if ok1 && ok2 {
+        sqlWhere += fmt.Sprintf(" AND A.node_left > %d", nodeLeft)
+        sqlWhere += fmt.Sprintf(" AND A.node_right < %d", nodeRight)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.dir_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.dir_id "
+    datalist   := make([]viewmodels.DocDirInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+func (d *DocDirRepo) GetById(ocId, artCatId int64) (*viewmodels.DocDirInfo, error) {
+    sqlSelect  := ` SELECT  A.oc_id,
+                            A.dir_id,
+                            A.dir_title,
+                            A.dir_desc,
+                            A.parent_id,
+                            A.is_fixed,
+                            A.node_left,
+                            A.node_right,
+                            A.node_level,
+                            A.is_leaf                            `
+    sqlFrom    := ` FROM  doc_dir AS A        `
+    sqlWhere   := ` WHERE A.deleted_flag = 0  `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlWhere   += fmt.Sprintf(" AND A.dir_id  = %d ", artCatId)
+    data := &viewmodels.DocDirInfo{}
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *DocDirRepo) Create(data *datamodels.DocDir) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *DocDirRepo) Update(data *datamodels.DocDir) error {
+    ocId  := data.OcId
+    dirId := data.DirId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("dir_id = ?", dirId).
+        Update(data)
+    return err
+}
+
+func (d *DocDirRepo) Delete(m map[string]interface{}) error {
+    ocId      := m["ocId"].(int64)
+    artCatId  := m["artCatId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.DocDir{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("dir_id = ?", artCatId).
+        Update(data)
+    return err
+}
+
+func (d *DocDirRepo) CountByParent(ocId, parentId int64)(int64, error  ){
+    docDir := &datamodels.DocDir{}
+    return  d.engine.Where("oc_id = %d", ocId).
+        Where("parent_id = %d", parentId).
+        Where("deleted_flag = %d", 0).
+        Count(docDir)
+}
+
+func (d *DocDirRepo) IncrementLeft(ocId int64 ,steps int64 ,nodeLeft int64) error {
+    sql  := fmt.Sprintf("UPDATE doc_dir SET node_left = node_left + %d  WHERE oc_id =%d AND node_left >= %d AND deleted_flag = 0" ,steps ,ocId ,nodeLeft)
+    _, err :=d.engine.Exec(sql)
+    
+    return err
+}
+
+func (d *DocDirRepo) IncrementRight(ocId int64 ,steps int64 ,nodeRight int64) error {
+    sql  := fmt.Sprintf("UPDATE doc_dir SET node_right = node_right + %d WHERE oc_id =%d AND node_right >= %d AND deleted_flag = 0" ,steps ,ocId ,nodeRight)
+    _, err :=d.engine.Exec(sql)
+    return err
+}
+
+func (d *DocDirRepo) DecrementLeft(ocId int64 ,steps int64 ,nodeLeft int64) error {
+    sql  := fmt.Sprintf("UPDATE doc_dir SET node_left = node_left - %d  WHERE oc_id =%d AND node_left > %d AND deleted_flag = 0" ,steps ,ocId ,nodeLeft)
+    _, err :=d.engine.Exec(sql)
+    return err
+}
+
+func (d *DocDirRepo) DecrementRight(ocId int64 ,steps int64 ,nodeRight int64) error {
+    sql  := fmt.Sprintf("UPDATE doc_dir SET node_right = node_right - %d WHERE oc_id =%d AND node_right > %d AND deleted_flag = 0" ,steps ,ocId ,nodeRight)
+    _, err :=d.engine.Exec(sql)
+    return err
+}
+
+func (d *DocDirRepo) BatchDelete(ocId ,nodeLeft ,nodeRight int64) error {
+    sql := fmt.Sprintf("DELETE FROM doc_dir WHERE oc_id = %d AND node_left >= %d AND node_right <= %d " ,ocId ,nodeLeft ,nodeRight)
+    _ ,err := d.engine.Exec(sql)
+    return err
+}

+ 171 - 0
repositories/doc_file_repo.go

@@ -0,0 +1,171 @@
+package repositories
+
+import (
+    "fmt"
+    "time"
+    "xorm.io/xorm"
+    "xps/datamodels"
+    "xps/viewmodels"
+)
+
+type DocFileRepo struct {
+    engine *xorm.Engine
+}
+
+func NewDocFileRepo(engine *xorm.Engine) *DocFileRepo {
+    return &DocFileRepo{
+        engine: engine,
+    }
+}
+
+func (d *DocFileRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    limit     := m["limit"].(int)
+    page      := m["page"].(int)
+    
+    sqlSelect := ` SELECT   A.oc_id,
+                            A.file_id,
+                            A.file_title,
+                            A.dir_id,
+                            A.file_icon,
+                            A.file_url,
+                            A.file_ext,
+                            A.file_mime_type,
+                            A.file_size,
+                            A.file_author,
+                            A.file_desc,
+                            A.uploaded_by  AS uploader_id,
+                            B.account_name AS uploader_name,
+                            A.uploaded_at        `
+    sqlFrom   := ` FROM      doc_file  AS A
+                   LEFT JOIN account   AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id) `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    if ocId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if fileId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.file_id = %d ", fileId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.file_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlCount := ` SELECT COUNT(*)            `
+    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.DocFile))
+    if err1 != nil {
+        return nil, err1
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.file_id "
+    pageStart  := (page - 1) * limit
+    sqlLimit   := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
+    
+    datalist := make([]datamodels.DocFile, 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 *DocFileRepo) GetList(m map[string]interface{}) ([]viewmodels.DocFileInfo, error) {
+    sqlSelect := ` SELECT   A.oc_id,
+                            A.file_id,
+                            A.file_title,
+                            A.dir_id,
+                            A.file_icon,
+                            A.file_url,
+                            A.file_ext,
+                            A.file_mime_type,
+                            A.file_size,
+                            A.file_author,
+                            A.file_desc,
+                            A.uploaded_by  AS uploader_id,
+                            B.account_name AS uploader_name,
+                            A.uploaded_at        `
+    sqlFrom   := ` FROM      doc_file  AS A
+                   LEFT JOIN account   AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id) `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    if ocId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    }
+    if fileId, ok := m["ocId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.file_id = %d ", fileId)
+    }
+    if keywords, ok := m["keywords"]; ok {
+        sqlWhere += " AND A.file_title like '%" + fmt.Sprintf("%s", keywords) + "%' "
+    }
+    
+    sqlOrderBy := " ORDER BY A.oc_id, A.file_id "
+    datalist   := make([]viewmodels.DocFileInfo, 0)
+    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
+    if err != nil {
+        return nil, err
+    } else {
+        return datalist, nil
+    }
+}
+
+func (d *DocFileRepo) GetById(ocId, fileId int64) (*viewmodels.DocFileInfo, error) {
+    sqlSelect := ` SELECT   A.oc_id,
+                            A.file_id,
+                            A.file_title,
+                            A.dir_id,
+                            A.file_icon,
+                            A.file_url,
+                            A.file_ext,
+                            A.file_mime_type,
+                            A.file_size,
+                            A.file_author,
+                            A.file_desc,
+                            A.uploaded_by  AS uploader_id,
+                            B.account_name AS uploader_name,
+                            A.uploaded_at        `
+    sqlFrom   := ` FROM      doc_file  AS A
+                   LEFT JOIN account   AS B ON (A.oc_id = B.oc_id AND A.uploaded_by = B.account_id) `
+    sqlWhere  := ` WHERE  A.deleted_flag = 0 `
+    sqlWhere   += fmt.Sprintf(" AND A.oc_id = %d ", ocId)
+    sqlWhere   += fmt.Sprintf(" AND A.file_id  = %d ", fileId)
+    data := &viewmodels.DocFileInfo{}
+    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
+    if !has || err != nil {
+        return nil, err
+    } else {
+        return data, nil
+    }
+}
+
+func (d *DocFileRepo) Create(data *datamodels.DocFile) error {
+    data.CreatedAt = time.Now()
+    _, err := d.engine.Insert(data)
+    return err
+}
+
+func (d *DocFileRepo) Update(data *datamodels.DocFile) error {
+    fileId := data.FileId
+    
+    data.UpdatedAt = time.Now()
+    _, err := d.engine.Where("file_id = ?", fileId).Update(data)
+    return err
+}
+
+func (d *DocFileRepo) Delete(m map[string]interface{}) error {
+    ocId      := m["ocId"].(int64)
+    fileId  := m["fileId"].(int64)
+    deletedBy := m["deletedBy"].(int64)
+    
+    data := &datamodels.DocFile{}
+    data.DeletedFlag = 1
+    data.DeletedBy = deletedBy
+    data.DeletedAt = time.Now()
+    _, err := d.engine.
+        Where("oc_id = ?", ocId).
+        Where("file_id = ?", fileId).
+        Update(data)
+    return err
+}

+ 52 - 0
service/art_cat_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type ArtCatService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.ArtCatInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocId, artCatId int64) (*viewmodels.ArtCatInfo, error)
+    Create(d *datamodels.ArtCat) error
+    Update(d *datamodels.ArtCat) error
+    Delete(m map[string]interface{}) error
+}
+
+type artCatService struct {
+    repo *repositories.ArtCatRepo
+}
+
+func NewArtCatService() ArtCatService {
+    return &artCatService{
+        repo: repositories.NewArtCatRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *artCatService) GetList(m map[string]interface{}) ([]viewmodels.ArtCatInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *artCatService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *artCatService) GetById(ocId, artCatId int64) (*viewmodels.ArtCatInfo, error) {
+    return s.repo.GetById(ocId, artCatId)
+}
+
+func (s *artCatService) Create(ArtCat *datamodels.ArtCat) error {
+    ArtCat.ArtCatId = NewID()
+    return s.repo.Create(ArtCat)
+}
+
+func (s *artCatService) Update(ArtCat *datamodels.ArtCat) error {
+    return s.repo.Update(ArtCat)
+}
+
+func (s *artCatService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 52 - 0
service/art_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type ArtService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.ArtInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocId, artId int64) (*viewmodels.ArtInfo, error)
+    Create(d *datamodels.Art) error
+    Update(d *datamodels.Art) error
+    Delete(m map[string]interface{}) error
+}
+
+type artService struct {
+    repo *repositories.ArtRepo
+}
+
+func NewArtService() ArtService {
+    return &artService{
+        repo: repositories.NewArtRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *artService) GetList(m map[string]interface{}) ([]viewmodels.ArtInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *artService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *artService) GetById(ocId, artId int64) (*viewmodels.ArtInfo, error) {
+    return s.repo.GetById(ocId, artId)
+}
+
+func (s *artService) Create(Art *datamodels.Art) error {
+    Art.ArtId = NewID()
+    return s.repo.Create(Art)
+}
+
+func (s *artService) Update(Art *datamodels.Art) error {
+    return s.repo.Update(Art)
+}
+
+func (s *artService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 52 - 0
service/doc_cat_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type DocCatService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.DocCatInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocId, docCatId int64) (*viewmodels.DocCatInfo, error)
+    Create(d *datamodels.DocCat) error
+    Update(d *datamodels.DocCat) error
+    Delete(m map[string]interface{}) error
+}
+
+type docCatService struct {
+    repo *repositories.DocCatRepo
+}
+
+func NewDocCatService() DocCatService {
+    return &docCatService{
+        repo: repositories.NewDocCatRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *docCatService) GetList(m map[string]interface{}) ([]viewmodels.DocCatInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *docCatService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *docCatService) GetById(ocId, docCatId int64) (*viewmodels.DocCatInfo, error) {
+    return s.repo.GetById(ocId, docCatId)
+}
+
+func (s *docCatService) Create(DocCat *datamodels.DocCat) error {
+    DocCat.DocCatId = NewID()
+    return s.repo.Create(DocCat)
+}
+
+func (s *docCatService) Update(DocCat *datamodels.DocCat) error {
+    return s.repo.Update(DocCat)
+}
+
+func (s *docCatService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 52 - 0
service/doc_dir_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type DocDirService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.DocDirInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocId, dirId int64) (*viewmodels.DocDirInfo, error)
+    Create(d *datamodels.DocDir) error
+    Update(d *datamodels.DocDir) error
+    Delete(m map[string]interface{}) error
+}
+
+type docDirService struct {
+    repo *repositories.DocDirRepo
+}
+
+func NewDocDirService() DocDirService {
+    return &docDirService{
+        repo: repositories.NewDocDirRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *docDirService) GetList(m map[string]interface{}) ([]viewmodels.DocDirInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *docDirService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *docDirService) GetById(ocId, docDirId int64) (*viewmodels.DocDirInfo, error) {
+    return s.repo.GetById(ocId, docDirId)
+}
+
+func (s *docDirService) Create(d *datamodels.DocDir) error {
+    d.DirId = NewID()
+    return s.repo.Create(d)
+}
+
+func (s *docDirService) Update(DocDir *datamodels.DocDir) error {
+    return s.repo.Update(DocDir)
+}
+
+func (s *docDirService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 52 - 0
service/doc_file_service.go

@@ -0,0 +1,52 @@
+package service
+
+import (
+    "xps/datamodels"
+    "xps/datasource"
+    "xps/repositories"
+    "xps/viewmodels"
+)
+
+type DocFileService interface {
+    GetList(m map[string]interface{}) ([]viewmodels.DocFileInfo, error)
+    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
+    GetById(ocId, docFileId int64) (*viewmodels.DocFileInfo, error)
+    Create(d *datamodels.DocFile) error
+    Update(d *datamodels.DocFile) error
+    Delete(m map[string]interface{}) error
+}
+
+type docFileService struct {
+    repo *repositories.DocFileRepo
+}
+
+func NewDocFileService() DocFileService {
+    return &docFileService{
+        repo: repositories.NewDocFileRepo(datasource.InstanceMaster()),
+    }
+}
+
+func (s *docFileService) GetList(m map[string]interface{}) ([]viewmodels.DocFileInfo, error) {
+    return s.repo.GetList(m)
+}
+
+func (s *docFileService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
+    return s.repo.GetPage(m)
+}
+
+func (s *docFileService) GetById(ocId, docFileId int64) (*viewmodels.DocFileInfo, error) {
+    return s.repo.GetById(ocId, docFileId)
+}
+
+func (s *docFileService) Create(d *datamodels.DocFile) error {
+    d.FileId = NewID()
+    return s.repo.Create(d)
+}
+
+func (s *docFileService) Update(DocFile *datamodels.DocFile) error {
+    return s.repo.Update(DocFile)
+}
+
+func (s *docFileService) Delete(m map[string]interface{}) error {
+    return s.repo.Delete(m)
+}

+ 19 - 0
viewmodels/art_cat_info.go

@@ -0,0 +1,19 @@
+package viewmodels
+
+type ArtCatInfo struct {
+    ArtCatId      int64     `json:"artCatId"        xorm:"'art_cat_id'      bigint        pk  comment('主键ID')       "`
+    ArtCatTitle   string    `json:"artCatTitle"     xorm:"'art_cat_title'   varchar(50)       comment('群组类型名称')  "`
+    ArtCatDesc    string    `json:"artCatDesc"      xorm:"'art_cat_desc'    varchar(50)       comment('描述')         "`
+    
+    RootId        int64     `json:"rootId"          xorm:"'root_id'         bigint not null   comment('Order')      " `
+    ParentId      int64     `json:"parentId"        xorm:"'parent_id'       bigint not null   comment('父群组ID')    " `
+    NodeLeft      int64     `json:"nodeLeft"        xorm:"'node_left'       bigint not null   comment('群组LEFT')    " `
+    NodeRight     int64     `json:"nodeRight"       xorm:"'node_right'      bigint not null   comment('群组RIGHT')   " `
+    NodeLevel     int64     `json:"nodeLevel"       xorm:"'node_level'      bigint not null   comment('群组LEVEL')   " `
+    IsLeaf        int64     `json:"isLeaf"          xorm:"'is_leaf'         bigint not null   comment('LEAF群组')    " `
+    IsFixed       int64     `json:"isFixed"         xorm:"'is_fixed'        bigint not null   comment('群组STATUS')  " `
+}
+
+func (t *ArtCatInfo) TableName() string {
+    return "art_cat"
+}

+ 33 - 0
viewmodels/art_detail_info.go

@@ -0,0 +1,33 @@
+package viewmodels
+
+import (
+    "time"
+)
+
+type ArtDetailInfo struct {
+    OcId        int64     `json:"ocId"         xorm:"'oc_id'         bigint     pk  comment('OC ID')    "`
+    ArtId       int64     `json:"artId"        xorm:"'art_id'        bigint     pk  comment('ArtId')    "`
+    ArtCatId    int64     `json:"artCatId"     xorm:"'art_cat_id'    bigint     pk  comment('ArtCatId') "`
+    ArtCatTitle string    `json:"artCatTitle"  xorm:"'art_cat_title' varchar(127)   comment('ArtTitle') "`
+    
+    ArtTitle    string    `json:"artTitle"     xorm:"'art_title'     varchar(127)   comment('ArtTitle') "`
+    ArtContent  string    `json:"artContent"   xorm:"'art_content'   varchar(127)   comment('Content')  "`
+    ArtAuthor   string    `json:"artAuthor"    xorm:"'art_author'    varchar(127)   comment('Content')  "`
+    
+    ArtSource   string    `json:"artSource"    xorm:"'art_source'    varchar(127)   comment('Content')  "`
+    
+    
+    IssuedAt    time.Time `json:"issuedAt"     xorm:"'issued_at'     datetime       comment('Datetime')  "`
+    IsFixed     int64     `json:"isFixed"      xorm:"'is_fixed'      bigint         comment('是否可修改')  "`
+    
+    EditorId    int64     `json:"editorId"     xorm:"'editor_id'     bigint         comment('EditorId')  "`
+    EditorName  string    `json:"editorName"   xorm:"'editor_name'   varchar(127)   comment('Content')  "`
+    
+    Status      int64     `json:"status"       xorm:"'status'        bigint         comment('Status')    "`
+
+    AttachList  []AttachInfo
+}
+
+func (t *ArtDetailInfo) TableName() string {
+    return "art"
+}

+ 21 - 0
viewmodels/art_info.go

@@ -0,0 +1,21 @@
+package viewmodels
+
+import "time"
+
+type ArtInfo struct {
+    OcId        int64     `json:"ocId"         xorm:"'oc_id'         bigint     pk  comment('OC ID')    "`
+    ArtId       int64     `json:"artId"        xorm:"'art_id'        bigint     pk  comment('ArtId')    "`
+    ArtCatId    int64     `json:"artCatId"     xorm:"'art_cat_id'    bigint     pk  comment('ArtCatId') "`
+    ArtTitle    string    `json:"artTitle"     xorm:"'art_title'     varchar(127)   comment('ArtTitle') "`
+    ArtContent  string    `json:"artContent"   xorm:"'art_content'   varchar(127)   comment('Content')  "`
+    ArtAuthor   string    `json:"artAuthor"    xorm:"'art_author'    varchar(127)   comment('Content')  "`
+    
+    Status      int64     `json:"status"       xorm:"'status'        bigint         comment('Status')    "`
+    EditorId    int64     `json:"editorId"     xorm:"'editor_id'     bigint         comment('EditorId')  "`
+    IssuedAt    time.Time `json:"issuedAt"     xorm:"'issued_at'     datetime       comment('Datetime')  "`
+    IsFixed     int64     `json:"isFixed"      xorm:"'is_fixed'      bigint         comment('是否可修改')  "`
+}
+
+func (t *ArtInfo) TableName() string {
+    return "art"
+}

+ 26 - 0
viewmodels/attach_info.go

@@ -0,0 +1,26 @@
+package viewmodels
+
+import "time"
+
+type AttachInfo struct {
+    FileId       int64     `json:"fileId"           xorm:"'file_id'        bigint     pk comment('File ID')        "`
+    FileTitle    string    `json:"fileTitle"        xorm:"'file_title'     varchar(50)   comment('File Title')     "`
+    FileIcon     string    `json:"fileIcon"         xorm:"'file_icon'      varchar(50)   comment('File Url')      "`
+    FileExt      string    `json:"fileExt"          xorm:"'file_ext'       varchar(50)   comment('File Url')      "`
+    
+    DirId        int64     `json:"dirId"            xorm:"'dir_id'         bigint        comment('Dir ID')        "`
+    
+    FileUrl      string    `json:"fileUrl"          xorm:"'file_url'       varchar(50)   comment('File Url')      "`
+    FileSize     int64     `json:"fileSize"         xorm:"'file_size'      bigint        comment('File Size')      "`
+    
+    FileAuthor   string    `json:"fileAuthor"       xorm:"'file_author'    varchar(50)   comment('File Url')      "`
+    FileDesc     string    `json:"fileDesc"         xorm:"'file_desc'      varchar(50)   comment('File Desc')      "`
+
+    UploadedAt   time.Time `json:"uploadedAt"       xorm:"'uploaded_at'    "`
+    UploaderId   int64     `json:"uploaderId"       xorm:"'uploader_id'    "`
+    UploaderName string    `json:"uploaderName"     xorm:"'uploader_name'  "`
+}
+
+func (t *AttachInfo) TableName() string {
+    return "doc_file"
+}

+ 13 - 0
viewmodels/doc_cat_info.go

@@ -0,0 +1,13 @@
+package viewmodels
+
+type DocCatInfo struct {
+    OcId          int64     `json:"ocId"            xorm:"'oc_id'           bigint     pk comment('OC ID')          "`
+    DocCatId      int64     `json:"docCatId"        xorm:"'doc_cat_id'      bigint     pk comment('DOC CAT ID')     "`
+    DocCatTitle   string    `json:"docCatTitle"     xorm:"'doc_cat_title'   varchar(127)  comment('群组类型名称')     "`
+    DocCatDesc    string    `json:"docCatDesc"      xorm:"'doc_cat_desc'    varchar(127)  comment('描述')            "`
+    IsFixed       int64     `json:"isFixed"         xorm:"'is_fixed'        int           comment('是否可修改')       "`
+}
+
+func (t *DocCatInfo) TableName() string {
+    return "doc_cat"
+}

+ 21 - 0
viewmodels/doc_dir_info.go

@@ -0,0 +1,21 @@
+package viewmodels
+
+type DocDirInfo struct {
+    OcId        int64     `json:"ocId"         xorm:"'oc_id'       bigint     pk  comment('OC ID')    "`
+    
+    DirId       int64     `json:"dirId"        xorm:"'dir_id'      bigint        pk  comment('主键ID')       "`
+    DirTitle    string    `json:"dirTitle"     xorm:"'dir_title'   varchar(50)       comment('群组类型名称')  "`
+    DirDesc     string    `json:"dirDesc"      xorm:"'dir_desc'    varchar(50)       comment('描述')         "`
+    
+    RootId      int64     `json:"rootId"       xorm:"'root_id'     bigint not null   comment('Order')      " `
+    ParentId    int64     `json:"parentId"     xorm:"'parent_id'   bigint not null   comment('父群组ID')    " `
+    NodeLeft    int64     `json:"nodeLeft"     xorm:"'node_left'   bigint not null   comment('群组LEFT')    " `
+    NodeRight   int64     `json:"nodeRight"    xorm:"'node_right'  bigint not null   comment('群组RIGHT')   " `
+    NodeLevel   int64     `json:"nodeLevel"    xorm:"'node_level   bigint not null   comment('群组LEVEL')   " `
+    IsLeaf      int64     `json:"isLeaf"       xorm:"'is_leaf'     bigint not null   comment('LEAF群组')    " `
+    IsFixed     int64     `json:"isFixed"      xorm:"'is_fixed'    bigint not null   comment('群组STATUS')  " `
+}
+
+func (t *DocDirInfo) TableName() string {
+    return "doc_dir"
+}

+ 26 - 0
viewmodels/doc_file_info.go

@@ -0,0 +1,26 @@
+package viewmodels
+
+import "time"
+
+type DocFileInfo struct {
+    OcId            int64     `json:"ocId"             xorm:"'oc_id'            bigint     pk comment('OC Id')       " `
+    
+    FileId          int64     `json:"fileId"           xorm:"'file_id'          bigint     pk comment('主键ID')       " `
+    FileTitle       string    `json:"fileTitle"        xorm:"'file_title'       varchar(50)   comment('File Title')  "`
+    FileIcon        string    `json:"fileIcon"         xorm:"'file_icon'        varchar(50)   comment('File Url')    "`
+    FileExt         string    `json:"fileExt"          xorm:"'file_ext'         varchar(50)   comment('File Url')    "`
+    
+    DirId           int64     `json:"dirId"            xorm:"'dir_id'           bigint        comment('Dir ID')      "`
+    
+    FileUrl         string    `json:"fileUrl"          xorm:"'file_url'         varchar(50)   comment('File Url')    "`
+    FileSize        int64     `json:"fileSize"         xorm:"'file_size'        bigint        comment('File Size')   "`
+    
+    FileAuthor      string    `json:"fileAuthor"       xorm:"'file_author'      varchar(50)   comment('File Url')    "`
+    FileMimeType    string    `json:"fileMimeType"     xorm:"'file_mime_type'   varchar(50)   comment('File Url')    "`
+    
+    FileDesc        string    `json:"fileDesc"         xorm:"'file_desc'        varchar(50)   comment('File Desc')   "`
+    
+    UploadedAt      time.Time `json:"uploadedAt"       xorm:"'uploaded_at'    "`
+    UploaderId      int64     `json:"uploaderId"       xorm:"'uploader_id'    "`
+    UploaderName    string    `json:"uploaderName"     xorm:"'uploader_name'  "`
+}

+ 19 - 0
viewmodels/wf_activity_action_def_info.go

@@ -0,0 +1,19 @@
+package viewmodels
+
+type WfActivityActionDefInfo struct {
+    WfDefId             int64     `json:"wfDefId"               xorm:"'wf_def_id'               bigint    pk comment('主键ID')       " `
+    ActivityDefId       int64     `json:"activityDefId"         xorm:"'activity_def_id'         bigint    pk comment('主键ID')       " `
+    
+    ActionId            int64     `json:"actionId"              xorm:"'action_id'               varchar(127) comment('TASK类型名称')  " `
+    ActionCode          string    `json:"actionCode"            xorm:"'action_code'             varchar(127) comment('描述')         " `
+    ActionTitle         string    `json:"actionTitle"           xorm:"'action_title'            varchar(127) comment('描述')         " `
+    ActionDesc          string    `json:"actionDesc"            xorm:"'action_desc'             varchar(127) comment('描述')         " `
+    
+    FormCode            string    `json:"formCode"              xorm:"'form_code'               varchar(127) comment('描述')         " `
+    
+    TargetActivityDefId int64     `json:"targetActivityDefId"   xorm:"'target_activity_def_id'  bigint       comment('Target Activity Def id')  " `
+}
+
+func (m *WfActivityActionDefInfo) TableName() string {
+    return "wf_activity_action_def"
+}

+ 40 - 0
viewmodels/wf_activity_action_ins_info.go

@@ -0,0 +1,40 @@
+package viewmodels
+
+import "time"
+
+type WfActivityActionInsInfo struct {
+    OcId                int64     `json:"OcId"                  xorm:"'oc_id'                   bigint    pk comment('OC ID')       "`
+    
+    WfDefId             int64     `json:"wfDefId"               xorm:"'wf_def_id'               bigint    pk comment('WF DEF ID')   " `
+    WfInsId             int64     `json:"wfInsId"               xorm:"'wf_ins_id'               bigint    pk comment('WF INS ID')   " `
+    
+    ActivityDefId       int64     `json:"activityDefId"         xorm:"'activity_def_id'         bigint    pk comment('主键ID')       " `
+    ActivityInsId       int64     `json:"activityInsId"         xorm:"'activity_ins_id'         bigint    pk comment('主键ID')       " `
+    
+    ActionInsId         int64     `json:"actionInsId"           xorm:"'action_ins_id'           bigint       comment('Action Ins Id')  " `
+    
+    ActionId            int64     `json:"actionId"              xorm:"'action_id'               bigint       comment('Action Id')   " `
+    ActionCode          string    `json:"actionCode"            xorm:"'action_code'             varchar(127) comment('描述')         " `
+    ActionTitle         string    `json:"actionTitle"           xorm:"'action_title'            varchar(127) comment('描述')         " `
+    ActionDesc          string    `json:"actionDesc"            xorm:"'action_desc'             varchar(127) comment('描述')         " `
+    FormCode            string    `json:"formCode"              xorm:"'form_code'               varchar(127) comment('描述')         " `
+    
+    ActionTime          time.Time `json:"actionTime"            xorm:"'action_time'  " `
+    
+    ActionRemark        string    `json:"actionRemark"          xorm:"'action_remark'           varchar(127) comment('描述')         " `
+    ActionResult        string    `json:"actionResult"          xorm:"'action_result'           varchar(127) comment('描述')         " `
+    
+    TargetActivityInsId int64     `json:"targetActivityInsId"   xorm:"'target_activity_ins_id'  bigint       comment('Target Activity Ins id')" `
+    
+    GroupId             int64     `json:"groupId"               xorm:"'group_id'                bigint       comment('Group Id')     " `
+    GroupName           string    `json:"groupName"             xorm:"'group_name'              varchar(127) comment('Group Name')   " `
+    PositionId          int64     `json:"positionId"            xorm:"'position_id'             bigint       comment('Position Id')  " `
+    PositionName        string    `json:"positionName"          xorm:"'position_name'           varchar(127) comment('Position Name')" `
+    AccountId           int64     `json:"accountId"             xorm:"'account_id'              bigint       comment('Account Id')   " `
+    AccountName         string    `json:"accountName"           xorm:"'account_name'            varchar(127) comment('Account Name') " `
+
+}
+
+func (m *WfActivityActionInsInfo) TableName() string {
+    return "wf_activity_action_ins"
+}

+ 16 - 0
viewmodels/wf_activity_def_info.go

@@ -0,0 +1,16 @@
+package viewmodels
+
+type WfActivityDefInfo struct {
+    WfDefId             int64     `json:"wfDefId"           xorm:"'wf_def_id'           bigint    pk comment('主键ID')       " `
+    ActivityDefId       int64     `json:"activityDefId"     xorm:"'activity_def_id'     bigint    pk comment('主键ID')       " `
+    ActivityDefTitle    string    `json:"activityDefTitle"  xorm:"'activity_def_title'  varchar(127) comment('TASK类型名称')  " `
+    
+    ActivityCode        string    `json:"activityCode"      xorm:"'activity_code'       varchar(127) comment('TASK类型名称')  " `
+    ActivityDefDesc     string    `json:"activityDefDesc"   xorm:"'activity_def_desc'   varchar(127) comment('描述')         " `
+    
+    FormCode            string    `json:"formCode"          xorm:"'form_code'           varchar(127) comment('描述')         " `
+}
+
+func (m *WfActivityDefInfo) TableName() string {
+    return "wf_activity_def"
+}

+ 36 - 0
viewmodels/wf_activity_ins_info.go

@@ -0,0 +1,36 @@
+package viewmodels
+
+import "time"
+
+type WfActivityInsInfo struct {
+    OcId                int64     `json:"OcId"              xorm:"'oc_id'               bigint    pk comment('OC ID')       "`
+    
+    WfDefId             int64     `json:"wfDefId"           xorm:"'wf_def_id'           bigint    pk comment('主键ID')       " `
+    WfInsId             int64     `json:"wfInsId"           xorm:"'wf_ins_id'           bigint    pk comment('WF INS ID')   " `
+    
+    ActivityDefId       int64     `json:"activityDefId"     xorm:"'activity_def_id'     bigint    pk comment('主键ID')       " `
+    ActivityInsId       int64     `json:"activityInsId"     xorm:"'activity_ins_id'     bigint    pk comment('主键ID')       " `
+    ActivityInsTitle    string    `json:"activityInsTitle"  xorm:"'activity_ins_title'  varchar(127) comment('Activity Ins Title')"`
+    ActivityCode        string    `json:"activityCode"      xorm:"'activity_code'       varchar(127) comment('Activity Code')"`
+    
+    GroupId             int64     `json:"groupId"           xorm:"'group_id'            bigint       comment('Group Id')     " `
+    GroupName           string    `json:"groupName"         xorm:"'group_name'          varchar(127) comment('Group Name')   " `
+    PositionId          int64     `json:"positionId"        xorm:"'position_id'         bigint       comment('Position Id')  " `
+    PositionName        string    `json:"positionName"      xorm:"'position_name'       varchar(127) comment('Position Name')" `
+    AccountId           int64     `json:"accountId"         xorm:"'account_id'          bigint       comment('Account Id')   " `
+    AccountName         string    `json:"accountName"       xorm:"'account_name'        varchar(127) comment('Account Name') " `
+    
+    FormCode            string    `json:"formCode"          xorm:"'form_code'           varchar(127) comment('描述')         " `
+    
+    ActivityInsFrom     int64     `json:"activityInsFrom"   xorm:"'activity_ins_from'   bigint    pk comment('主键ID')       " `
+    ActivityInsTo       int64     `json:"activityInsTo"     xorm:"'activity_ins_to'     bigint    pk comment('主键ID')       " `
+    
+    StartTime           time.Time `json:"startTime"         xorm:"'start_time'  " `
+    EndTime             time.Time `json:"endTime"           xorm:"'end_time'    " `
+    
+    Status              int64     `json:"status"            xorm:"'status'              bigint       comment('Account Id')   " `
+}
+
+func (m *WfActivityInsInfo) TableName() string {
+    return "wf_activity_ins"
+}

+ 11 - 0
viewmodels/wf_def_info.go

@@ -0,0 +1,11 @@
+package viewmodels
+
+type WfDefInfo struct {
+    WfDefId      int64     `json:"wfDefId"         xorm:"'wf_def_id'     bigint    pk comment('主键ID')       " `
+    WfDefTitle   string    `json:"wfDefTitle"      xorm:"'wf_def_title'  varchar(127) comment('TASK类型名称')  " `
+    WfDefDesc    string    `json:"wfDefDesc"       xorm:"'wf_def_desc'   varchar(127) comment('描述')         " `
+}
+
+func (m *WfDefInfo) TableName() string {
+    return "wf_def"
+}

+ 31 - 0
viewmodels/wf_ins_attach_info.go

@@ -0,0 +1,31 @@
+package viewmodels
+
+import "time"
+
+type WfInsAttachInfo struct {
+    OcId            int64     `json:"ocId"             xorm:"'oc_id'            bigint     pk comment('OC Id')       " `
+    WfInsId         int64     `json:"wfInsId"          xorm:"'wf_ins_id'        bigint     pk comment('主键ID')       " `
+    ActivityInsId   int64     `json:"activityInsId"    xorm:"'activity_ins_id'  bigint     pk comment('主键ID')       " `
+    ActivityCode    string    `json:"activityCode"     xorm:"'activity_code'    varchar(127)  comment('Activity Code')"`
+    
+    FileId          int64     `json:"fileId"           xorm:"'file_id'          bigint     pk comment('主键ID')       " `
+    FileTitle       string    `json:"fileTitle"        xorm:"'file_title'       varchar(50)   comment('File Title')  "`
+    FileIcon        string    `json:"fileIcon"         xorm:"'file_icon'        varchar(50)   comment('File Url')    "`
+    FileExt         string    `json:"fileExt"          xorm:"'file_ext'         varchar(50)   comment('File Url')    "`
+    
+    DirId           int64     `json:"dirId"            xorm:"'dir_id'           bigint        comment('Dir ID')      "`
+    
+    FileUrl         string    `json:"fileUrl"          xorm:"'file_url'         varchar(50)   comment('File Url')    "`
+    FileSize        int64     `json:"fileSize"         xorm:"'file_size'        bigint        comment('File Size')   "`
+    
+    FileAuthor      string    `json:"fileAuthor"       xorm:"'file_author'      varchar(50)   comment('File Url')    "`
+    FileDesc        string    `json:"fileDesc"         xorm:"'file_desc'        varchar(50)   comment('File Desc')   "`
+    
+    UploadedAt      time.Time `json:"uploadedAt"       xorm:"'uploaded_at'    "`
+    UploaderId      int64     `json:"uploaderId"       xorm:"'uploader_id'    "`
+    UploaderName    string    `json:"uploaderName"     xorm:"'uploader_name'  "`
+}
+
+func (m *WfInsAttachInfo) TableName() string {
+    return "wf_ins_attach"
+}

+ 30 - 0
viewmodels/wf_ins_info.go

@@ -0,0 +1,30 @@
+package viewmodels
+import "time"
+
+type WfInsInfo struct {
+    OcId                int64       `json:"ocId"                    xorm:"'oc_id'                   bigint    pk comment('OC Id')       " `
+    WfDefId             int64       `json:"wfDefId"                 xorm:"'wf_def_id'               bigint    pk comment('主键ID')       " `
+    WfInsId             int64       `json:"wfInsId"                 xorm:"'wf_ins_id'               bigint    pk comment('主键ID')       " `
+    WfInsTitle          string      `json:"wfInsTitle"              xorm:"'wf_ins_title'            varchar(127) comment('描述')         " `
+    BeginTime           time.Time   `json:"beginTime"               xorm:"'begin_time'              datetime     comment('描述')         " `
+    FinishTime          time.Time   `json:"finishTime"              xorm:"'finish_time'             datetime     comment('描述')         " `
+    Status              int64       `json:"status"                  xorm:"'status'                  bigint       comment('Status')      " `
+    CurGroupId          int64       `json:"curGroupId"              xorm:"'cur_group_id'            bigint       comment('CurGroupId')  " `
+    CurGroupName        string      `json:"curGroupName"            xorm:"'cur_group_name'          varchar(127) comment('描述')         " `
+    CurPositionId       int64       `json:"curPositionId"           xorm:"'cur_position_id'         bigint       comment('CurGroupId')  " `
+    CurPositionName     string      `json:"curPositionName"         xorm:"'cur_position_name'       varchar(127) comment('描述')         " `
+    CurAccountId        int64       `json:"curAccountId"            xorm:"'cur_account_id'          bigint       comment('CurGroupId')  " `
+    CurAccountName      string      `json:"curAccountName"          xorm:"'cur_account_name'        varchar(127) comment('描述')         " `
+    
+    CurActivityInsId     int64      `json:"curActivityInsId"        xorm:"'cur_activity_ins_id'     bigint       comment('CurGroupId')  " `
+    CurActivityBeginTime time.Time  `json:"curActivityBeginTime"    xorm:"'cur_activity_begin_name' varchar(127) comment('描述')         " `
+    
+    CurActivityCode     string      `json:"curActivityCode"         xorm:"'cur_activity_code'       varchar(127) comment('描述')         " `
+    CurActivityTitle    string      `json:"curActivityTitle"        xorm:"'cur_activity_title'      varchar(127) comment('描述')         " `
+    
+    CurFormCode         string      `json:"curFormCode"             xorm:"'cur_form_code'           varchar(127) comment('描述')         " `
+}
+
+func (m *WfInsInfo) TableName() string {
+    return "wf_ins"
+}