sys_user_company.api 4.6 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_user_company
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_user_companyGet
    get /sys_user_company/:id (SysUserCompanyGetRequest) returns (SysUserCompanyGetResponse)
    @doc  "保存"
	@handler sys_user_companySave
    post /sys_user_company (SysUserCompanySaveRequest) returns (SysUserCompanySaveResponse)
    @doc  "删除"
	@handler sys_user_companyDelete
    delete /sys_user_company/:id (SysUserCompanyDeleteRequest) returns (SysUserCompanyDeleteResponse)
    @doc  "更新"
	@handler sys_user_companyUpdate
    put /sys_user_company/:id (SysUserCompanyUpdateRequest) returns (SysUserCompanyUpdateResponse)
    @doc  "搜索"
	@handler sys_user_companySearch
    post /sys_user_company/search (SysUserCompanySearchRequest) returns (SysUserCompanySearchResponse)
}

type (
    SysUserCompanyGetRequest {
		Id int64 `path:"id"`
	}
    SysUserCompanyGetResponse struct{
		SysUserCompany SysUserCompanyItem `json:"sys_user_company"`
    }

	SysUserCompanySaveRequest struct{
		SysUserCompany SysUserCompanyItem `json:"sys_user_company"`
    }
    SysUserCompanySaveResponse struct{}

	SysUserCompanyDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysUserCompanyDeleteResponse struct{}

	SysUserCompanyUpdateRequest struct{
		Id int64 `path:"id"`
        SysUserCompany SysUserCompanyItem `json:"sys_user_company"`
    }
    SysUserCompanyUpdateResponse struct{}

 	SysUserCompanySearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysUserCompanySearchResponse{
        List []SysUserCompanyItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysUserCompanyItem struct{
	
	}
)

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

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

//func NewDomainSysUserCompany(item types.SysUserCompanyItem) *domain.SysUserCompany {
//	return &domain.SysUserCompany{

//	}
//}
//
//func NewTypesSysUserCompany(item *domain.SysUserCompany) types.SysUserCompanyItem {
//	return types.SysUserCompanyItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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