XMLWAN 4 years ago
parent
commit
2bbeaf1750

+ 99 - 1
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View File

@@ -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{}{
@@ -1660,3 +1659,102 @@ func (this *NewDialysisApiController) DeleteChildInspection() {
1660 1659
 	this.ServeSuccessJSON(returnData)
1661 1660
 	return
1662 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
+	fmt.Print("-----======", birth)
1717
+	role := models.App_Role{
1718
+		Birthday: birth,
1719
+	}
1720
+	err = service.SaveBirthday(ids, orgid, appid, &role)
1721
+	if err != nil {
1722
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1723
+		return
1724
+	}
1725
+	this.ServeSuccessJSON(map[string]interface{}{
1726
+		"role": role,
1727
+	})
1728
+}
1729
+
1730
+func (this *NewDialysisApiController) GetOrgName() {
1731
+
1732
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1733
+	name, err := service.GetOrgName(orgid)
1734
+	if err != nil {
1735
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1736
+		return
1737
+	}
1738
+	this.ServeSuccessJSON(map[string]interface{}{
1739
+		"name": name,
1740
+	})
1741
+}
1742
+
1743
+func (this *NewDialysisApiController) GetRoleName() {
1744
+	id, _ := this.GetInt64("id")
1745
+	fmt.Println("id", id)
1746
+	orgid := this.GetMobileAdminUserInfo().Org.Id
1747
+	fmt.Println("orgid", orgid)
1748
+	appid := this.GetMobileAdminUserInfo().App.Id
1749
+	fmt.Println("appid", appid)
1750
+	name, err := service.GetRoleName(id, orgid, appid)
1751
+	positionName, err := service.GetPositionName(id, orgid, appid)
1752
+	if err != nil {
1753
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1754
+		return
1755
+	}
1756
+	this.ServeSuccessJSON(map[string]interface{}{
1757
+		"name":         name,
1758
+		"positionName": positionName,
1759
+	})
1760
+}

+ 5 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go View File

@@ -102,4 +102,9 @@ func NewMobileAPIControllersRegisterRouters() {
102 102
 	beego.Router("/m/api/patient/deletechild", &NewDialysisApiController{}, "Delete:DeleteChild")
103 103
 	beego.Router("/m/api/patient/deleteinspection", &NewDialysisApiController{}, "Delete:DeleteInspection")
104 104
 	beego.Router("/m/api/patient/deletechildinspection", &NewDialysisApiController{}, "Delete:DeleteChildInspection")
105
+	beego.Router("/m/api/patient/savemessage", &NewDialysisApiController{}, "Get:SaveMessage")
106
+	beego.Router("/m/api/patient/savesex", &NewDialysisApiController{}, "Get:SaveSex")
107
+	beego.Router("/m/api/patient/savebirthday", &NewDialysisApiController{}, "Post:SaveBirthday")
108
+	beego.Router("/m/api/patient/getorgname", &NewDialysisApiController{}, "Get:GetOrgName")
109
+	beego.Router("/m/api/patient/getrolename", &NewDialysisApiController{}, "Get:GetRoleName")
105 110
 }

+ 21 - 0
models/role_models.go View File

@@ -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 {
@@ -80,3 +83,21 @@ var UserTitle = map[int]string{
80 83
 	12: "运营专员",
81 84
 	13: "运营主管",
82 85
 }
86
+
87
+type Roles struct {
88
+	Id           int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
89
+	RoleName     string `gorm:"column:role_name" json:"role_name"`
90
+	RoleIntro    string `gorm:"column:role_introduction" json:"intro"`
91
+	Creator      int64  `json:"-"`
92
+	OrgId        int64  `gorm:"column:org_id" json:"-"`
93
+	AppId        int64  `gorm:"column:app_id" json:"-"`
94
+	IsSuperAdmin bool   `gorm:"column:is_super_admin" json:"is_super_admin"`
95
+	Status       int8   `json:"status"`                // 状态 0.无效 1.有效 2.禁用
96
+	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
97
+	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
98
+	StaffNumber  int64  `gorm:"-" json:"staff_number"`
99
+}
100
+
101
+func (Roles) TableName() string {
102
+	return "sgj_user_role"
103
+}

+ 14 - 0
service/manage_service.go View File

@@ -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
+}

+ 16 - 0
service/patientmanage_service.go View File

@@ -985,3 +985,19 @@ func DeleteChildInspection(name string, date int64, orgid int64) error {
985 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 986
 	return err
987 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
+}