sys_group.api 4.2 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_group
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_groupGet
    get /sys_group/:id (SysGroupGetRequest) returns (SysGroupGetResponse)
    @doc  "保存"
	@handler sys_groupSave
    post /sys_group (SysGroupSaveRequest) returns (SysGroupSaveResponse)
    @doc  "删除"
	@handler sys_groupDelete
    delete /sys_group/:id (SysGroupDeleteRequest) returns (SysGroupDeleteResponse)
    @doc  "更新"
	@handler sys_groupUpdate
    put /sys_group/:id (SysGroupUpdateRequest) returns (SysGroupUpdateResponse)
    @doc  "搜索"
	@handler sys_groupSearch
    post /sys_group/search (SysGroupSearchRequest) returns (SysGroupSearchResponse)
}

type (
    SysGroupGetRequest {
		Id int64 `path:"id"`
	}
    SysGroupGetResponse struct{
		SysGroup SysGroupItem `json:"sys_group"`
    }

	SysGroupSaveRequest struct{
		SysGroup SysGroupItem `json:"sys_group"`
    }
    SysGroupSaveResponse struct{}

	SysGroupDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysGroupDeleteResponse struct{}

	SysGroupUpdateRequest struct{
		Id int64 `path:"id"`
        SysGroup SysGroupItem `json:"sys_group"`
    }
    SysGroupUpdateResponse struct{}

 	SysGroupSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysGroupSearchResponse{
        List []SysGroupItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysGroupItem struct{
	
	}
)

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

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

//func NewDomainSysGroup(item types.SysGroupItem) *domain.SysGroup {
//	return &domain.SysGroup{

//	}
//}
//
//func NewTypesSysGroup(item *domain.SysGroup) types.SysGroupItem {
//	return types.SysGroupItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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