sys_user_role.api 4.4 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_user_role
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_user_roleGet
    get /sys_user_role/:id (SysUserRoleGetRequest) returns (SysUserRoleGetResponse)
    @doc  "保存"
	@handler sys_user_roleSave
    post /sys_user_role (SysUserRoleSaveRequest) returns (SysUserRoleSaveResponse)
    @doc  "删除"
	@handler sys_user_roleDelete
    delete /sys_user_role/:id (SysUserRoleDeleteRequest) returns (SysUserRoleDeleteResponse)
    @doc  "更新"
	@handler sys_user_roleUpdate
    put /sys_user_role/:id (SysUserRoleUpdateRequest) returns (SysUserRoleUpdateResponse)
    @doc  "搜索"
	@handler sys_user_roleSearch
    post /sys_user_role/search (SysUserRoleSearchRequest) returns (SysUserRoleSearchResponse)
}

type (
    SysUserRoleGetRequest {
		Id int64 `path:"id"`
	}
    SysUserRoleGetResponse struct{
		SysUserRole SysUserRoleItem `json:"sys_user_role"`
    }

	SysUserRoleSaveRequest struct{
		SysUserRole SysUserRoleItem `json:"sys_user_role"`
    }
    SysUserRoleSaveResponse struct{}

	SysUserRoleDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysUserRoleDeleteResponse struct{}

	SysUserRoleUpdateRequest struct{
		Id int64 `path:"id"`
        SysUserRole SysUserRoleItem `json:"sys_user_role"`
    }
    SysUserRoleUpdateResponse struct{}

 	SysUserRoleSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysUserRoleSearchResponse{
        List []SysUserRoleItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysUserRoleItem struct{
	
	}
)

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

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

//func NewDomainSysUserRole(item types.SysUserRoleItem) *domain.SysUserRole {
//	return &domain.SysUserRole{

//	}
//}
//
//func NewTypesSysUserRole(item *domain.SysUserRole) types.SysUserRoleItem {
//	return types.SysUserRoleItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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