46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
|  | package admin_feature | ||
|  | 
 | ||
|  | import ( | ||
|  | 	"context" | ||
|  | 	"tyc-server/app/main/api/internal/svc" | ||
|  | 	"tyc-server/app/main/api/internal/types" | ||
|  | 	"tyc-server/common/xerr" | ||
|  | 
 | ||
|  | 	"github.com/pkg/errors" | ||
|  | 	"github.com/zeromicro/go-zero/core/logx" | ||
|  | ) | ||
|  | 
 | ||
|  | type AdminGetFeatureDetailLogic struct { | ||
|  | 	logx.Logger | ||
|  | 	ctx    context.Context | ||
|  | 	svcCtx *svc.ServiceContext | ||
|  | } | ||
|  | 
 | ||
|  | func NewAdminGetFeatureDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminGetFeatureDetailLogic { | ||
|  | 	return &AdminGetFeatureDetailLogic{ | ||
|  | 		Logger: logx.WithContext(ctx), | ||
|  | 		ctx:    ctx, | ||
|  | 		svcCtx: svcCtx, | ||
|  | 	} | ||
|  | } | ||
|  | 
 | ||
|  | func (l *AdminGetFeatureDetailLogic) AdminGetFeatureDetail(req *types.AdminGetFeatureDetailReq) (resp *types.AdminGetFeatureDetailResp, err error) { | ||
|  | 	// 1. 查询记录 | ||
|  | 	record, err := l.svcCtx.FeatureModel.FindOne(l.ctx, req.Id) | ||
|  | 	if err != nil { | ||
|  | 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), | ||
|  | 			"查找功能失败, err: %v, id: %d", err, req.Id) | ||
|  | 	} | ||
|  | 
 | ||
|  | 	// 2. 构建响应 | ||
|  | 	resp = &types.AdminGetFeatureDetailResp{ | ||
|  | 		Id:         record.Id, | ||
|  | 		ApiId:      record.ApiId, | ||
|  | 		Name:       record.Name, | ||
|  | 		CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"), | ||
|  | 		UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"), | ||
|  | 	} | ||
|  | 
 | ||
|  | 	return resp, nil | ||
|  | } |