Bläddra i källkod

Merge branch 'master' of http://git.shengws.com/csx/XT_New

csx 4 år sedan
förälder
incheckning
0766f3c527

+ 295 - 1
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Visa fil

@@ -1549,7 +1549,6 @@ func (this *NewDialysisApiController) GetMyInformation() {
1549 1549
 	adminUserInfo := this.GetMobileAdminUserInfo()
1550 1550
 
1551 1551
 	roleInfo := adminUserInfo.AppRole
1552
-	fmt.Print("aa")
1553 1552
 	es, _ := service.GetAdminUserElectronicSignature(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id)
1554 1553
 
1555 1554
 	this.ServeSuccessJSON(map[string]interface{}{
@@ -1606,8 +1605,11 @@ func (this *NewDialysisApiController) SaveFeed() {
1606 1605
 	fmt.Print("phone", phone)
1607 1606
 	times, _ := this.GetInt64("time")
1608 1607
 	fmt.Print("time", times)
1608
+	adminuserid, _ := this.GetInt64("admin_user_id")
1609
+	fmt.Println("admin", adminuserid)
1609 1610
 	adminUser := this.GetMobileAdminUserInfo()
1610 1611
 	orgid := adminUser.Org.Id
1612
+	appid := adminUser.App.Id
1611 1613
 	feedback := models.XtPatientFeedback{
1612 1614
 		ProblemType: question,
1613 1615
 		Title:       title,
@@ -1617,6 +1619,8 @@ func (this *NewDialysisApiController) SaveFeed() {
1617 1619
 		UserOrgId:   orgid,
1618 1620
 		Ctime:       time.Now().Unix(),
1619 1621
 		Status:      1,
1622
+		AdminUserId: adminuserid,
1623
+		AppId:       appid,
1620 1624
 	}
1621 1625
 	err := service.CreateFeedBack(&feedback)
1622 1626
 	if err != nil {
@@ -1640,3 +1644,293 @@ func (this *NewDialysisApiController) DeleteInspection() {
1640 1644
 	this.ServeSuccessJSON(returnData)
1641 1645
 	return
1642 1646
 }
1647
+
1648
+func (this *NewDialysisApiController) DeleteChildInspection() {
1649
+	admininfo := this.GetMobileAdminUserInfo()
1650
+	orgid := admininfo.Org.Id
1651
+	name := this.GetString("name")
1652
+	fmt.Println("name", name)
1653
+	date, _ := this.GetInt64("date")
1654
+	fmt.Println("date", date)
1655
+	err := service.DeleteChildInspection(name, date, orgid)
1656
+	fmt.Println("删除失败", err)
1657
+	returnData := make(map[string]interface{}, 0)
1658
+	returnData["msg"] = "手机号码已存在"
1659
+	this.ServeSuccessJSON(returnData)
1660
+	return
1661
+}
1662
+
1663
+func (this *NewDialysisApiController) SaveMessage() {
1664
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1665
+	appid := this.GetMobileAdminUserInfo().App.Id
1666
+	id, _ := this.GetInt64("id")
1667
+	fmt.Println("id", id)
1668
+	message := this.GetString("message")
1669
+	fmt.Println("message", message)
1670
+	role := models.App_Role{
1671
+		Message: message,
1672
+	}
1673
+	err := service.SaveMessage(orgid, appid, id, &role)
1674
+	if err != nil {
1675
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1676
+		return
1677
+	}
1678
+	this.ServeSuccessJSON(map[string]interface{}{
1679
+		"role": role,
1680
+	})
1681
+}
1682
+
1683
+func (this *NewDialysisApiController) SaveSex() {
1684
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1685
+	appid := this.GetMobileAdminUserInfo().App.Id
1686
+	sex, _ := this.GetInt64("sex")
1687
+	fmt.Println("sex", sex)
1688
+	id, _ := this.GetInt64("id")
1689
+	fmt.Println("id", id)
1690
+	role := models.App_Role{
1691
+		Sex: sex,
1692
+	}
1693
+	err := service.SaveSex(id, orgid, appid, &role)
1694
+	if err != nil {
1695
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1696
+		return
1697
+	}
1698
+	this.ServeSuccessJSON(map[string]interface{}{
1699
+		"role": role,
1700
+	})
1701
+}
1702
+
1703
+func (this *NewDialysisApiController) SaveBirthday() {
1704
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1705
+	appid := this.GetMobileAdminUserInfo().App.Id
1706
+	dataBody := make(map[string]interface{}, 0)
1707
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1708
+	fmt.Println(err)
1709
+	id := dataBody["id"].(string)
1710
+	ids, err := strconv.ParseInt(id, 10, 64)
1711
+	fmt.Print("id", id)
1712
+	birthday := dataBody["birth"].(string)
1713
+	timeLayout := "2006-01-02 15:04:05"
1714
+	theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
1715
+	birth := theTime.Unix()
1716
+	role := models.App_Role{
1717
+		Birthday: birth,
1718
+	}
1719
+	err = service.SaveBirthday(ids, orgid, appid, &role)
1720
+	if err != nil {
1721
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1722
+		return
1723
+	}
1724
+	this.ServeSuccessJSON(map[string]interface{}{
1725
+		"role": role,
1726
+	})
1727
+}
1728
+
1729
+func (this *NewDialysisApiController) GetOrgName() {
1730
+
1731
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1732
+	name, err := service.GetOrgName(orgid)
1733
+	if err != nil {
1734
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1735
+		return
1736
+	}
1737
+	this.ServeSuccessJSON(map[string]interface{}{
1738
+		"name": name,
1739
+	})
1740
+}
1741
+
1742
+func (this *NewDialysisApiController) GetRoleName() {
1743
+	id, _ := this.GetInt64("id")
1744
+	fmt.Println("id", id)
1745
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1746
+	fmt.Println("orgid", orgid)
1747
+	appid := this.GetMobileAdminUserInfo().App.Id
1748
+	fmt.Println("appid", appid)
1749
+	name, err := service.GetRoleName(id, orgid, appid)
1750
+	positionName, err := service.GetPositionName(id, orgid, appid)
1751
+	if err != nil {
1752
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1753
+		return
1754
+	}
1755
+	this.ServeSuccessJSON(map[string]interface{}{
1756
+		"name":         name,
1757
+		"positionName": positionName,
1758
+	})
1759
+}
1760
+
1761
+func (this *NewDialysisApiController) SavePartition() {
1762
+	adminInfo := this.GetMobileAdminUserInfo()
1763
+	name := this.GetString("name")
1764
+	fmt.Println("分区名称", name)
1765
+	zonetype, _ := this.GetInt64("type")
1766
+	fmt.Println("分区型号", zonetype)
1767
+	strInt64 := strconv.FormatInt(zonetype, 10)
1768
+	typeid, _ := strconv.Atoi(strInt64)
1769
+	zone := models.DeviceZone{
1770
+		Name:       name,
1771
+		Type:       typeid,
1772
+		OrgID:      adminInfo.Org.Id,
1773
+		Status:     1,
1774
+		CreateTime: time.Now().Unix(),
1775
+	}
1776
+	err := service.CreatedZone(&zone)
1777
+	if err != nil {
1778
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1779
+		return
1780
+	}
1781
+	this.ServeSuccessJSON(map[string]interface{}{
1782
+		"zone": zone,
1783
+	})
1784
+}
1785
+
1786
+func (this *NewDialysisApiController) GetAllZone() {
1787
+
1788
+	adminUser := this.GetMobileAdminUserInfo()
1789
+	orgid := adminUser.Org.Id
1790
+	page, _ := this.GetInt64("page")
1791
+	limit, _ := this.GetInt64("limit")
1792
+	zone, total, err := service.GetAllZone(orgid, page, limit)
1793
+	if err != nil {
1794
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1795
+		return
1796
+	}
1797
+	this.ServeSuccessJSON(map[string]interface{}{
1798
+		"zone":  zone,
1799
+		"total": total,
1800
+	})
1801
+}
1802
+
1803
+func (this *NewDialysisApiController) DeleteZone() {
1804
+	id, _ := this.GetInt64("id")
1805
+	err := service.DeleteZoneById(id)
1806
+	fmt.Println("删除失败", err)
1807
+	returnData := make(map[string]interface{}, 0)
1808
+	returnData["msg"] = "删除失败"
1809
+	this.ServeSuccessJSON(returnData)
1810
+	return
1811
+}
1812
+
1813
+func (this *NewDialysisApiController) SaveGroup() {
1814
+	adminUser := this.GetMobileAdminUserInfo()
1815
+	orgid := adminUser.Org.Id
1816
+	name := this.GetString("name")
1817
+	fmt.Println("name", name)
1818
+	group := models.DeviceGroup{
1819
+		Name:       name,
1820
+		Status:     1,
1821
+		CreateTime: time.Now().Unix(),
1822
+		OrgID:      orgid,
1823
+	}
1824
+	err := service.SaveGroup(&group)
1825
+	if err != nil {
1826
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1827
+		return
1828
+	}
1829
+	this.ServeSuccessJSON(map[string]interface{}{
1830
+		"group": group,
1831
+	})
1832
+}
1833
+
1834
+func (this *NewDialysisApiController) GetAllGroup() {
1835
+	adminUser := this.GetMobileAdminUserInfo()
1836
+	orgid := adminUser.Org.Id
1837
+	page, _ := this.GetInt64("page")
1838
+	fmt.Println("page", page)
1839
+	limit, _ := this.GetInt64("limit")
1840
+	fmt.Println("limit", limit)
1841
+	group, total, err := service.GetAllGroup(orgid, page, limit)
1842
+	if err != nil {
1843
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1844
+		return
1845
+	}
1846
+	this.ServeSuccessJSON(map[string]interface{}{
1847
+		"group": group,
1848
+		"total": total,
1849
+	})
1850
+}
1851
+
1852
+func (this *NewDialysisApiController) DeleteGroup() {
1853
+	id, _ := this.GetInt64("id")
1854
+	fmt.Println("id", id)
1855
+	err := service.DeleteGroup(id)
1856
+	fmt.Println("删除失败", err)
1857
+	returnData := make(map[string]interface{}, 0)
1858
+	returnData["msg"] = "删除失败"
1859
+	this.ServeSuccessJSON(returnData)
1860
+	return
1861
+}
1862
+
1863
+func (this *NewDialysisApiController) GetAllGroupOne() {
1864
+	admininfo := this.GetMobileAdminUserInfo()
1865
+	orgid := admininfo.Org.Id
1866
+	zone, _ := service.GetAllZoneOne(orgid)
1867
+	group, err := service.GetAllGroupOne(orgid)
1868
+	if err != nil {
1869
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1870
+		return
1871
+	}
1872
+	this.ServeSuccessJSON(map[string]interface{}{
1873
+		"zone":  zone,
1874
+		"group": group,
1875
+	})
1876
+}
1877
+
1878
+func (this *NewDialysisApiController) SaveBed() {
1879
+	adminuser := this.GetMobileAdminUserInfo()
1880
+	orgid := adminuser.Org.Id
1881
+	name := this.GetString("name")
1882
+	fmt.Println("name", name)
1883
+	zone, _ := this.GetInt64("zone")
1884
+	fmt.Print("zone", zone)
1885
+	group, _ := this.GetInt64("group")
1886
+	fmt.Println("group", group)
1887
+	number := models.DeviceNumber{
1888
+		Number:     name,
1889
+		ZoneID:     zone,
1890
+		GroupID:    group,
1891
+		OrgID:      orgid,
1892
+		Status:     1,
1893
+		CreateTime: time.Now().Unix(),
1894
+	}
1895
+	err := service.CreateNumber(&number)
1896
+	if err != nil {
1897
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1898
+		return
1899
+	}
1900
+	this.ServeSuccessJSON(map[string]interface{}{
1901
+		"number": number,
1902
+	})
1903
+}
1904
+
1905
+func (this *NewDialysisApiController) GetAllNumber() {
1906
+	admininfo := this.GetMobileAdminUserInfo()
1907
+	orgid := admininfo.Org.Id
1908
+	page, _ := this.GetInt64("page")
1909
+	fmt.Print("page", page)
1910
+	limit, _ := this.GetInt64("limit")
1911
+	fmt.Println("limit", limit)
1912
+	number, total, err := service.GetAllNumber(page, limit, orgid)
1913
+	zone, _ := service.GetAllZoneOne(orgid)
1914
+	group, _ := service.GetAllGroupOne(orgid)
1915
+	if err != nil {
1916
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1917
+		return
1918
+	}
1919
+	this.ServeSuccessJSON(map[string]interface{}{
1920
+		"number": number,
1921
+		"total":  total,
1922
+		"zone":   zone,
1923
+		"group":  group,
1924
+	})
1925
+}
1926
+
1927
+func (this *NewDialysisApiController) DeleteBed() {
1928
+	id, _ := this.GetInt64("id")
1929
+	fmt.Println("id", id)
1930
+	err := service.DeleteBed(id)
1931
+	fmt.Println("删除失败", err)
1932
+	returnData := make(map[string]interface{}, 0)
1933
+	returnData["msg"] = "删除失败"
1934
+	this.ServeSuccessJSON(returnData)
1935
+	return
1936
+}

+ 16 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Visa fil

@@ -105,4 +105,20 @@ func NewMobileAPIControllersRegisterRouters() {
105 105
 	beego.Router("/m/api/patient/savefeed", &NewDialysisApiController{}, "Get:SaveFeed")
106 106
 	beego.Router("/m/api/patient/deletechild", &NewDialysisApiController{}, "Delete:DeleteChild")
107 107
 	beego.Router("/m/api/patient/deleteinspection", &NewDialysisApiController{}, "Delete:DeleteInspection")
108
+	beego.Router("/m/api/patient/deletechildinspection", &NewDialysisApiController{}, "Delete:DeleteChildInspection")
109
+	beego.Router("/m/api/patient/savemessage", &NewDialysisApiController{}, "Get:SaveMessage")
110
+	beego.Router("/m/api/patient/savesex", &NewDialysisApiController{}, "Get:SaveSex")
111
+	beego.Router("/m/api/patient/savebirthday", &NewDialysisApiController{}, "Post:SaveBirthday")
112
+	beego.Router("/m/api/patient/getorgname", &NewDialysisApiController{}, "Get:GetOrgName")
113
+	beego.Router("/m/api/patient/getrolename", &NewDialysisApiController{}, "Get:GetRoleName")
114
+	beego.Router("/m/api/patient/savepartition", &NewDialysisApiController{}, "Get:SavePartition")
115
+	beego.Router("/m/api/patient/getallzone", &NewDialysisApiController{}, "Get:GetAllZone")
116
+	beego.Router("/m/api/patient/deletezone", &NewDialysisApiController{}, "Delete:DeleteZone")
117
+	beego.Router("/m/api/patient/savegroup", &NewDialysisApiController{}, "Get:SaveGroup")
118
+	beego.Router("/m/api/patient/getallgroup", &NewDialysisApiController{}, "Get:GetAllGroup")
119
+	beego.Router("/m/api/patient/deletegroup", &NewDialysisApiController{}, "Delete:DeleteGroup")
120
+	beego.Router("m/api/patient/getallgroupone", &NewDialysisApiController{}, "Get:GetAllGroupOne")
121
+	beego.Router("/m/api/patient/savebed", &NewDialysisApiController{}, "Get:SaveBed")
122
+	beego.Router("/m/api/patient/getallnumber", &NewDialysisApiController{}, "Get:GetAllNumber")
123
+	beego.Router("/m/api/patient/deletebed", &NewDialysisApiController{}, "Delete:DeleteBed")
108 124
 }

+ 21 - 0
models/role_models.go Visa fil

@@ -52,6 +52,9 @@ type App_Role struct {
52 52
 	UserTitleName string    `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
53 53
 	RoleIds       string    `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
54 54
 	AdminUser     AdminUser `gorm:"ForeignKey:ID;AssociationForeignKey:AdminUserId" json:"admin"`
55
+	Message       string    `gorm:"column:message" json:"message" form:"message"`
56
+	Sex           int64     `gorm:"column:sex" json:"sex" form:"sex"`
57
+	Birthday      int64     `gorm:"column:birthday" json:"birthday" form:"birthday"`
55 58
 }
56 59
 
57 60
 func (App_Role) TableName() string {
@@ -95,3 +98,21 @@ type SgjUserRoleFuncPurview struct {
95 98
 func (SgjUserRoleFuncPurview) TableName() string {
96 99
 	return "sgj_user_role_func_purview"
97 100
 }
101
+
102
+type Roles struct {
103
+	Id           int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
104
+	RoleName     string `gorm:"column:role_name" json:"role_name"`
105
+	RoleIntro    string `gorm:"column:role_introduction" json:"intro"`
106
+	Creator      int64  `json:"-"`
107
+	OrgId        int64  `gorm:"column:org_id" json:"-"`
108
+	AppId        int64  `gorm:"column:app_id" json:"-"`
109
+	IsSuperAdmin bool   `gorm:"column:is_super_admin" json:"is_super_admin"`
110
+	Status       int8   `json:"status"`                // 状态 0.无效 1.有效 2.禁用
111
+	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
112
+	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
113
+	StaffNumber  int64  `gorm:"-" json:"staff_number"`
114
+}
115
+
116
+func (Roles) TableName() string {
117
+	return "sgj_user_role"
118
+}

+ 14 - 0
service/manage_service.go Visa fil

@@ -1050,3 +1050,17 @@ func DeleteImages(id int64) error {
1050 1050
 	err := UserWriteDB().Model(&repair).Where("id=?", id).Update(map[string]interface{}{"images": "", "image_name": ""}).Error
1051 1051
 	return err
1052 1052
 }
1053
+
1054
+func GetRoleName(adminid int64, orgid int64, appid int64) (models.Roles, error) {
1055
+
1056
+	role := models.Roles{}
1057
+	err := UserReadDB().Model(&role).Where("creator = ? and org_id = ? and app_id = ? and status =1", adminid, orgid, appid).Find(&role).Error
1058
+	return role, err
1059
+}
1060
+
1061
+func GetPositionName(adminid int64, orgid int64, appid int64) (models.App_Role, error) {
1062
+
1063
+	role := models.App_Role{}
1064
+	err := UserReadDB().Model(&role).Where("admin_user_id = ? and org_id = ? and app_id = ?", adminid, orgid, appid).Find(&role).Error
1065
+	return role, err
1066
+}

+ 100 - 0
service/patientmanage_service.go Visa fil

@@ -979,3 +979,103 @@ func DeleteInspection(date int64, orgid int64) error {
979 979
 	err := XTWriteDB().Model(models.Inspection{}).Where("inspect_date = ? and org_id = ?", date, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
980 980
 	return err
981 981
 }
982
+
983
+func DeleteChildInspection(name string, date int64, orgid int64) error {
984
+
985
+	err := XTWriteDB().Model(models.Inspection{}).Where("project_name = ? and inspect_date = ? and org_id = ?", name, date, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
986
+	return err
987
+}
988
+
989
+func SaveMessage(orgid int64, appid int64, id int64, role *models.App_Role) error {
990
+
991
+	err := UserWriteDB().Model(models.App_Role{}).Where("org_id = ? and app_id = ? and admin_user_id = ?", orgid, appid, id).Update(map[string]interface{}{"message": role.Message, "mtime": time.Now().Unix()}).Error
992
+	return err
993
+}
994
+
995
+func SaveSex(id int64, orgid int64, appid int64, role *models.App_Role) error {
996
+	err := UserWriteDB().Model(models.App_Role{}).Where("org_id = ? and app_id = ? and admin_user_id = ?", orgid, appid, id).Update(map[string]interface{}{"sex": role.Sex, "mtime": time.Now().Unix()}).Error
997
+	return err
998
+}
999
+
1000
+func SaveBirthday(id int64, orgid int64, appid int64, role *models.App_Role) error {
1001
+	err := UserWriteDB().Model(models.App_Role{}).Where("org_id = ? and app_id = ? and admin_user_id = ?", orgid, appid, id).Update(map[string]interface{}{"birthday": role.Birthday, "mtime": time.Now().Unix()}).Error
1002
+	return err
1003
+}
1004
+
1005
+func CreatedZone(zone *models.DeviceZone) error {
1006
+
1007
+	err := XTWriteDB().Model(&zone).Create(&zone).Error
1008
+	return err
1009
+}
1010
+
1011
+func GetAllZone(orgid int64, page int64, limit int64) (zone []*models.DeviceZone, total int64, err error) {
1012
+
1013
+	db := XTReadDB().Table("xt_device_zone as x").Where("x.status =1")
1014
+	if orgid > 0 {
1015
+		db = db.Where("x.org_id = ?", orgid)
1016
+	}
1017
+	offset := (page - 1) * limit
1018
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.type").Find(&zone).Error
1019
+	return zone, total, err
1020
+}
1021
+
1022
+func DeleteZoneById(id int64) error {
1023
+
1024
+	err := XTWriteDB().Model(models.DeviceZone{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
1025
+	return err
1026
+}
1027
+
1028
+func SaveGroup(group *models.DeviceGroup) error {
1029
+	err := XTWriteDB().Model(&group).Create(&group).Error
1030
+	return err
1031
+}
1032
+
1033
+func GetAllGroup(orgid int64, page int64, limit int64) (group []*models.DeviceGroup, total int64, err error) {
1034
+	db := XTReadDB().Table("xt_device_group as x").Where("x.status = 1")
1035
+	if orgid > 0 {
1036
+		db = db.Where("x.org_id = ?", orgid)
1037
+	}
1038
+	offset := (page - 1) * limit
1039
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.status,x.ctime,x.mtime").Find(&group).Error
1040
+	return group, total, err
1041
+}
1042
+
1043
+func DeleteGroup(id int64) error {
1044
+	err := XTWriteDB().Model(models.DeviceGroup{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
1045
+	return err
1046
+}
1047
+
1048
+func GetAllZoneOne(orgid int64) (zone []*models.DeviceZone, err error) {
1049
+
1050
+	err = XTReadDB().Model(&zone).Where("org_id = ?", orgid).Find(&zone).Error
1051
+	return zone, err
1052
+}
1053
+
1054
+func GetAllGroupOne(orgid int64) (group []*models.DeviceGroup, err error) {
1055
+
1056
+	err = XTReadDB().Model(&group).Where("org_id =?", orgid).Find(&group).Error
1057
+	return group, err
1058
+}
1059
+
1060
+func CreateNumber(number *models.DeviceNumber) error {
1061
+
1062
+	err := XTWriteDB().Model(&number).Create(&number).Error
1063
+	return err
1064
+}
1065
+
1066
+func GetAllNumber(page int64, limit int64, orgid int64) (number []*models.DeviceNumber, total int64, err error) {
1067
+
1068
+	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
1069
+	if orgid > 0 {
1070
+		db = db.Where("x.org_id = ?", orgid)
1071
+	}
1072
+	offset := (page - 1) * limit
1073
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.number,x.group_id,x.zone_id,x.status").Find(&number).Error
1074
+
1075
+	return number, total, err
1076
+}
1077
+
1078
+func DeleteBed(id int64) error {
1079
+	err := XTWriteDB().Model(models.DeviceNumber{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "ctime": time.Now().Unix()}).Error
1080
+	return err
1081
+}