You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: session.go
    path of file: ./repos/next-terminal/server/service
    
    the code of the file until where you have to start completion: package service

import (
	"context"
	"encoding/base64"
	"errors"
	"next-terminal/server/common/nt"
	"os"
	"path"
	"strconv"
	"sync"

	"next-terminal/server/common"
	"next-terminal/server/common/guacamole"
	"next-terminal/server/config"
	"next-terminal/server/env"
	"next-terminal/server/global/session"
	"next-terminal/server/log"
	"next-terminal/server/
    
func (service sessionService) DisDBSess(sessionId string, code int, reason string) {
	_ = env.GetDB().Transaction(func(tx *gorm.DB) error {
		c := service.Context(tx)
		s, err := repository.SessionRepository.FindById(c, sessionId)
		if err != nil {
			return err
		}

		if s.Status == nt.Disconnected {
			return nil
		}

		if s.Status == nt.Connecting {
			// 会话还未建立成功，无需保留数据
			if err := repository.SessionRepository.DeleteById(c, sessionId); err != nil {
				return err
			}
			return nil
		}

		ss := model.Session{}
		ss.ID = sessionId
		ss.Status = nt.Disconnected
		ss.DisconnectedTime = common.NowJsonTime()
		ss.Code = code
		ss.Message = reason
		ss.Password = "-"
		ss.PrivateKey = "-"
		ss.Passphrase = "-"

		if err := repository.SessionRepository.UpdateById(c, &ss, sessionId); err != nil {
			return err
		}

		return nil
	})
}