sys_company.api 4.3 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_company
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_companyGet
    get /sys_company/:id (SysCompanyGetRequest) returns (SysCompanyGetResponse)
    @doc  "保存"
	@handler sys_companySave
    post /sys_company (SysCompanySaveRequest) returns (SysCompanySaveResponse)
    @doc  "删除"
	@handler sys_companyDelete
    delete /sys_company/:id (SysCompanyDeleteRequest) returns (SysCompanyDeleteResponse)
    @doc  "更新"
	@handler sys_companyUpdate
    put /sys_company/:id (SysCompanyUpdateRequest) returns (SysCompanyUpdateResponse)
    @doc  "搜索"
	@handler sys_companySearch
    post /sys_company/search (SysCompanySearchRequest) returns (SysCompanySearchResponse)
}

type (
    SysCompanyGetRequest {
		Id int64 `path:"id"`
	}
    SysCompanyGetResponse struct{
		SysCompany SysCompanyItem `json:"sys_company"`
    }

	SysCompanySaveRequest struct{
		SysCompany SysCompanyItem `json:"sys_company"`
    }
    SysCompanySaveResponse struct{}

	SysCompanyDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysCompanyDeleteResponse struct{}

	SysCompanyUpdateRequest struct{
		Id int64 `path:"id"`
        SysCompany SysCompanyItem `json:"sys_company"`
    }
    SysCompanyUpdateResponse struct{}

 	SysCompanySearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysCompanySearchResponse{
        List []SysCompanyItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysCompanyItem struct{
	
	}
)

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

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

//func NewDomainSysCompany(item types.SysCompanyItem) *domain.SysCompany {
//	return &domain.SysCompany{

//	}
//}
//
//func NewTypesSysCompany(item *domain.SysCompany) types.SysCompanyItem {
//	return types.SysCompanyItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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