39 lines
		
	
	
		
			772 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			772 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package db
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"fmt"
 | |
| 	"time"
 | |
| 
 | |
| 	db "management/internal/db/sqlc"
 | |
| )
 | |
| 
 | |
| func initRole() (*db.SysRole, error) {
 | |
| 	arg := db.CreateSysRoleParams{
 | |
| 		Name:        "Company",
 | |
| 		DisplayName: "公司",
 | |
| 		Vip:         false,
 | |
| 		ParentID:    0,
 | |
| 		ParentPath:  ",0,",
 | |
| 		Status:      0,
 | |
| 		CreatedAt:   time.Now(),
 | |
| 		UpdatedAt:   time.Now(),
 | |
| 	}
 | |
| 	role, err := db.Engine.CreateSysRole(context.Background(), &arg)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 
 | |
| 	arg = db.CreateSysRoleParams{
 | |
| 		Name:        "SuperAdmin",
 | |
| 		DisplayName: "超级管理员",
 | |
| 		Vip:         true,
 | |
| 		ParentID:    role.ID,
 | |
| 		ParentPath:  fmt.Sprintf(",0,%d,", role.ID),
 | |
| 		Status:      0,
 | |
| 		CreatedAt:   time.Now(),
 | |
| 		UpdatedAt:   time.Now(),
 | |
| 	}
 | |
| 	return db.Engine.CreateSysRole(context.Background(), &arg)
 | |
| }
 |