oilsupplierSession.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package supplier
  2. import (
  3. . "dashoo.cn/backend/api/mydb"
  4. "github.com/go-xorm/xorm"
  5. "strconv"
  6. )
  7. type OilSupplierSession struct {
  8. MySessionBase
  9. }
  10. func GetOilSupplierSession(session *xorm.Session) *OilSupplierSession {
  11. s := new(OilSupplierSession)
  12. s.Session = session
  13. return s
  14. }
  15. func (s *OilSupplierSession) CanUpdateSupplier(oilSupplierCertTableName string, supplierId int) (bool){
  16. sql := "select count(*) from " + oilSupplierCertTableName + " where SupplierId='" + strconv.Itoa(supplierId) + "' and status > 0"
  17. resultsSlice, _ := s.Session.Query(sql)
  18. var total int64
  19. if len(resultsSlice) > 0 {
  20. results := resultsSlice[0]
  21. for _, value := range results {
  22. total, _ = strconv.ParseInt(string(value), 10, 64)
  23. break
  24. }
  25. }
  26. return total <= 0
  27. }
  28. func (s *OilSupplierSession) GetUpdateCols(oilSupplierCertTableName string, supplierTypeCode string, supplierId int) ([]string){
  29. canEdit := s.CanUpdateSupplier(oilSupplierCertTableName, supplierId)
  30. cols := []string{
  31. "SupplierName",
  32. "OilCertificateNo",
  33. "Grade",
  34. "MgrUnit",
  35. "OperType",
  36. "Country",
  37. "MaunAgent",
  38. "ConstructTeam",
  39. "CommercialNo",
  40. "OrganCode",
  41. "CountryTaxNo",
  42. "LocalTaxNo",
  43. "Address",
  44. "Province",
  45. "City",
  46. "Street",
  47. "HouseNo",
  48. "ZipCode",
  49. "QualitySystemCert",
  50. "ProductQualityCert",
  51. "MaunLicense",
  52. "QualifCert",
  53. "QualifCertLevel",
  54. "SafetyLicense",
  55. "TechServiceLic",
  56. "TJInNotify",
  57. "SpecIndustryCert",
  58. "LegalPerson",
  59. "CategoryCode",
  60. "CategoryName",
  61. "RegCapital",
  62. "Currency",
  63. "ContactName",
  64. "CompanyType",
  65. "SetupTime",
  66. "DepositBank",
  67. "BankAccount",
  68. "EMail",
  69. "BankCreditRating",
  70. "Mobile",
  71. "Telphone",
  72. "Fax",
  73. "CompanyTel",
  74. "QQ",
  75. "CompanyUrl",
  76. "SpecSupplier",
  77. "SpecTypeCode",
  78. "SpecTypeName",
  79. /*"WorkerTotal",
  80. "ContractNum ",
  81. "UniversityNum",
  82. "TechnicalNum",
  83. "AboveProfNum",
  84. "MiddleProfNum",
  85. "NationalRegNum",
  86. "NationalCertTotal",
  87. "DesignerTotal",
  88. "SkillerTotal",*/
  89. "Remark",
  90. "IsDelete",
  91. "CreateOn",
  92. "CreateUserId",
  93. "CreateBy",
  94. "ModifiedOn",
  95. "ModifiedUserId",
  96. "ModifiedBy",
  97. "LinkAddress",
  98. "LinkProvince",
  99. "LinkCity",
  100. "LinkStreet",
  101. "LinkHouseNo",
  102. "LinkZipCode",
  103. "HseTraining",
  104. "CredentialFlag",
  105. "SupplierCertificate",
  106. "PACNumber",
  107. }
  108. if !canEdit {
  109. cols = []string{
  110. "OilCertificateNo",
  111. "Grade",
  112. "MgrUnit",
  113. "OperType",
  114. "Country",
  115. "MaunAgent",
  116. "ConstructTeam",
  117. "CommercialNo",
  118. "OrganCode",
  119. "QualitySystemCert",
  120. "ProductQualityCert",
  121. "MaunLicense",
  122. "QualifCert",
  123. "QualifCertLevel",
  124. "SafetyLicense",
  125. "TechServiceLic",
  126. "TJInNotify",
  127. "SpecIndustryCert",
  128. "LegalPerson",
  129. "CategoryCode",
  130. "CategoryName",
  131. "RegCapital",
  132. "Currency",
  133. "ContactName",
  134. "WorkerTotal",
  135. "ContractNum ",
  136. "UniversityNum",
  137. "TechnicalNum",
  138. "AboveProfNum",
  139. "MiddleProfNum",
  140. "NationalRegNum",
  141. "NationalCertTotal",
  142. "DesignerTotal",
  143. "SkillerTotal",
  144. "Remark",
  145. }
  146. }
  147. return cols
  148. }