config_data.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. package backend
  2. import (
  3. "context"
  4. "kpt-pasture/model"
  5. "net/http"
  6. xxerr "gitee.com/xuyiping_admin/pkg/xerr"
  7. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  8. )
  9. var DrugCategoryMap = map[pasturePb.DrugCategory_Kind]string{
  10. pasturePb.DrugCategory_Antibiotics: "抗生素类",
  11. pasturePb.DrugCategory_Antivirals: "抗病毒类",
  12. pasturePb.DrugCategory_Antifungals: "抗真菌类",
  13. pasturePb.DrugCategory_Antiparasitics: "抗寄生虫类",
  14. pasturePb.DrugCategory_Analgesics: "镇痛类",
  15. pasturePb.DrugCategory_Antipyretic: "退烧类",
  16. pasturePb.DrugCategory_Vitamin: "维生素类",
  17. pasturePb.DrugCategory_Brine: "盐水",
  18. pasturePb.DrugCategory_Glucose: "葡萄糖",
  19. pasturePb.DrugCategory_Hormone: "激素类",
  20. pasturePb.DrugCategory_Anti_Stress: "抗应激类",
  21. pasturePb.DrugCategory_Disinfect: "消毒类",
  22. pasturePb.DrugCategory_Chinese_Herbal: "中药合剂",
  23. pasturePb.DrugCategory_Tocolytic: "保胎类",
  24. }
  25. var UnitMap = map[pasturePb.Unit_Kind]string{
  26. pasturePb.Unit_Pieces: "个",
  27. pasturePb.Unit_Package: "包/袋",
  28. pasturePb.Unit_Bottle: "瓶",
  29. pasturePb.Unit_Box: "盒",
  30. pasturePb.Unit_Boxful: "箱",
  31. pasturePb.Unit_Branch: "支",
  32. pasturePb.Unit_Barrel: "桶",
  33. pasturePb.Unit_Pot: "罐",
  34. }
  35. var DrugUsageMap = map[pasturePb.DrugUsage_Kind]string{
  36. pasturePb.DrugUsage_Oral_Medications: "口服",
  37. pasturePb.DrugUsage_Injectable_Medications: "肌注",
  38. pasturePb.DrugUsage_Topical_Medications: "外用",
  39. pasturePb.DrugUsage_Drink_Medications: "饮水",
  40. }
  41. func (s *StoreEntry) BarnTypeEnumList() []*pasturePb.ConfigOptionsList {
  42. barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  43. barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
  44. Value: int32(pasturePb.PenType_Lactating_Calves),
  45. Label: "哺乳犊牛舍",
  46. Disabled: true,
  47. }, &pasturePb.ConfigOptionsList{
  48. Value: int32(pasturePb.PenType_Weaned_Calves),
  49. Label: "断奶犊牛舍",
  50. Disabled: true,
  51. }, &pasturePb.ConfigOptionsList{
  52. Value: int32(pasturePb.PenType_Youth),
  53. Label: "育成牛舍",
  54. Disabled: true,
  55. }, &pasturePb.ConfigOptionsList{
  56. Value: int32(pasturePb.PenType_Nurturing),
  57. Label: "育成牛舍",
  58. Disabled: true,
  59. }, &pasturePb.ConfigOptionsList{
  60. Value: int32(pasturePb.PenType_Lactation),
  61. Label: "泌乳牛舍",
  62. Disabled: true,
  63. }, &pasturePb.ConfigOptionsList{
  64. Value: int32(pasturePb.PenType_Peripartum),
  65. Label: "围产牛舍",
  66. Disabled: true,
  67. }, &pasturePb.ConfigOptionsList{
  68. Value: int32(pasturePb.PenType_Dry_Milking),
  69. Label: "干奶牛舍",
  70. Disabled: true,
  71. }, &pasturePb.ConfigOptionsList{
  72. Value: int32(pasturePb.PenType_Sick_Cow),
  73. Label: "病牛舍",
  74. Disabled: true,
  75. }, &pasturePb.ConfigOptionsList{
  76. Value: int32(pasturePb.PenType_Eliminate),
  77. Label: "淘汰牛舍",
  78. Disabled: true,
  79. })
  80. return barnTypeList
  81. }
  82. func (s *StoreEntry) BreedStatusEnumList() []*pasturePb.ConfigOptionsList {
  83. breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  84. breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
  85. Value: int32(pasturePb.BreedStatus_Unmarried),
  86. Label: "未配",
  87. Disabled: true,
  88. }, &pasturePb.ConfigOptionsList{
  89. Value: int32(pasturePb.BreedStatus_InCheck_Unpregnant),
  90. Label: "初检无胎",
  91. Disabled: true,
  92. }, &pasturePb.ConfigOptionsList{
  93. Value: int32(pasturePb.BreedStatus_InCheck_Pregnant),
  94. Label: "初检有胎",
  95. Disabled: true,
  96. }, &pasturePb.ConfigOptionsList{
  97. Value: int32(pasturePb.BreedStatus_Recheck_Unpregnant),
  98. Label: "复检无胎",
  99. Disabled: true,
  100. }, &pasturePb.ConfigOptionsList{
  101. Value: int32(pasturePb.BreedStatus_Recheck_Pregnant),
  102. Label: "复检有胎",
  103. Disabled: true,
  104. }, &pasturePb.ConfigOptionsList{
  105. Value: int32(pasturePb.BreedStatus_Pause_Pregnant),
  106. Label: "停配",
  107. Disabled: true,
  108. }, &pasturePb.ConfigOptionsList{
  109. Value: int32(pasturePb.BreedStatus_No_Pregnant),
  110. Label: "禁配",
  111. Disabled: true,
  112. })
  113. return breedStatusList
  114. }
  115. func (s *StoreEntry) CowKindEnumList() []*pasturePb.ConfigOptionsList {
  116. cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
  117. cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
  118. Value: int32(pasturePb.CowKind_HST),
  119. Label: "荷斯坦",
  120. Disabled: true,
  121. }, &pasturePb.ConfigOptionsList{
  122. Value: int32(pasturePb.CowKind_JSN),
  123. Label: "娟姗牛",
  124. Disabled: true,
  125. }, &pasturePb.ConfigOptionsList{
  126. Value: int32(pasturePb.CowKind_SHN),
  127. Label: "三河牛",
  128. Disabled: true,
  129. }, &pasturePb.ConfigOptionsList{
  130. Value: int32(pasturePb.CowKind_XJHN),
  131. Label: "新疆褐牛",
  132. Disabled: true,
  133. }, &pasturePb.ConfigOptionsList{
  134. Value: int32(pasturePb.CowKind_MN),
  135. Label: "牦牛",
  136. Disabled: true,
  137. }, &pasturePb.ConfigOptionsList{
  138. Value: int32(pasturePb.CowKind_XMTEN),
  139. Label: "西门塔尔牛",
  140. Disabled: true,
  141. })
  142. return cowKindList
  143. }
  144. func (s *StoreEntry) CowSourceEnumList() []*pasturePb.ConfigOptionsList {
  145. cowSourceList := make([]*pasturePb.ConfigOptionsList, 0)
  146. cowSourceList = append(cowSourceList, &pasturePb.ConfigOptionsList{
  147. Value: int32(pasturePb.CowSource_Calving),
  148. Label: "产犊",
  149. Disabled: true,
  150. }, &pasturePb.ConfigOptionsList{
  151. Value: int32(pasturePb.CowSource_Transfer_In),
  152. Label: "调入",
  153. Disabled: true,
  154. }, &pasturePb.ConfigOptionsList{
  155. Value: int32(pasturePb.CowSource_Buy),
  156. Label: "购买",
  157. Disabled: true,
  158. })
  159. return cowSourceList
  160. }
  161. func (s *StoreEntry) CowStatusEnumList() []*pasturePb.ConfigOptionsList {
  162. cowStatusList := make([]*pasturePb.ConfigOptionsList, 0)
  163. cowStatusList = append(cowStatusList, &pasturePb.ConfigOptionsList{
  164. Value: int32(pasturePb.CowStatus_Calving),
  165. Label: "产犊",
  166. Disabled: true,
  167. }, &pasturePb.ConfigOptionsList{
  168. Value: int32(pasturePb.CowStatus_Empty),
  169. Label: "空怀",
  170. Disabled: true,
  171. }, &pasturePb.ConfigOptionsList{
  172. Value: int32(pasturePb.CowStatus_Breeding),
  173. Label: "配种",
  174. Disabled: true,
  175. }, &pasturePb.ConfigOptionsList{
  176. Value: int32(pasturePb.CowStatus_Pregnant),
  177. Label: "怀孕",
  178. Disabled: true,
  179. }, &pasturePb.ConfigOptionsList{
  180. Value: int32(pasturePb.CowStatus_Dry_Milk),
  181. Label: "干奶",
  182. Disabled: true,
  183. }, &pasturePb.ConfigOptionsList{
  184. Value: int32(pasturePb.CowStatus_Peripartum),
  185. Label: "围产",
  186. Disabled: true,
  187. }, &pasturePb.ConfigOptionsList{
  188. Value: int32(pasturePb.CowStatus_No_Pregnant),
  189. Label: "禁配",
  190. Disabled: true,
  191. })
  192. return cowStatusList
  193. }
  194. func (s *StoreEntry) CowTypeEnumList() []*pasturePb.ConfigOptionsList {
  195. cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
  196. cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
  197. Value: int32(pasturePb.CowType_Lactating_Calf),
  198. Label: "哺乳犊牛",
  199. Disabled: true,
  200. }, &pasturePb.ConfigOptionsList{
  201. Value: int32(pasturePb.CowType_Weaned_Calf),
  202. Label: "断奶犊牛",
  203. Disabled: true,
  204. }, &pasturePb.ConfigOptionsList{
  205. Value: int32(pasturePb.CowType_Youth),
  206. Label: "青年牛",
  207. Disabled: true,
  208. }, &pasturePb.ConfigOptionsList{
  209. Value: int32(pasturePb.CowType_Nurturing),
  210. Label: "育成牛",
  211. Disabled: true,
  212. }, &pasturePb.ConfigOptionsList{
  213. Value: int32(pasturePb.CowType_Lactation),
  214. Label: "泌乳牛",
  215. Disabled: true,
  216. }, &pasturePb.ConfigOptionsList{
  217. Value: int32(pasturePb.CowType_Dry_Milk),
  218. Label: "干奶牛",
  219. Disabled: true,
  220. })
  221. return cowTypeList
  222. }
  223. func (s *StoreEntry) TransferPenEnumList() []*pasturePb.ConfigOptionsList {
  224. transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
  225. transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
  226. Value: int32(pasturePb.TransferPenReason_Normal),
  227. Label: "正常转群",
  228. Disabled: true,
  229. }, &pasturePb.ConfigOptionsList{
  230. Value: int32(pasturePb.TransferPenReason_Feed),
  231. Label: "饲喂转群",
  232. Disabled: true,
  233. }, &pasturePb.ConfigOptionsList{
  234. Value: int32(pasturePb.TransferPenReason_Dry_Milk),
  235. Label: "干奶转群",
  236. Disabled: true,
  237. }, &pasturePb.ConfigOptionsList{
  238. Value: int32(pasturePb.TransferPenReason_Pregnant),
  239. Label: "怀孕转群",
  240. Disabled: true,
  241. }, &pasturePb.ConfigOptionsList{
  242. Value: int32(pasturePb.TransferPenReason_Overantibody),
  243. Label: "过抗转群",
  244. Disabled: true,
  245. })
  246. return transferPenList
  247. }
  248. func (s *StoreEntry) ChildNumberEnumList() []*pasturePb.ConfigOptionsList {
  249. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  250. configOptions = append(configOptions,
  251. &pasturePb.ConfigOptionsList{
  252. Value: int32(pasturePb.ChildNumber_One),
  253. Label: "单胎",
  254. Disabled: true,
  255. }, &pasturePb.ConfigOptionsList{
  256. Value: int32(pasturePb.ChildNumber_Two),
  257. Label: "双胎",
  258. Disabled: true,
  259. }, &pasturePb.ConfigOptionsList{
  260. Value: int32(pasturePb.ChildNumber_Three),
  261. Label: "三胎",
  262. Disabled: true,
  263. }, &pasturePb.ConfigOptionsList{
  264. Value: int32(pasturePb.ChildNumber_Four),
  265. Label: "四胎",
  266. Disabled: true,
  267. })
  268. return configOptions
  269. }
  270. func (s *StoreEntry) CalvingLevelEnumList() []*pasturePb.ConfigOptionsList {
  271. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  272. configOptions = append(configOptions,
  273. &pasturePb.ConfigOptionsList{
  274. Value: int32(pasturePb.CalvingLevel_Natural_Childbirth),
  275. Label: "自然分娩",
  276. Disabled: true,
  277. }, &pasturePb.ConfigOptionsList{
  278. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
  279. Label: "人工助产(1-2人)",
  280. Disabled: true,
  281. }, &pasturePb.ConfigOptionsList{
  282. Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
  283. Label: "人工助产(3人以上)",
  284. Disabled: true,
  285. }, &pasturePb.ConfigOptionsList{
  286. Value: int32(pasturePb.CalvingLevel_Caesarean),
  287. Label: "剖腹产",
  288. Disabled: true,
  289. })
  290. return configOptions
  291. }
  292. func (s *StoreEntry) DystociaReasonEnumList() []*pasturePb.ConfigOptionsList {
  293. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  294. configOptions = append(configOptions,
  295. &pasturePb.ConfigOptionsList{
  296. Value: int32(pasturePb.DystociaReason_Malposition),
  297. Label: "胎位不正",
  298. Disabled: true,
  299. }, &pasturePb.ConfigOptionsList{
  300. Value: int32(pasturePb.DystociaReason_Fetal_Overgrowth),
  301. Label: "胎儿过大",
  302. Disabled: true,
  303. }, &pasturePb.ConfigOptionsList{
  304. Value: int32(pasturePb.DystociaReason_Uterine_Atony),
  305. Label: "子宫收缩无力",
  306. Disabled: true,
  307. }, &pasturePb.ConfigOptionsList{
  308. Value: int32(pasturePb.DystociaReason_Pelvic_Stenosis),
  309. Label: "盆骨狭小",
  310. Disabled: true,
  311. }, &pasturePb.ConfigOptionsList{
  312. Value: int32(pasturePb.DystociaReason_Sub_Health),
  313. Label: "母牛亚健康状态",
  314. Disabled: true,
  315. })
  316. return configOptions
  317. }
  318. func (s *StoreEntry) PregnantCheckResultEnumList() []*pasturePb.ConfigOptionsList {
  319. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  320. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  321. Value: int32(pasturePb.PregnantCheckResult_InCheck_UnPregnant),
  322. Label: "初检未孕",
  323. Disabled: true,
  324. }, &pasturePb.ConfigOptionsList{
  325. Value: int32(pasturePb.PregnantCheckResult_InCheck_Pregnant),
  326. Label: "初检已孕",
  327. Disabled: true,
  328. }, &pasturePb.ConfigOptionsList{
  329. Value: int32(pasturePb.PregnantCheckResult_Recheck_UnPregnant),
  330. Label: "复检未孕",
  331. Disabled: true,
  332. }, &pasturePb.ConfigOptionsList{
  333. Value: int32(pasturePb.PregnantCheckResult_Recheck_Pregnant),
  334. Label: "初检已孕",
  335. Disabled: true,
  336. })
  337. return configOptions
  338. }
  339. func (s *StoreEntry) PregnantCheckMethodEnumList() []*pasturePb.ConfigOptionsList {
  340. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  341. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  342. Value: int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
  343. Label: "B超",
  344. Disabled: true,
  345. }, &pasturePb.ConfigOptionsList{
  346. Value: int32(pasturePb.PregnantCheckMethod_Blood_Testing),
  347. Label: "血检",
  348. Disabled: true,
  349. }, &pasturePb.ConfigOptionsList{
  350. Value: int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
  351. Label: "人工检查",
  352. Disabled: true,
  353. })
  354. return configOptions
  355. }
  356. func (s *StoreEntry) DrugCategoryEnumList() []*pasturePb.ConfigOptionsList {
  357. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  358. configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
  359. Value: int32(pasturePb.DrugCategory_Antibiotics),
  360. Label: "抗生素类",
  361. Disabled: true,
  362. }, &pasturePb.ConfigOptionsList{
  363. Value: int32(pasturePb.DrugCategory_Antivirals),
  364. Label: "抗病毒类",
  365. Disabled: true,
  366. }, &pasturePb.ConfigOptionsList{
  367. Value: int32(pasturePb.DrugCategory_Antifungals),
  368. Label: "抗真菌类",
  369. Disabled: true,
  370. }, &pasturePb.ConfigOptionsList{
  371. Value: int32(pasturePb.DrugCategory_Antiparasitics),
  372. Label: "抗寄生虫类",
  373. Disabled: true,
  374. }, &pasturePb.ConfigOptionsList{
  375. Value: int32(pasturePb.DrugCategory_Analgesics),
  376. Label: "镇痛类",
  377. Disabled: true,
  378. }, &pasturePb.ConfigOptionsList{
  379. Value: int32(pasturePb.DrugCategory_Antipyretic),
  380. Label: "退烧类",
  381. Disabled: true,
  382. }, &pasturePb.ConfigOptionsList{
  383. Value: int32(pasturePb.DrugCategory_Vitamin),
  384. Label: "维生素类",
  385. Disabled: true,
  386. }, &pasturePb.ConfigOptionsList{
  387. Value: int32(pasturePb.DrugCategory_Brine),
  388. Label: "盐水",
  389. Disabled: true,
  390. }, &pasturePb.ConfigOptionsList{
  391. Value: int32(pasturePb.DrugCategory_Glucose),
  392. Label: "葡萄糖",
  393. Disabled: true,
  394. }, &pasturePb.ConfigOptionsList{
  395. Value: int32(pasturePb.DrugCategory_Hormone),
  396. Label: "激素类",
  397. Disabled: true,
  398. }, &pasturePb.ConfigOptionsList{
  399. Value: int32(pasturePb.DrugCategory_Anti_Stress),
  400. Label: "抗应激类",
  401. Disabled: true,
  402. }, &pasturePb.ConfigOptionsList{
  403. Value: int32(pasturePb.DrugCategory_Disinfect),
  404. Label: "消毒类",
  405. Disabled: true,
  406. }, &pasturePb.ConfigOptionsList{
  407. Value: int32(pasturePb.DrugCategory_Chinese_Herbal),
  408. Label: "中药合剂",
  409. Disabled: true,
  410. }, &pasturePb.ConfigOptionsList{
  411. Value: int32(pasturePb.DrugCategory_Tocolytic),
  412. Label: "保胎类",
  413. Disabled: true,
  414. })
  415. return configOptions
  416. }
  417. func (s *StoreEntry) DrugUsageEnumList() []*pasturePb.ConfigOptionsList {
  418. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  419. configOptions = append(configOptions,
  420. &pasturePb.ConfigOptionsList{
  421. Value: int32(pasturePb.DrugUsage_Oral_Medications),
  422. Label: "口服",
  423. Disabled: true,
  424. }, &pasturePb.ConfigOptionsList{
  425. Value: int32(pasturePb.DrugUsage_Injectable_Medications),
  426. Label: "肌注",
  427. Disabled: true,
  428. }, &pasturePb.ConfigOptionsList{
  429. Value: int32(pasturePb.DrugUsage_Topical_Medications),
  430. Label: "外用",
  431. Disabled: true,
  432. }, &pasturePb.ConfigOptionsList{
  433. Value: int32(pasturePb.DrugUsage_Drink_Medications),
  434. Label: "饮水",
  435. Disabled: true,
  436. })
  437. return configOptions
  438. }
  439. func (s *StoreEntry) UnitEnumList() []*pasturePb.ConfigOptionsList {
  440. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  441. configOptions = append(configOptions,
  442. &pasturePb.ConfigOptionsList{
  443. Value: int32(pasturePb.Unit_Pieces),
  444. Label: "个",
  445. Disabled: true,
  446. }, &pasturePb.ConfigOptionsList{
  447. Value: int32(pasturePb.Unit_Package),
  448. Label: "包/袋",
  449. Disabled: true,
  450. }, &pasturePb.ConfigOptionsList{
  451. Value: int32(pasturePb.Unit_Bottle),
  452. Label: "瓶",
  453. Disabled: true,
  454. }, &pasturePb.ConfigOptionsList{
  455. Value: int32(pasturePb.Unit_Box),
  456. Label: "盒",
  457. Disabled: true,
  458. }, &pasturePb.ConfigOptionsList{
  459. Value: int32(pasturePb.Unit_Boxful),
  460. Label: "箱",
  461. Disabled: true,
  462. }, &pasturePb.ConfigOptionsList{
  463. Value: int32(pasturePb.Unit_Branch),
  464. Label: "支",
  465. Disabled: true,
  466. }, &pasturePb.ConfigOptionsList{
  467. Value: int32(pasturePb.Unit_Barrel),
  468. Label: "桶",
  469. Disabled: true,
  470. }, &pasturePb.ConfigOptionsList{
  471. Value: int32(pasturePb.Unit_Pot),
  472. Label: "罐",
  473. Disabled: true,
  474. })
  475. return configOptions
  476. }
  477. func (s *StoreEntry) DrugUsageMaps(key pasturePb.DrugUsage_Kind) string {
  478. res := ""
  479. for _, v := range s.DrugUsageEnumList() {
  480. if v.Value != int32(key) {
  481. continue
  482. }
  483. res = v.Label
  484. }
  485. return res
  486. }
  487. func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  488. return &pasturePb.ConfigOptionsListResponse{
  489. Code: http.StatusOK,
  490. Message: "ok",
  491. Data: s.BarnTypeEnumList(),
  492. }, nil
  493. }
  494. func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
  495. penList := make([]*model.Pen, 0)
  496. pref := s.DB.Table(new(model.Pen).TableName()).
  497. Where("is_delete = ?", pasturePb.IsShow_Ok)
  498. if penType != -1 {
  499. pref.Where("pen_type = ?", penType)
  500. }
  501. if err := pref.Find(&penList).Error; err != nil {
  502. return nil, err
  503. }
  504. return &pasturePb.ConfigOptionsListResponse{
  505. Code: http.StatusOK,
  506. Message: "ok",
  507. Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
  508. }, nil
  509. }
  510. func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  511. return &pasturePb.ConfigOptionsListResponse{
  512. Code: http.StatusOK,
  513. Message: "ok",
  514. Data: s.BreedStatusEnumList(),
  515. }, nil
  516. }
  517. func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  518. return &pasturePb.ConfigOptionsListResponse{
  519. Code: http.StatusOK,
  520. Message: "ok",
  521. Data: s.CowKindEnumList(),
  522. }, nil
  523. }
  524. func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  525. return &pasturePb.ConfigOptionsListResponse{
  526. Code: http.StatusOK,
  527. Message: "ok",
  528. Data: s.CowSourceEnumList(),
  529. }, nil
  530. }
  531. func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  532. return &pasturePb.ConfigOptionsListResponse{
  533. Code: http.StatusOK,
  534. Message: "ok",
  535. Data: s.CowStatusEnumList(),
  536. }, nil
  537. }
  538. func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  539. return &pasturePb.ConfigOptionsListResponse{
  540. Code: http.StatusOK,
  541. Message: "ok",
  542. Data: s.CowTypeEnumList(),
  543. }, nil
  544. }
  545. func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
  546. return &pasturePb.ConfigOptionsListResponse{
  547. Code: http.StatusOK,
  548. Message: "ok",
  549. Data: s.TransferPenEnumList(),
  550. }, nil
  551. }
  552. func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
  553. systemUserList := make([]*model.SystemUser, 0)
  554. pref := s.DB.Table(new(model.SystemUser).TableName()).
  555. Where("is_delete = ?", pasturePb.IsShow_Ok).
  556. Where("is_show =? ", pasturePb.IsShow_Ok)
  557. if depId != -1 && depId > 0 {
  558. pref = pref.Where("dept_id = ?", depId)
  559. }
  560. if err := pref.Find(&systemUserList).Error; err != nil {
  561. return nil, xxerr.WithStack(err)
  562. }
  563. return &pasturePb.ConfigOptionsListResponse{
  564. Code: http.StatusOK,
  565. Message: "ok",
  566. Data: model.SystemUserSlice(systemUserList).ToPB2(),
  567. }, nil
  568. }
  569. func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
  570. configOptions := make([]*pasturePb.ConfigOptionsList, 0)
  571. switch optionsName {
  572. case "childNumber":
  573. configOptions = s.ChildNumberEnumList()
  574. case "calvingLevel":
  575. configOptions = s.CalvingLevelEnumList()
  576. case "dystociaReason":
  577. configOptions = s.DystociaReasonEnumList()
  578. case "drugCategory":
  579. configOptions = s.DrugCategoryEnumList()
  580. case "drugUsage":
  581. configOptions = s.DrugUsageEnumList()
  582. case "unit":
  583. configOptions = s.UnitEnumList()
  584. case "pregnantCheckResult":
  585. configOptions = s.PregnantCheckResultEnumList()
  586. case "pregnantCheckMethod":
  587. configOptions = s.PregnantCheckMethodEnumList()
  588. }
  589. return &pasturePb.ConfigOptionsListResponse{
  590. Code: http.StatusOK,
  591. Message: "ok",
  592. Data: configOptions,
  593. }, nil
  594. }