package supplier import ( . "dashoo.cn/backend/api/mydb" "github.com/go-xorm/xorm" "strconv" ) type OilSupplierSession struct { MySessionBase } func GetOilSupplierSession(session *xorm.Session) *OilSupplierSession { s := new(OilSupplierSession) s.Session = session return s } func (s *OilSupplierSession) CanUpdateSupplier(oilSupplierCertTableName string, supplierId int) (bool){ sql := "select count(*) from " + oilSupplierCertTableName + " where SupplierId='" + strconv.Itoa(supplierId) + "' and status > 0" resultsSlice, _ := s.Session.Query(sql) var total int64 if len(resultsSlice) > 0 { results := resultsSlice[0] for _, value := range results { total, _ = strconv.ParseInt(string(value), 10, 64) break } } return total <= 0 } func (s *OilSupplierSession) GetUpdateCols(oilSupplierCertTableName string, supplierTypeCode string, supplierId int) ([]string){ canEdit := s.CanUpdateSupplier(oilSupplierCertTableName, supplierId) cols := []string{ "SupplierName", "OilCertificateNo", "Grade", "MgrUnit", "OperType", "Country", "MaunAgent", "ConstructTeam", "CommercialNo", "OrganCode", "CountryTaxNo", "LocalTaxNo", "Address", "Province", "City", "Street", "HouseNo", "ZipCode", "QualitySystemCert", "ProductQualityCert", "MaunLicense", "QualifCert", "QualifCertLevel", "SafetyLicense", "TechServiceLic", "TJInNotify", "SpecIndustryCert", "LegalPerson", "CategoryCode", "CategoryName", "RegCapital", "Currency", "ContactName", "CompanyType", "SetupTime", "DepositBank", "BankAccount", "EMail", "BankCreditRating", "Mobile", "Telphone", "Fax", "CompanyTel", "QQ", "CompanyUrl", "SpecSupplier", "SpecTypeCode", "SpecTypeName", "WorkerTotal", "ContractNum ", "UniversityNum", "TechnicalNum", "AboveProfNum", "MiddleProfNum", "NationalRegNum", "NationalCertTotal", "DesignerTotal", "SkillerTotal", "Remark", "IsDelete", "CreateOn", "CreateUserId", "CreateBy", "ModifiedOn", "ModifiedUserId", "ModifiedBy", "LinkAddress", "LinkProvince", "LinkCity", "LinkStreet", "LinkHouseNo", "LinkZipCode", "HseTraining", } if !canEdit { cols = []string{ "OilCertificateNo", "Grade", "MgrUnit", "OperType", "Country", "MaunAgent", "ConstructTeam", "CommercialNo", "OrganCode", "QualitySystemCert", "ProductQualityCert", "MaunLicense", "QualifCert", "QualifCertLevel", "SafetyLicense", "TechServiceLic", "TJInNotify", "SpecIndustryCert", "LegalPerson", "CategoryCode", "CategoryName", "RegCapital", "Currency", "ContactName", "WorkerTotal", "ContractNum ", "UniversityNum", "TechnicalNum", "AboveProfNum", "MiddleProfNum", "NationalRegNum", "NationalCertTotal", "DesignerTotal", "SkillerTotal", "Remark", } } return cols }