sys_role.api 4.1 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_role
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_roleGet
    get /sys_role/:id (SysRoleGetRequest) returns (SysRoleGetResponse)
    @doc  "保存"
	@handler sys_roleSave
    post /sys_role (SysRoleSaveRequest) returns (SysRoleSaveResponse)
    @doc  "删除"
	@handler sys_roleDelete
    delete /sys_role/:id (SysRoleDeleteRequest) returns (SysRoleDeleteResponse)
    @doc  "更新"
	@handler sys_roleUpdate
    put /sys_role/:id (SysRoleUpdateRequest) returns (SysRoleUpdateResponse)
    @doc  "搜索"
	@handler sys_roleSearch
    post /sys_role/search (SysRoleSearchRequest) returns (SysRoleSearchResponse)
}

type (
    SysRoleGetRequest {
		Id int64 `path:"id"`
	}
    SysRoleGetResponse struct{
		SysRole SysRoleItem `json:"sys_role"`
    }

	SysRoleSaveRequest struct{
		SysRole SysRoleItem `json:"sys_role"`
    }
    SysRoleSaveResponse struct{}

	SysRoleDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysRoleDeleteResponse struct{}

	SysRoleUpdateRequest struct{
		Id int64 `path:"id"`
        SysRole SysRoleItem `json:"sys_role"`
    }
    SysRoleUpdateResponse struct{}

 	SysRoleSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysRoleSearchResponse{
        List []SysRoleItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysRoleItem struct{
	
	}
)

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

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

//func NewDomainSysRole(item types.SysRoleItem) *domain.SysRole {
//	return &domain.SysRole{

//	}
//}
//
//func NewTypesSysRole(item *domain.SysRole) types.SysRoleItem {
//	return types.SysRoleItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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