sys_user_department.api 4.8 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_user_department
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_user_departmentGet
    get /sys_user_department/:id (SysUserDepartmentGetRequest) returns (SysUserDepartmentGetResponse)
    @doc  "保存"
	@handler sys_user_departmentSave
    post /sys_user_department (SysUserDepartmentSaveRequest) returns (SysUserDepartmentSaveResponse)
    @doc  "删除"
	@handler sys_user_departmentDelete
    delete /sys_user_department/:id (SysUserDepartmentDeleteRequest) returns (SysUserDepartmentDeleteResponse)
    @doc  "更新"
	@handler sys_user_departmentUpdate
    put /sys_user_department/:id (SysUserDepartmentUpdateRequest) returns (SysUserDepartmentUpdateResponse)
    @doc  "搜索"
	@handler sys_user_departmentSearch
    post /sys_user_department/search (SysUserDepartmentSearchRequest) returns (SysUserDepartmentSearchResponse)
}

type (
    SysUserDepartmentGetRequest {
		Id int64 `path:"id"`
	}
    SysUserDepartmentGetResponse {
		SysUserDepartment SysUserDepartmentItem `json:"sys_user_department"`
    }

	SysUserDepartmentSaveRequest {
		SysUserDepartment SysUserDepartmentItem `json:"sys_user_department"`
    }
    SysUserDepartmentSaveResponse {}

	SysUserDepartmentDeleteRequest {
        Id int64 `path:"id"`
    }
    SysUserDepartmentDeleteResponse {}

	SysUserDepartmentUpdateRequest {
		Id int64 `path:"id"`
        SysUserDepartment SysUserDepartmentItem `json:"sys_user_department"`
    }
    SysUserDepartmentUpdateResponse {}

 	SysUserDepartmentSearchRequest {
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysUserDepartmentSearchResponse{
        List []SysUserDepartmentItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysUserDepartmentItem {
	
	}
)

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

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

//func NewDomainSysUserDepartment(item types.SysUserDepartmentItem) *domain.SysUserDepartment {
//	return &domain.SysUserDepartment{

//	}
//}
//
//func NewTypesSysUserDepartment(item *domain.SysUserDepartment) types.SysUserDepartmentItem {
//	return types.SysUserDepartmentItem{
//		Id:     item.Id,
//	}
//}

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

// Delete
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysUserDepartment
	//)
	//if dm, err = l.svcCtx.SysUserDepartmentRepository.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.SysUserDepartmentRepository.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.SysUserDepartment
	//	total int64
	//)
	//
	//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
	//	WithKV("", "")

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

// Update
	//var (
	//	conn = l.svcCtx.DefaultDBConn()
	//	dm   *domain.SysUserDepartment
	//)
	//if dm, err = l.svcCtx.SysUserDepartmentRepository.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.SysUserDepartmentRepository.UpdateWithVersion(l.ctx, conn, dm)
	//	return err
	//}, true); err != nil {
	//	return nil, xerr.NewErrMsg("更新失败")
	//}
	//resp = &types.SysUserDepartmentUpdateResponse{}
	//return