32 lines
		
	
	
		
			548 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			548 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package budget
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"strconv"
 | |
| 
 | |
| 	db "management/internal/db/sqlc"
 | |
| 	"management/internal/global"
 | |
| )
 | |
| 
 | |
| func AllBudgets(ctx context.Context, projectId int64) []*global.DataDict {
 | |
| 	pp, err := db.Engine.ListBudgets(ctx, projectId)
 | |
| 	if err != nil || len(pp) == 0 {
 | |
| 		return nil
 | |
| 	}
 | |
| 
 | |
| 	var res []*global.DataDict
 | |
| 	res = append(res, &global.DataDict{
 | |
| 		Name:  "请选择",
 | |
| 		Value: "0",
 | |
| 	})
 | |
| 	for _, v := range pp {
 | |
| 		item := global.DataDict{
 | |
| 			Name:  v.Name,
 | |
| 			Value: strconv.Itoa(int(v.ID)),
 | |
| 		}
 | |
| 		res = append(res, &item)
 | |
| 	}
 | |
| 
 | |
| 	return res
 | |
| }
 |