(ctx context.Context, key string)
| 9 | ) |
| 10 | |
| 11 | func (c *Client) GetConfigItem(ctx context.Context, key string) (string, error) { |
| 12 | result, err := c.Ent.ConfigItem.Query().Where(configitem.NameEQ(key)).First(ctx) |
| 13 | |
| 14 | switch { |
| 15 | case ent.IsNotFound(err): |
| 16 | return "", nil |
| 17 | case err != nil: |
| 18 | return "", fmt.Errorf("select config item: %w: %w", err, QueryFail) |
| 19 | default: |
| 20 | return result.Value, nil |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | func (c *Client) SetConfigItem(ctx context.Context, key string, value string) error { |
| 25 | err := c.Ent.ConfigItem. |