sys_employee.api 4.4 KB

syntax = "v1"

info(
    title: "xx实例"
    desc: "xx实例"
    author: "author"
    email: "email"
    version: "v1"
)

@server(
    prefix: v1
    group: sys_employee
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_employeeGet
    get /sys_employee/:id (SysEmployeeGetRequest) returns (SysEmployeeGetResponse)
    @doc  "保存"
	@handler sys_employeeSave
    post /sys_employee (SysEmployeeSaveRequest) returns (SysEmployeeSaveResponse)
    @doc  "删除"
	@handler sys_employeeDelete
    delete /sys_employee/:id (SysEmployeeDeleteRequest) returns (SysEmployeeDeleteResponse)
    @doc  "更新"
	@handler sys_employeeUpdate
    put /sys_employee/:id (SysEmployeeUpdateRequest) returns (SysEmployeeUpdateResponse)
    @doc  "搜索"
	@handler sys_employeeSearch
    post /sys_employee/search (SysEmployeeSearchRequest) returns (SysEmployeeSearchResponse)
}

type (
    SysEmployeeGetRequest {
		Id int64 `path:"id"`
	}
    SysEmployeeGetResponse struct{
		SysEmployee SysEmployeeItem `json:"sys_employee"`
    }

	SysEmployeeSaveRequest struct{
		SysEmployee SysEmployeeItem `json:"sys_employee"`
    }
    SysEmployeeSaveResponse struct{}

	SysEmployeeDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysEmployeeDeleteResponse struct{}

	SysEmployeeUpdateRequest struct{
		Id int64 `path:"id"`
        SysEmployee SysEmployeeItem `json:"sys_employee"`
    }
    SysEmployeeUpdateResponse struct{}

 	SysEmployeeSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysEmployeeSearchResponse{
        List []SysEmployeeItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysEmployeeItem struct{
	
	}
)

// logic CRUD
// Save
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysEmployee
	//)
	//// 唯一判断

	//dm = NewDomainSysEmployee(req.SysEmployee)
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	dm, err = l.svcCtx.SysEmployeeRepository.Insert(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("保存失败")
	//}
	////resp = &types.SysEmployeeSaveResponse{}
	//return

//func NewDomainSysEmployee(item types.SysEmployeeItem) *domain.SysEmployee {
//	return &domain.SysEmployee{

//	}
//}
//
//func NewTypesSysEmployee(item *domain.SysEmployee) types.SysEmployeeItem {
//	return types.SysEmployeeItem{
//		Id:     item.Id,
//	}
//}

// Get
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysEmployee
	//)
	//// 货号唯一
	//if dm, err = l.svcCtx.SysEmployeeRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//resp = &types.SysEmployeeGetResponse{
	//	SysEmployee: NewTypesSysEmployee(dm),
	//}
	//return

// Delete
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysEmployee
	//)
	//if dm, err = l.svcCtx.SysEmployeeRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	if dm, err = l.svcCtx.SysEmployeeRepository.Delete(l.ctx, conn, dm); err != nil {
	//		return err
	//	}
	//	return nil
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsgErr("移除失败", err)
	//}
	//return

// Search
	//var (
	//	conn  = l.svcCtx.DefaultDBConn()
	//	dms   []*domain.SysEmployee
	//	total int64
	//)
	//
	//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
	//	WithKV("", "")

	//total, dms, err = l.svcCtx.SysEmployeeRepository.Find(l.ctx, conn, queryOptions)
	//list := make([]types.SysEmployeeItem, 0)
	//for i := range dms {
	//	list = append(list, NewTypesSysEmployee(dms[i]))
	//}
	//resp = &types.SysEmployeeSearchResponse{
	//	List:  list,
	//	Total: total,
	//}
	//return

// Update
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysEmployee
	//)
	//if dm, err = l.svcCtx.SysEmployeeRepository.FindOne(l.ctx, conn, req.Id); err != nil {
	//	return nil, xerr.NewErrMsgErr("不存在", err)
	//}
	//// 不可编辑判断
	
	//// 赋值

	//// 更新
	//if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
	//	dm, err = l.svcCtx.SysEmployeeRepository.UpdateWithVersion(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("更新失败")
	//}
	//resp = &types.SysEmployeeUpdateResponse{}
	//return