sys_user.api 4.1 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_user
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_userGet
    get /sys_user/:id (SysUserGetRequest) returns (SysUserGetResponse)
    @doc  "保存"
	@handler sys_userSave
    post /sys_user (SysUserSaveRequest) returns (SysUserSaveResponse)
    @doc  "删除"
	@handler sys_userDelete
    delete /sys_user/:id (SysUserDeleteRequest) returns (SysUserDeleteResponse)
    @doc  "更新"
	@handler sys_userUpdate
    put /sys_user/:id (SysUserUpdateRequest) returns (SysUserUpdateResponse)
    @doc  "搜索"
	@handler sys_userSearch
    post /sys_user/search (SysUserSearchRequest) returns (SysUserSearchResponse)
}

type (
    SysUserGetRequest {
		Id int64 `path:"id"`
	}
    SysUserGetResponse struct{
		SysUser SysUserItem `json:"sys_user"`
    }

	SysUserSaveRequest struct{
		SysUser SysUserItem `json:"sys_user"`
    }
    SysUserSaveResponse struct{}

	SysUserDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysUserDeleteResponse struct{}

	SysUserUpdateRequest struct{
		Id int64 `path:"id"`
        SysUser SysUserItem `json:"sys_user"`
    }
    SysUserUpdateResponse struct{}

 	SysUserSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysUserSearchResponse{
        List []SysUserItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysUserItem struct{
	
	}
)

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

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

//func NewDomainSysUser(item types.SysUserItem) *domain.SysUser {
//	return &domain.SysUser{

//	}
//}
//
//func NewTypesSysUser(item *domain.SysUser) types.SysUserItem {
//	return types.SysUserItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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