industrial_analyst.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package cygx
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type IndustrialAnalystAdd struct {
  8. AnalystName string `description:"分析师名称"`
  9. IndustrialManagementId int `description:"产业id"`
  10. }
  11. type IndustrialAnalystDelete struct {
  12. IndustrialAnalystId int `orm:"column(industrial_analyst_id);pk" description:"分析师id"`
  13. }
  14. type CygxIndustrialAnalyst struct {
  15. IndustrialAnalystId int `orm:"column(industrial_analyst_id);pk" description:"分析师id"`
  16. IndustrialManagementId int `description:"产业id"`
  17. AnalystName string `description:"分析师名称"`
  18. CreateTime time.Time `description:"创建时间"`
  19. }
  20. type GetIndustrialAnalystList struct {
  21. List []*CygxIndustrialAnalyst
  22. }
  23. //新增
  24. func AddIndustrialAnalyst(item *CygxIndustrialAnalyst) (err error) {
  25. o := orm.NewOrm()
  26. _, err = o.Insert(item)
  27. return
  28. }
  29. //列表
  30. func GetIndustrialAnalystAll(IndustrialManagementId int) (items []*CygxIndustrialAnalyst, err error) {
  31. o := orm.NewOrm()
  32. sql := `SELECT * FROM cygx_industrial_analyst where industrial_management_id = ? `
  33. _, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items)
  34. return
  35. }
  36. //获取数量
  37. func GetIndustrialAnalystCount(condition string, pars []interface{}) (count int, err error) {
  38. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_industrial_analyst WHERE 1=1 `
  39. if condition != "" {
  40. sqlCount += condition
  41. }
  42. fmt.Println(sqlCount)
  43. o := orm.NewOrm()
  44. err = o.Raw(sqlCount, pars).QueryRow(&count)
  45. return
  46. }
  47. //修改
  48. func EditIndustrialAnalyst(item *CygxIndustrialAnalyst) (err error) {
  49. sql := `UPDATE cygx_industrial_analyst SET analyst_name=? WHERE industrial_analyst_id=? `
  50. o := orm.NewOrm()
  51. _, err = o.Raw(sql, item.AnalystName, item.IndustrialAnalystId).Exec()
  52. return
  53. }
  54. //删除数据
  55. func DeleteIndustrialAnalyst(industrialAnalystId int) (err error) {
  56. o := orm.NewOrm()
  57. sql := ` DELETE FROM cygx_industrial_analyst WHERE industrial_analyst_id = ?`
  58. _, err = o.Raw(sql, industrialAnalystId).Exec()
  59. return
  60. }