article_security.api 4.7 KB

syntax = "v1"

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

@server(
    prefix: article_security/v1
    group: article_security
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler article_securityGet
    get /article_security/:id (ArticleSecurityGetRequest) returns (ArticleSecurityGetResponse)
    @doc  "保存"
	@handler article_securitySave
    post /article_security (ArticleSecuritySaveRequest) returns (ArticleSecuritySaveResponse)
    @doc  "删除"
	@handler article_securityDelete
    delete /article_security/:id (ArticleSecurityDeleteRequest) returns (ArticleSecurityDeleteResponse)
    @doc  "更新"
	@handler article_securityUpdate
    put /article_security/:id (ArticleSecurityUpdateRequest) returns (ArticleSecurityUpdateResponse)
    @doc  "搜索"
	@handler article_securitySearch
    post /article_security/search (ArticleSecuritySearchRequest) returns (ArticleSecuritySearchResponse)
}

type (
    ArticleSecurityGetRequest {
		Id int64 `path:"id"`
	}
    ArticleSecurityGetResponse struct{
		ArticleSecurity ArticleSecurityItem `json:"article_security"`
    }

	ArticleSecuritySaveRequest struct{
		ArticleSecurity ArticleSecurityItem `json:"article_security"`
    }
    ArticleSecuritySaveResponse struct{}

	ArticleSecurityDeleteRequest struct{
        Id int64 `path:"id"`
    }
    ArticleSecurityDeleteResponse struct{}

	ArticleSecurityUpdateRequest struct{
		Id int64 `path:"id"`
        ArticleSecurity ArticleSecurityItem `json:"article_security"`
    }
    ArticleSecurityUpdateResponse struct{}

 	ArticleSecuritySearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    ArticleSecuritySearchResponse{
        List []ArticleSecurityItem  `json:"list"`
        Total int64 `json:"total"`
    }
	ArticleSecurityItem struct{
	
	}
)

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

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

//func NewDomainArticleSecurity(item types.ArticleSecurityItem) *domain.ArticleSecurity {
//	return &domain.ArticleSecurity{

//	}
//}
//
//func NewTypesArticleSecurity(item *domain.ArticleSecurity) types.ArticleSecurityItem {
//	return types.ArticleSecurityItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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