浏览代码

岗位管理

yxh 4 年之前
父节点
当前提交
dd73e863d2

+ 1 - 1
api/v1/system/sys_dept.go

@@ -54,7 +54,7 @@ type DeptEditRes struct {
 
 type DeptDeleteReq struct {
 	g.Meta `path:"/dept/delete" tags:"部门管理" method:"delete" summary:"删除部门"`
-	Id     int `p:"id" v:"required#id不能为空"`
+	Id     int64 `p:"id" v:"required#id不能为空"`
 }
 
 type DeptDeleteRes struct {

+ 28 - 0
api/v1/system/sys_post.go

@@ -0,0 +1,28 @@
+/*
+* @desc:岗位相关参数
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/4/7 23:09
+ */
+
+package system
+
+import (
+	"github.com/gogf/gf/v2/frame/g"
+	commonApi "github.com/tiger1103/gfast/v3/api/v1/common"
+	"github.com/tiger1103/gfast/v3/internal/app/system/model/entity"
+)
+
+type PostSearchReq struct {
+	g.Meta   `path:"/post/list" tags:"岗位管理" method:"get" summary:"岗位列表"`
+	PostCode string `p:"postCode"` //岗位编码
+	PostName string `p:"postName"` //岗位名称
+	Status   string `p:"status"`   //状态
+	commonApi.PageReq
+}
+
+type PostSearchRes struct {
+	g.Meta `mime:"application/json"`
+	commonApi.ListRes
+	PostList []*entity.SysPost `json:"postList"`
+}

+ 1 - 1
internal/app/system/controller/sys_dept.go

@@ -39,6 +39,6 @@ func (c *sysDeptController) Edit(ctx context.Context, req *system.DeptEditReq) (
 }
 
 func (c *sysDeptController) Delete(ctx context.Context, req *system.DeptDeleteReq) (res *system.DeptDeleteRes, err error) {
-
+	err = service.Dept().Delete(ctx, req.Id)
 	return
 }

+ 25 - 0
internal/app/system/controller/sys_post.go

@@ -0,0 +1,25 @@
+/*
+* @desc:岗位管理
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/4/7 23:12
+ */
+
+package controller
+
+import (
+	"context"
+	"github.com/tiger1103/gfast/v3/api/v1/system"
+	"github.com/tiger1103/gfast/v3/internal/app/system/service"
+)
+
+var Post = postController{}
+
+type postController struct {
+	BaseController
+}
+
+func (c *postController) List(ctx context.Context, req *system.PostSearchReq) (res *system.PostSearchRes, err error) {
+	res, err = service.Post().List(ctx, req)
+	return
+}

+ 24 - 0
internal/app/system/model/entity/sys_post.go

@@ -0,0 +1,24 @@
+// =================================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21
+// =================================================================================
+
+package entity
+
+import (
+	"github.com/gogf/gf/v2/os/gtime"
+)
+
+// SysPost is the golang structure for table sys_post.
+type SysPost struct {
+	PostId    uint64      `json:"postId"    description:"岗位ID"`
+	PostCode  string      `json:"postCode"  description:"岗位编码"`
+	PostName  string      `json:"postName"  description:"岗位名称"`
+	PostSort  int         `json:"postSort"  description:"显示顺序"`
+	Status    uint        `json:"status"    description:"状态(0正常 1停用)"`
+	Remark    string      `json:"remark"    description:"备注"`
+	CreatedBy uint64      `json:"createdBy" description:"创建人"`
+	UpdatedBy uint64      `json:"updatedBy" description:"修改人"`
+	CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
+	UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
+	DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"`
+}

+ 92 - 0
internal/app/system/service/internal/dao/internal/sys_post.go

@@ -0,0 +1,92 @@
+// ==========================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/database/gdb"
+	"github.com/gogf/gf/v2/frame/g"
+)
+
+// SysPostDao is the data access object for table sys_post.
+type SysPostDao struct {
+	table   string         // table is the underlying table name of the DAO.
+	group   string         // group is the database configuration group name of current DAO.
+	columns SysPostColumns // columns contains all the column names of Table for convenient usage.
+}
+
+// SysPostColumns defines and stores column names for table sys_post.
+type SysPostColumns struct {
+	PostId    string // 岗位ID
+	PostCode  string // 岗位编码
+	PostName  string // 岗位名称
+	PostSort  string // 显示顺序
+	Status    string // 状态(0正常 1停用)
+	Remark    string // 备注
+	CreatedBy string // 创建人
+	UpdatedBy string // 修改人
+	CreatedAt string // 创建时间
+	UpdatedAt string // 修改时间
+	DeletedAt string // 删除时间
+}
+
+//  sysPostColumns holds the columns for table sys_post.
+var sysPostColumns = SysPostColumns{
+	PostId:    "post_id",
+	PostCode:  "post_code",
+	PostName:  "post_name",
+	PostSort:  "post_sort",
+	Status:    "status",
+	Remark:    "remark",
+	CreatedBy: "created_by",
+	UpdatedBy: "updated_by",
+	CreatedAt: "created_at",
+	UpdatedAt: "updated_at",
+	DeletedAt: "deleted_at",
+}
+
+// NewSysPostDao creates and returns a new DAO object for table data access.
+func NewSysPostDao() *SysPostDao {
+	return &SysPostDao{
+		group:   "default",
+		table:   "sys_post",
+		columns: sysPostColumns,
+	}
+}
+
+// DB retrieves and returns the underlying raw database management object of current DAO.
+func (dao *SysPostDao) DB() gdb.DB {
+	return g.DB(dao.group)
+}
+
+// Table returns the table name of current dao.
+func (dao *SysPostDao) Table() string {
+	return dao.table
+}
+
+// Columns returns all column names of current dao.
+func (dao *SysPostDao) Columns() SysPostColumns {
+	return dao.columns
+}
+
+// Group returns the configuration group name of database of current dao.
+func (dao *SysPostDao) Group() string {
+	return dao.group
+}
+
+// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
+func (dao *SysPostDao) Ctx(ctx context.Context) *gdb.Model {
+	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
+}
+
+// Transaction wraps the transaction logic using function f.
+// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
+// It commits the transaction and returns nil if function f returns nil.
+//
+// Note that, you should not Commit or Rollback the transaction in function f
+// as it is automatically handled by this function.
+func (dao *SysPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
+	return dao.Ctx(ctx).Transaction(ctx, f)
+}

+ 24 - 0
internal/app/system/service/internal/dao/sys_post.go

@@ -0,0 +1,24 @@
+// =================================================================================
+// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
+// =================================================================================
+
+package dao
+
+import (
+	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/dao/internal"
+)
+
+// sysPostDao is the data access object for table sys_post.
+// You can define custom methods on it to extend its functionality as you wish.
+type sysPostDao struct {
+	*internal.SysPostDao
+}
+
+var (
+	// SysPost is globally public accessible object for table sys_post operations.
+	SysPost = sysPostDao{
+		internal.NewSysPostDao(),
+	}
+)
+
+// Fill with you ideas below.

+ 26 - 0
internal/app/system/service/internal/do/sys_post.go

@@ -0,0 +1,26 @@
+// =================================================================================
+// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21
+// =================================================================================
+
+package do
+
+import (
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gtime"
+)
+
+// SysPost is the golang structure of table sys_post for DAO operations like Where/Data.
+type SysPost struct {
+	g.Meta    `orm:"table:sys_post, do:true"`
+	PostId    interface{} // 岗位ID
+	PostCode  interface{} // 岗位编码
+	PostName  interface{} // 岗位名称
+	PostSort  interface{} // 显示顺序
+	Status    interface{} // 状态(0正常 1停用)
+	Remark    interface{} // 备注
+	CreatedBy interface{} // 创建人
+	UpdatedBy interface{} // 修改人
+	CreatedAt *gtime.Time // 创建时间
+	UpdatedAt *gtime.Time // 修改时间
+	DeletedAt *gtime.Time // 删除时间
+}

+ 1 - 0
internal/app/system/service/sys_dept.go

@@ -26,6 +26,7 @@ type IDept interface {
 	Add(ctx context.Context, req *system.DeptAddReq) (err error)
 	Edit(ctx context.Context, req *system.DeptEditReq) (err error)
 	GetFromCache(ctx context.Context) (list []*entity.SysDept, err error)
+	Delete(ctx context.Context, id int64) (err error)
 }
 
 var deptService = deptImpl{}

+ 61 - 0
internal/app/system/service/sys_post.go

@@ -0,0 +1,61 @@
+/*
+* @desc:岗位处理
+* @company:云南奇讯科技有限公司
+* @Author: yixiaohu
+* @Date:   2022/4/7 23:18
+ */
+
+package service
+
+import (
+	"context"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/tiger1103/gfast/v3/api/v1/system"
+	"github.com/tiger1103/gfast/v3/internal/app/system/consts"
+	"github.com/tiger1103/gfast/v3/internal/app/system/service/internal/dao"
+	"github.com/tiger1103/gfast/v3/library/liberr"
+)
+
+type IPost interface {
+	List(ctx context.Context, req *system.PostSearchReq) (res *system.PostSearchRes, err error)
+}
+
+type postImpl struct {
+}
+
+var postService = postImpl{}
+
+func Post() IPost {
+	return IPost(&postService)
+}
+
+// List 岗位列表
+func (s *postImpl) List(ctx context.Context, req *system.PostSearchReq) (res *system.PostSearchRes, err error) {
+	err = g.Try(func() {
+		m := dao.SysPost.Ctx(ctx)
+		if req != nil {
+			if req.PostCode != "" {
+				m = m.Where("post_code like ?", "%"+req.PostCode+"%")
+			}
+			if req.PostName != "" {
+				m = m.Where("post_name like ?", "%"+req.PostName+"%")
+			}
+			if req.Status != "" {
+				m = m.Where("status", gconv.Uint(req.Status))
+			}
+		}
+		res.Total, err = m.Count()
+		liberr.ErrIsNil(ctx, err, "获取岗位失败")
+		if req.PageNum == 0 {
+			req.PageNum = 1
+		}
+		if req.PageSize == 0 {
+			req.PageSize = consts.PageSize
+		}
+		res = new(system.PostSearchRes)
+		err = m.Page(req.PageNum, req.PageSize).Order("post_sort asc,post_id asc").Scan(&res.PostList)
+		liberr.ErrIsNil(ctx, err, "获取岗位失败")
+	})
+	return
+}

+ 1 - 1
manifest/config/config.yaml

@@ -76,7 +76,7 @@ gfcli:
   gen:
     dao:
       - link:            "mysql:root:123456@tcp(127.0.0.1:3306)/gfast-v3"
-        tables:          "sys_dept"
+        tables:          "sys_post"
         removePrefix:    "gf_"
         descriptionTag:  true
         noModelComment:  true