03技师认证.sql 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* 技师基本信息视图 */
  2. DROP VIEW IF EXISTS v_coach_info;
  3. CREATE OR REPLACE VIEW v_coach_info AS
  4. SELECT
  5. cir.id AS id /* 记录ID */,
  6. cu.id AS coach_id /* 技师ID */,
  7. cir.nickname AS nickname /* 昵称 */,
  8. cir.gender AS gender /* 性别 */,
  9. cir.mobile AS mobile /* 手机号码 */,
  10. cir.birthday AS birthday /* 出生日期 */,
  11. cir.intention_city AS intention_city /* 意向城市 */,
  12. cir.introduction AS introduction /* 个人简介 */,
  13. cu.state AS coach_state /* 技师状态 */,
  14. cir.state AS info_record_state /* 审核状态 */,
  15. cir.avatar AS avatar /* 头像图片 */,
  16. cir.life_photos AS life_photos /* 生活照片数组 */,
  17. cir.created_at AS created_at /* 申请时间 */,
  18. cir.auditor AS auditor /* 审核人 */,
  19. cir.audit_time AS audit_time /* 审核时间 */,
  20. cir.audit_remark AS audit_remark /* 审核备注 */,
  21. cir.work_years AS work_years /* 工作年限 */
  22. FROM
  23. coach_info_records cir /* 技师基本信息记录 */
  24. LEFT JOIN coach_users cu ON cu.id = cir.coach_id /* 技师ID */
  25. WHERE
  26. cir.deleted_at IS NULL
  27. AND cu.deleted_at IS NULL;
  28. /* 技师实名认证记录视图 */
  29. DROP VIEW IF EXISTS v_coach_real_record;
  30. CREATE VIEW v_coach_real_record AS
  31. SELECT
  32. cr.id AS id /* 实名认证记录ID */,
  33. cu.id AS coach_id /* 技师ID */,
  34. cir.id AS info_record_id /* 技师信息记录ID */,
  35. cir.nickname AS nickname /* 技师昵称 */,
  36. cir.avatar AS avatar /* 头像图片 */,
  37. cir.gender AS gender /* 技师性别 */,
  38. cir.mobile AS mobile /* 技师手机号码 */,
  39. cir.intention_city AS intention_city /* 技师期望城市 */,
  40. cr.real_name AS real_name /* 真实姓名 */,
  41. cr.id_card AS id_card /* 身份证号码 */,
  42. cu.state AS coach_state /* 技师状态 */,
  43. cr.state AS state /* 审核状态 */,
  44. cr.id_card_front_photo AS id_card_front_photo /* 身份证照片正面 */,
  45. cr.id_card_back_photo AS id_card_back_photo /* 身份证照片反面 */,
  46. cr.id_card_hand_photo AS id_card_hand_photo /* 身份证手持照片 */,
  47. cr.created_at AS created_at /* 申请时间 */,
  48. cr.auditor AS auditor /* 审核人 */,
  49. cr.audit_time AS audit_time /* 审核时间 */,
  50. cr.audit_remark AS audit_remark /* 审核备注 */
  51. FROM
  52. coach_real_records cr
  53. LEFT JOIN coach_users cu ON cu.id = cr.coach_id
  54. LEFT JOIN coach_info_records cir ON cir.id = cu.info_record_id
  55. WHERE
  56. cr.deleted_at IS NULL
  57. AND cu.deleted_at IS NULL
  58. AND cir.deleted_at IS NULL;
  59. /* 技师资质认证记录视图 */
  60. DROP VIEW IF EXISTS v_coach_qual_record;
  61. CREATE VIEW v_coach_qual_record AS
  62. SELECT DISTINCT
  63. cqr.id AS id /* 资质证书记录ID */,
  64. cu.id AS coach_id /* 技师ID */,
  65. cir.id AS info_record_id /* 技师信息记录ID */,
  66. cir.nickname AS nickname /* 技师昵称 */,
  67. cir.gender AS gender /* 技师性别 */,
  68. cir.mobile AS mobile /* 技师手机号码 */,
  69. cir.intention_city AS intention_city /* 技师期望城市 */,
  70. cir.introduction AS introduction /* 技师个人简介 */,
  71. cir.avatar AS avatar /* 头像图片 */,
  72. cir.life_photos AS life_photos /* 生活照片数组 */,
  73. cqr.qual_type AS qual_type /* 资质类型 */,
  74. cqr.qual_photo AS qual_photo /* 资质图片 */,
  75. cqr.business_license AS business_license /* 技师营业执照 */,
  76. cqr.health_cert AS health_cert /* 技师健康证 */,
  77. cr.id_card_front_photo AS id_card_front_photo /* 技师身份证照片正面 */,
  78. cr.id_card_back_photo AS id_card_back_photo /* 技师身份证照片反面 */,
  79. cr.id_card_hand_photo AS id_card_hand_photo /* 技师身份证手持照片 */,
  80. cu.state AS coach_state /* 技师状态 */,
  81. cqr.state AS qualification_record_state /* 审核状态 */,
  82. cqr.created_at AS created_at /* 申请时间 */,
  83. cqr.auditor AS auditor /* 审核人 */,
  84. cqr.audit_time AS audit_time /* 审核时间 */,
  85. cqr.audit_remark AS audit_remark /* 审核备注 */
  86. FROM
  87. coach_qual_records cqr
  88. LEFT JOIN coach_users cu ON cu.id = cqr.coach_id /* 先关联技师用户表 */
  89. LEFT JOIN coach_info_records cir ON cir.id = cu.info_record_id /* 再关联技师信息记录表 */
  90. LEFT JOIN coach_real_records cr ON cr.id = cu.real_auth_record_id /* 最后关联实名认证记录表 */
  91. WHERE
  92. cqr.deleted_at IS NULL
  93. AND cu.deleted_at IS NULL
  94. AND cir.deleted_at IS NULL
  95. AND cr.deleted_at IS NULL;