AuthService.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package service
  2. import (
  3. "app.yhyue.com/moapp/jybase/go-xweb/log"
  4. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
  5. "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
  6. "fmt"
  7. "time"
  8. )
  9. type AuthService struct{}
  10. //认证信息保存
  11. func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) {
  12. //先判断用户是否存在
  13. user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
  14. "user_id": in.UserId, "appid": in.Appid,
  15. }, "id", "")
  16. if user != nil {
  17. if in.OperationType == "add" {
  18. return false, "用户已验证"
  19. }
  20. } else {
  21. if in.OperationType == "update" {
  22. return false, "用户未认证,不可修改"
  23. }
  24. }
  25. if in.OperationType == "update" {
  26. //修改处理
  27. data := map[string]interface{}{
  28. "name": in.Name,
  29. "phone": in.Phone,
  30. "position": in.Position,
  31. "department": in.Department,
  32. "mail": in.Mail,
  33. "ent_code": in.EntCode,
  34. "ent_name": in.EntName,
  35. }
  36. ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId, "appid": in.Appid}, data)
  37. if ok1 {
  38. return true, ""
  39. } else {
  40. log.Println(fmt.Sprintf("认证修改失败:入参:%v:%v,", in.UserId, data))
  41. return false, "修改失败"
  42. }
  43. } else {
  44. //新增处理
  45. data := map[string]interface{}{
  46. "name": in.Name,
  47. "phone": in.Phone,
  48. "position": in.Position,
  49. "department": in.Department,
  50. "mail": in.Mail,
  51. "ent_code": in.EntCode,
  52. "ent_name": in.EntName,
  53. "user_id": in.UserId,
  54. "create_time": time.Now().Local(),
  55. "appid": in.Appid,
  56. }
  57. ok := entity.BaseMysql.Insert(entity.DOMAIN_CAPITAL_RETENTION, data)
  58. if ok > 0 {
  59. return true, ""
  60. } else {
  61. log.Println(fmt.Sprintf("认证失败:参数:%v", data))
  62. return false, "认证失败"
  63. }
  64. }
  65. }
  66. //认证信息查询
  67. func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} {
  68. //先判断用户是否存在
  69. user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
  70. "user_id": in.UserId, "appid": in.Appid,
  71. }, "id", "")
  72. return user
  73. }