sys_log.api 4.1 KB

syntax = "v1"

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

@server(
    prefix: v1
    group: sys_log
    jwt: JwtAuth
)
service Core {
	@doc  "详情"
    @handler sys_logGet
    get /sys_log/:id (SysLogGetRequest) returns (SysLogGetResponse)
    @doc  "保存"
	@handler sys_logSave
    post /sys_log (SysLogSaveRequest) returns (SysLogSaveResponse)
    @doc  "删除"
	@handler sys_logDelete
    delete /sys_log/:id (SysLogDeleteRequest) returns (SysLogDeleteResponse)
    @doc  "更新"
	@handler sys_logUpdate
    put /sys_log/:id (SysLogUpdateRequest) returns (SysLogUpdateResponse)
    @doc  "搜索"
	@handler sys_logSearch
    post /sys_log/search (SysLogSearchRequest) returns (SysLogSearchResponse)
}

type (
    SysLogGetRequest {
		Id int64 `path:"id"`
	}
    SysLogGetResponse struct{
		SysLog SysLogItem `json:"sys_log"`
    }

	SysLogSaveRequest struct{
		SysLog SysLogItem `json:"sys_log"`
    }
    SysLogSaveResponse struct{}

	SysLogDeleteRequest struct{
        Id int64 `path:"id"`
    }
    SysLogDeleteResponse struct{}

	SysLogUpdateRequest struct{
		Id int64 `path:"id"`
        SysLog SysLogItem `json:"sys_log"`
    }
    SysLogUpdateResponse struct{}

 	SysLogSearchRequest struct{
         Page int  `json:"page"`
         Size int  `json:"size"`
    }
    SysLogSearchResponse{
        List []SysLogItem  `json:"list"`
        Total int64 `json:"total"`
    }
	SysLogItem struct{
	
	}
)

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

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

//func NewDomainSysLog(item types.SysLogItem) *domain.SysLog {
//	return &domain.SysLog{

//	}
//}
//
//func NewTypesSysLog(item *domain.SysLog) types.SysLogItem {
//	return types.SysLogItem{
//		Id:     item.Id,
//	}
//}

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

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

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

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