Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/jiwei/wlyy2.0 into dev

# Conflicts:
#	svr/svr-base/pom.xml
liuwenbin 7 years ago
parent
commit
315516c6ae
100 changed files with 7560 additions and 4176 deletions
  1. 67 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/PatientHospitalRecordDO.java
  2. 77 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistArticleDO.java
  3. 117 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistConsultDO.java
  4. 108 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistDO.java
  5. 170 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java
  6. 101 0
      common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationInformationDO.java
  7. 81 0
      common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationPerformanceDO.java
  8. 71 0
      common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationPlanningDO.java
  9. 68 0
      common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationTreatmentProgramDO.java
  10. 75 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/rehabilitation/RehabilitationRequestMapping.java
  11. 20 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java
  12. 8 8
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java
  13. 0 3
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopList.java
  14. 4 19
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopPage.java
  15. 9 33
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/base/BaseEnvelop.java
  16. 91 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationInformationVO.java
  17. 71 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationPerformanceVO.java
  18. 63 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationPlanningVO.java
  19. 57 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationTreatmentProgramVO.java
  20. 166 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/SpecialistPatientRelationVO.java
  21. 4 0
      server/svr-discovery/pom.xml
  22. 185 0
      server/svr-discovery/src/main/java/com.yihu.jw/controller/DiscoveryController.java
  23. 1 0
      svr-lib-parent-pom/pom.xml
  24. 0 4
      svr/svr-base/pom.xml
  25. 27 27
      svr/svr-base/src/main/java/com/yihu/jw/business/login/dao/BaseLoginAccountDao.java
  26. 11 11
      svr/svr-base/src/main/java/com/yihu/jw/business/login/dao/BaseLoginLogDao.java
  27. 75 75
      svr/svr-base/src/main/java/com/yihu/jw/business/login/service/BaseLoginAccountService.java
  28. 20 20
      svr/svr-base/src/main/java/com/yihu/jw/business/sms/dao/SmsGatewayDao.java
  29. 68 68
      svr/svr-base/src/main/java/com/yihu/jw/business/sms/service/SmsGatewayService.java
  30. 95 95
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseMenuController.java
  31. 220 220
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseRoleController.java
  32. 203 203
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployController.java
  33. 28 28
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/PatientController.java
  34. 32 32
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseMenuDao.java
  35. 28 28
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseRoleDao.java
  36. 26 26
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseRoleMenuDao.java
  37. 24 24
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployRoleDao.java
  38. 137 137
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseMenuService.java
  39. 154 154
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleMenuService.java
  40. 174 174
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleService.java
  41. 152 152
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployRoleService.java
  42. 7 3
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployService.java
  43. 125 125
      svr/svr-base/src/main/java/com/yihu/jw/business/version/controller/UserVersionController.java
  44. 14 14
      svr/svr-base/src/main/java/com/yihu/jw/business/version/dao/BaseUserVersionDao.java
  45. 41 41
      svr/svr-base/src/main/java/com/yihu/jw/business/version/service/BaseUserVersionService.java
  46. 644 644
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/WechatResponse.java
  47. 138 138
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WechatConfigController.java
  48. 47 47
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxAccessTokenController.java
  49. 164 164
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxGraphicMessageController.java
  50. 236 236
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxMenuController.java
  51. 188 188
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxTemplateController.java
  52. 27 27
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WechatDao.java
  53. 17 17
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxAccessTokenDao.java
  54. 15 15
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxGraphicMessageDao.java
  55. 47 47
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxMenuDao.java
  56. 21 21
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxTemplateDao.java
  57. 114 114
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WechatService.java
  58. 96 96
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxAccessTokenService.java
  59. 177 177
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxGraphicMessageService.java
  60. 357 356
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxMenuService.java
  61. 157 157
      svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxTemplateService.java
  62. 3 3
      svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java
  63. 6 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java
  64. 3 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java
  65. 12 3
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java
  66. 8 2
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java
  67. 179 0
      svr/svr-rehabilitation/pom.xml
  68. 0 0
      svr/svr-rehabilitation/readme.MD
  69. 16 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/SvrRehabilitationApplication.java
  70. 49 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/SwaggerConfig.java
  71. 29 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/HibernateProperties.java
  72. 58 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/RehabilitationJpa.java
  73. 117 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationInformationController.java
  74. 99 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPerformanceController.java
  75. 119 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPlanningController.java
  76. 103 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationTreatmentProgramController.java
  77. 16 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationInformationDao.java
  78. 13 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationPerformanceDao.java
  79. 13 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationPlanningDao.java
  80. 13 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationTreatmentProgramDao.java
  81. 112 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationInformationService.java
  82. 77 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationPerformanceService.java
  83. 78 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationPlanningService.java
  84. 77 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationTreatmentProgramService.java
  85. 88 0
      svr/svr-rehabilitation/src/main/resources/application.yml
  86. 6 0
      svr/svr-rehabilitation/src/main/resources/banner.txt
  87. 46 0
      svr/svr-rehabilitation/src/main/resources/bootstrap.yml
  88. 61 0
      svr/svr-wlyy-archives/src/main/java/com/yihu/jw/util/ReflectUtil.java
  89. 125 0
      svr/svr-wlyy-specialist/pom.xml
  90. 1 0
      svr/svr-wlyy-specialist/readme.MD
  91. 18 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/SvrWlyySpecialistApplication.java
  92. 51 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/config/SwaggerConfig.java
  93. 29 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/config/jpa/HibernateProperties.java
  94. 58 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/config/jpa/WlyySpecialistJpa.java
  95. 109 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java
  96. 12 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/PatientHospitalRecordDao.java
  97. 12 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistArticleDao.java
  98. 12 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistConsultDao.java
  99. 12 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistDao.java
  100. 0 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java

+ 67 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/PatientHospitalRecordDO.java

@ -0,0 +1,67 @@
package com.yihu.jw.entity.specialist;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by Trick on 2018/4/24.
 */
@Entity
@Table(name = "wlyy_patient_hospital_record")
public class PatientHospitalRecordDO extends IdEntityWithOperation implements Serializable {
    private String saasId;//
    private String code;//智业记录code
    private String patient;//患者
    private String patientName;//患者姓名
    private String type;//出院:1;住院:0
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
}

+ 77 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistArticleDO.java

@ -0,0 +1,77 @@
package com.yihu.jw.entity.specialist;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by Trick on 2018/4/24.
 */
@Entity
@Table(name = "wlyy_specialist_Article")
public class SpecialistArticleDO extends IdEntityWithOperation implements Serializable {
    private String saasId;
    private String patient;//居民
    private String patientName;//居民
    private String doctor;//医生
    private String doctorName;//医生
    private String article;//文章
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "article")
    public String getArticle() {
        return article;
    }
    public void setArticle(String article) {
        this.article = article;
    }
}

+ 117 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistConsultDO.java

@ -0,0 +1,117 @@
package com.yihu.jw.entity.specialist;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by Trick on 2018/4/24.
 */
@Entity
@Table(name = "wlyy_specialist_consult")
public class SpecialistConsultDO extends IdEntityWithOperation implements Serializable {
    private String saasId;
    private String consult;//关联咨询code
    private String doctor;//专科医生
    private String doctorName;//专科医生姓名
    private String type;//类型:1.家庭医生咨询,2.居民咨询
    private String member;//咨询对象
    private String memberName;//咨询对象
    private String status;// 1.咨询完成,0.咨询进行中
    private String reply;// 1.专科医生已经参与;0.~未参与
    private String content;//咨询内容
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "consult")
    public String getConsult() {
        return consult;
    }
    public void setConsult(String consult) {
        this.consult = consult;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "member")
    public String getMember() {
        return member;
    }
    public void setMember(String member) {
        this.member = member;
    }
    @Column(name = "member_name")
    public String getMemberName() {
        return memberName;
    }
    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "reply")
    public String getReply() {
        return reply;
    }
    public void setReply(String reply) {
        this.reply = reply;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
}

+ 108 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistDO.java

@ -0,0 +1,108 @@
package com.yihu.jw.entity.specialist;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by Trick on 2018/4/24.
 */
@Entity
@Table(name = "wlyy_specialist")
public class SpecialistDO extends IdEntityWithOperation implements Serializable {
    private String saasId;
    private String name; //专科医生姓名
    private String profession; //专业
    private String professionName; // 专业名称
    private String dept; //科室
    private String deptName; //科室名称
    private String hospital;//医院
    private String hospitalName;//医院名称
    private String del;//1:有效;0:删除
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "profession")
    public String getProfession() {
        return profession;
    }
    public void setProfession(String profession) {
        this.profession = profession;
    }
    @Column(name = "profession_name")
    public String getProfessionName() {
        return professionName;
    }
    public void setProfessionName(String professionName) {
        this.professionName = professionName;
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 170 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java

@ -0,0 +1,170 @@
package com.yihu.jw.entity.specialist;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by Trick on 2018/4/24.
 */
@Entity
@Table(name = "wlyy_specialist_patient_relation")
public class SpecialistPatientRelationDO extends IdEntityWithOperation implements Serializable {
    private String saasId;
    private String dischargeRecord;//最新出院记录
    private String doctor;//专科医生
    private String doctorName;//专科医生姓名
    private String patient;// 居民(患者)
    private String patientName;//居民(患者)姓名
    private String status;//1.已经分配,0,待分配
    private String signCode;//签约code
    private String signDoctor;//签约医生
    private String signDoctorName;//签约医生
    private String healthDoctor;//健康管理师
    private String healthDoctorName;//健康管理师姓名
    private String signYear;//签约年度
    private Integer teamCode;//签约团队
    private Date signDate;//签约日期
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "discharge_record")
    public String getDischargeRecord() {
        return dischargeRecord;
    }
    public void setDischargeRecord(String dischargeRecord) {
        this.dischargeRecord = dischargeRecord;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "sign_code")
    public String getSignCode() {
        return signCode;
    }
    public void setSignCode(String signCode) {
        this.signCode = signCode;
    }
    @Column(name = "sign_doctor")
    public String getSignDoctor() {
        return signDoctor;
    }
    public void setSignDoctor(String signDoctor) {
        this.signDoctor = signDoctor;
    }
    @Column(name = "sign_doctor_name")
    public String getSignDoctorName() {
        return signDoctorName;
    }
    public void setSignDoctorName(String signDoctorName) {
        this.signDoctorName = signDoctorName;
    }
    @Column(name = "health_doctor")
    public String getHealthDoctor() {
        return healthDoctor;
    }
    public void setHealthDoctor(String healthDoctor) {
        this.healthDoctor = healthDoctor;
    }
    @Column(name = "health_doctor_name")
    public String getHealthDoctorName() {
        return healthDoctorName;
    }
    public void setHealthDoctorName(String healthDoctorName) {
        this.healthDoctorName = healthDoctorName;
    }
    @Column(name = "sign_year")
    public String getSignYear() {
        return signYear;
    }
    public void setSignYear(String signYear) {
        this.signYear = signYear;
    }
    @Column(name = "sign_date")
    public Date getSignDate() {
        return signDate;
    }
    public void setSignDate(Date signDate) {
        this.signDate = signDate;
    }
    @Column(name = "team_code")
    public Integer getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Integer teamCode) {
        this.teamCode = teamCode;
    }
}

+ 101 - 0
common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationInformationDO.java

@ -0,0 +1,101 @@
package com.yihu.jw.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 就诊信息表
 * @author humingfen on 2018/4/25.
 */
@Entity
@Table(name = "rehabilitation_information")
public class RehabilitationInformationDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "patient_id")
    private String patientId;//居民id
    @Column(name = "hospital")
    private String hospital;//就诊医院
    @Column(name = "departmen")
    private String departmen;//就诊科室
    @Column(name = "summary")
    private String summary;//诊断小结
    @Column(name = "advice")
    private String advice;//医嘱
    @Column(name = "disease")
    private String disease;//疾病标签
    @Column(name = "discharge_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date dischargeTime;//出院时间
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getDepartmen() {
        return departmen;
    }
    public void setDepartmen(String departmen) {
        this.departmen = departmen;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    public Date getDischargeTime() {
        return dischargeTime;
    }
    public void setDischargeTime(Date dischargeTime) {
        this.dischargeTime = dischargeTime;
    }
}

+ 81 - 0
common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationPerformanceDO.java

@ -0,0 +1,81 @@
package com.yihu.jw.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 康复计划执行情况表
 * @author humingfen on 2018/4/25.
 */
@Entity
@Table(name = "rehabilitation_performance")
public class RehabilitationPerformanceDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "program_id")
    private String programId;//治疗方案ID
    @Column(name = "start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private String startTime;//开始执行的时间
    @Column(name = "end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private String endTime;//结束执行的时间
    @Column(name = "status")
    private Integer status;//执行状态
    @Column(name = "description")
    private String description;//描述身体健康状态详情
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getProgramId() {
        return programId;
    }
    public void setProgramId(String programId) {
        this.programId = programId;
    }
    public String getStartTime() {
        return startTime;
    }
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 71 - 0
common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationPlanningDO.java

@ -0,0 +1,71 @@
package com.yihu.jw.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 康复计划表
 * @author humingfen on 2018/4/25.
 */
@Entity
@Table(name = "rehabilitation_planning")
public class RehabilitationPlanningDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "patient_id")
    private String patientId;//居民ID
    @Column(name = "program_id")
    private String programId;//治疗方案ID,可多个用逗号隔开
    @Column(name = "recheck_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date recheckTime;//复检时间
    @Column(name = "description")
    private String description;//附加说明,如先执行哪个方案,什么时间执行最佳
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getProgramId() {
        return programId;
    }
    public void setProgramId(String programId) {
        this.programId = programId;
    }
    public Date getRecheckTime() {
        return recheckTime;
    }
    public void setRecheckTime(Date recheckTime) {
        this.recheckTime = recheckTime;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 68 - 0
common/common-entity/src/main/java/com/yihu/jw/rehabilitation/RehabilitationTreatmentProgramDO.java

@ -0,0 +1,68 @@
package com.yihu.jw.rehabilitation;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 治疗方案表
 * @author humingfen on 2018/4/25.
 */
@Entity
@Table(name = "rehabilitation_treatment_program")
public class RehabilitationTreatmentProgramDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "name")
    private String name;
    @Column(name =  "frequency")
    private String frequency;
    @Column(name = "times_daily")
    private Integer timesDaily;
    @Column(name = "description")
    private String description;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getFrequency() {
        return frequency;
    }
    public void setFrequency(String frequency) {
        this.frequency = frequency;
    }
    public Integer getTimesDaily() {
        return timesDaily;
    }
    public void setTimesDaily(Integer timesDaily) {
        this.timesDaily = timesDaily;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 75 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/rehabilitation/RehabilitationRequestMapping.java

@ -0,0 +1,75 @@
package com.yihu.jw.rm.rehabilitation;
/**
 * Created by humingfen on 2018/4/25 .
 */
public class RehabilitationRequestMapping {
    public static final String api_rehabilitation_common = "svr-rehabilitation";
    /**
     * 公共模块
     */
    public static class Common {
        public static final String message_success_update = "update success";
        public static final String message_success_delete = "delete success";
        public static final String message_success_find = "find success";
        public static final String message_success_create = "create success";
        public static final String message_success_find_functions = "message_success_find_functions";
    }
    public static class Information {
        public static final String information = api_rehabilitation_common + "/information";
        public static final String api_create = "createInformation";
        public static final String api_delete = "delInformation";
        public static final String api_getById = "getInformationById";
        public static final String api_update = "updateInformation";
        public static final String findInformationById = "findInformationById";
        public static final String findInformationByPatientId = "findInformationByPatientId";
        public static final String findInformationPage = "findInformationPage";
    }
    public static class TreatmentProgram {
        public static final String treatmentProgram = api_rehabilitation_common + "/treatmentProgram";
        public static final String findTreatmentProgramPage = "findTreatmentProgramPage";
        public static final String api_create = "createTreatmentProgram";
        public static final String api_delete = "delTreatmentProgram";
        public static final String api_getById = "getTreatmentProgramById";
        public static final String api_update = "updateTreatmentProgram";
        public static final String findTreatmentProgramById = "findTreatmentProgramById";
    }
    public static class Planning {
        public static final String planning = api_rehabilitation_common + "/planning";
        public static final String findPlanningPage = "findPlanningPage";
        public static final String findTreatmentByProgramId = "findTreatmentByProgramId";
        public static final String api_create = "createPlanning";
        public static final String api_delete = "delPlanning";
        public static final String api_getById = "getPlanningById";
        public static final String api_update = "updatePlanning";
        public static final String findPlanningById = "findPlanningById";
    }
    public static class Performance {
        public static final String performance = api_rehabilitation_common + "/performance";
        public static final String findPerformancePage = "findPerformancePage";
        public static final String api_create = "createPerformance";
        public static final String api_delete = "delPerformance";
        public static final String api_getById = "getPerformanceById";
        public static final String api_update = "updatePerformance";
        public static final String findPerformanceById = "findPerformanceById";
    }
}

+ 20 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -0,0 +1,20 @@
package com.yihu.jw.rm.specialist;
/**
 * Created by Trick on 2018/4/25.
 */
public class SpecialistMapping {
    public static final String api_specialist_common = "svr-specialist";
    public static final Integer api_specialist_fail = -1;
    public static final String api_success ="succes";
    public static class specialist{
        public static final String createSpecialists = "/createSpecialists";
        public static final String createSpecialistRelation = "/createSpecialistRelation";
        public static final String createConsult = "/createConsult";
        public static final String createArticle = "/createArticle";
        public static final String findSpecialistPatientRelation = "/findSpecialistPatientRelation";
    }
}

+ 8 - 8
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java

@ -100,14 +100,14 @@ public class Envelop<T> extends BaseEnvelop implements Serializable {
    public static Envelop getSuccess(String message) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setStatus(200);
        return envelop;
    }
    public static Envelop getSuccess(String message, Object obj) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setObj(obj);
        envelop.setStatus(200);
        return envelop;
@ -115,7 +115,7 @@ public class Envelop<T> extends BaseEnvelop implements Serializable {
    public static Envelop getSuccess(String message, Object obj,Integer total) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setObj(obj);
        envelop.setTotalCount(total);
        envelop.setStatus(200);
@ -124,7 +124,7 @@ public class Envelop<T> extends BaseEnvelop implements Serializable {
    public static Envelop getSuccessListWithPage(String message, List detailModelList, int page, int size, Long count) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setPageSize(size);
        envelop.setDetailModelList(detailModelList);
        envelop.setCurrPage(page);
@ -135,21 +135,21 @@ public class Envelop<T> extends BaseEnvelop implements Serializable {
    public static Envelop getError(String message, int errorCode) {
        Envelop envelop = new Envelop();
        envelop.setErrorMsg(message);
        envelop.setMessage(message);
        envelop.setStatus(errorCode);
        return envelop;
    }
    public static Envelop getError(String message) {
        Envelop envelop = new Envelop();
        envelop.setErrorMsg(message);
        envelop.setMessage(message);
        envelop.setStatus(-1);
        return envelop;
    }
    public static Envelop getSuccessList(String message, List objList) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setDetailModelList(objList);
        envelop.setStatus(200);
        return envelop;
@ -157,7 +157,7 @@ public class Envelop<T> extends BaseEnvelop implements Serializable {
    public static Envelop getSuccessList(String message, List objList,Integer total) {
        Envelop envelop = new Envelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setDetailModelList(objList);
        envelop.setTotalCount(total);
        envelop.setStatus(200);

+ 0 - 3
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopList.java

@ -29,9 +29,6 @@ public class EnvelopList<T> extends BaseEnvelop implements Serializable {
    @ApiModelProperty("列表内容")
    private List<T> detailModelList;
    public EnvelopList(String errorMsg, String successMsg) {
        super(errorMsg, successMsg);
    }
    public List<T> getDetailModelList() {
        return detailModelList;

+ 4 - 19
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/EnvelopPage.java

@ -59,13 +59,6 @@ public class EnvelopPage<T> extends BaseEnvelop implements Serializable {
        this.detailModelList = detailModelList;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    public int getPageSize() {
@ -97,23 +90,15 @@ public class EnvelopPage<T> extends BaseEnvelop implements Serializable {
        this.totalPage = totalPage;
    }
    public String getSuccessMsg() {
        return successMsg;
    }
    public void setSuccessMsg(String successMsg) {
        this.successMsg = successMsg;
    }
    public static EnvelopPage getSuccess(String message) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        return envelop;
    }
    public static EnvelopPage getSuccessListWithPage(String message, List detailModelList, int page, int size, Long count) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setPageSize(size);
        envelop.setDetailModelList(detailModelList);
        envelop.setCurrPage(page);
@ -123,13 +108,13 @@ public class EnvelopPage<T> extends BaseEnvelop implements Serializable {
    public static EnvelopPage getError(String message, int errorCode) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setErrorMsg(message);
        envelop.setMessage(message);
        return envelop;
    }
    public static EnvelopPage getSuccessList(String message, List objList) {
        EnvelopPage envelop = new EnvelopPage();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setDetailModelList(objList);
        return envelop;
    }

+ 9 - 33
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/base/BaseEnvelop.java

@ -11,22 +11,14 @@ import io.swagger.annotations.ApiModelProperty;
@ApiModel(description = "基础实体")
public class BaseEnvelop {
    @ApiModelProperty("错误编码")
    protected String errorCode;
    @ApiModelProperty("成功信息")
    protected String errorMsg;
    @ApiModelProperty("成功信息")
    protected String successMsg;
    @ApiModelProperty("信息")
    protected String message;
    @ApiModelProperty("状态(200成功,-1是失败)")
    protected Integer status;
    public BaseEnvelop() {
    }
    public BaseEnvelop(String errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    public Integer getStatus() {
        return status;
@ -36,47 +28,31 @@ public class BaseEnvelop {
        this.status = status;
    }
    public String getErrorMsg() {
        return errorMsg;
    }
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    public String getSuccessMsg() {
        return successMsg;
    }
    public void setSuccessMsg(String successMsg) {
        this.successMsg = successMsg;
    }
    public String getErrorCode() {
        return errorCode;
    public String getMessage() {
        return message;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    public void setMessage(String message) {
        this.message = message;
    }
    public static BaseEnvelop getSuccess(String message) {
        BaseEnvelop envelop = new BaseEnvelop();
        envelop.setSuccessMsg(message);
        envelop.setMessage(message);
        envelop.setStatus(200);
        return envelop;
    }
    public static BaseEnvelop getError(String message, int errorCode) {
        BaseEnvelop envelop = new BaseEnvelop();
        envelop.setErrorMsg(message);
        envelop.setMessage(message);
        envelop.setStatus(errorCode);
        return envelop;
    }
    public static BaseEnvelop getError(String message) {
        BaseEnvelop envelop = new BaseEnvelop();
        envelop.setErrorMsg(message);
        envelop.setMessage(message);
        envelop.setStatus(-1);
        return envelop;
    }

+ 91 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationInformationVO.java

@ -0,0 +1,91 @@
package com.yihu.jw.restmodel.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
/**
 * 就诊信息表
 * @author humingfen on 2018/4/26.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "就诊记录表", description = "就诊记录表")
public class RehabilitationInformationVO extends BaseVO implements Serializable {
    @ApiModelProperty("居民id")
    private String patientId;
    @ApiModelProperty("就诊医院")
    private String hospital;
    @ApiModelProperty("就诊科室")
    private String department;
    @ApiModelProperty("诊断小结")
    private String summary;
    @ApiModelProperty("医嘱")
    private String advice;
    @ApiModelProperty("疾病标签")
    private String disease;
    @ApiModelProperty("出院时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    private Date dischargeTime;
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getDepartment() {
        return department;
    }
    public void setDepartment(String department) {
        this.department = department;
    }
    public String getSummary() {
        return summary;
    }
    public void setSummary(String summary) {
        this.summary = summary;
    }
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    public Date getDischargeTime() {
        return dischargeTime;
    }
    public void setDischargeTime(Date dischargeTime) {
        this.dischargeTime = dischargeTime;
    }
}

+ 71 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationPerformanceVO.java

@ -0,0 +1,71 @@
package com.yihu.jw.restmodel.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.sql.Date;
/**
 * 康复计划执行情况表
 * @author humingfen on 2018/5/2.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "康复计划执行情况表", description = "康复计划执行情况表")
public class RehabilitationPerformanceVO extends BaseVO implements Serializable {
    @ApiModelProperty("治疗方案id")
    private String programId;
    @ApiModelProperty("开始执行时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    private Date startTime;
    @ApiModelProperty("结束执行时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    private Date endTime;
    @ApiModelProperty("执行状态")
    private Integer status;
    @ApiModelProperty("身体健康状态说明")
    private String description;
    public String getProgramId() {
        return programId;
    }
    public void setProgramId(String programId) {
        this.programId = programId;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 63 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationPlanningVO.java

@ -0,0 +1,63 @@
package com.yihu.jw.restmodel.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
/**
 * 康复计划表
 * @author humingfen on 2018/5/2.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "康复计划表", description = "康复计划表")
public class RehabilitationPlanningVO extends BaseVO implements Serializable {
    @ApiModelProperty("居民id")
    private String patientId;
    @ApiModelProperty("治疗方案id")
    private String programId;
    @ApiModelProperty("复检时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    private Date recheckTime;
    @ApiModelProperty("附加说明")
    private String description;
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getProgramId() {
        return programId;
    }
    public void setProgramId(String programId) {
        this.programId = programId;
    }
    public Date getRecheckTime() {
        return recheckTime;
    }
    public void setRecheckTime(Date recheckTime) {
        this.recheckTime = recheckTime;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 57 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/rehabilitation/RehabilitationTreatmentProgramVO.java

@ -0,0 +1,57 @@
package com.yihu.jw.restmodel.rehabilitation;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 治疗方案表
 * @author humingfen on 2018/4/27.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "治疗方案表", description = "治疗方案表")
public class RehabilitationTreatmentProgramVO extends BaseVO implements Serializable {
    @ApiModelProperty("方案名称")
    private String name;
    @ApiModelProperty("训练次数/时间")
    private String frequency;
    @ApiModelProperty("每日次数")
    private Integer timesDaily;
    @ApiModelProperty("附加说明")
    private String description;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getFrequency() {
        return frequency;
    }
    public void setFrequency(String frequency) {
        this.frequency = frequency;
    }
    public Integer getTimesDaily() {
        return timesDaily;
    }
    public void setTimesDaily(Integer timesDaily) {
        this.timesDaily = timesDaily;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 166 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/SpecialistPatientRelationVO.java

@ -0,0 +1,166 @@
package com.yihu.jw.restmodel.specialist;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * Created by Trick on 2018/4/25.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "专科医生与居民匹配关系", description = "专科医生与居民匹配关系")
public class SpecialistPatientRelationVO {
    @ApiModelProperty("saasid")
    private String saasId;
    @ApiModelProperty("最新出院记录")
    private String dischargeRecord;//最新出院记录
    @ApiModelProperty("专科医生")
    private String doctor;//专科医生
    @ApiModelProperty("专科医生姓名")
    private String doctorName;//专科医生姓名
    @ApiModelProperty("居民(患者)")
    private String patient;// 居民(患者)
    @ApiModelProperty("居民(患者)姓名")
    private String patientName;//居民(患者)姓名
    @ApiModelProperty("1.已经分配,0,待分配")
    private String status;//1.已经分配,0,待分配
    @ApiModelProperty("签约code")
    private String signCode;//签约code
    @ApiModelProperty("签约医生")
    private String signDoctor;//签约医生
    @ApiModelProperty("签约医生")
    private String signDoctorName;//签约医生
    @ApiModelProperty("健康管理师")
    private String healthDoctor;//健康管理师
    @ApiModelProperty("健康管理师姓名")
    private String healthDoctorName;//健康管理师姓名
    @ApiModelProperty("签约年度")
    private String signYear;//签约年度
    @ApiModelProperty("签约团队")
    private Integer teamCode;//签约团队
    @ApiModelProperty("签约日期")
    private Date signDate;//签约日期
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getDischargeRecord() {
        return dischargeRecord;
    }
    public void setDischargeRecord(String dischargeRecord) {
        this.dischargeRecord = dischargeRecord;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getSignCode() {
        return signCode;
    }
    public void setSignCode(String signCode) {
        this.signCode = signCode;
    }
    public String getSignDoctor() {
        return signDoctor;
    }
    public void setSignDoctor(String signDoctor) {
        this.signDoctor = signDoctor;
    }
    public String getSignDoctorName() {
        return signDoctorName;
    }
    public void setSignDoctorName(String signDoctorName) {
        this.signDoctorName = signDoctorName;
    }
    public String getHealthDoctor() {
        return healthDoctor;
    }
    public void setHealthDoctor(String healthDoctor) {
        this.healthDoctor = healthDoctor;
    }
    public String getHealthDoctorName() {
        return healthDoctorName;
    }
    public void setHealthDoctorName(String healthDoctorName) {
        this.healthDoctorName = healthDoctorName;
    }
    public String getSignYear() {
        return signYear;
    }
    public void setSignYear(String signYear) {
        this.signYear = signYear;
    }
    public Integer getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Integer teamCode) {
        this.teamCode = teamCode;
    }
    public Date getSignDate() {
        return signDate;
    }
    public void setSignDate(Date signDate) {
        this.signDate = signDate;
    }
}

+ 4 - 0
server/svr-discovery/pom.xml

@ -38,6 +38,10 @@
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
        </dependency>
    </dependencies>
    <build>

+ 185 - 0
server/svr-discovery/src/main/java/com.yihu.jw/controller/DiscoveryController.java

@ -0,0 +1,185 @@
package com.yihu.jw.controller;
import com.netflix.appinfo.DataCenterInfo;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.appinfo.LeaseInfo;
import com.netflix.discovery.shared.Application;
import com.netflix.eureka.EurekaServerContext;
import com.netflix.eureka.cluster.PeerEurekaNode;
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
/**
 * Created by chenweida on 2018/5/5 0005.
 */
@RestController
@RequestMapping(value = "/discovery", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DiscoveryController {
    @Autowired
    private EurekaServerContext eurekaServerContext;
    /**
     * 获取发现服务的信息
     * @return
     */
    @GetMapping("eurukaMessage")
    public String eurukaMessage() {
        JSONObject jo = new JSONObject();
        jo.put("euruka服务器数", eurekaServerContext.getPeerEurekaNodes().getPeerEurekaNodes().size());
        EurekaInstanceConfig eurekaInstanceConfig = eurekaServerContext.getApplicationInfoManager().getEurekaInstanceConfig();
        jo.put("appGroupName", eurekaInstanceConfig.getAppGroupName());
        jo.put("getAppname", eurekaInstanceConfig.getAppname());
        jo.put("getASGName", eurekaInstanceConfig.getASGName());
        jo.put("DataCenterInfo-name", eurekaInstanceConfig.getDataCenterInfo().getName());
        jo.put("getDefaultAddressResolutionOrder", eurekaInstanceConfig.getDefaultAddressResolutionOrder());
        jo.put("getHealthCheckUrl", eurekaInstanceConfig.getHealthCheckUrl());
        jo.put("getHealthCheckUrlPath", eurekaInstanceConfig.getHealthCheckUrlPath());
        jo.put("getHomePageUrl", eurekaInstanceConfig.getHomePageUrl());
        jo.put("getHomePageUrlPath", eurekaInstanceConfig.getHomePageUrlPath());
        jo.put("getHostName", eurekaInstanceConfig.getHostName(true));
        jo.put("getInstanceId", eurekaInstanceConfig.getInstanceId());
        jo.put("getIpAddress", eurekaInstanceConfig.getIpAddress());
        jo.put("getLeaseExpirationDurationInSeconds", eurekaInstanceConfig.getLeaseExpirationDurationInSeconds());
        jo.put("getLeaseRenewalIntervalInSeconds", eurekaInstanceConfig.getLeaseRenewalIntervalInSeconds());
        jo.put("getMetadataMap", eurekaInstanceConfig.getMetadataMap());
        jo.put("getNamespace", eurekaInstanceConfig.getNamespace());
        jo.put("getNonSecurePort", eurekaInstanceConfig.getNonSecurePort());
        jo.put("getSecureHealthCheckUrl", eurekaInstanceConfig.getSecureHealthCheckUrl());
        jo.put("getSecurePort", eurekaInstanceConfig.getSecurePort());
        jo.put("getSecurePortEnabled", eurekaInstanceConfig.getSecurePortEnabled());
        jo.put("getSecureVirtualHostName", eurekaInstanceConfig.getSecureVirtualHostName());
        jo.put("getSecureHealthCheckUrl", eurekaInstanceConfig.getSecureHealthCheckUrl());
        JSONArray ja = new JSONArray();
        for (int i = 0; i < eurekaServerContext.getPeerEurekaNodes().getPeerNodesView().size(); i++) {
            PeerEurekaNode peerEurekaNode = eurekaServerContext.getPeerEurekaNodes().getPeerNodesView().get(i);
            JSONObject temp = new JSONObject();
            temp.put("服务器地址(serviceUrl)", peerEurekaNode.getServiceUrl());
            temp.put("batcherName", peerEurekaNode.getBatcherName());
            ja.add(temp);
        }
        jo.put("euruka服务器资料", ja);
        return jo.toString();
    }
    /**
     * 获取注册服务的信息
     * @return
     */
    @GetMapping("eurukaApplicationMessage")
    public String eurukaApplicationMessage() {
        PeerAwareInstanceRegistry peerAwareInstanceRegistry = eurekaServerContext.getRegistry();
        JSONObject jo = new JSONObject();
        jo.put("注册到发现服务的应用数目:", peerAwareInstanceRegistry.getApplications().size());
        JSONArray ja = new JSONArray();
        for (int i = 0; i < peerAwareInstanceRegistry.getApplications().getRegisteredApplications().size(); i++) {
            Application application = peerAwareInstanceRegistry.getApplications().getRegisteredApplications().get(i);
            JSONObject temp = new JSONObject();
            temp.put("名称", application.getName());
            ja.add(temp);
        }
        jo.put("服务列表",ja);
        return jo.toString();
    }
    /**
     * 注册服务
     * @param instanceId
     * @param appName
     * @param appGroupName
     * @param ipAddr
     * @param sid
     * @param port
     * @param securePort
     * @param homePageUrl
     * @param statusPageUrl
     * @param healthCheckUrl
     * @param secureHealthCheckUrl
     * @param vipAddress
     * @param secureVipAddress
     * @param countryId
     * @param dataCenterInfo
     * @param hostName
     * @param status
     * @param overriddenstatus
     * @param leaseInfo
     * @param isCoordinatingDiscoveryServer
     * @param metadata
     * @param lastUpdatedTimestamp
     * @param lastDirtyTimestamp
     * @param actionType
     * @param asgName
     * @return
     */
    @PostMapping("register")
    public String register(
            @RequestParam("instanceId") String instanceId,
            @RequestParam("app") String appName,
            @RequestParam("appGroupName") String appGroupName,
            @RequestParam("ipAddr") String ipAddr,
            @RequestParam("sid") String sid,
            @RequestParam("port") InstanceInfo.PortWrapper port,
            @RequestParam("securePort") InstanceInfo.PortWrapper securePort,
            @RequestParam("homePageUrl") String homePageUrl,
            @RequestParam("statusPageUrl") String statusPageUrl,
            @RequestParam("healthCheckUrl") String healthCheckUrl,
            @RequestParam("secureHealthCheckUrl") String secureHealthCheckUrl,
            @RequestParam("vipAddress") String vipAddress,
            @RequestParam("secureVipAddress") String secureVipAddress,
            @RequestParam("countryId") int countryId,
            @RequestParam("dataCenterInfo") DataCenterInfo dataCenterInfo,
            @RequestParam("hostName") String hostName,
            @RequestParam("status") InstanceInfo.InstanceStatus status,
            @RequestParam("overriddenstatus") InstanceInfo.InstanceStatus overriddenstatus,
            @RequestParam("leaseInfo") LeaseInfo leaseInfo,
            @RequestParam("isCoordinatingDiscoveryServer") Boolean isCoordinatingDiscoveryServer,
            @RequestParam("metadata") HashMap<String, String> metadata,
            @RequestParam("lastUpdatedTimestamp") Long lastUpdatedTimestamp,
            @RequestParam("lastDirtyTimestamp") Long lastDirtyTimestamp,
            @RequestParam("actionType") InstanceInfo.ActionType actionType,
            @RequestParam("asgName") String asgName
    ) {
        try {
            InstanceInfo info = new InstanceInfo(
                    instanceId, appName, appGroupName, ipAddr,
                    sid, port, securePort, homePageUrl,
                    statusPageUrl, healthCheckUrl, secureHealthCheckUrl, vipAddress,
                    secureVipAddress, countryId, dataCenterInfo, hostName,
                    status, overriddenstatus, leaseInfo, isCoordinatingDiscoveryServer,
                    metadata, lastUpdatedTimestamp, lastDirtyTimestamp, actionType, asgName);
            eurekaServerContext.getRegistry().register(info, true);
            return "注册成功";
        } catch (Exception e) {
            return "注册失败";
        }
    }
    /**
     * 取消注册
     * @param appName
     * @param id
     * @param isReplication
     * @return
     */
    @PostMapping("cancel")
    public String cancel(
            @RequestParam("appName") String appName,
            @RequestParam("id") String id,
            @RequestParam("isReplication") boolean isReplication
    ) {
        try {
            eurekaServerContext.getRegistry().cancel(appName, id, isReplication);
            return "取消成功";
        } catch (Exception e) {
            return "取消失败";
        }
    }
}

+ 1 - 0
svr-lib-parent-pom/pom.xml

@ -44,6 +44,7 @@
        <module>../svr/svr-wlyy</module><!--i健康微服务-->
        <!--<module>../svr/svr-manage</module>&lt;!&ndash;后台管理系统&ndash;&gt;-->
        <module>../svr/svr-iot</module><!--物联网平台-->
        <module>../svr/svr-rehabilitation</module><!--专科医生康复计划-->
        <!--网关-->
        <module>../web-gateway</module><!--web网关-->

+ 0 - 4
svr/svr-base/pom.xml

@ -60,10 +60,6 @@
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-mysql</artifactId>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.yihu.base</groupId>-->
            <!--<artifactId>common-security</artifactId>-->
        <!--</dependency>-->
        <!--公共的 end-->
        <dependency>

+ 27 - 27
svr/svr-base/src/main/java/com/yihu/jw/business/login/dao/BaseLoginAccountDao.java

@ -1,27 +1,27 @@
package com.yihu.jw.business.login.dao;
import com.yihu.jw.base.login.BaseLoginAccountDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by LiTaohong on 2017/12/05.
 * 账户表,识别用户类型,医生,行政人员等
 */
public interface BaseLoginAccountDao extends PagingAndSortingRepository<BaseLoginAccountDO, String>, JpaSpecificationExecutor<BaseLoginAccountDO> {
    /**
     * 删除用户账号
     * @param id
     */
    @Query("update BaseLoginAccountDO ba set ba.accountStatus = -1 where ba.id = ?1")
    void deleteAccount(String id);
    /**
     * 锁定用户账号
     * @param id
     */
    @Query("update BaseLoginAccountDO ba set ba.accountStatus = -2 where ba.id = ?1")
    void updateAccount(String id);
}
//package com.yihu.jw.business.login.dao;
//
//import com.yihu.jw.base.login.BaseLoginAccountDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by LiTaohong on 2017/12/05.
// * 账户表,识别用户类型,医生,行政人员等
// */
//public interface BaseLoginAccountDao extends PagingAndSortingRepository<BaseLoginAccountDO, String>, JpaSpecificationExecutor<BaseLoginAccountDO> {
//
//    /**
//     * 删除用户账号
//     * @param id
//     */
//    @Query("update BaseLoginAccountDO ba set ba.accountStatus = -1 where ba.id = ?1")
//    void deleteAccount(String id);
//
//    /**
//     * 锁定用户账号
//     * @param id
//     */
//    @Query("update BaseLoginAccountDO ba set ba.accountStatus = -2 where ba.id = ?1")
//    void updateAccount(String id);
//}

+ 11 - 11
svr/svr-base/src/main/java/com/yihu/jw/business/login/dao/BaseLoginLogDao.java

@ -1,11 +1,11 @@
package com.yihu.jw.business.login.dao;
import com.yihu.jw.base.login.BaseLoginLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/20.
 */
public interface BaseLoginLogDao extends PagingAndSortingRepository<BaseLoginLogDO, String>, JpaSpecificationExecutor<BaseLoginLogDO> {
}
//package com.yihu.jw.business.login.dao;
//
//import com.yihu.jw.base.login.BaseLoginLogDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by chenweida on 2017/6/20.
// */
//public interface BaseLoginLogDao extends PagingAndSortingRepository<BaseLoginLogDO, String>, JpaSpecificationExecutor<BaseLoginLogDO> {
//}

+ 75 - 75
svr/svr-base/src/main/java/com/yihu/jw/business/login/service/BaseLoginAccountService.java

@ -1,75 +1,75 @@
package com.yihu.jw.business.login.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.login.BaseLoginAccountDO;
import com.yihu.jw.business.login.dao.BaseLoginAccountDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
/**
 * Created by LiTaohong on 2017/12/5.
 * 用户账户功能
 */
@Service
public class BaseLoginAccountService extends BaseJpaService<BaseLoginAccountDO,BaseLoginAccountDao> {
    @Autowired
    private BaseLoginAccountDao baseLoginAccountDao;
    /**
     * 创建账户
     * @param baseLoginAccountDO
     * @return
     */
    @Transactional
    public BaseLoginAccountDO createBaseLoginAccount(BaseLoginAccountDO baseLoginAccountDO){
        if (StringUtils.isEmpty(baseLoginAccountDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseLoginAccountDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseLoginAccountDao.save(baseLoginAccountDO);
    }
    /**
     * 修改账户
     * @param baseLoginAccountDO
     * @return
     */
    @Transactional
    public BaseLoginAccountDO updateBaseLoginAccount(BaseLoginAccountDO baseLoginAccountDO){
        return this.baseLoginAccountDao.save(baseLoginAccountDO);
    }
    /**
     * 锁定账户
     * @param id
     * @return
     */
    @Transactional
    public void lockBaseLoginAccount(String id){
         this.baseLoginAccountDao.updateAccount(id);
    }
    /**
     * 删除账户
     * @param id
     * @return
     */
    @Transactional
    public void deleteBaseLoginAccount(String id){
         this.baseLoginAccountDao.deleteAccount(id);
    }
}
//package com.yihu.jw.business.login.service;
//
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.base.login.BaseLoginAccountDO;
//import com.yihu.jw.business.login.dao.BaseLoginAccountDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
///**
// * Created by LiTaohong on 2017/12/5.
// * 用户账户功能
// */
//@Service
//public class BaseLoginAccountService extends BaseJpaService<BaseLoginAccountDO,BaseLoginAccountDao> {
//
//    @Autowired
//    private BaseLoginAccountDao baseLoginAccountDao;
//
//    /**
//     * 创建账户
//     * @param baseLoginAccountDO
//     * @return
//     */
//    @Transactional
//    public BaseLoginAccountDO createBaseLoginAccount(BaseLoginAccountDO baseLoginAccountDO){
//        if (StringUtils.isEmpty(baseLoginAccountDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseLoginAccountDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseLoginAccountDao.save(baseLoginAccountDO);
//    }
//
//
//    /**
//     * 修改账户
//     * @param baseLoginAccountDO
//     * @return
//     */
//    @Transactional
//    public BaseLoginAccountDO updateBaseLoginAccount(BaseLoginAccountDO baseLoginAccountDO){
//        return this.baseLoginAccountDao.save(baseLoginAccountDO);
//    }
//
//
//    /**
//     * 锁定账户
//     * @param id
//     * @return
//     */
//    @Transactional
//    public void lockBaseLoginAccount(String id){
//         this.baseLoginAccountDao.updateAccount(id);
//    }
//
//    /**
//     * 删除账户
//     * @param id
//     * @return
//     */
//    @Transactional
//    public void deleteBaseLoginAccount(String id){
//         this.baseLoginAccountDao.deleteAccount(id);
//    }
//
//
//
//
//}

+ 20 - 20
svr/svr-base/src/main/java/com/yihu/jw/business/sms/dao/SmsGatewayDao.java

@ -1,20 +1,20 @@
package com.yihu.jw.business.sms.dao;
import com.yihu.jw.base.sms.BaseSmsGatewayDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface SmsGatewayDao extends PagingAndSortingRepository<BaseSmsGatewayDO, String>, JpaSpecificationExecutor<BaseSmsGatewayDO> {
    @Query("from BaseSmsGatewayDO f where f.name=?1 and f.status=1")
    BaseSmsGatewayDO findByName(String name);
    @Query("from BaseSmsGatewayDO f where f.name=?1 and f.status=1 and f.id != ?2")
    BaseSmsGatewayDO findByNameExcludeCode(String name, String code);
    @Query("from BaseSmsGatewayDO f where f.id=?1 and f.status=1")
    BaseSmsGatewayDO findById(String id);
}
//package com.yihu.jw.business.sms.dao;
//
//import com.yihu.jw.base.sms.BaseSmsGatewayDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by chenweida on 2017/5/22.
// */
//public interface SmsGatewayDao extends PagingAndSortingRepository<BaseSmsGatewayDO, String>, JpaSpecificationExecutor<BaseSmsGatewayDO> {
//    @Query("from BaseSmsGatewayDO f where f.name=?1 and f.status=1")
//    BaseSmsGatewayDO findByName(String name);
//
//    @Query("from BaseSmsGatewayDO f where f.name=?1 and f.status=1 and f.id != ?2")
//    BaseSmsGatewayDO findByNameExcludeCode(String name, String code);
//
//    @Query("from BaseSmsGatewayDO f where f.id=?1 and f.status=1")
//    BaseSmsGatewayDO findById(String id);
//}

+ 68 - 68
svr/svr-base/src/main/java/com/yihu/jw/business/sms/service/SmsGatewayService.java

@ -1,68 +1,68 @@
package com.yihu.jw.business.sms.service;
import com.yihu.jw.base.sms.BaseSmsGatewayDO;
import com.yihu.jw.business.sms.dao.SmsGatewayDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rm.base.BaseSmsRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
/**
 * Created by chenweida on 2017/5/22.
 */
@Service
public class SmsGatewayService extends BaseJpaService<BaseSmsGatewayDO, SmsGatewayDao> {
    @Autowired
    private SmsGatewayDao smsGatewayDao;
    @Transactional
    public BaseSmsGatewayDO createSmsGateway(BaseSmsGatewayDO smsGateway) throws ApiException {
        if (StringUtils.isEmpty(smsGateway.getId())) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        BaseSmsGatewayDO smsGatewayTmp = smsGatewayDao.findByName(smsGateway.getName());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
    @Transactional
    public BaseSmsGatewayDO updateSmsGateway(BaseSmsGatewayDO smsGateway) {
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getId())) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        BaseSmsGatewayDO smsGatewayTmp = smsGatewayDao.findByNameExcludeCode(smsGateway.getName(), smsGateway.getId());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
    public BaseSmsGatewayDO findById(String id) {
        BaseSmsGatewayDO smsGateway = smsGatewayDao.findById(id);
        if (smsGateway == null) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return smsGateway;
    }
    @Transactional
    public void deleteSmsGateway(String id) {
        BaseSmsGatewayDO smsGateway = smsGatewayDao.findById(id);
        if (smsGateway == null) {
            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        smsGateway.setStatus(-1);
    }
}
//package com.yihu.jw.business.sms.service;
//
//import com.yihu.jw.base.sms.BaseSmsGatewayDO;
//import com.yihu.jw.business.sms.dao.SmsGatewayDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.BaseSmsRequestMapping;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
///**
// * Created by chenweida on 2017/5/22.
// */
//@Service
//public class SmsGatewayService extends BaseJpaService<BaseSmsGatewayDO, SmsGatewayDao> {
//    @Autowired
//    private SmsGatewayDao smsGatewayDao;
//
//    @Transactional
//    public BaseSmsGatewayDO createSmsGateway(BaseSmsGatewayDO smsGateway) throws ApiException {
//        if (StringUtils.isEmpty(smsGateway.getId())) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(smsGateway.getName())) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        BaseSmsGatewayDO smsGatewayTmp = smsGatewayDao.findByName(smsGateway.getName());
//        if (smsGatewayTmp != null) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return smsGatewayDao.save(smsGateway);
//    }
//
//    @Transactional
//    public BaseSmsGatewayDO updateSmsGateway(BaseSmsGatewayDO smsGateway) {
//        if (StringUtils.isEmpty(smsGateway.getName())) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(smsGateway.getId())) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        BaseSmsGatewayDO smsGatewayTmp = smsGatewayDao.findByNameExcludeCode(smsGateway.getName(), smsGateway.getId());
//        if (smsGatewayTmp != null) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return smsGatewayDao.save(smsGateway);
//    }
//
//    public BaseSmsGatewayDO findById(String id) {
//        BaseSmsGatewayDO smsGateway = smsGatewayDao.findById(id);
//        if (smsGateway == null) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        return smsGateway;
//    }
//
//    @Transactional
//    public void deleteSmsGateway(String id) {
//        BaseSmsGatewayDO smsGateway = smsGatewayDao.findById(id);
//        if (smsGateway == null) {
//            throw new ApiException(BaseSmsRequestMapping.SmsGateway.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        smsGateway.setStatus(-1);
//    }
//}

+ 95 - 95
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseMenuController.java

@ -1,95 +1,95 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.service.BaseMenuService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@RestController
@RequestMapping(BaseUserRequestMapping.api_user_common)
@Api(description = "基础菜单")
public class BaseMenuController extends EnvelopRestController {
    @Autowired
    private BaseMenuService baseMenuService;
    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建菜单", notes = "创建单个菜单")
    public Envelop createBaseMenu(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,baseMenuService.createBaseMenu(baseMenuDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改菜单", notes = "修改菜单")
    public Envelop updateBaseMenu(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_update,baseMenuService.updateBaseMenuDO(baseMenuDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_getOne, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询单个菜单", notes = "根据菜单id查询菜单信息")
    public Envelop getOneMenuById(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_find,baseMenuService.findById(baseMenuDO.getId()));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_getchildren, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询单个菜单的所有子菜单信息", notes = "根据平台和菜单名称查询菜单信息")
    public Envelop getChlidrenMenuList(@ApiParam(name = "saasId", value = "", defaultValue = "") @RequestParam String saasId,
                                       @ApiParam(name = "parentId", value = "", defaultValue = "") @RequestParam String parentId){
        try{
            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_find,baseMenuService.getChlidrenMenuList(saasId,parentId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_getList, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询多个菜单", notes = "根据平台saasId查询所有菜单信息")
    public Envelop getMenuListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_find,baseMenuService.findAllBySaasId(baseMenuDO.getSaasId()));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量删除菜单", notes = "删除某一平台saasId下所有菜单信息")
    public Envelop deleteMenusBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
            baseMenuService.deleteBaseMenusBySaasId(baseMenuDO.getSaasId());
            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete);
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}
//package com.yihu.jw.business.user.contorller;
//
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.business.user.service.BaseMenuService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//@RestController
//@RequestMapping(BaseUserRequestMapping.api_user_common)
//@Api(description = "基础菜单")
//public class BaseMenuController extends EnvelopRestController {
//
//    @Autowired
//    private BaseMenuService baseMenuService;
//
//    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建菜单", notes = "创建单个菜单")
//    public Envelop createBaseMenu(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,baseMenuService.createBaseMenu(baseMenuDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改菜单", notes = "修改菜单")
//    public Envelop updateBaseMenu(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_update,baseMenuService.updateBaseMenuDO(baseMenuDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_getOne, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询单个菜单", notes = "根据菜单id查询菜单信息")
//    public Envelop getOneMenuById(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_find,baseMenuService.findById(baseMenuDO.getId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_getchildren, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询单个菜单的所有子菜单信息", notes = "根据平台和菜单名称查询菜单信息")
//    public Envelop getChlidrenMenuList(@ApiParam(name = "saasId", value = "", defaultValue = "") @RequestParam String saasId,
//                                       @ApiParam(name = "parentId", value = "", defaultValue = "") @RequestParam String parentId){
//        try{
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_find,baseMenuService.getChlidrenMenuList(saasId,parentId));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_getList, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询多个菜单", notes = "根据平台saasId查询所有菜单信息")
//    public Envelop getMenuListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_find,baseMenuService.findAllBySaasId(baseMenuDO.getSaasId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "批量删除菜单", notes = "删除某一平台saasId下所有菜单信息")
//    public Envelop deleteMenusBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseMenuDO baseMenuDO = toEntity(jsonData,BaseMenuDO.class);
//            baseMenuService.deleteBaseMenusBySaasId(baseMenuDO.getSaasId());
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete);
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//}

+ 220 - 220
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseRoleController.java

@ -1,220 +1,220 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.base.user.BaseRoleMenuDO;
import com.yihu.jw.business.user.service.BaseRoleMenuService;
import com.yihu.jw.business.user.service.BaseRoleService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.user.BaseEmployVO;
import com.yihu.jw.restmodel.base.user.BaseRoleVO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@RestController
@RequestMapping(BaseUserRequestMapping.api_user_common)
@Api(description = "基础角色")
public class BaseRoleController extends EnvelopRestController {
    @Autowired
    private BaseRoleService baseRoleService;
    @Autowired
    private BaseRoleMenuService baseRoleMenuService;
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建角色", notes = "创建单个角色")
    public Envelop createRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_create,baseRoleService.createBaseRole(baseRoleDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改角色", notes = "修改角色")
    public Envelop updateBaseRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_update,baseRoleService.updateBaseRole(baseRoleDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询单个角色", notes = "根据角色id查询角色信息")
    public Envelop getOneRoleById(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findById(baseRoleDO.getId()));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getOne, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询单个角色", notes = "根据平台和角色名称查询角色信息")
    public Envelop getOneRoleBySaasIdAndName(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findBySaasIdAndName(baseRoleDO.getName(),baseRoleDO.getSaasId()));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getlistNoPage, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询多个角色", notes = "根据平台id查询所有角色信息,不分页")
    public Envelop getRoleListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findAllBySaasId(baseRoleDO.getSaasId()));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据指定条件查询所有角色列表,分页")
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getListPage)
    public Envelop getRoleListPage(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,remark") @RequestParam(value = "fields", required = false) String fields,
                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
        if (StringUtils.isBlank(filters)) {
            return Envelop.getError(BaseUserRequestMapping.BaseRole.message_fail_params_not_present, ExceptionCode.common_error_params_code);
        } else {
            filters = "status<>-1;" + filters;
        }
        if (StringUtils.isBlank(sorts)) {
            sorts = "-updateTime";
        }
        //得到list数据
        List<BaseRoleVO> list = baseRoleService.search(fields, filters, sorts, page, size);
        //获取总数
        long count = baseRoleService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<BaseRoleVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseRoleVO.class, fields);
        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseRole.message_success_find, mFunctions, page, size, count);
    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除角色", notes = "根据角色id删除角色")
    public Envelop deleteRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            baseRoleService.deleteBaseRole(baseRoleDO);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_deleteBySaasId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量删除角色", notes = "删除某一平台下所有角色信息")
    public Envelop deleteRolesBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
            baseRoleService.deleteBaseRolesBySaasId(baseRoleDO.getSaasId());
            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "給角色添加菜单", notes = "給角色添加菜单")
    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Envelop addMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
        try{
            String[] menuIdArray = menuIds.split(",");
            List<BaseRoleMenuDO> list = new ArrayList<>();
            for(String menuId:menuIdArray){
                BaseRoleMenuDO baseRoleMenuDO = new BaseRoleMenuDO();
                baseRoleMenuDO.setRoleId(roleId);
                baseRoleMenuDO.setRoleId(menuId);
            }
            if(menuIdArray.length < 1){
                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBaseRoleMenuDO(list.get(0)));
            }else{
                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBatchBaseRoleMenuDO(list));
            }
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "修改角色菜单")
    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_update)
    public Envelop updateMenuForRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
                                    @ApiParam(name = "newMenuId", value = "newMenuId", required = true) @RequestParam(value = "roleId", required = true) String newMenuId) {
        try {
            BaseRoleMenuDO baseEmployRoleDO = new BaseRoleMenuDO();
            baseEmployRoleDO.setId(id);
            baseEmployRoleDO.setMenuId(newMenuId);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.updateBaseEmployRoleDO(baseEmployRoleDO));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "查看角色菜单列表,不分页")
    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_getListNoPage)
    public Envelop findMenuListForRole(@ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String roleId) {
        try {
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.findAllByRoleId(roleId));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "删除角色菜单", notes = "删除角色菜单")
    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Envelop deleteMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
        try{
            String[] menuIdArray = menuIds.split(",");
            if(menuIdArray.length < 1){
                this.baseRoleMenuService.deleteBaseRoleMenuDO(roleId,menuIds);
                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色单个菜单信息");
            }else{
                this.baseRoleMenuService.deleteBatchBaseRoleMenuDO(roleId,menuIds);
                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色多个菜单信息");
            }
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}
//package com.yihu.jw.business.user.contorller;
//
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.base.user.BaseRoleMenuDO;
//import com.yihu.jw.business.user.service.BaseRoleMenuService;
//import com.yihu.jw.business.user.service.BaseRoleService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.base.user.BaseEmployVO;
//import com.yihu.jw.restmodel.base.user.BaseRoleVO;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//@RestController
//@RequestMapping(BaseUserRequestMapping.api_user_common)
//@Api(description = "基础角色")
//public class BaseRoleController extends EnvelopRestController {
//
//    @Autowired
//    private BaseRoleService baseRoleService;
//
//    @Autowired
//    private BaseRoleMenuService baseRoleMenuService;
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建角色", notes = "创建单个角色")
//    public Envelop createRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_create,baseRoleService.createBaseRole(baseRoleDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改角色", notes = "修改角色")
//    public Envelop updateBaseRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_update,baseRoleService.updateBaseRole(baseRoleDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询单个角色", notes = "根据角色id查询角色信息")
//    public Envelop getOneRoleById(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findById(baseRoleDO.getId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getOne, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询单个角色", notes = "根据平台和角色名称查询角色信息")
//    public Envelop getOneRoleBySaasIdAndName(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findBySaasIdAndName(baseRoleDO.getName(),baseRoleDO.getSaasId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getlistNoPage, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询多个角色", notes = "根据平台id查询所有角色信息,不分页")
//    public Envelop getRoleListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findAllBySaasId(baseRoleDO.getSaasId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "根据指定条件查询所有角色列表,分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getListPage)
//    public Envelop getRoleListPage(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,remark") @RequestParam(value = "fields", required = false) String fields,
//                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
//                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
//                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
//                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
//                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
//        if (StringUtils.isBlank(filters)) {
//            return Envelop.getError(BaseUserRequestMapping.BaseRole.message_fail_params_not_present, ExceptionCode.common_error_params_code);
//        } else {
//            filters = "status<>-1;" + filters;
//        }
//        if (StringUtils.isBlank(sorts)) {
//            sorts = "-updateTime";
//        }
//
//        //得到list数据
//        List<BaseRoleVO> list = baseRoleService.search(fields, filters, sorts, page, size);
//
//        //获取总数
//        long count = baseRoleService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<BaseRoleVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseRoleVO.class, fields);
//
//        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseRole.message_success_find, mFunctions, page, size, count);
//    }
//
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "删除角色", notes = "根据角色id删除角色")
//    public Envelop deleteRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            baseRoleService.deleteBaseRole(baseRoleDO);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_deleteBySaasId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "批量删除角色", notes = "删除某一平台下所有角色信息")
//    public Envelop deleteRolesBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            baseRoleService.deleteBaseRolesBySaasId(baseRoleDO.getSaasId());
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "給角色添加菜单", notes = "給角色添加菜单")
//    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Envelop addMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
//                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
//        try{
//            String[] menuIdArray = menuIds.split(",");
//            List<BaseRoleMenuDO> list = new ArrayList<>();
//            for(String menuId:menuIdArray){
//                BaseRoleMenuDO baseRoleMenuDO = new BaseRoleMenuDO();
//                baseRoleMenuDO.setRoleId(roleId);
//                baseRoleMenuDO.setRoleId(menuId);
//            }
//            if(menuIdArray.length < 1){
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBaseRoleMenuDO(list.get(0)));
//            }else{
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBatchBaseRoleMenuDO(list));
//            }
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @ApiOperation(value = "修改角色菜单")
//    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_update)
//    public Envelop updateMenuForRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
//                                    @ApiParam(name = "newMenuId", value = "newMenuId", required = true) @RequestParam(value = "roleId", required = true) String newMenuId) {
//        try {
//            BaseRoleMenuDO baseEmployRoleDO = new BaseRoleMenuDO();
//            baseEmployRoleDO.setId(id);
//            baseEmployRoleDO.setMenuId(newMenuId);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.updateBaseEmployRoleDO(baseEmployRoleDO));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "查看角色菜单列表,不分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_getListNoPage)
//    public Envelop findMenuListForRole(@ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String roleId) {
//        try {
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.findAllByRoleId(roleId));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @ApiOperation(value = "删除角色菜单", notes = "删除角色菜单")
//    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Envelop deleteMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
//                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
//        try{
//            String[] menuIdArray = menuIds.split(",");
//            if(menuIdArray.length < 1){
//                this.baseRoleMenuService.deleteBaseRoleMenuDO(roleId,menuIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色单个菜单信息");
//            }else{
//                this.baseRoleMenuService.deleteBatchBaseRoleMenuDO(roleId,menuIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色多个菜单信息");
//            }
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//}

+ 203 - 203
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployController.java

@ -1,203 +1,203 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.base.base.FunctionDO;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.business.user.service.EmployRoleService;
import com.yihu.jw.business.user.service.EmployService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.base.FunctionVO;
import com.yihu.jw.restmodel.base.user.BaseEmployVO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 */
@RestController
@RequestMapping(BaseUserRequestMapping.api_user_common)
@Api(description = "医生,行政人员等非患者用户(基础用户)")
public class EmployController extends EnvelopRestController {
    @Autowired
    private EmployService employService;
    @Autowired
    private EmployRoleService employRoleService;
    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建用户", notes = "创建单个用户")
    public Envelop createBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_create,employService.createBaseEmployDO(baseEmployDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改用户", notes = "修改用户")
    public Envelop updateBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_update,employService.updateBaseEmployDO(baseEmployDO));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据id查找用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
    public Envelop getEmployeeById(@ApiParam(name = "id", value = "id", required = true) @RequestParam(value = "id", required = true) String id) {
        try{
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findById(id));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据saasId查找所有用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListBySaasId)
    public Envelop getAllEmployeeBySaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
        try{
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllBySaasId(saasId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据手机号和saasId查找用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getByPhone)
    public Envelop getEmployeeByPhoneAndSaasId(@ApiParam(name = "phone", value = "phone", required = true) @RequestParam(value = "phone", required = true) String phone,
                                               @ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
        try {
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employService.findByPhoneAndSaasId(phone,saasId));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据name模糊查询某saasId平台下的所有用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListByName)
    public Envelop getListByNameAndSaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId,
                                          @ApiParam(name = "name", value = "name", required = true) @RequestParam(value = "name", required = true) String name) {
        try{
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllByNameAndSaasId(name,saasId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据指定条件查询用户列表,分页")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListNoPage)
    public Envelop getListPageByNameAndSaasId(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,sex,photo,skill,email,phone,family_tel,introduction,jxzc,lczc,xlzc,xzzc") @RequestParam(value = "fields", required = false) String fields,
                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
        if (StringUtils.isBlank(filters)) {
            return Envelop.getError(BaseUserRequestMapping.BaseEmploy.message_fail_params_not_present, ExceptionCode.common_error_params_code);
        } else {
            filters = "status<>-1;" + filters;
        }
        if (StringUtils.isBlank(sorts)) {
            sorts = "-updateTime";
        }
        //得到list数据
        List<BaseEmployVO> list = employService.search(fields, filters, sorts, page, size);
        //获取总数
        long count = employService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<BaseEmployVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseEmployVO.class, fields);
        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseEmploy.message_success_find, mFunctions, page, size, count);
    }
    @ApiOperation(value = "给某一用户新增角色")
    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_create)
    public Envelop createEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
        try {
            String[] roleIdArray = roleIds.split(",");
            List<BaseEmployRoleDO> list = new ArrayList<>();
            for (String roleId : roleIdArray) {
                BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
                baseEmployRoleDO.setEmployId(employId);
                baseEmployRoleDO.setRoleId(roleId);
                list.add(baseEmployRoleDO);
            }
            if (roleIdArray.length < 1) {
                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBaseEmployRoleDO(list.get(0)));
            }else{
                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBatchBaseEmployRoleDO(list));
            }
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "修改用户角色")
    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_update)
    public Envelop updateEmployRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
                                    @ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String newRoleId) {
        try {
            BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
            baseEmployRoleDO.setId(id);
            baseEmployRoleDO.setRoleId(newRoleId);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.updateBaseEmployRoleDO(baseEmployRoleDO));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "查看用户角色列表,不分页")
    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_getListNoPage)
    public Envelop findEmployRoleList(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId) {
        try {
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.findAllByEmployId(employId));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "删除用户角色")
    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_delete)
    public Envelop deleteEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
        try {
            String[] idArray = roleIds.split(",");
            if (idArray.length < 1) {
                this.employRoleService.deleteBaseEmployRoleDO(employId,roleIds);
                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete,"删除单个角色");
            }else{
                this.employRoleService.deleteBatchBaseEmployRoleDO(employId,roleIds);
                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, "删除多个角色");
            }
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}
//package com.yihu.jw.business.user.contorller;
//
//import com.yihu.jw.base.base.FunctionDO;
//import com.yihu.jw.base.user.BaseEmployDO;
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.business.user.service.EmployRoleService;
//import com.yihu.jw.business.user.service.EmployService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.base.base.FunctionVO;
//import com.yihu.jw.restmodel.base.user.BaseEmployVO;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/11.
// */
//@RestController
//@RequestMapping(BaseUserRequestMapping.api_user_common)
//@Api(description = "医生,行政人员等非患者用户(基础用户)")
//public class EmployController extends EnvelopRestController {
//    @Autowired
//    private EmployService employService;
//
//    @Autowired
//    private EmployRoleService employRoleService;
//
//    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建用户", notes = "创建单个用户")
//    public Envelop createBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_create,employService.createBaseEmployDO(baseEmployDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改用户", notes = "修改用户")
//    public Envelop updateBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_update,employService.updateBaseEmployDO(baseEmployDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "根据id查找用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
//    public Envelop getEmployeeById(@ApiParam(name = "id", value = "id", required = true) @RequestParam(value = "id", required = true) String id) {
//        try{
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findById(id));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "根据saasId查找所有用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListBySaasId)
//    public Envelop getAllEmployeeBySaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
//        try{
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllBySaasId(saasId));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @ApiOperation(value = "根据手机号和saasId查找用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getByPhone)
//    public Envelop getEmployeeByPhoneAndSaasId(@ApiParam(name = "phone", value = "phone", required = true) @RequestParam(value = "phone", required = true) String phone,
//                                               @ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
//        try {
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employService.findByPhoneAndSaasId(phone,saasId));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "根据name模糊查询某saasId平台下的所有用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListByName)
//    public Envelop getListByNameAndSaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId,
//                                          @ApiParam(name = "name", value = "name", required = true) @RequestParam(value = "name", required = true) String name) {
//        try{
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllByNameAndSaasId(name,saasId));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "根据指定条件查询用户列表,分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListNoPage)
//    public Envelop getListPageByNameAndSaasId(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,sex,photo,skill,email,phone,family_tel,introduction,jxzc,lczc,xlzc,xzzc") @RequestParam(value = "fields", required = false) String fields,
//                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
//                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
//                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
//                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
//                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
//        if (StringUtils.isBlank(filters)) {
//            return Envelop.getError(BaseUserRequestMapping.BaseEmploy.message_fail_params_not_present, ExceptionCode.common_error_params_code);
//        } else {
//            filters = "status<>-1;" + filters;
//        }
//        if (StringUtils.isBlank(sorts)) {
//            sorts = "-updateTime";
//        }
//
//        //得到list数据
//        List<BaseEmployVO> list = employService.search(fields, filters, sorts, page, size);
//
//        //获取总数
//        long count = employService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<BaseEmployVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseEmployVO.class, fields);
//
//        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseEmploy.message_success_find, mFunctions, page, size, count);
//    }
//
//
//    @ApiOperation(value = "给某一用户新增角色")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_create)
//    public Envelop createEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
//                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
//        try {
//            String[] roleIdArray = roleIds.split(",");
//            List<BaseEmployRoleDO> list = new ArrayList<>();
//            for (String roleId : roleIdArray) {
//                BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
//                baseEmployRoleDO.setEmployId(employId);
//                baseEmployRoleDO.setRoleId(roleId);
//                list.add(baseEmployRoleDO);
//            }
//            if (roleIdArray.length < 1) {
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBaseEmployRoleDO(list.get(0)));
//            }else{
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBatchBaseEmployRoleDO(list));
//            }
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "修改用户角色")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_update)
//    public Envelop updateEmployRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
//                                    @ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String newRoleId) {
//        try {
//            BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
//            baseEmployRoleDO.setId(id);
//            baseEmployRoleDO.setRoleId(newRoleId);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.updateBaseEmployRoleDO(baseEmployRoleDO));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "查看用户角色列表,不分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_getListNoPage)
//    public Envelop findEmployRoleList(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId) {
//        try {
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.findAllByEmployId(employId));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @ApiOperation(value = "删除用户角色")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_delete)
//    public Envelop deleteEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
//                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
//        try {
//            String[] idArray = roleIds.split(",");
//            if (idArray.length < 1) {
//                this.employRoleService.deleteBaseEmployRoleDO(employId,roleIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete,"删除单个角色");
//            }else{
//                this.employRoleService.deleteBatchBaseEmployRoleDO(employId,roleIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, "删除多个角色");
//            }
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//}

+ 28 - 28
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/PatientController.java

@ -1,28 +1,28 @@
package com.yihu.jw.business.user.contorller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida on 2017/5/10.
 */
@RestController
@RequestMapping("/patient")
@Api(description = "患者")
public class PatientController {
    @Autowired
    private Tracer tracer;
    @ApiOperation(value = "根据code查找患者")
    @GetMapping(value = "findByCode")
    public String findByCode(
            @ApiParam(name = "code", value = "患者code", required = true)@RequestParam(value = "code", required = true) String code) {
      tracer.getCurrentSpan().logEvent("进入微服务查询患者");
       return "调用根据code查找患者";
    }
}
//package com.yihu.jw.business.user.contorller;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.sleuth.Tracer;
//import org.springframework.web.bind.annotation.*;
//
///**
// * Created by chenweida on 2017/5/10.
// */
//@RestController
//@RequestMapping("/patient")
//@Api(description = "患者")
//public class PatientController {
//    @Autowired
//    private Tracer tracer;
//
//
//    @ApiOperation(value = "根据code查找患者")
//    @GetMapping(value = "findByCode")
//    public String findByCode(
//            @ApiParam(name = "code", value = "患者code", required = true)@RequestParam(value = "code", required = true) String code) {
//      tracer.getCurrentSpan().logEvent("进入微服务查询患者");
//       return "调用根据code查找患者";
//    }
//}

+ 32 - 32
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseMenuDao.java

@ -1,32 +1,32 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.base.user.BaseMenuDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by LiTaohong on 2017/12/05.
 */
public interface BaseMenuDao extends PagingAndSortingRepository<BaseMenuDO, String>, JpaSpecificationExecutor<BaseMenuDO> {
    //角色与saasId为一对多关系
    @Query("from BaseMenuDO b where b.saasId = ?1")
    List<BaseMenuDO> findAllBySaasId(String saasId);
    @Query("from BaseMenuDO b where b.saasId = ?1 and b.name = ?2")
    BaseMenuDO findOneBySaasIdAndName(String saasId, String name);
    @Query("from BaseMenuDO b where b.name like %?1%")
    List<BaseMenuDO> findAllByName(String name);
    @Query("from BaseMenuDO b where b.saasId = ?1 and b.parentId = ?2")
    List<BaseMenuDO> getChildrenMenuList(String saasId,String parentId);
}
//package com.yihu.jw.business.user.dao;
//
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.base.user.BaseMenuDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/12/05.
// */
//public interface BaseMenuDao extends PagingAndSortingRepository<BaseMenuDO, String>, JpaSpecificationExecutor<BaseMenuDO> {
//
//    //角色与saasId为一对多关系
//    @Query("from BaseMenuDO b where b.saasId = ?1")
//    List<BaseMenuDO> findAllBySaasId(String saasId);
//
//    @Query("from BaseMenuDO b where b.saasId = ?1 and b.name = ?2")
//    BaseMenuDO findOneBySaasIdAndName(String saasId, String name);
//
//    @Query("from BaseMenuDO b where b.name like %?1%")
//    List<BaseMenuDO> findAllByName(String name);
//
//    @Query("from BaseMenuDO b where b.saasId = ?1 and b.parentId = ?2")
//    List<BaseMenuDO> getChildrenMenuList(String saasId,String parentId);
//
//
//
//
//}

+ 28 - 28
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseRoleDao.java

@ -1,28 +1,28 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseRoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public interface BaseRoleDao extends PagingAndSortingRepository<BaseRoleDO, String>, JpaSpecificationExecutor<BaseRoleDO> {
    @Query("from BaseRoleDO b where b.id = ?1")
    BaseRoleDO findOneById(String id);
    //角色与saasId为一对多关系
    @Query("from BaseRoleDO b where b.saasId = ?1")
    List<BaseRoleDO> findAllBySaasId(String saasId);
    @Query("from BaseRoleDO b where b.saasId = ?1 and b.name = ?2")
    BaseRoleDO findOneBySaasIdAndName(String saasId,String name);
    @Query("from BaseRoleDO b where b.name like %?1%")
    List<BaseRoleDO> findAllByName(String name);
}
//package com.yihu.jw.business.user.dao;
//
//import com.yihu.jw.base.user.BaseRoleDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//public interface BaseRoleDao extends PagingAndSortingRepository<BaseRoleDO, String>, JpaSpecificationExecutor<BaseRoleDO> {
//
//
//    @Query("from BaseRoleDO b where b.id = ?1")
//    BaseRoleDO findOneById(String id);
//
//    //角色与saasId为一对多关系
//    @Query("from BaseRoleDO b where b.saasId = ?1")
//    List<BaseRoleDO> findAllBySaasId(String saasId);
//
//    @Query("from BaseRoleDO b where b.saasId = ?1 and b.name = ?2")
//    BaseRoleDO findOneBySaasIdAndName(String saasId,String name);
//
//    @Query("from BaseRoleDO b where b.name like %?1%")
//    List<BaseRoleDO> findAllByName(String name);
//}

+ 26 - 26
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseRoleMenuDao.java

@ -1,26 +1,26 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.base.user.BaseRoleMenuDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public interface BaseRoleMenuDao extends PagingAndSortingRepository<BaseRoleMenuDO, String>, JpaSpecificationExecutor<BaseRoleMenuDO> {
    @Query("from BaseRoleMenuDO ba where ba.roleId = ?1")
    List<BaseRoleMenuDO> findRoleMenuListByRoleId(String employId);
    @Query("delete from BaseRoleMenuDO ba where ba.roleId = ?1 and ba.menuId = ?2")
    int deleteOneByRoleIdAndMenuId(String roleId,String menuId);
    @Query("delete from BaseRoleMenuDO ba where ba.roleId = ?1 and ba.menuId in (?2)")
    int deleteManyByRoleIdAndMenuIds(String roleId,String menuIds);
}
//package com.yihu.jw.business.user.dao;
//
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.base.user.BaseRoleMenuDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//public interface BaseRoleMenuDao extends PagingAndSortingRepository<BaseRoleMenuDO, String>, JpaSpecificationExecutor<BaseRoleMenuDO> {
//
//
//    @Query("from BaseRoleMenuDO ba where ba.roleId = ?1")
//    List<BaseRoleMenuDO> findRoleMenuListByRoleId(String employId);
//
//    @Query("delete from BaseRoleMenuDO ba where ba.roleId = ?1 and ba.menuId = ?2")
//    int deleteOneByRoleIdAndMenuId(String roleId,String menuId);
//
//    @Query("delete from BaseRoleMenuDO ba where ba.roleId = ?1 and ba.menuId in (?2)")
//    int deleteManyByRoleIdAndMenuIds(String roleId,String menuIds);
//}

+ 24 - 24
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployRoleDao.java

@ -1,24 +1,24 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseRoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public interface EmployRoleDao extends PagingAndSortingRepository<BaseEmployRoleDO, String>, JpaSpecificationExecutor<BaseEmployRoleDO> {
    @Query("from BaseEmployRoleDO ba where ba.employId = ?1")
    List<BaseEmployRoleDO> findRoleListByEmployId(String employId);
    @Query("delete from BaseEmployRoleDO ba where ba.employId = ?1 and ba.roleId = ?2")
    int deleteOneByEmployIdAndRoleId(String employId,String roleId);
    @Query("delete from BaseEmployRoleDO ba where ba.employId = ?1 and ba.roleId in (?2)")
    int deleteManyByEmployIdAndRoleIds(String employId,String roleIds);
}
//package com.yihu.jw.business.user.dao;
//
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//public interface EmployRoleDao extends PagingAndSortingRepository<BaseEmployRoleDO, String>, JpaSpecificationExecutor<BaseEmployRoleDO> {
//
//    @Query("from BaseEmployRoleDO ba where ba.employId = ?1")
//    List<BaseEmployRoleDO> findRoleListByEmployId(String employId);
//
//    @Query("delete from BaseEmployRoleDO ba where ba.employId = ?1 and ba.roleId = ?2")
//    int deleteOneByEmployIdAndRoleId(String employId,String roleId);
//
//    @Query("delete from BaseEmployRoleDO ba where ba.employId = ?1 and ba.roleId in (?2)")
//    int deleteManyByEmployIdAndRoleIds(String employId,String roleIds);
//}

+ 137 - 137
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseMenuService.java

@ -1,137 +1,137 @@
package com.yihu.jw.business.user.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.business.user.dao.BaseMenuDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by LiTaohong on 2017/12/5.
 * 基础菜单功能
 */
@Service
public class BaseMenuService extends BaseJpaService<BaseMenuDO,BaseMenuDao>{
    @Autowired
    private BaseMenuDao baseMenuDao;
    /**
     * 创建菜单
     * @param baseMenuDO
     * @return
     */
    @Transactional
    public BaseMenuDO createBaseMenu(BaseMenuDO baseMenuDO){
        if (StringUtils.isEmpty(baseMenuDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseMenuDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseMenuDao.save(baseMenuDO);
    }
    /**
     * 更新菜单
     * @param baseMenuDO
     * @return
     */
    @Transactional
    public BaseMenuDO updateBaseMenuDO(BaseMenuDO baseMenuDO){
        if (StringUtils.isEmpty(baseMenuDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseMenuDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseMenuDao.save(baseMenuDO);
    }
    /**
     * 根据Id查询菜单
     * @param id
     * @return
     */
    public BaseMenuDO findById(String id){
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
        BaseMenuDO baseRoleDO = this.baseMenuDao.findOne(id);
        if (null == baseRoleDO) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
        }
        return baseRoleDO;
    }
    /**
     * 查询某要saasId平台下的所有菜单
     * @param saasId
     * @return
     */
    public List<BaseMenuDO> findAllBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseMenuDO> list = this.baseMenuDao.findAllBySaasId(saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 根据Id删除菜单
     * @param baseMenuDO
     */
    @Transactional
    public void deleteBaseMenu(BaseMenuDO baseMenuDO){
        if (StringUtils.isEmpty(baseMenuDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseMenuDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        baseMenuDO.setStatus(-1);
        this.baseMenuDao.save(baseMenuDO);
    }
    /**
     * 删除某一saasId相关的所有菜单
     * @param saasId
     */
    @Transactional
    public void deleteBaseMenusBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        List<BaseMenuDO> list = this.baseMenuDao.findAllBySaasId(saasId);
        for(BaseMenuDO baseMenuDO:list){
            baseMenuDO.setStatus(-1);
        }
        this.baseMenuDao.save(list);
    }
    /**
     * 获取某一平台下某一父级菜单的所有子菜单
     * @param saasId
     * @param parentId
     * @return
     */
    public List<BaseMenuDO> getChlidrenMenuList(String saasId,String parentId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_param_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(parentId)) {
            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_param_parentId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseMenuDao.getChildrenMenuList(saasId,parentId);
    }
}
//package com.yihu.jw.business.user.service;
//
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.business.user.dao.BaseMenuDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/12/5.
// * 基础菜单功能
// */
//@Service
//public class BaseMenuService extends BaseJpaService<BaseMenuDO,BaseMenuDao>{
//    @Autowired
//    private BaseMenuDao baseMenuDao;
//
//    /**
//     * 创建菜单
//     * @param baseMenuDO
//     * @return
//     */
//    @Transactional
//    public BaseMenuDO createBaseMenu(BaseMenuDO baseMenuDO){
//        if (StringUtils.isEmpty(baseMenuDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseMenuDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseMenuDao.save(baseMenuDO);
//    }
//
//    /**
//     * 更新菜单
//     * @param baseMenuDO
//     * @return
//     */
//    @Transactional
//    public BaseMenuDO updateBaseMenuDO(BaseMenuDO baseMenuDO){
//        if (StringUtils.isEmpty(baseMenuDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseMenuDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseMenuDao.save(baseMenuDO);
//    }
//
//    /**
//     * 根据Id查询菜单
//     * @param id
//     * @return
//     */
//    public BaseMenuDO findById(String id){
//        if (StringUtils.isEmpty(id)) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//        BaseMenuDO baseRoleDO = this.baseMenuDao.findOne(id);
//        if (null == baseRoleDO) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return baseRoleDO;
//    }
//
//    /**
//     * 查询某要saasId平台下的所有菜单
//     * @param saasId
//     * @return
//     */
//    public List<BaseMenuDO> findAllBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseMenuDO> list = this.baseMenuDao.findAllBySaasId(saasId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//    /**
//     * 根据Id删除菜单
//     * @param baseMenuDO
//     */
//    @Transactional
//    public void deleteBaseMenu(BaseMenuDO baseMenuDO){
//        if (StringUtils.isEmpty(baseMenuDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseMenuDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        baseMenuDO.setStatus(-1);
//        this.baseMenuDao.save(baseMenuDO);
//    }
//
//    /**
//     * 删除某一saasId相关的所有菜单
//     * @param saasId
//     */
//    @Transactional
//    public void deleteBaseMenusBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        List<BaseMenuDO> list = this.baseMenuDao.findAllBySaasId(saasId);
//        for(BaseMenuDO baseMenuDO:list){
//            baseMenuDO.setStatus(-1);
//        }
//        this.baseMenuDao.save(list);
//    }
//
//    /**
//     * 获取某一平台下某一父级菜单的所有子菜单
//     * @param saasId
//     * @param parentId
//     * @return
//     */
//    public List<BaseMenuDO> getChlidrenMenuList(String saasId,String parentId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_param_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(parentId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseMenu.message_param_parentId_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseMenuDao.getChildrenMenuList(saasId,parentId);
//    }
//}

+ 154 - 154
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleMenuService.java

@ -1,154 +1,154 @@
package com.yihu.jw.business.user.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.base.user.BaseRoleMenuDO;
import com.yihu.jw.business.user.dao.BaseMenuDao;
import com.yihu.jw.business.user.dao.BaseRoleMenuDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by LiTaohong on 2017/12/05.
 * 基础角色菜单功能
 */
@Service
public class BaseRoleMenuService extends BaseJpaService<BaseRoleMenuDO,BaseRoleMenuDao> {
    @Autowired
    private BaseRoleMenuDao baseRoleMenuDao;
    @Autowired
    private BaseMenuDao baseMenuDao;
    /**
     * 新增角色菜单
     * @param baseRoleMenuDO
     * @return
     */
    @Transactional
    public BaseRoleMenuDO createBaseRoleMenuDO(BaseRoleMenuDO baseRoleMenuDO){
        if (StringUtils.isEmpty(baseRoleMenuDO.getRoleId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseRoleMenuDao.save(baseRoleMenuDO);
    }
    /**
     * 批量新增角色菜单,一个角色拥有多个菜单的权限
     * @param list
     * @return
     */
    @Transactional
    public Iterable<BaseRoleMenuDO> createBatchBaseRoleMenuDO(List<BaseRoleMenuDO> list){
        return this.baseRoleMenuDao.save(list);
    }
    /**
     * 修改角色菜单信息
     * @param baseRoleMenuDO
     * @return
     */
    @Transactional
    public BaseRoleMenuDO updateBaseEmployRoleDO(BaseRoleMenuDO baseRoleMenuDO){
        BaseRoleMenuDO OldbaseRoleMenuDO = this.baseRoleMenuDao.findOne(baseRoleMenuDO.getId());
        if(null == OldbaseRoleMenuDO){
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_baseRoleMenu_no_exist, ExceptionCode.common_error_params_code);
        }
        //菜单id一样,表示菜单没有变,则不修改
        if (baseRoleMenuDO.getMenuId().equals(OldbaseRoleMenuDO.getMenuId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_same_menuId, ExceptionCode.common_error_params_code);
        }
        baseRoleMenuDO.setRoleId(OldbaseRoleMenuDO.getRoleId());
        return this.baseRoleMenuDao.save(baseRoleMenuDO);
    }
    /**
     * 查询某一角色的菜单列表(角色与菜单为一对多关系)
     * @param roleId
     * @return
     */
    public List<BaseMenuDO> findAllByRoleId(String roleId){
        if (StringUtils.isEmpty(roleId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
        }
        List<BaseRoleMenuDO> list = this.baseRoleMenuDao.findRoleMenuListByRoleId(roleId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_baseRoleMenu_no_exist,ExceptionCode.common_error_params_code);
        }
        List<String> ids = new ArrayList<>();
        for(BaseRoleMenuDO baseRoleMenuDO:list){
            ids.add(baseRoleMenuDO.getMenuId());
        }
        Iterable<String> iterable = (Iterable<String>)ids.iterator();
        List<BaseMenuDO> result = (List<BaseMenuDO>)baseMenuDao.findAll(iterable);
        return result;
    }
    /**
     * 根据id删除角色菜单
     * @param id
     * @return
     */
    @Transactional
    public void deleteBaseRoleMenuDO(String id){
        try{
            this.baseRoleMenuDao.delete(id);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
    /**
     * 根据roleId和menuId删除角色菜单
     * @param roleId
     * @param menuId
     * @return
     */
    @Transactional
    public void deleteBaseRoleMenuDO(String roleId,String menuId){
        try{
            this.baseRoleMenuDao.deleteOneByRoleIdAndMenuId(roleId,menuId);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
    /**
     * 根据roleId和menuId删除角色菜单
     * @param roleId
     * @param menuIds
     * @return
     */
    @Transactional
    public void deleteBatchBaseRoleMenuDO(String roleId,String menuIds){
        try{
            this.baseRoleMenuDao.deleteManyByRoleIdAndMenuIds(roleId,menuIds);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
}
//package com.yihu.jw.business.user.service;
//
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.base.user.BaseRoleMenuDO;
//import com.yihu.jw.business.user.dao.BaseMenuDao;
//import com.yihu.jw.business.user.dao.BaseRoleMenuDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/12/05.
// * 基础角色菜单功能
// */
//@Service
//public class BaseRoleMenuService extends BaseJpaService<BaseRoleMenuDO,BaseRoleMenuDao> {
//
//    @Autowired
//    private BaseRoleMenuDao baseRoleMenuDao;
//
//    @Autowired
//    private BaseMenuDao baseMenuDao;
//
//    /**
//     * 新增角色菜单
//     * @param baseRoleMenuDO
//     * @return
//     */
//    @Transactional
//    public BaseRoleMenuDO createBaseRoleMenuDO(BaseRoleMenuDO baseRoleMenuDO){
//        if (StringUtils.isEmpty(baseRoleMenuDO.getRoleId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseRoleMenuDao.save(baseRoleMenuDO);
//    }
//
//    /**
//     * 批量新增角色菜单,一个角色拥有多个菜单的权限
//     * @param list
//     * @return
//     */
//    @Transactional
//    public Iterable<BaseRoleMenuDO> createBatchBaseRoleMenuDO(List<BaseRoleMenuDO> list){
//        return this.baseRoleMenuDao.save(list);
//    }
//
//    /**
//     * 修改角色菜单信息
//     * @param baseRoleMenuDO
//     * @return
//     */
//    @Transactional
//    public BaseRoleMenuDO updateBaseEmployRoleDO(BaseRoleMenuDO baseRoleMenuDO){
//        BaseRoleMenuDO OldbaseRoleMenuDO = this.baseRoleMenuDao.findOne(baseRoleMenuDO.getId());
//        if(null == OldbaseRoleMenuDO){
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_baseRoleMenu_no_exist, ExceptionCode.common_error_params_code);
//        }
//        //菜单id一样,表示菜单没有变,则不修改
//        if (baseRoleMenuDO.getMenuId().equals(OldbaseRoleMenuDO.getMenuId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_same_menuId, ExceptionCode.common_error_params_code);
//        }
//        baseRoleMenuDO.setRoleId(OldbaseRoleMenuDO.getRoleId());
//        return this.baseRoleMenuDao.save(baseRoleMenuDO);
//    }
//
//
//    /**
//     * 查询某一角色的菜单列表(角色与菜单为一对多关系)
//     * @param roleId
//     * @return
//     */
//    public List<BaseMenuDO> findAllByRoleId(String roleId){
//        if (StringUtils.isEmpty(roleId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleMenuDO> list = this.baseRoleMenuDao.findRoleMenuListByRoleId(roleId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_baseRoleMenu_no_exist,ExceptionCode.common_error_params_code);
//        }
//        List<String> ids = new ArrayList<>();
//        for(BaseRoleMenuDO baseRoleMenuDO:list){
//            ids.add(baseRoleMenuDO.getMenuId());
//        }
//        Iterable<String> iterable = (Iterable<String>)ids.iterator();
//        List<BaseMenuDO> result = (List<BaseMenuDO>)baseMenuDao.findAll(iterable);
//        return result;
//    }
//
//
//    /**
//     * 根据id删除角色菜单
//     * @param id
//     * @return
//     */
//    @Transactional
//    public void deleteBaseRoleMenuDO(String id){
//        try{
//            this.baseRoleMenuDao.delete(id);
//        }
//        catch (ApiException e){
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//
//    }
//
//    /**
//     * 根据roleId和menuId删除角色菜单
//     * @param roleId
//     * @param menuId
//     * @return
//     */
//    @Transactional
//    public void deleteBaseRoleMenuDO(String roleId,String menuId){
//        try{
//            this.baseRoleMenuDao.deleteOneByRoleIdAndMenuId(roleId,menuId);
//        }
//        catch (ApiException e){
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//    }
//
//    /**
//     * 根据roleId和menuId删除角色菜单
//     * @param roleId
//     * @param menuIds
//     * @return
//     */
//    @Transactional
//    public void deleteBatchBaseRoleMenuDO(String roleId,String menuIds){
//        try{
//            this.baseRoleMenuDao.deleteManyByRoleIdAndMenuIds(roleId,menuIds);
//        }
//        catch (ApiException e){
//            throw new ApiException(BaseUserRequestMapping.BaseRoleMenu.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//    }
//
//
//
//
//
//
//
//
//
//}

+ 174 - 174
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleService.java

@ -1,174 +1,174 @@
package com.yihu.jw.business.user.service;
import com.netflix.discovery.converters.Auto;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.dao.BaseRoleDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import net.bytebuddy.implementation.bytecode.Throw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 * 基础角色功能
 */
@Service
public class BaseRoleService extends BaseJpaService<BaseRoleDO,BaseRoleDao>{
    @Autowired
    private BaseRoleDao baseRoleDao;
    /**
     * 创建role
     * @param baseRoleDO
     * @return
     */
    @Transactional
    public BaseRoleDO createBaseRole(BaseRoleDO baseRoleDO){
        if (StringUtils.isEmpty(baseRoleDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getName())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 更新role
     * @param baseRoleDO
     * @return
     */
    @Transactional
    public BaseRoleDO updateBaseRole(BaseRoleDO baseRoleDO){
        if (StringUtils.isEmpty(baseRoleDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 根据roleId查询role
     * @param id
     * @return
     */
    public BaseRoleDO findById(String id){
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneById(id);
        if (null == baseRoleDO) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
        }
        return baseRoleDO;
    }
    /**
     * 查询某要saasId平台下的所有role
     * @param saasId
     * @return
     */
    public List<BaseRoleDO> findAllBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 查找某一平台下某一个role
     * @param saasId
     * @param name
     * @return
     */
    public BaseRoleDO findBySaasIdAndName(String saasId,String name){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(name)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null,ExceptionCode.common_error_params_code);
        }
        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneBySaasIdAndName(name,saasId);
        if (null == baseRoleDO) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
        }
        return baseRoleDO;
    }
    /**
     * 根据name查询所有的role,包括不同平台saasid的
     * @param name
     * @return
     */
    public List<BaseRoleDO> getRoleListByName(String name){
        if (StringUtils.isEmpty(name)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_name_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseRoleDO> list = this.baseRoleDao.findAllByName(name);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 根据roleId删除role
     * @param baseRoleDO
     */
    @Transactional
    public void deleteBaseRole(BaseRoleDO baseRoleDO){
        if (StringUtils.isEmpty(baseRoleDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        baseRoleDO.setStatus(-1);
        this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 删除某一saasId相关的所有role
     * @param saasId
     */
    @Transactional
    public void deleteBaseRolesBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
        for(BaseRoleDO baseRoleDO:list){
            baseRoleDO.setStatus(-1);
        }
        this.baseRoleDao.save(list);
    }
    /**
     * 根据saasId和name删除角色
     * @param saasId
     * @param name
     */
    @Transactional
    public void deleteBaseRoleByNameAndSaasId(String saasId,String name){
        BaseRoleDO baseRoleDO = this.findBySaasIdAndName(saasId,name);
        baseRoleDO.setStatus(-1);
        this.baseRoleDao.save(baseRoleDO);
    }
}
//package com.yihu.jw.business.user.service;
//
//import com.netflix.discovery.converters.Auto;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.business.user.dao.BaseRoleDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import net.bytebuddy.implementation.bytecode.Throw;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// * 基础角色功能
// */
//@Service
//public class BaseRoleService extends BaseJpaService<BaseRoleDO,BaseRoleDao>{
//    @Autowired
//    private BaseRoleDao baseRoleDao;
//
//    /**
//     * 创建role
//     * @param baseRoleDO
//     * @return
//     */
//    @Transactional
//    public BaseRoleDO createBaseRole(BaseRoleDO baseRoleDO){
//        if (StringUtils.isEmpty(baseRoleDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getName())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 更新role
//     * @param baseRoleDO
//     * @return
//     */
//    @Transactional
//    public BaseRoleDO updateBaseRole(BaseRoleDO baseRoleDO){
//        if (StringUtils.isEmpty(baseRoleDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 根据roleId查询role
//     * @param id
//     * @return
//     */
//    public BaseRoleDO findById(String id){
//        if (StringUtils.isEmpty(id)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneById(id);
//        if (null == baseRoleDO) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return baseRoleDO;
//    }
//
//    /**
//     * 查询某要saasId平台下的所有role
//     * @param saasId
//     * @return
//     */
//    public List<BaseRoleDO> findAllBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//    /**
//     * 查找某一平台下某一个role
//     * @param saasId
//     * @param name
//     * @return
//     */
//    public BaseRoleDO findBySaasIdAndName(String saasId,String name){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(name)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null,ExceptionCode.common_error_params_code);
//        }
//        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneBySaasIdAndName(name,saasId);
//        if (null == baseRoleDO) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return baseRoleDO;
//    }
//
//    /**
//     * 根据name查询所有的role,包括不同平台saasid的
//     * @param name
//     * @return
//     */
//    public List<BaseRoleDO> getRoleListByName(String name){
//        if (StringUtils.isEmpty(name)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_name_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleDO> list = this.baseRoleDao.findAllByName(name);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//
//    /**
//     * 根据roleId删除role
//     * @param baseRoleDO
//     */
//    @Transactional
//    public void deleteBaseRole(BaseRoleDO baseRoleDO){
//        if (StringUtils.isEmpty(baseRoleDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        baseRoleDO.setStatus(-1);
//        this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 删除某一saasId相关的所有role
//     * @param saasId
//     */
//    @Transactional
//    public void deleteBaseRolesBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
//        for(BaseRoleDO baseRoleDO:list){
//            baseRoleDO.setStatus(-1);
//        }
//        this.baseRoleDao.save(list);
//    }
//
//    /**
//     * 根据saasId和name删除角色
//     * @param saasId
//     * @param name
//     */
//    @Transactional
//    public void deleteBaseRoleByNameAndSaasId(String saasId,String name){
//        BaseRoleDO baseRoleDO = this.findBySaasIdAndName(saasId,name);
//        baseRoleDO.setStatus(-1);
//        this.baseRoleDao.save(baseRoleDO);
//    }
//}

+ 152 - 152
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployRoleService.java

@ -1,152 +1,152 @@
package com.yihu.jw.business.user.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.dao.BaseRoleDao;
import com.yihu.jw.business.user.dao.EmployRoleDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 * 用户角色表功能
 */
@Service
public class EmployRoleService extends BaseJpaService<BaseEmployRoleDO,EmployRoleDao> {
    @Autowired
    private EmployRoleDao employRoleDao;
    @Autowired
    private BaseRoleDao baseRoleDao;
    /**
     * 新增用户角色
     * @param baseEmployRoleDO
     * @return
     */
    @Transactional
    public BaseEmployRoleDO createBaseEmployRoleDO(BaseEmployRoleDO baseEmployRoleDO){
        if (StringUtils.isEmpty(baseEmployRoleDO.getRoleId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseEmployRoleDO.getEmployId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employId_is_null, ExceptionCode.common_error_params_code);
        }
        return this.employRoleDao.save(baseEmployRoleDO);
    }
    /**
     * 批量新增用户角色,一个用户可能有多个角色
     * @param list
     * @return
     */
    @Transactional
    public Iterable<BaseEmployRoleDO> createBatchBaseEmployRoleDO(List<BaseEmployRoleDO> list){
       return this.employRoleDao.save(list);
    }
    /**
     * 修改用户角色
     * @param baseEmployRoleDO
     * @return
     */
    @Transactional
    public BaseEmployRoleDO updateBaseEmployRoleDO(BaseEmployRoleDO baseEmployRoleDO){
        BaseEmployRoleDO OldbaseEmployRoleDO = this.employRoleDao.findOne(baseEmployRoleDO.getId());
        if(null == OldbaseEmployRoleDO){
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employeeRole_no_exist, ExceptionCode.common_error_params_code);
        }
        if (baseEmployRoleDO.getRoleId().equals(OldbaseEmployRoleDO.getRoleId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_same_roleId, ExceptionCode.common_error_params_code);
        }
        baseEmployRoleDO.setEmployId(OldbaseEmployRoleDO.getEmployId());
        return this.employRoleDao.save(baseEmployRoleDO);
    }
    /**
     * 查询某一用户的角色列表(用户与角色为一对多关系)
     * @param employId
     * @return
     */
    public List<BaseRoleDO> findAllByEmployId(String employId){
        if (StringUtils.isEmpty(employId)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employId_is_null, ExceptionCode.common_error_params_code);
        }
        List<BaseEmployRoleDO> list = this.employRoleDao.findRoleListByEmployId(employId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employeeRole_no_exist,ExceptionCode.common_error_params_code);
        }
        List ids = new ArrayList<>();
        for(BaseEmployRoleDO baseEmployRoleDO:list){
            ids.add(baseEmployRoleDO.getRoleId());
        }
        Iterable iterable = (Iterable)ids.iterator();
        List<BaseRoleDO> result = (List<BaseRoleDO>)baseRoleDao.findAll(iterable);
        return result;
    }
    /**
     * 根据Id删除用户角色
     * @param id
     * @return
     */
    @Transactional
    public void deleteBaseEmployRoleDO(String id){
        try{
            this.employRoleDao.delete(id);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
    /**
     * 根据用户Id和角色id删除用户角色
     * @param employId
     * @param roleIds
     * @return
     */
    @Transactional
    public void deleteBaseEmployRoleDO(String employId,String roleIds){
        try{
            this.employRoleDao.deleteOneByEmployIdAndRoleId(employId,roleIds);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
    /**
     * 批量删除用户角色
     * @param employId
     * @param roleIds
     * @return
     */
    @Transactional
    public void deleteBatchBaseEmployRoleDO(String employId,String roleIds){
        try{
            this.employRoleDao.deleteManyByEmployIdAndRoleIds(employId,roleIds);
        }
        catch (ApiException e){
            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
    }
}
//package com.yihu.jw.business.user.service;
//
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.base.user.BaseEmployDO;
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.business.user.dao.BaseRoleDao;
//import com.yihu.jw.business.user.dao.EmployRoleDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/11.
// * 用户角色表功能
// */
//@Service
//public class EmployRoleService extends BaseJpaService<BaseEmployRoleDO,EmployRoleDao> {
//
//    @Autowired
//    private EmployRoleDao employRoleDao;
//
//    @Autowired
//    private BaseRoleDao baseRoleDao;
//
//    /**
//     * 新增用户角色
//     * @param baseEmployRoleDO
//     * @return
//     */
//    @Transactional
//    public BaseEmployRoleDO createBaseEmployRoleDO(BaseEmployRoleDO baseEmployRoleDO){
//        if (StringUtils.isEmpty(baseEmployRoleDO.getRoleId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_roleId_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseEmployRoleDO.getEmployId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employId_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.employRoleDao.save(baseEmployRoleDO);
//    }
//
//    /**
//     * 批量新增用户角色,一个用户可能有多个角色
//     * @param list
//     * @return
//     */
//    @Transactional
//    public Iterable<BaseEmployRoleDO> createBatchBaseEmployRoleDO(List<BaseEmployRoleDO> list){
//       return this.employRoleDao.save(list);
//    }
//
//    /**
//     * 修改用户角色
//     * @param baseEmployRoleDO
//     * @return
//     */
//    @Transactional
//    public BaseEmployRoleDO updateBaseEmployRoleDO(BaseEmployRoleDO baseEmployRoleDO){
//        BaseEmployRoleDO OldbaseEmployRoleDO = this.employRoleDao.findOne(baseEmployRoleDO.getId());
//        if(null == OldbaseEmployRoleDO){
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employeeRole_no_exist, ExceptionCode.common_error_params_code);
//        }
//        if (baseEmployRoleDO.getRoleId().equals(OldbaseEmployRoleDO.getRoleId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_same_roleId, ExceptionCode.common_error_params_code);
//        }
//        baseEmployRoleDO.setEmployId(OldbaseEmployRoleDO.getEmployId());
//        return this.employRoleDao.save(baseEmployRoleDO);
//    }
//
//
//    /**
//     * 查询某一用户的角色列表(用户与角色为一对多关系)
//     * @param employId
//     * @return
//     */
//    public List<BaseRoleDO> findAllByEmployId(String employId){
//        if (StringUtils.isEmpty(employId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employId_is_null, ExceptionCode.common_error_params_code);
//        }
//        List<BaseEmployRoleDO> list = this.employRoleDao.findRoleListByEmployId(employId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_employeeRole_no_exist,ExceptionCode.common_error_params_code);
//        }
//        List ids = new ArrayList<>();
//        for(BaseEmployRoleDO baseEmployRoleDO:list){
//            ids.add(baseEmployRoleDO.getRoleId());
//        }
//        Iterable iterable = (Iterable)ids.iterator();
//        List<BaseRoleDO> result = (List<BaseRoleDO>)baseRoleDao.findAll(iterable);
//        return result;
//    }
//
//
//    /**
//     * 根据Id删除用户角色
//     * @param id
//     * @return
//     */
//    @Transactional
//    public void deleteBaseEmployRoleDO(String id){
//        try{
//            this.employRoleDao.delete(id);
//        }
//        catch (ApiException e){
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//
//    }
//
//    /**
//     * 根据用户Id和角色id删除用户角色
//     * @param employId
//     * @param roleIds
//     * @return
//     */
//    @Transactional
//    public void deleteBaseEmployRoleDO(String employId,String roleIds){
//        try{
//            this.employRoleDao.deleteOneByEmployIdAndRoleId(employId,roleIds);
//        }
//        catch (ApiException e){
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//
//    }
//
//    /**
//     * 批量删除用户角色
//     * @param employId
//     * @param roleIds
//     * @return
//     */
//    @Transactional
//    public void deleteBatchBaseEmployRoleDO(String employId,String roleIds){
//        try{
//            this.employRoleDao.deleteManyByEmployIdAndRoleIds(employId,roleIds);
//        }
//        catch (ApiException e){
//            throw new ApiException(BaseUserRequestMapping.BaseEmployRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//
//    }
//
//}

+ 7 - 3
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployService.java

@ -3,17 +3,21 @@ package com.yihu.jw.business.user.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.dao.BaseRoleDao;
import com.yihu.jw.business.user.dao.EmployDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.*;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import javax.servlet.Servlet;
import java.util.List;
/**
@ -67,7 +71,7 @@ public class EmployService extends BaseJpaService<BaseEmployDO,EmployDao> {
     * @param id
     * @return
     */
    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
//    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
    public BaseEmployDO findById(String id){
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null,ExceptionCode.common_error_params_code);
@ -86,7 +90,7 @@ public class EmployService extends BaseJpaService<BaseEmployDO,EmployDao> {
     * @param saasId
     * @return
     */
    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
//    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
    public BaseEmployDO findByPhoneAndSaasId(String phone,String saasId){
        if (StringUtils.isEmpty(phone)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null,ExceptionCode.common_error_params_code);

+ 125 - 125
svr/svr-base/src/main/java/com/yihu/jw/business/version/controller/UserVersionController.java

@ -1,125 +1,125 @@
package com.yihu.jw.business.version.controller;
import com.yihu.jw.base.version.BaseUserVersionDO;
import com.yihu.jw.business.version.service.BaseUserVersionService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseVersionRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.PathParam;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/11/10.
 */
@RestController
@RequestMapping(BaseVersionRequestMapping.api_common)
@Api(description = "灰度发布,用户版本信息")
public class UserVersionController extends EnvelopRestController {
    @Autowired
    private BaseUserVersionService baseEmployeeVersionService;
    @PostMapping(value = BaseVersionRequestMapping.UserVersion.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "给用户添加灰度发布版本信息", notes = "给用户添加灰度发布版本信息")
    public Envelop createUserVersion(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseUserVersionDO baseUserVersion = toEntity(jsonData, BaseUserVersionDO.class);
            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_create, baseEmployeeVersionService.createUserVersion(baseUserVersion));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = BaseVersionRequestMapping.UserVersion.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除用户灰度发布版本信息", notes = "删除用户灰度发布版本信息")
    public Envelop deleteUsersVersion(
            @ApiParam(name = "ids", value = "ids")
            @RequestParam(value = "ids", required = true) String ids) {
        try {
            baseEmployeeVersionService.deleteUserVersion(ids);
            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_delete);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseVersionRequestMapping.UserVersion.api_getByUserId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据用户和saadId获取用户的灰度发布版本信息", notes = "根据用户获取用户的灰度发布版本信息")
    public Envelop getUserVersionByUserId(
            @ApiParam(name = "userId", value = "userId")
            @PathParam(value = "userId") String userId) {
        try {
            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_find, baseEmployeeVersionService.getUserVersionByUserId(userId));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseVersionRequestMapping.UserVersion.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据ID获取用户的灰度发布版本信息", notes = "根据ID获取用户的灰度发布版本信息")
    public Envelop getUserVersion(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_find, baseEmployeeVersionService.getUserVersion(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseVersionRequestMapping.UserVersion.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取用户的灰度发布版本信息(分页)", notes = "根据用户获取用户的灰度发布版本信息")
    public Envelop getSmsGateways(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<BaseUserVersionDO> list = baseEmployeeVersionService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=baseEmployeeVersionService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<BaseUserVersionDO> baseUserVersions = convertToModels(list, new ArrayList<>(list.size()), BaseUserVersionDO.class, fields);
        return Envelop.getSuccessListWithPage(BaseVersionRequestMapping.UserVersion.message_success_find,baseUserVersions, page, size,count);
    }
    @GetMapping(value =BaseVersionRequestMapping.UserVersion.api_getListNoPage)
    @ApiOperation(value = "获取用户的灰度发布版本信息,不分页")
    public Envelop getAppsNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<BaseUserVersionDO> list = baseEmployeeVersionService.search(fields,filters,sorts);
        //封装返回格式
        List<BaseUserVersionDO> baseUserVersions = convertToModels(list, new ArrayList<>(list.size()), BaseUserVersionDO.class, fields);
        return Envelop.getSuccessList(BaseVersionRequestMapping.UserVersion.message_success_find,baseUserVersions);
    }
}
//package com.yihu.jw.business.version.controller;
//
//import com.yihu.jw.base.version.BaseUserVersionDO;
//import com.yihu.jw.business.version.service.BaseUserVersionService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseVersionRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.ws.rs.PathParam;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/11/10.
// */
//@RestController
//@RequestMapping(BaseVersionRequestMapping.api_common)
//@Api(description = "灰度发布,用户版本信息")
//public class UserVersionController extends EnvelopRestController {
//    @Autowired
//    private BaseUserVersionService baseEmployeeVersionService;
//
//
//    @PostMapping(value = BaseVersionRequestMapping.UserVersion.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "给用户添加灰度发布版本信息", notes = "给用户添加灰度发布版本信息")
//    public Envelop createUserVersion(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            BaseUserVersionDO baseUserVersion = toEntity(jsonData, BaseUserVersionDO.class);
//            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_create, baseEmployeeVersionService.createUserVersion(baseUserVersion));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @DeleteMapping(value = BaseVersionRequestMapping.UserVersion.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "删除用户灰度发布版本信息", notes = "删除用户灰度发布版本信息")
//    public Envelop deleteUsersVersion(
//            @ApiParam(name = "ids", value = "ids")
//            @RequestParam(value = "ids", required = true) String ids) {
//        try {
//            baseEmployeeVersionService.deleteUserVersion(ids);
//            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_delete);
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @GetMapping(value = BaseVersionRequestMapping.UserVersion.api_getByUserId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "根据用户和saadId获取用户的灰度发布版本信息", notes = "根据用户获取用户的灰度发布版本信息")
//    public Envelop getUserVersionByUserId(
//            @ApiParam(name = "userId", value = "userId")
//            @PathParam(value = "userId") String userId) {
//        try {
//            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_find, baseEmployeeVersionService.getUserVersionByUserId(userId));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @GetMapping(value = BaseVersionRequestMapping.UserVersion.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "根据ID获取用户的灰度发布版本信息", notes = "根据ID获取用户的灰度发布版本信息")
//    public Envelop getUserVersion(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id) {
//        try {
//            return Envelop.getSuccess(BaseVersionRequestMapping.UserVersion.message_success_find, baseEmployeeVersionService.getUserVersion(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @RequestMapping(value = BaseVersionRequestMapping.UserVersion.api_getList, method = RequestMethod.GET)
//    @ApiOperation(value = "获取用户的灰度发布版本信息(分页)", notes = "根据用户获取用户的灰度发布版本信息")
//    public Envelop getSmsGateways(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        //得到list数据
//        List<BaseUserVersionDO> list = baseEmployeeVersionService.search(fields, filters, sorts, page, size);
//        //获取总数
//        long count=baseEmployeeVersionService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<BaseUserVersionDO> baseUserVersions = convertToModels(list, new ArrayList<>(list.size()), BaseUserVersionDO.class, fields);
//
//        return Envelop.getSuccessListWithPage(BaseVersionRequestMapping.UserVersion.message_success_find,baseUserVersions, page, size,count);
//    }
//
//
//    @GetMapping(value =BaseVersionRequestMapping.UserVersion.api_getListNoPage)
//    @ApiOperation(value = "获取用户的灰度发布版本信息,不分页")
//    public Envelop getAppsNoPage(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        //得到list数据
//        List<BaseUserVersionDO> list = baseEmployeeVersionService.search(fields,filters,sorts);
//        //封装返回格式
//        List<BaseUserVersionDO> baseUserVersions = convertToModels(list, new ArrayList<>(list.size()), BaseUserVersionDO.class, fields);
//        return Envelop.getSuccessList(BaseVersionRequestMapping.UserVersion.message_success_find,baseUserVersions);
//    }
//}

+ 14 - 14
svr/svr-base/src/main/java/com/yihu/jw/business/version/dao/BaseUserVersionDao.java

@ -1,14 +1,14 @@
package com.yihu.jw.business.version.dao;
import com.yihu.jw.base.version.BaseUserVersionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/11/13.
 */
public interface BaseUserVersionDao extends PagingAndSortingRepository<BaseUserVersionDO, String>, JpaSpecificationExecutor<BaseUserVersionDO> {
    @Query("from BaseUserVersionDO where userId=?1")
    BaseUserVersionDO getUserVersionByUserId(String userId);
}
//package com.yihu.jw.business.version.dao;
//
//import com.yihu.jw.base.version.BaseUserVersionDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by chenweida on 2017/11/13.
// */
//public interface BaseUserVersionDao extends PagingAndSortingRepository<BaseUserVersionDO, String>, JpaSpecificationExecutor<BaseUserVersionDO> {
//    @Query("from BaseUserVersionDO where userId=?1")
//    BaseUserVersionDO getUserVersionByUserId(String userId);
//}

+ 41 - 41
svr/svr-base/src/main/java/com/yihu/jw/business/version/service/BaseUserVersionService.java

@ -1,41 +1,41 @@
package com.yihu.jw.business.version.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.base.version.BaseUserVersionDO;
import com.yihu.jw.business.sms.dao.SmsGatewayDao;
import com.yihu.jw.business.version.dao.BaseUserVersionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
/**
 * Created by chenweida on 2017/11/10.
 */
@Service
public class BaseUserVersionService extends BaseJpaService<BaseUserVersionDO, BaseUserVersionDao> {
    @Autowired
    private BaseUserVersionDao baseUserVersionDao;
    @Transactional
    public BaseUserVersionDO createUserVersion(BaseUserVersionDO baseUserVersion) {
        return baseUserVersionDao.save(baseUserVersion);
    }
    @Transactional
    public void deleteUserVersion(String ids) {
        String[] idStr = ids.split(",");
        for (String id : idStr) {
            baseUserVersionDao.delete(id);
        }
    }
    public BaseUserVersionDO getUserVersionByUserId(String userId) {
        return baseUserVersionDao.getUserVersionByUserId(userId);
    }
    public BaseUserVersionDO getUserVersion(String id) {
        return baseUserVersionDao.findOne(id);
    }
}
//package com.yihu.jw.business.version.service;
//
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.base.version.BaseUserVersionDO;
//import com.yihu.jw.business.sms.dao.SmsGatewayDao;
//import com.yihu.jw.business.version.dao.BaseUserVersionDao;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Arrays;
//
///**
// * Created by chenweida on 2017/11/10.
// */
//@Service
//public class BaseUserVersionService extends BaseJpaService<BaseUserVersionDO, BaseUserVersionDao> {
//    @Autowired
//    private BaseUserVersionDao baseUserVersionDao;
//
//    @Transactional
//    public BaseUserVersionDO createUserVersion(BaseUserVersionDO baseUserVersion) {
//        return baseUserVersionDao.save(baseUserVersion);
//    }
//
//    @Transactional
//    public void deleteUserVersion(String ids) {
//        String[] idStr = ids.split(",");
//        for (String id : idStr) {
//            baseUserVersionDao.delete(id);
//        }
//    }
//
//    public BaseUserVersionDO getUserVersionByUserId(String userId) {
//        return baseUserVersionDao.getUserVersionByUserId(userId);
//    }
//
//    public BaseUserVersionDO getUserVersion(String id) {
//        return baseUserVersionDao.findOne(id);
//    }
//}

+ 644 - 644
svr/svr-base/src/main/java/com/yihu/jw/business/wx/WechatResponse.java

@ -1,644 +1,644 @@
package com.yihu.jw.business.wx;
/**
 * Created by Administrator on 2017/5/27 0027.
 */
public class WechatResponse {
    /**
     * 微信返回值
     * 具体见   https://mp.weixin.qq.com/wiki
     *  -1       系统繁忙,此时请开发者稍候再试
     *  0        请求成功
     *  40001    获取access_token时AppSecret错误,或者access_token无效。请开发者认真比对AppSecret的正确性,或查看是否正在为恰当的公众号调用接口
     *  40002    不合法的凭证类型
     *  40003    不合法的OpenID,请开发者确认OpenID(该用户)是否已关注公众号,或是否是其他公众号的OpenID
     *  40004    不合法的媒体文件类型
     *  40005    不合法的文件类型
     *  40006    不合法的文件大小
     *  40007    不合法的媒体文件id
     *  40008    不合法的消息类型
     *  40009    不合法的图片文件大小
     *  40010    不合法的语音文件大小
     *  40011    不合法的视频文件大小
     *  40012    不合法的缩略图文件大小
     *  40013    不合法的AppID,请开发者检查AppID的正确性,避免异常字符,注意大小写
     *  40014    不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
     *  40015    不合法的菜单类型
     *  40016    不合法的按钮个数
     *  40017    不合法的按钮个数
     *  40018    不合法的按钮名字长度
     *  40019    不合法的按钮KEY长度
     *  40020    不合法的按钮URL长度
     *  40021    不合法的菜单版本号
     *  40022    不合法的子菜单级数
     *  40023    不合法的子菜单按钮个数
     *  40024    不合法的子菜单按钮类型
     *  40025    不合法的子菜单按钮名字长度
     *  40026    不合法的子菜单按钮KEY长度
     *  40027    不合法的子菜单按钮URL长度
     *  40028    不合法的自定义菜单使用用户
     *  40029    不合法的oauth_code
     *  40030    不合法的refresh_token
     *  40031    不合法的openid列表
     *  40032    不合法的openid列表长度
     *  40033    不合法的请求字符,不能包含\  uxxxx格式的字符
     *  40035    不合法的参数
     *  40038    不合法的请求格式
     *  40039    不合法的URL长度
     *  40050    不合法的分组id
     *  40051    分组名字不合法
     *  40060    删除单篇图文时,指定的 article_idx 不合法
     *  40117    分组名字不合法
     *  40118    media_id大小不合法
     *  40119    button类型错误
     *  40120    button类型错误
     *  40121    不合法的media_id类型
     *  40132    微信号不合法
     *  40137    不支持的图片格式
     *  40155    请勿添加其他公众号的主页链接
     *  41001    缺少access_token参数
     *  41002    缺少appid参数
     *  41003    缺少refresh_token参数
     *  41004    缺少secret参数
     *  41005    缺少多媒体文件数据
     *  41006    缺少media_id参数
     *  41007    缺少子菜单数据
     *  41008    缺少oauth code
     *  41009    缺少openid
     *  42001    access_token超时,请检查access_token的有效期,请参考基础支持-获取access_token中,对access_token的详细机制说明
     *  42002    refresh_token超时
     *  42003    oauth_code超时
     *  42007    用户修改微信密码,accesstoken和refreshtoken失效,需要重新授权
     *  43001    需要GET请求
     *  43002    需要POST请求
     *  43003    需要HTTPS请求
     *  43004    需要接收者关注
     *  43005    需要好友关系
     *  43019    需要将接收者从黑名单中移除
     *  44001    多媒体文件为空
     *  44002    POST的数据包为空
     *  44003    图文消息内容为空
     *  44004    文本消息内容为空
     *  45001    多媒体文件大小超过限制
     *  45002    消息内容超过限制
     *  45003    标题字段超过限制
     *  45004    描述字段超过限制
     *  45005    链接字段超过限制
     *  45006    图片链接字段超过限制
     *  45007    语音播放时间超过限制
     *  45008    图文消息超过限制
     *  45009    接口调用超过限制
     *  45010    创建菜单个数超过限制
     *  45011    API调用太频繁,请稍候再试
     *  45015    回复时间超过限制
     *  45016    系统分组,不允许修改
     *  45017    分组名字过长
     *  45018    分组数量超过上限
     *  45047    客服接口下行条数超过上限
     *  46001    不存在媒体数据
     *  46002    不存在的菜单版本
     *  46003    不存在的菜单数据
     *  46004    不存在的用户
     *  47001    解析JSON/XML内容错误
     *  48001    api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限
     *  48002    粉丝拒收消息(粉丝在公众号选项中,关闭了“接收消息”)
     *  48004    api接口被封禁,请登录mp.weixin.qq.com查看详情
     *  48005    api禁止删除被自动回复和自定义菜单引用的素材
     *  48006    api禁止清零调用次数,因为清零次数达到上限
     *  50001    用户未授权该api
     *  50002    用户受限,可能是违规后接口被封禁
     *  61451    参数错误(invalid parameter)
     *  61452    无效客服账号(invalid kf_account)
     *  61453    客服帐号已存在(kf_account exsited)
     *  61454    客服帐号名长度超过限制(仅允许10个英文字符,不包括@及@后的公众号的微信号)(invalid   kf_acount length)
     *  61455    客服帐号名包含非法字符(仅允许英文+数字)(illegal character in     kf_account)
     *  61456    客服帐号个数超过限制(10个客服账号)(kf_account count exceeded)
     *  61457    无效头像文件类型(invalid   file type)
     *  61450    系统错误(system error)
     *  61500    日期格式错误
     *  65301    不存在此menuid对应的个性化菜单
     *  65302    没有相应的用户
     *  65303    没有默认菜单,不能创建个性化菜单
     *  65304    MatchRule信息为空
     *  65305    个性化菜单数量受限
     *  65306    不支持个性化菜单的帐号
     *  65307    个性化菜单信息为空
     *  65308    包含没有响应类型的button
     *  65309    个性化菜单开关处于关闭状态
     *  65310    填写了省份或城市信息,国家信息不能为空
     *  65311    填写了城市信息,省份信息不能为空
     *  65312    不合法的国家信息
     *  65313    不合法的省份信息
     *  65314    不合法的城市信息
     *  65316    该公众号的菜单设置了过多的域名外跳(最多跳转到3个域名的链接)
     *  65317    不合法的URL
     *  9001001    POST数据参数不合法
     *  9001002    远端服务不可用
     *  9001003    Ticket不合法
     *  9001004    获取摇周边用户信息失败
     *  9001005    获取商户信息失败
     *  9001006    获取OpenID失败
     *  9001007    上传文件缺失
     *  9001008    上传素材的文件类型不合法
     *  9001009    上传素材的文件尺寸不合法
     *  9001010    上传失败
     *  9001020    帐号不合法
     *  9001021    已有设备激活率低于50%,不能新增设备
     *  9001022    设备申请数不合法,必须为大于0的数字
     *  9001023    已存在审核中的设备ID申请
     *  9001024    一次查询设备ID数量不能超过50
     *  9001025    设备ID不合法
     *  9001026    页面ID不合法
     *  9001027    页面参数不合法
     *  9001028    一次删除页面ID数量不能超过10
     *  9001029    页面已应用在设备中,请先解除应用关系再删除
     *  9001030    一次查询页面ID数量不能超过50
     *  9001031    时间区间不合法
     *  9001032    保存设备与页面的绑定关系参数错误
     *  9001033    门店ID不合法
     *  9001034    设备备注信息过长
     *  9001035    设备申请参数不合法
     *  9001036    查询起始值begin不合法
     */
    private Integer resultCode;
    /** 返回码对应信息 ***/
    private String msg;
    public Integer getResultCode() {
        return resultCode;
    }
    public void setResultCode(Integer resultCode) {
        this.resultCode = resultCode;
    }
    public WechatResponse(Integer resultCode) {
        this.resultCode = resultCode;
    }
    public String getMsg() {
        switch (resultCode) {
        case -1:
            msg="系统繁忙,此时请开发者稍候再试";
            break;
        case 0:
            msg="请求成功";
            break;
        case 40001:
            msg="获取access_token时AppSecret错误,或者access_token无效。请开发者认真比对AppSecret的正确性,或查看是否正在为恰当的公众号调用接口";
            break;
        case 40002:
            msg="不合法的凭证类型";
            break;
        case 40003:
            msg="不合法的OpenID,请开发者确认OpenID(该用户)是否已关注公众号,或是否是其他公众号的OpenID";
            break;
        case 40004:
            msg="不合法的媒体文件类型";
            break;
        case 40005:
            msg="不合法的文件类型";
            break;
        case 40006:
            msg="不合法的文件大小";
            break;
        case 40007:
            msg="不合法的媒体文件id";
            break;
        case 40008:
            msg="不合法的消息类型";
            break;
        case 40009:
            msg="不合法的图片文件大小";
            break;
        case 40010:
            msg="不合法的语音文件大小";
            break;
        case 40011:
            msg="不合法的视频文件大小";
            break;
        case 40012:
            msg="不合法的缩略图文件大小";
            break;
        case 40013:
            msg="不合法的AppID,请开发者检查AppID的正确性,避免异常字符,注意大小写";
            break;
        case 40014:
            msg="不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口";
            break;
        case 40015:
            msg="不合法的菜单类型";
            break;
        case 40016:
            msg="不合法的按钮个数";
            break;
        case 40017:
            msg="不合法的按钮个数";
            break;
        case 40018:
            msg="不合法的按钮名字长度";
            break;
        case 40019:
            msg="不合法的按钮KEY长度";
            break;
        case 40020:
            msg="不合法的按钮URL长度";
            break;
        case 40021:
            msg="不合法的菜单版本号";
            break;
        case 40022:
            msg="不合法的子菜单级数";
            break;
        case 40023:
            msg="不合法的子菜单按钮个数";
            break;
        case 40024:
            msg="不合法的子菜单按钮类型";
            break;
        case 40025:
            msg="不合法的子菜单按钮名字长度";
            break;
        case 40026:
            msg="不合法的子菜单按钮KEY长度";
            break;
        case 40027:
            msg="不合法的子菜单按钮URL长度";
            break;
        case 40028:
            msg="不合法的自定义菜单使用用户";
            break;
        case 40029:
            msg="不合法的oauth_code";
            break;
        case 40030:
            msg="不合法的refresh_token";
            break;
        case 40031:
            msg="不合法的openid列表";
            break;
        case 40032:
            msg="不合法的openid列表长度";
            break;
        case 40033:
            msg="不合法的请求字符,不能包含\\uxxxx格式的字符";
            break;
        case 40035:
            msg="不合法的参数";
            break;
        case 40038:
            msg="不合法的请求格式";
            break;
        case 40039:
            msg="不合法的URL长度";
            break;
        case 40050:
            msg="不合法的分组id";
            break;
        case 40051:
            msg="分组名字不合法";
            break;
        case 40060:
            msg="删除单篇图文时,指定的 article_idx 不合法";
            break;
        case 40117:
            msg="分组名字不合法";
            break;
        case 40118:
            msg="media_id大小不合法";
            break;
        case 40119:
            msg="button类型错误";
            break;
        case 40120:
            msg="button类型错误";
            break;
        case 40121:
            msg="不合法的media_id类型";
            break;
        case 40132:
            msg="微信号不合法";
            break;
        case 40137:
            msg="不支持的图片格式";
            break;
        case 40155:
            msg="请勿添加其他公众号的主页链接";
            break;
        case 41001:
            msg="缺少access_token参数";
            break;
        case 41002:
            msg="缺少appid参数";
            break;
        case 41003:
            msg="缺少refresh_token参数";
            break;
        case 41004:
            msg="缺少secret参数";
            break;
        case 41005:
            msg="缺少多媒体文件数据";
            break;
        case 41006:
            msg="缺少media_id参数";
            break;
        case 41007:
            msg="缺少子菜单数据";
            break;
        case 41008:
            msg="缺少oauth code";
            break;
        case 41009:
            msg="缺少openid";
            break;
        case 42001:
            msg="access_token超时,请检查access_token的有效期,请参考基础支持-获取access_token中,对access_token的详细机制说明";
            break;
        case 42002:
            msg="refresh_token超时";
            break;
        case 42003:
            msg="oauth_code超时";
            break;
        case 42007:
            msg="用户修改微信密码,accesstoken和refreshtoken失效,需要重新授权";
            break;
        case 43001:
            msg="需要GET请求";
            break;
        case 43002:
            msg="需要POST请求";
            break;
        case 43003:
            msg="需要HTTPS请求";
            break;
        case 43004:
            msg="需要接收者关注";
            break;
        case 43005:
            msg="需要好友关系";
            break;
        case 43019:
            msg="需要将接收者从黑名单中移除";
            break;
        case 44001:
            msg="多媒体文件为空";
            break;
        case 44002:
            msg="POST的数据包为空";
            break;
        case 44003:
            msg="图文消息内容为空";
            break;
        case 44004:
            msg="文本消息内容为空";
            break;
        case 45001:
            msg="多媒体文件大小超过限制";
            break;
        case 45002:
            msg="消息内容超过限制";
            break;
        case 45003:
            msg="标题字段超过限制";
            break;
        case 45004:
            msg="描述字段超过限制";
            break;
        case 45005:
            msg="链接字段超过限制";
            break;
        case 45006:
            msg="图片链接字段超过限制";
            break;
        case 45007:
            msg="语音播放时间超过限制";
            break;
        case 45008:
            msg="图文消息超过限制";
            break;
        case 45009:
            msg="接口调用超过限制";
            break;
        case 45010:
            msg="创建菜单个数超过限制";
            break;
        case 45011:
            msg="API调用太频繁,请稍候再试";
            break;
        case 45015:
            msg="回复时间超过限制";
            break;
        case 45016:
            msg="系统分组,不允许修改";
            break;
        case 45017:
            msg="分组名字过长";
            break;
        case 45018:
            msg="分组数量超过上限";
            break;
        case 45047:
            msg="客服接口下行条数超过上限";
            break;
        case 46001:
            msg="不存在媒体数据";
            break;
        case 46002:
            msg="不存在的菜单版本";
            break;
        case 46003:
            msg="不存在的菜单数据";
            break;
        case 46004:
            msg="不存在的用户";
            break;
        case 47001:
            msg="解析JSON/XML内容错误";
            break;
        case 48001:
            msg="api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限";
            break;
        case 48002:
            msg="粉丝拒收消息(粉丝在公众号选项中,关闭了“接收消息”)";
            break;
        case 48004:
            msg="api接口被封禁,请登录mp.weixin.qq.com查看详情";
            break;
        case 48005:
            msg="api禁止删除被自动回复和自定义菜单引用的素材";
            break;
        case 48006:
            msg="api禁止清零调用次数,因为清零次数达到上限";
            break;
        case 50001:
            msg="用户未授权该api";
            break;
        case 50002:
            msg="用户受限,可能是违规后接口被封禁";
            break;
        case 61451:
            msg="参数错误(invalid parameter)";
            break;
        case 61452:
            msg="无效客服账号(invalid kf_account)";
            break;
        case 61453:
            msg="客服帐号已存在(kf_account exsited)";
            break;
        case 61454:
            msg="客服帐号名长度超过限制(仅允许10个英文字符,不包括@及@后的公众号的微信号)(invalid kf_acount length)";
            break;
        case 61455:
            msg="客服帐号名包含非法字符(仅允许英文+数字)(illegal character in kf_account)";
            break;
        case 61456:
            msg="客服帐号个数超过限制(10个客服账号)(kf_account count exceeded)";
            break;
        case 61457:
            msg="无效头像文件类型(invalid file type)";
            break;
        case 61450:
            msg="系统错误(system error)";
            break;
        case 61500:
            msg="日期格式错误";
            break;
        case 65301:
            msg="不存在此menuid对应的个性化菜单";
            break;
        case 65302:
            msg="没有相应的用户";
            break;
        case 65303:
            msg="没有默认菜单,不能创建个性化菜单";
            break;
        case 65304:
            msg="MatchRule信息为空";
            break;
        case 65305:
            msg="个性化菜单数量受限";
            break;
        case 65306:
            msg="不支持个性化菜单的帐号";
            break;
        case 65307:
            msg="个性化菜单信息为空";
            break;
        case 65308:
            msg="包含没有响应类型的button";
            break;
        case 65309:
            msg="个性化菜单开关处于关闭状态";
            break;
        case 65310:
            msg="填写了省份或城市信息,国家信息不能为空";
            break;
        case 65311:
            msg="填写了城市信息,省份信息不能为空";
            break;
        case 65312:
            msg="不合法的国家信息";
            break;
        case 65313:
            msg="不合法的省份信息";
            break;
        case 65314:
            msg="不合法的城市信息";
            break;
        case 65316:
            msg="该公众号的菜单设置了过多的域名外跳(最多跳转到3个域名的链接)";
            break;
        case 65317:
            msg="不合法的URL";
            break;
        case 9001001:
            msg="POST数据参数不合法";
            break;
        case 9001002:
            msg="远端服务不可用";
            break;
        case 9001003:
            msg="Ticket不合法";
            break;
        case 9001004:
            msg="获取摇周边用户信息失败";
            break;
        case 9001005:
            msg="获取商户信息失败";
            break;
        case 9001006:
            msg="获取OpenID失败";
            break;
        case 9001007:
            msg="上传文件缺失";
            break;
        case 9001008:
            msg="上传素材的文件类型不合法";
            break;
        case 9001009:
            msg="上传素材的文件尺寸不合法";
            break;
        case 9001010:
            msg="上传失败";
            break;
        case 9001020:
            msg="帐号不合法";
            break;
        case 9001021:
            msg="已有设备激活率低于50%,不能新增设备";
            break;
        case 9001022:
            msg="设备申请数不合法,必须为大于0的数字";
            break;
        case 9001023:
            msg="已存在审核中的设备ID申请";
            break;
        case 9001024:
            msg="一次查询设备ID数量不能超过50";
            break;
        case 9001025:
            msg="设备ID不合法";
            break;
        case 9001026:
            msg="页面ID不合法";
            break;
        case 9001027:
            msg="页面参数不合法";
            break;
        case 9001028:
            msg="一次删除页面ID数量不能超过10";
            break;
        case 9001029:
            msg="页面已应用在设备中,请先解除应用关系再删除";
            break;
        case 9001030:
            msg="一次查询页面ID数量不能超过50";
            break;
        case 9001031:
            msg="时间区间不合法";
            break;
        case 9001032:
            msg="保存设备与页面的绑定关系参数错误";
            break;
        case 9001033:
            msg="门店ID不合法";
            break;
        case 9001034:
            msg="设备备注信息过长";
            break;
        case 9001035:
            msg="设备申请参数不合法";
            break;
        case 9001036:
            msg="查询起始值begin不合法";
            break;
        default:
            msg = resultCode+":其他错误";
            break;
        }
        return msg;
    }
}
//package com.yihu.jw.business.wx;
//
///**
// * Created by Administrator on 2017/5/27 0027.
// */
//public class WechatResponse {
//    /**
//     * 微信返回值
//     * 具体见   https://mp.weixin.qq.com/wiki
//     *  -1       系统繁忙,此时请开发者稍候再试
//     *  0        请求成功
//     *  40001    获取access_token时AppSecret错误,或者access_token无效。请开发者认真比对AppSecret的正确性,或查看是否正在为恰当的公众号调用接口
//     *  40002    不合法的凭证类型
//     *  40003    不合法的OpenID,请开发者确认OpenID(该用户)是否已关注公众号,或是否是其他公众号的OpenID
//     *  40004    不合法的媒体文件类型
//     *  40005    不合法的文件类型
//     *  40006    不合法的文件大小
//     *  40007    不合法的媒体文件id
//     *  40008    不合法的消息类型
//     *  40009    不合法的图片文件大小
//     *  40010    不合法的语音文件大小
//     *  40011    不合法的视频文件大小
//     *  40012    不合法的缩略图文件大小
//     *  40013    不合法的AppID,请开发者检查AppID的正确性,避免异常字符,注意大小写
//     *  40014    不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
//     *  40015    不合法的菜单类型
//     *  40016    不合法的按钮个数
//     *  40017    不合法的按钮个数
//     *  40018    不合法的按钮名字长度
//     *  40019    不合法的按钮KEY长度
//     *  40020    不合法的按钮URL长度
//     *  40021    不合法的菜单版本号
//     *  40022    不合法的子菜单级数
//     *  40023    不合法的子菜单按钮个数
//     *  40024    不合法的子菜单按钮类型
//     *  40025    不合法的子菜单按钮名字长度
//     *  40026    不合法的子菜单按钮KEY长度
//     *  40027    不合法的子菜单按钮URL长度
//     *  40028    不合法的自定义菜单使用用户
//     *  40029    不合法的oauth_code
//     *  40030    不合法的refresh_token
//     *  40031    不合法的openid列表
//     *  40032    不合法的openid列表长度
//     *  40033    不合法的请求字符,不能包含\  uxxxx格式的字符
//     *  40035    不合法的参数
//     *  40038    不合法的请求格式
//     *  40039    不合法的URL长度
//     *  40050    不合法的分组id
//     *  40051    分组名字不合法
//     *  40060    删除单篇图文时,指定的 article_idx 不合法
//     *  40117    分组名字不合法
//     *  40118    media_id大小不合法
//     *  40119    button类型错误
//     *  40120    button类型错误
//     *  40121    不合法的media_id类型
//     *  40132    微信号不合法
//     *  40137    不支持的图片格式
//     *  40155    请勿添加其他公众号的主页链接
//     *  41001    缺少access_token参数
//     *  41002    缺少appid参数
//     *  41003    缺少refresh_token参数
//     *  41004    缺少secret参数
//     *  41005    缺少多媒体文件数据
//     *  41006    缺少media_id参数
//     *  41007    缺少子菜单数据
//     *  41008    缺少oauth code
//     *  41009    缺少openid
//     *  42001    access_token超时,请检查access_token的有效期,请参考基础支持-获取access_token中,对access_token的详细机制说明
//     *  42002    refresh_token超时
//     *  42003    oauth_code超时
//     *  42007    用户修改微信密码,accesstoken和refreshtoken失效,需要重新授权
//     *  43001    需要GET请求
//     *  43002    需要POST请求
//     *  43003    需要HTTPS请求
//     *  43004    需要接收者关注
//     *  43005    需要好友关系
//     *  43019    需要将接收者从黑名单中移除
//     *  44001    多媒体文件为空
//     *  44002    POST的数据包为空
//     *  44003    图文消息内容为空
//     *  44004    文本消息内容为空
//     *  45001    多媒体文件大小超过限制
//     *  45002    消息内容超过限制
//     *  45003    标题字段超过限制
//     *  45004    描述字段超过限制
//     *  45005    链接字段超过限制
//     *  45006    图片链接字段超过限制
//     *  45007    语音播放时间超过限制
//     *  45008    图文消息超过限制
//     *  45009    接口调用超过限制
//     *  45010    创建菜单个数超过限制
//     *  45011    API调用太频繁,请稍候再试
//     *  45015    回复时间超过限制
//     *  45016    系统分组,不允许修改
//     *  45017    分组名字过长
//     *  45018    分组数量超过上限
//     *  45047    客服接口下行条数超过上限
//     *  46001    不存在媒体数据
//     *  46002    不存在的菜单版本
//     *  46003    不存在的菜单数据
//     *  46004    不存在的用户
//     *  47001    解析JSON/XML内容错误
//     *  48001    api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限
//     *  48002    粉丝拒收消息(粉丝在公众号选项中,关闭了“接收消息”)
//     *  48004    api接口被封禁,请登录mp.weixin.qq.com查看详情
//     *  48005    api禁止删除被自动回复和自定义菜单引用的素材
//     *  48006    api禁止清零调用次数,因为清零次数达到上限
//     *  50001    用户未授权该api
//     *  50002    用户受限,可能是违规后接口被封禁
//     *  61451    参数错误(invalid parameter)
//     *  61452    无效客服账号(invalid kf_account)
//     *  61453    客服帐号已存在(kf_account exsited)
//     *  61454    客服帐号名长度超过限制(仅允许10个英文字符,不包括@及@后的公众号的微信号)(invalid   kf_acount length)
//     *  61455    客服帐号名包含非法字符(仅允许英文+数字)(illegal character in     kf_account)
//     *  61456    客服帐号个数超过限制(10个客服账号)(kf_account count exceeded)
//     *  61457    无效头像文件类型(invalid   file type)
//     *  61450    系统错误(system error)
//     *  61500    日期格式错误
//     *  65301    不存在此menuid对应的个性化菜单
//     *  65302    没有相应的用户
//     *  65303    没有默认菜单,不能创建个性化菜单
//     *  65304    MatchRule信息为空
//     *  65305    个性化菜单数量受限
//     *  65306    不支持个性化菜单的帐号
//     *  65307    个性化菜单信息为空
//     *  65308    包含没有响应类型的button
//     *  65309    个性化菜单开关处于关闭状态
//     *  65310    填写了省份或城市信息,国家信息不能为空
//     *  65311    填写了城市信息,省份信息不能为空
//     *  65312    不合法的国家信息
//     *  65313    不合法的省份信息
//     *  65314    不合法的城市信息
//     *  65316    该公众号的菜单设置了过多的域名外跳(最多跳转到3个域名的链接)
//     *  65317    不合法的URL
//     *  9001001    POST数据参数不合法
//     *  9001002    远端服务不可用
//     *  9001003    Ticket不合法
//     *  9001004    获取摇周边用户信息失败
//     *  9001005    获取商户信息失败
//     *  9001006    获取OpenID失败
//     *  9001007    上传文件缺失
//     *  9001008    上传素材的文件类型不合法
//     *  9001009    上传素材的文件尺寸不合法
//     *  9001010    上传失败
//     *  9001020    帐号不合法
//     *  9001021    已有设备激活率低于50%,不能新增设备
//     *  9001022    设备申请数不合法,必须为大于0的数字
//     *  9001023    已存在审核中的设备ID申请
//     *  9001024    一次查询设备ID数量不能超过50
//     *  9001025    设备ID不合法
//     *  9001026    页面ID不合法
//     *  9001027    页面参数不合法
//     *  9001028    一次删除页面ID数量不能超过10
//     *  9001029    页面已应用在设备中,请先解除应用关系再删除
//     *  9001030    一次查询页面ID数量不能超过50
//     *  9001031    时间区间不合法
//     *  9001032    保存设备与页面的绑定关系参数错误
//     *  9001033    门店ID不合法
//     *  9001034    设备备注信息过长
//     *  9001035    设备申请参数不合法
//     *  9001036    查询起始值begin不合法
//     */
//    private Integer resultCode;
//
//    /** 返回码对应信息 ***/
//    private String msg;
//
//    public Integer getResultCode() {
//        return resultCode;
//    }
//
//    public void setResultCode(Integer resultCode) {
//        this.resultCode = resultCode;
//    }
//
//    public WechatResponse(Integer resultCode) {
//        this.resultCode = resultCode;
//    }
//
//    public String getMsg() {
//        switch (resultCode) {
//        case -1:
//            msg="系统繁忙,此时请开发者稍候再试";
//            break;
//        case 0:
//            msg="请求成功";
//            break;
//        case 40001:
//            msg="获取access_token时AppSecret错误,或者access_token无效。请开发者认真比对AppSecret的正确性,或查看是否正在为恰当的公众号调用接口";
//            break;
//        case 40002:
//            msg="不合法的凭证类型";
//            break;
//        case 40003:
//            msg="不合法的OpenID,请开发者确认OpenID(该用户)是否已关注公众号,或是否是其他公众号的OpenID";
//            break;
//        case 40004:
//            msg="不合法的媒体文件类型";
//            break;
//        case 40005:
//            msg="不合法的文件类型";
//            break;
//        case 40006:
//            msg="不合法的文件大小";
//            break;
//        case 40007:
//            msg="不合法的媒体文件id";
//            break;
//        case 40008:
//            msg="不合法的消息类型";
//            break;
//        case 40009:
//            msg="不合法的图片文件大小";
//            break;
//        case 40010:
//            msg="不合法的语音文件大小";
//            break;
//        case 40011:
//            msg="不合法的视频文件大小";
//            break;
//        case 40012:
//            msg="不合法的缩略图文件大小";
//            break;
//        case 40013:
//            msg="不合法的AppID,请开发者检查AppID的正确性,避免异常字符,注意大小写";
//            break;
//        case 40014:
//            msg="不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口";
//            break;
//        case 40015:
//            msg="不合法的菜单类型";
//            break;
//        case 40016:
//            msg="不合法的按钮个数";
//            break;
//        case 40017:
//            msg="不合法的按钮个数";
//            break;
//        case 40018:
//            msg="不合法的按钮名字长度";
//            break;
//        case 40019:
//            msg="不合法的按钮KEY长度";
//            break;
//        case 40020:
//            msg="不合法的按钮URL长度";
//            break;
//        case 40021:
//            msg="不合法的菜单版本号";
//            break;
//        case 40022:
//            msg="不合法的子菜单级数";
//            break;
//        case 40023:
//            msg="不合法的子菜单按钮个数";
//            break;
//        case 40024:
//            msg="不合法的子菜单按钮类型";
//            break;
//        case 40025:
//            msg="不合法的子菜单按钮名字长度";
//            break;
//        case 40026:
//            msg="不合法的子菜单按钮KEY长度";
//            break;
//        case 40027:
//            msg="不合法的子菜单按钮URL长度";
//            break;
//        case 40028:
//            msg="不合法的自定义菜单使用用户";
//            break;
//        case 40029:
//            msg="不合法的oauth_code";
//            break;
//        case 40030:
//            msg="不合法的refresh_token";
//            break;
//        case 40031:
//            msg="不合法的openid列表";
//            break;
//        case 40032:
//            msg="不合法的openid列表长度";
//            break;
//        case 40033:
//            msg="不合法的请求字符,不能包含\\uxxxx格式的字符";
//            break;
//        case 40035:
//            msg="不合法的参数";
//            break;
//        case 40038:
//            msg="不合法的请求格式";
//            break;
//        case 40039:
//            msg="不合法的URL长度";
//            break;
//        case 40050:
//            msg="不合法的分组id";
//            break;
//        case 40051:
//            msg="分组名字不合法";
//            break;
//        case 40060:
//            msg="删除单篇图文时,指定的 article_idx 不合法";
//            break;
//        case 40117:
//            msg="分组名字不合法";
//            break;
//        case 40118:
//            msg="media_id大小不合法";
//            break;
//        case 40119:
//            msg="button类型错误";
//            break;
//        case 40120:
//            msg="button类型错误";
//            break;
//        case 40121:
//            msg="不合法的media_id类型";
//            break;
//        case 40132:
//            msg="微信号不合法";
//            break;
//        case 40137:
//            msg="不支持的图片格式";
//            break;
//        case 40155:
//            msg="请勿添加其他公众号的主页链接";
//            break;
//        case 41001:
//            msg="缺少access_token参数";
//            break;
//        case 41002:
//            msg="缺少appid参数";
//            break;
//        case 41003:
//            msg="缺少refresh_token参数";
//            break;
//        case 41004:
//            msg="缺少secret参数";
//            break;
//        case 41005:
//            msg="缺少多媒体文件数据";
//            break;
//        case 41006:
//            msg="缺少media_id参数";
//            break;
//        case 41007:
//            msg="缺少子菜单数据";
//            break;
//        case 41008:
//            msg="缺少oauth code";
//            break;
//        case 41009:
//            msg="缺少openid";
//            break;
//        case 42001:
//            msg="access_token超时,请检查access_token的有效期,请参考基础支持-获取access_token中,对access_token的详细机制说明";
//            break;
//        case 42002:
//            msg="refresh_token超时";
//            break;
//        case 42003:
//            msg="oauth_code超时";
//            break;
//        case 42007:
//            msg="用户修改微信密码,accesstoken和refreshtoken失效,需要重新授权";
//            break;
//        case 43001:
//            msg="需要GET请求";
//            break;
//        case 43002:
//            msg="需要POST请求";
//            break;
//        case 43003:
//            msg="需要HTTPS请求";
//            break;
//        case 43004:
//            msg="需要接收者关注";
//            break;
//        case 43005:
//            msg="需要好友关系";
//            break;
//        case 43019:
//            msg="需要将接收者从黑名单中移除";
//            break;
//        case 44001:
//            msg="多媒体文件为空";
//            break;
//        case 44002:
//            msg="POST的数据包为空";
//            break;
//        case 44003:
//            msg="图文消息内容为空";
//            break;
//        case 44004:
//            msg="文本消息内容为空";
//            break;
//        case 45001:
//            msg="多媒体文件大小超过限制";
//            break;
//        case 45002:
//            msg="消息内容超过限制";
//            break;
//        case 45003:
//            msg="标题字段超过限制";
//            break;
//        case 45004:
//            msg="描述字段超过限制";
//            break;
//        case 45005:
//            msg="链接字段超过限制";
//            break;
//        case 45006:
//            msg="图片链接字段超过限制";
//            break;
//        case 45007:
//            msg="语音播放时间超过限制";
//            break;
//        case 45008:
//            msg="图文消息超过限制";
//            break;
//        case 45009:
//            msg="接口调用超过限制";
//            break;
//        case 45010:
//            msg="创建菜单个数超过限制";
//            break;
//        case 45011:
//            msg="API调用太频繁,请稍候再试";
//            break;
//        case 45015:
//            msg="回复时间超过限制";
//            break;
//        case 45016:
//            msg="系统分组,不允许修改";
//            break;
//        case 45017:
//            msg="分组名字过长";
//            break;
//        case 45018:
//            msg="分组数量超过上限";
//            break;
//        case 45047:
//            msg="客服接口下行条数超过上限";
//            break;
//        case 46001:
//            msg="不存在媒体数据";
//            break;
//        case 46002:
//            msg="不存在的菜单版本";
//            break;
//        case 46003:
//            msg="不存在的菜单数据";
//            break;
//        case 46004:
//            msg="不存在的用户";
//            break;
//        case 47001:
//            msg="解析JSON/XML内容错误";
//            break;
//        case 48001:
//            msg="api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限";
//            break;
//        case 48002:
//            msg="粉丝拒收消息(粉丝在公众号选项中,关闭了“接收消息”)";
//            break;
//        case 48004:
//            msg="api接口被封禁,请登录mp.weixin.qq.com查看详情";
//            break;
//        case 48005:
//            msg="api禁止删除被自动回复和自定义菜单引用的素材";
//            break;
//        case 48006:
//            msg="api禁止清零调用次数,因为清零次数达到上限";
//            break;
//        case 50001:
//            msg="用户未授权该api";
//            break;
//        case 50002:
//            msg="用户受限,可能是违规后接口被封禁";
//            break;
//        case 61451:
//            msg="参数错误(invalid parameter)";
//            break;
//        case 61452:
//            msg="无效客服账号(invalid kf_account)";
//            break;
//        case 61453:
//            msg="客服帐号已存在(kf_account exsited)";
//            break;
//        case 61454:
//            msg="客服帐号名长度超过限制(仅允许10个英文字符,不包括@及@后的公众号的微信号)(invalid kf_acount length)";
//            break;
//        case 61455:
//            msg="客服帐号名包含非法字符(仅允许英文+数字)(illegal character in kf_account)";
//            break;
//        case 61456:
//            msg="客服帐号个数超过限制(10个客服账号)(kf_account count exceeded)";
//            break;
//        case 61457:
//            msg="无效头像文件类型(invalid file type)";
//            break;
//        case 61450:
//            msg="系统错误(system error)";
//            break;
//        case 61500:
//            msg="日期格式错误";
//            break;
//        case 65301:
//            msg="不存在此menuid对应的个性化菜单";
//            break;
//        case 65302:
//            msg="没有相应的用户";
//            break;
//        case 65303:
//            msg="没有默认菜单,不能创建个性化菜单";
//            break;
//        case 65304:
//            msg="MatchRule信息为空";
//            break;
//        case 65305:
//            msg="个性化菜单数量受限";
//            break;
//        case 65306:
//            msg="不支持个性化菜单的帐号";
//            break;
//        case 65307:
//            msg="个性化菜单信息为空";
//            break;
//        case 65308:
//            msg="包含没有响应类型的button";
//            break;
//        case 65309:
//            msg="个性化菜单开关处于关闭状态";
//            break;
//        case 65310:
//            msg="填写了省份或城市信息,国家信息不能为空";
//            break;
//        case 65311:
//            msg="填写了城市信息,省份信息不能为空";
//            break;
//        case 65312:
//            msg="不合法的国家信息";
//            break;
//        case 65313:
//            msg="不合法的省份信息";
//            break;
//        case 65314:
//            msg="不合法的城市信息";
//            break;
//        case 65316:
//            msg="该公众号的菜单设置了过多的域名外跳(最多跳转到3个域名的链接)";
//            break;
//        case 65317:
//            msg="不合法的URL";
//            break;
//        case 9001001:
//            msg="POST数据参数不合法";
//            break;
//        case 9001002:
//            msg="远端服务不可用";
//            break;
//        case 9001003:
//            msg="Ticket不合法";
//            break;
//        case 9001004:
//            msg="获取摇周边用户信息失败";
//            break;
//        case 9001005:
//            msg="获取商户信息失败";
//            break;
//        case 9001006:
//            msg="获取OpenID失败";
//            break;
//        case 9001007:
//            msg="上传文件缺失";
//            break;
//        case 9001008:
//            msg="上传素材的文件类型不合法";
//            break;
//        case 9001009:
//            msg="上传素材的文件尺寸不合法";
//            break;
//        case 9001010:
//            msg="上传失败";
//            break;
//        case 9001020:
//            msg="帐号不合法";
//            break;
//        case 9001021:
//            msg="已有设备激活率低于50%,不能新增设备";
//            break;
//        case 9001022:
//            msg="设备申请数不合法,必须为大于0的数字";
//            break;
//        case 9001023:
//            msg="已存在审核中的设备ID申请";
//            break;
//        case 9001024:
//            msg="一次查询设备ID数量不能超过50";
//            break;
//        case 9001025:
//            msg="设备ID不合法";
//            break;
//        case 9001026:
//            msg="页面ID不合法";
//            break;
//        case 9001027:
//            msg="页面参数不合法";
//            break;
//        case 9001028:
//            msg="一次删除页面ID数量不能超过10";
//            break;
//        case 9001029:
//            msg="页面已应用在设备中,请先解除应用关系再删除";
//            break;
//        case 9001030:
//            msg="一次查询页面ID数量不能超过50";
//            break;
//        case 9001031:
//            msg="时间区间不合法";
//            break;
//        case 9001032:
//            msg="保存设备与页面的绑定关系参数错误";
//            break;
//        case 9001033:
//            msg="门店ID不合法";
//            break;
//        case 9001034:
//            msg="设备备注信息过长";
//            break;
//        case 9001035:
//            msg="设备申请参数不合法";
//            break;
//        case 9001036:
//            msg="查询起始值begin不合法";
//            break;
//        default:
//            msg = resultCode+":其他错误";
//            break;
//        }
//        return msg;
//    }
//}

+ 138 - 138
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WechatConfigController.java

@ -1,138 +1,138 @@
package com.yihu.jw.business.wx.controller;
import com.yihu.jw.base.wx.WxWechatDO;
import com.yihu.jw.business.wx.service.WechatService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.base.wx.WxWechatVO;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 */
@RestController
@RequestMapping(WechatRequestMapping.api_common)
@Api(value = "微信相关操作", description = "微信相关操作")
public class WechatConfigController extends EnvelopRestController {
    @Autowired
    private WechatService wechatService;
    @PostMapping(value = WechatRequestMapping.WxConfig.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信配置", notes = "创建微信配置")
    public Envelop createWechat(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxWechatDO wechat = toEntity(jsonData, WxWechatDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_create, wechatService.createWechat(wechat));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WechatRequestMapping.WxConfig.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信配置", notes = "修改微信配置")
    public Envelop updateWechat(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxWechatDO wechat = toEntity(jsonData, WxWechatDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_update, wechatService.updateWxchat(wechat));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WechatRequestMapping.WxConfig.api_delete)
    @ApiOperation(value = "删除微信配置", notes = "删除微信配置")
    public Envelop deleteWechat(
            @ApiParam(name = "ids", value = "ids")
            @RequestParam(value = "ids", required = true) String ids,
            @ApiParam(name = "userId", value = "userId")
            @RequestParam(value = "userId", required = true) String userId,
            @ApiParam(name = "userName", value = "userName")
            @RequestParam(value = "userName", required = true) String userName
            ) {
        try {
            wechatService.deleteWechat(ids,userId,userName);
            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WechatRequestMapping.WxConfig.api_getById)
    @ApiOperation(value = "根据Id查找微信配置", notes = "根据code查找微信配置")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_find, wechatService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WechatRequestMapping.WxConfig.api_getWechats, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信配置列表(分页)")
    public Envelop getWechats(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if(StringUtils.isBlank(sorts)){
            sorts = "-updateTime";
        }
        //得到list数据
        List<WxWechatDO> list = wechatService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wechatService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WxWechatVO> WxWechatVOs = convertToModels(list, new ArrayList<>(list.size()), WxWechatVO.class, fields);
        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxConfig.message_success_find_functions,WxWechatVOs, page, size,count);
    }
    @GetMapping(value = WechatRequestMapping.WxConfig.api_getWechatNoPage)
    @ApiOperation(value = "获取微信列表配置,不分页")
    public Envelop getWechatNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WxWechatDO> list = wechatService.search(fields,filters,sorts);
        //封装返回格式
        List<WxWechatVO> WxWechatVOs = convertToModels(list, new ArrayList<>(list.size()), WxWechatVO.class, fields);
        return Envelop.getSuccessList(WechatRequestMapping.WxConfig.message_success_find_functions,WxWechatVOs);
    }
}
//package com.yihu.jw.business.wx.controller;
//
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.service.WechatService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.restmodel.base.wx.WxWechatVO;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/11.
// */
//@RestController
//@RequestMapping(WechatRequestMapping.api_common)
//@Api(value = "微信相关操作", description = "微信相关操作")
//public class WechatConfigController extends EnvelopRestController {
//    @Autowired
//    private WechatService wechatService;
//
//    @PostMapping(value = WechatRequestMapping.WxConfig.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建微信配置", notes = "创建微信配置")
//    public Envelop createWechat(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxWechatDO wechat = toEntity(jsonData, WxWechatDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_create, wechatService.createWechat(wechat));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PutMapping(value = WechatRequestMapping.WxConfig.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改微信配置", notes = "修改微信配置")
//    public Envelop updateWechat(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxWechatDO wechat = toEntity(jsonData, WxWechatDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_update, wechatService.updateWxchat(wechat));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @DeleteMapping(value = WechatRequestMapping.WxConfig.api_delete)
//    @ApiOperation(value = "删除微信配置", notes = "删除微信配置")
//    public Envelop deleteWechat(
//            @ApiParam(name = "ids", value = "ids")
//            @RequestParam(value = "ids", required = true) String ids,
//            @ApiParam(name = "userId", value = "userId")
//            @RequestParam(value = "userId", required = true) String userId,
//            @ApiParam(name = "userName", value = "userName")
//            @RequestParam(value = "userName", required = true) String userName
//            ) {
//        try {
//            wechatService.deleteWechat(ids,userId,userName);
//            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_delete );
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @GetMapping(value = WechatRequestMapping.WxConfig.api_getById)
//    @ApiOperation(value = "根据Id查找微信配置", notes = "根据code查找微信配置")
//    public Envelop findById(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id
//    ) {
//        try {
//            return Envelop.getSuccess(WechatRequestMapping.WxConfig.message_success_find, wechatService.findById(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @RequestMapping(value = WechatRequestMapping.WxConfig.api_getWechats, method = RequestMethod.GET)
//    @ApiOperation(value = "获取微信配置列表(分页)")
//    public Envelop getWechats(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        if(StringUtils.isBlank(sorts)){
//            sorts = "-updateTime";
//        }
//        //得到list数据
//        List<WxWechatDO> list = wechatService.search(fields, filters, sorts, page, size);
//        //获取总数
//        long count=wechatService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<WxWechatVO> WxWechatVOs = convertToModels(list, new ArrayList<>(list.size()), WxWechatVO.class, fields);
//
//        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxConfig.message_success_find_functions,WxWechatVOs, page, size,count);
//    }
//
//
//    @GetMapping(value = WechatRequestMapping.WxConfig.api_getWechatNoPage)
//    @ApiOperation(value = "获取微信列表配置,不分页")
//    public Envelop getWechatNoPage(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        //得到list数据
//        List<WxWechatDO> list = wechatService.search(fields,filters,sorts);
//        //封装返回格式
//        List<WxWechatVO> WxWechatVOs = convertToModels(list, new ArrayList<>(list.size()), WxWechatVO.class, fields);
//        return Envelop.getSuccessList(WechatRequestMapping.WxConfig.message_success_find_functions,WxWechatVOs);
//    }
//
//}

+ 47 - 47
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxAccessTokenController.java

@ -1,47 +1,47 @@
package com.yihu.jw.business.wx.controller;
import com.yihu.jw.base.wx.WxAccessTokenDO;
import com.yihu.jw.business.wx.service.WxAccessTokenService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by cyx on 2017/5/11.
 */
@RestController
@RequestMapping(WechatRequestMapping.api_common)
@Api(value = "微信token模块", description = "微信token模块接口管理")
public class WxAccessTokenController extends EnvelopRestController {
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 根据wechatCode获取WxAccessToken
     * @param wechatId
     * @return MWxAccessToken
     * @throws Exception
     */
    @GetMapping(value = WechatRequestMapping.WxAccessToken.api_get)
    @ApiOperation(value = "根据wechatId获取最新的WxAccessToken")
    public Envelop getWxAccessToken(
            @ApiParam(name = "wechatId", value = "wechatId")
            @RequestParam(value = "wechatId") String wechatId) {
        try {
            WxAccessTokenDO wxAccessToken = wxAccessTokenService.getWxAccessTokenById(wechatId);
            return Envelop.getSuccess(WechatRequestMapping.WxAccessToken.message_success_get, wxAccessToken);
        }catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}
//package com.yihu.jw.business.wx.controller;
//
//import com.yihu.jw.base.wx.WxAccessTokenDO;
//import com.yihu.jw.business.wx.service.WxAccessTokenService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * Created by cyx on 2017/5/11.
// */
//@RestController
//@RequestMapping(WechatRequestMapping.api_common)
//@Api(value = "微信token模块", description = "微信token模块接口管理")
//public class WxAccessTokenController extends EnvelopRestController {
//
//    @Autowired
//    private WxAccessTokenService wxAccessTokenService;
//
//    /**
//     * 根据wechatCode获取WxAccessToken
//     * @param wechatId
//     * @return MWxAccessToken
//     * @throws Exception
//     */
//    @GetMapping(value = WechatRequestMapping.WxAccessToken.api_get)
//    @ApiOperation(value = "根据wechatId获取最新的WxAccessToken")
//    public Envelop getWxAccessToken(
//            @ApiParam(name = "wechatId", value = "wechatId")
//            @RequestParam(value = "wechatId") String wechatId) {
//        try {
//            WxAccessTokenDO wxAccessToken = wxAccessTokenService.getWxAccessTokenById(wechatId);
//            return Envelop.getSuccess(WechatRequestMapping.WxAccessToken.message_success_get, wxAccessToken);
//        }catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//}

+ 164 - 164
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxGraphicMessageController.java

@ -1,164 +1,164 @@
package com.yihu.jw.business.wx.controller;
import com.yihu.jw.base.wx.WxGraphicMessageDO;
import com.yihu.jw.business.wx.service.WxGraphicMessageService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 *   2017/5/11.
 */
@RestController
@RequestMapping(WechatRequestMapping.api_common)
@Api(value = "微信图文相关操作", description = "微信图文相关操作")
public class WxGraphicMessageController extends EnvelopRestController {
    @Autowired
    private WxGraphicMessageService wxGraphicMessageService;
    @PostMapping(value = WechatRequestMapping.WxGraphicMessage.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信图文消息", notes = "创建微信图文消息")
    public Envelop createWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxGraphicMessageDO WxGraphicMessage = toEntity(jsonData, WxGraphicMessageDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_create, wxGraphicMessageService.createWxGraphicMessage(WxGraphicMessage));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WechatRequestMapping.WxGraphicMessage.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信图文消息", notes = "修改微信图文消息")
    public Envelop updateWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxGraphicMessageDO WxGraphicMessage = toEntity(jsonData, WxGraphicMessageDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_update, wxGraphicMessageService.updateWxGraphicMessage(WxGraphicMessage));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WechatRequestMapping.WxGraphicMessage.api_delete)
    @ApiOperation(value = "删除微信图文消息", notes = "删除微信图文消息")
    public Envelop deleteWxGraphicMessage(
            @ApiParam(name = "codes", value = "codes")
            @RequestParam(value = "codes", required = true) String codes,
            @ApiParam(name = "userCode", value = "userCode")
            @RequestParam(value = "userCode", required = true) String userCode,
            @ApiParam(name = "userName", value = "userName")
            @RequestParam(value = "userName", required = true) String userName
    ) {
        try {
            wxGraphicMessageService.deleteWxGraphicMessage(codes, userCode, userName);
            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WechatRequestMapping.WxGraphicMessage.api_getById)
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    public Envelop findByCode(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_find, wxGraphicMessageService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WechatRequestMapping.WxGraphicMessage.api_getWxGraphicMessages, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信图文消息列表(分页)")
    public Envelop getWxGraphicMessages(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if(StringUtils.isBlank(sorts)){
            sorts = "-updateTime";
        }
        //得到list数据
        List<WxGraphicMessageDO> list = wxGraphicMessageService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wxGraphicMessageService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WxGraphicMessageVO> WxGraphicMessageVOs = convertToModels(list, new ArrayList<>(list.size()), WxGraphicMessageVO.class, fields);
        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxGraphicMessage.message_success_find_functions,WxGraphicMessageVOs, page, size,count);
    }
    @GetMapping(value = WechatRequestMapping.WxGraphicMessage.api_getWxGraphicMessageNoPage)
    @ApiOperation(value = "获取图文消息列表,不分页")
    public Envelop getWxGraphicMessageNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WxGraphicMessageDO> list = wxGraphicMessageService.search(fields,filters,sorts);
        //封装返回格式
        List<WxGraphicMessageVO> WxGraphicMessageVOs = convertToModels(list, new ArrayList<>(list.size()), WxGraphicMessageVO.class, fields);
        return Envelop.getSuccessList(WechatRequestMapping.WxGraphicMessage.message_success_find_functions,WxGraphicMessageVOs);
    }
    //@GetMapping(value = WlyyContants.WxGraphicMessage.api_sendGraphicMessages)
    //@ApiOperation(value = "发送图文消息")
    //public Envelop sendGraphicMessages(
    //        @ApiParam(name = "codes", value = "根据code发送微信图文消息,多个code用,分割")
    //        @RequestParam(value = "codes", required = true) String codes,HttpServletRequest request) throws Exception {
    //    String messages = wxGraphicMessageService.sendGraphicMessages(codes, request);
    //    return Envelop.getSuccess("成功",messages);
    //}
    @GetMapping(value = WechatRequestMapping.WxGraphicMessage.api_sendGraphicMessages)
    @ApiOperation(value = "发送图文消息")
    @ResponseBody
    public String sendGraphicMessages(
            @ApiParam(name = "ids", value = "根据code发送微信图文消息,多个code用,分割")
            @RequestParam(value = "ids", required = true) String ids,
            @ApiParam(name = "fromUserName", value = "用户openid")
            @RequestParam(value = "fromUserName", required = true) String fromUserName,
            @ApiParam(name = "toUserName", value = "公众号")
            @RequestParam(value = "toUserName", required = true) String toUserName
            ) throws Exception {
        String messages = wxGraphicMessageService.sendGraphicMessages(ids, fromUserName,toUserName);
        return messages;
    }
}
//package com.yihu.jw.business.wx.controller;
//
//import com.yihu.jw.base.wx.WxGraphicMessageDO;
//import com.yihu.jw.business.wx.service.WxGraphicMessageService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// *   2017/5/11.
// */
//@RestController
//@RequestMapping(WechatRequestMapping.api_common)
//@Api(value = "微信图文相关操作", description = "微信图文相关操作")
//public class WxGraphicMessageController extends EnvelopRestController {
//    @Autowired
//    private WxGraphicMessageService wxGraphicMessageService;
//
//    @PostMapping(value = WechatRequestMapping.WxGraphicMessage.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建微信图文消息", notes = "创建微信图文消息")
//    public Envelop createWxGraphicMessage(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxGraphicMessageDO WxGraphicMessage = toEntity(jsonData, WxGraphicMessageDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_create, wxGraphicMessageService.createWxGraphicMessage(WxGraphicMessage));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @PutMapping(value = WechatRequestMapping.WxGraphicMessage.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改微信图文消息", notes = "修改微信图文消息")
//    public Envelop updateWxGraphicMessage(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxGraphicMessageDO WxGraphicMessage = toEntity(jsonData, WxGraphicMessageDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_update, wxGraphicMessageService.updateWxGraphicMessage(WxGraphicMessage));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @DeleteMapping(value = WechatRequestMapping.WxGraphicMessage.api_delete)
//    @ApiOperation(value = "删除微信图文消息", notes = "删除微信图文消息")
//    public Envelop deleteWxGraphicMessage(
//            @ApiParam(name = "codes", value = "codes")
//            @RequestParam(value = "codes", required = true) String codes,
//            @ApiParam(name = "userCode", value = "userCode")
//            @RequestParam(value = "userCode", required = true) String userCode,
//            @ApiParam(name = "userName", value = "userName")
//            @RequestParam(value = "userName", required = true) String userName
//    ) {
//        try {
//            wxGraphicMessageService.deleteWxGraphicMessage(codes, userCode, userName);
//            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_delete );
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @GetMapping(value = WechatRequestMapping.WxGraphicMessage.api_getById)
//    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
//    public Envelop findByCode(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id
//    ) {
//        try {
//            return Envelop.getSuccess(WechatRequestMapping.WxGraphicMessage.message_success_find, wxGraphicMessageService.findById(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @RequestMapping(value = WechatRequestMapping.WxGraphicMessage.api_getWxGraphicMessages, method = RequestMethod.GET)
//    @ApiOperation(value = "获取微信图文消息列表(分页)")
//    public Envelop getWxGraphicMessages(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        if(StringUtils.isBlank(sorts)){
//            sorts = "-updateTime";
//        }
//        //得到list数据
//        List<WxGraphicMessageDO> list = wxGraphicMessageService.search(fields, filters, sorts, page, size);
//        //获取总数
//        long count=wxGraphicMessageService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<WxGraphicMessageVO> WxGraphicMessageVOs = convertToModels(list, new ArrayList<>(list.size()), WxGraphicMessageVO.class, fields);
//
//        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxGraphicMessage.message_success_find_functions,WxGraphicMessageVOs, page, size,count);
//    }
//
//
//    @GetMapping(value = WechatRequestMapping.WxGraphicMessage.api_getWxGraphicMessageNoPage)
//    @ApiOperation(value = "获取图文消息列表,不分页")
//    public Envelop getWxGraphicMessageNoPage(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        //得到list数据
//        List<WxGraphicMessageDO> list = wxGraphicMessageService.search(fields,filters,sorts);
//        //封装返回格式
//        List<WxGraphicMessageVO> WxGraphicMessageVOs = convertToModels(list, new ArrayList<>(list.size()), WxGraphicMessageVO.class, fields);
//        return Envelop.getSuccessList(WechatRequestMapping.WxGraphicMessage.message_success_find_functions,WxGraphicMessageVOs);
//    }
//
//    //@GetMapping(value = WlyyContants.WxGraphicMessage.api_sendGraphicMessages)
//    //@ApiOperation(value = "发送图文消息")
//    //public Envelop sendGraphicMessages(
//    //        @ApiParam(name = "codes", value = "根据code发送微信图文消息,多个code用,分割")
//    //        @RequestParam(value = "codes", required = true) String codes,HttpServletRequest request) throws Exception {
//    //    String messages = wxGraphicMessageService.sendGraphicMessages(codes, request);
//    //    return Envelop.getSuccess("成功",messages);
//    //}
//
//    @GetMapping(value = WechatRequestMapping.WxGraphicMessage.api_sendGraphicMessages)
//    @ApiOperation(value = "发送图文消息")
//    @ResponseBody
//    public String sendGraphicMessages(
//            @ApiParam(name = "ids", value = "根据code发送微信图文消息,多个code用,分割")
//            @RequestParam(value = "ids", required = true) String ids,
//            @ApiParam(name = "fromUserName", value = "用户openid")
//            @RequestParam(value = "fromUserName", required = true) String fromUserName,
//            @ApiParam(name = "toUserName", value = "公众号")
//            @RequestParam(value = "toUserName", required = true) String toUserName
//            ) throws Exception {
//        String messages = wxGraphicMessageService.sendGraphicMessages(ids, fromUserName,toUserName);
//        return messages;
//    }
//
//
//}

+ 236 - 236
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxMenuController.java

@ -1,236 +1,236 @@
package com.yihu.jw.business.wx.controller;
import com.yihu.jw.base.wx.WxMenuDO;
import com.yihu.jw.base.wx.WxWechatDO;
import com.yihu.jw.business.wx.WechatResponse;
import com.yihu.jw.business.wx.service.WechatService;
import com.yihu.jw.business.wx.service.WxMenuService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.base.wx.WxMenuVO;
import com.yihu.jw.restmodel.base.wx.WxWechatVO;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@RestController
@RequestMapping(WechatRequestMapping.api_common)
@Api(value = "微信菜单相关操作", description = "微信菜单相关操作")
public class WxMenuController extends EnvelopRestController {
    @Autowired
    private WxMenuService wxMenuService;
    @Autowired
    private WechatService wechatService;
    @PostMapping(value = WechatRequestMapping.WxMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "添加微信菜单", notes = "添加微信菜单")
    public Envelop createWxMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxMenuDO wxMenu = toEntity(jsonData, WxMenuDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_create, wxMenuService.createWxMenu(wxMenu));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WechatRequestMapping.WxMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信菜单", notes = "修改微信菜单")
    public Envelop updateWxMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxMenuDO wxMenu = toEntity(jsonData, WxMenuDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_update, wxMenuService.updateWxMenu(wxMenu));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WechatRequestMapping.WxMenu.api_delete)
    @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
    public Envelop deleteWxMenu(
            @ApiParam(name = "ids", value = "ids")
            @RequestParam(value = "ids", required = true) String ids,
            @ApiParam(name = "userId", value = "userId")
            @RequestParam(value = "userId", required = true) String userId,
            @ApiParam(name = "userName", value = "userName")
            @RequestParam(value = "userName", required = true) String userName
    ) {
        try {
            wxMenuService.deleteWxMenu(ids, userId, userName);
            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WechatRequestMapping.WxMenu.api_getById)
    @ApiOperation(value = "根据code查找微信菜单", notes = "根据code查找微信菜单")
    public Envelop findByCode(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, wxMenuService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WechatRequestMapping.WxMenu.api_getWxMenus, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信菜单列表(分页)")
    public Envelop getWxMenus(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if(StringUtils.isBlank(sorts)){
            sorts = "-updateTime";
        }
        //得到微信列表数据
        List<WxWechatDO> wechats = wechatService.search(fields, filters, sorts, page, size);
        for(WxWechatDO wechat:wechats){
            List<WxMenuDO> parentMenus = wxMenuService.findParentMenuByWechatCode(wechat.getId());
            if (parentMenus.size()>0){
                wechat.setState("closed");
            }else{
                wechat.setState("open");
            }
        }
        //获取总数
        long count=wechatService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WxWechatVO> mwechats = convertToModels(wechats, new ArrayList<>(wechats.size()), WxWechatVO.class, fields);
        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxMenu.message_success_find_functions,mwechats, page, size,count);
    }
    @GetMapping(value = WechatRequestMapping.WxMenu.api_getWxMenuNoPage)
    @ApiOperation(value = "获取微信菜单列表,不分页")
    public Envelop getWxMenuNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        if(filters!=null){
            filters = "supMenucode=0;"+filters;
        }else{
            filters = "supMenucode=0;";
        }
        //得到list数据
        List<WxMenuDO> list = wxMenuService.search(fields,filters,sorts);
        for(WxMenuDO wxMenu:list){
            List<WxMenuDO> childMenus = wxMenuService.findChildMenus(wxMenu.getId());
            wxMenu.setChildren(childMenus);
        }
        //封装返回格式
        List<WxMenuVO> WxMenuVOs = convertToModels(list, new ArrayList<>(list.size()), WxMenuVO.class, fields);
        Map<String, String> map = wechatService.getAllWechatConfig();
        for(WxMenuVO menu:WxMenuVOs){
            menu.setWechatName(map.get(menu.getWechatCode()));
        }
        return Envelop.getSuccessList(WechatRequestMapping.WxMenu.message_success_find_functions,WxMenuVOs);
    }
    /**
     * 创建微信公众号菜单
     *
     * @return
     */
    @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
    @RequestMapping(value = WechatRequestMapping.WxMenu.api_createMenu ,method = RequestMethod.GET)
    public Envelop createWechatMenu(
            @ApiParam(name = "wechatId", value = "", defaultValue = "")
            @RequestParam(value = "wechatId", required = true)String wechatId){
        try{
            JSONObject result = wxMenuService.createWechatMenu(wechatId);
            String errcode = result.get("errcode").toString();
            WechatResponse wechatResponse = new WechatResponse(Integer.valueOf(errcode));
            String msg = wechatResponse.getMsg();
            return Envelop.getSuccess("成功",msg);
        }catch (Exception e){
            return Envelop.getSuccess("创建失败",e );
        }
    }
    /**
     * 根据微信code查找父菜单
     * @param wechatId
     * @return
     */
    @GetMapping(value = WechatRequestMapping.WxMenu.api_getParentMenu)
    @ApiOperation(value = "根据微信code查找父菜单", notes = "根据微信code查找父菜单")
    public Envelop getParentMenu(
            @ApiParam(name = "wechatId", value = "wechatId")
            @PathVariable(value = "wechatId", required = true) String wechatId
    ) {
        try {
            List<WxMenuDO> parentMenus = wxMenuService.findParentMenuByWechatCode(wechatId);
            for(WxMenuDO parentMenu:parentMenus){
                List<WxMenuDO> childMenus = wxMenuService.findChildMenus(parentMenu.getId());
                if (childMenus.size()>0){
                    parentMenu.setState("closed");
                }else{
                    parentMenu.setState("open");
                }
            }
            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, parentMenus);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    /**
     * 根据父级菜单code查找子菜单
     * @param parentCode
     * @return
     */
    @GetMapping(value = WechatRequestMapping.WxMenu.api_getChildMenus)
    @ApiOperation(value = "根据父级菜单code查找子菜单", notes = "根据父级菜单code查找子菜单")
    public Envelop getChildMenus(
            @ApiParam(name = "parentCode", value = "parentCode")
            @PathVariable(value = "parentCode", required = true) String parentCode
    ) {
        try {
            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, wxMenuService.findChildMenus(parentCode));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}
//package com.yihu.jw.business.wx.controller;
//
//import com.yihu.jw.base.wx.WxMenuDO;
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.WechatResponse;
//import com.yihu.jw.business.wx.service.WechatService;
//import com.yihu.jw.business.wx.service.WxMenuService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.restmodel.base.wx.WxMenuVO;
//import com.yihu.jw.restmodel.base.wx.WxWechatVO;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.json.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//@RestController
//@RequestMapping(WechatRequestMapping.api_common)
//@Api(value = "微信菜单相关操作", description = "微信菜单相关操作")
//public class WxMenuController extends EnvelopRestController {
//
//    @Autowired
//    private WxMenuService wxMenuService;
//
//    @Autowired
//    private WechatService wechatService;
//
//    @PostMapping(value = WechatRequestMapping.WxMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "添加微信菜单", notes = "添加微信菜单")
//    public Envelop createWxMenu(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxMenuDO wxMenu = toEntity(jsonData, WxMenuDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_create, wxMenuService.createWxMenu(wxMenu));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PutMapping(value = WechatRequestMapping.WxMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改微信菜单", notes = "修改微信菜单")
//    public Envelop updateWxMenu(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxMenuDO wxMenu = toEntity(jsonData, WxMenuDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_update, wxMenuService.updateWxMenu(wxMenu));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    @DeleteMapping(value = WechatRequestMapping.WxMenu.api_delete)
//    @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
//    public Envelop deleteWxMenu(
//            @ApiParam(name = "ids", value = "ids")
//            @RequestParam(value = "ids", required = true) String ids,
//            @ApiParam(name = "userId", value = "userId")
//            @RequestParam(value = "userId", required = true) String userId,
//            @ApiParam(name = "userName", value = "userName")
//            @RequestParam(value = "userName", required = true) String userName
//    ) {
//        try {
//            wxMenuService.deleteWxMenu(ids, userId, userName);
//            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_delete );
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @GetMapping(value = WechatRequestMapping.WxMenu.api_getById)
//    @ApiOperation(value = "根据code查找微信菜单", notes = "根据code查找微信菜单")
//    public Envelop findByCode(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id
//    ) {
//        try {
//            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, wxMenuService.findById(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @RequestMapping(value = WechatRequestMapping.WxMenu.api_getWxMenus, method = RequestMethod.GET)
//    @ApiOperation(value = "获取微信菜单列表(分页)")
//    public Envelop getWxMenus(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        if(StringUtils.isBlank(sorts)){
//            sorts = "-updateTime";
//        }
//
//        //得到微信列表数据
//        List<WxWechatDO> wechats = wechatService.search(fields, filters, sorts, page, size);
//        for(WxWechatDO wechat:wechats){
//            List<WxMenuDO> parentMenus = wxMenuService.findParentMenuByWechatCode(wechat.getId());
//            if (parentMenus.size()>0){
//                wechat.setState("closed");
//            }else{
//                wechat.setState("open");
//            }
//        }
//        //获取总数
//        long count=wechatService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<WxWechatVO> mwechats = convertToModels(wechats, new ArrayList<>(wechats.size()), WxWechatVO.class, fields);
//        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxMenu.message_success_find_functions,mwechats, page, size,count);
//    }
//
//
//    @GetMapping(value = WechatRequestMapping.WxMenu.api_getWxMenuNoPage)
//    @ApiOperation(value = "获取微信菜单列表,不分页")
//    public Envelop getWxMenuNoPage(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        if(filters!=null){
//            filters = "supMenucode=0;"+filters;
//        }else{
//            filters = "supMenucode=0;";
//        }
//        //得到list数据
//        List<WxMenuDO> list = wxMenuService.search(fields,filters,sorts);
//        for(WxMenuDO wxMenu:list){
//            List<WxMenuDO> childMenus = wxMenuService.findChildMenus(wxMenu.getId());
//            wxMenu.setChildren(childMenus);
//        }
//        //封装返回格式
//        List<WxMenuVO> WxMenuVOs = convertToModels(list, new ArrayList<>(list.size()), WxMenuVO.class, fields);
//        Map<String, String> map = wechatService.getAllWechatConfig();
//        for(WxMenuVO menu:WxMenuVOs){
//            menu.setWechatName(map.get(menu.getWechatCode()));
//        }
//        return Envelop.getSuccessList(WechatRequestMapping.WxMenu.message_success_find_functions,WxMenuVOs);
//    }
//
//    /**
//     * 创建微信公众号菜单
//     *
//     * @return
//     */
//    @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
//    @RequestMapping(value = WechatRequestMapping.WxMenu.api_createMenu ,method = RequestMethod.GET)
//    public Envelop createWechatMenu(
//            @ApiParam(name = "wechatId", value = "", defaultValue = "")
//            @RequestParam(value = "wechatId", required = true)String wechatId){
//        try{
//            JSONObject result = wxMenuService.createWechatMenu(wechatId);
//            String errcode = result.get("errcode").toString();
//            WechatResponse wechatResponse = new WechatResponse(Integer.valueOf(errcode));
//            String msg = wechatResponse.getMsg();
//            return Envelop.getSuccess("成功",msg);
//        }catch (Exception e){
//            return Envelop.getSuccess("创建失败",e );
//        }
//    }
//
//    /**
//     * 根据微信code查找父菜单
//     * @param wechatId
//     * @return
//     */
//    @GetMapping(value = WechatRequestMapping.WxMenu.api_getParentMenu)
//    @ApiOperation(value = "根据微信code查找父菜单", notes = "根据微信code查找父菜单")
//    public Envelop getParentMenu(
//            @ApiParam(name = "wechatId", value = "wechatId")
//            @PathVariable(value = "wechatId", required = true) String wechatId
//    ) {
//        try {
//            List<WxMenuDO> parentMenus = wxMenuService.findParentMenuByWechatCode(wechatId);
//            for(WxMenuDO parentMenu:parentMenus){
//                List<WxMenuDO> childMenus = wxMenuService.findChildMenus(parentMenu.getId());
//                if (childMenus.size()>0){
//                    parentMenu.setState("closed");
//                }else{
//                    parentMenu.setState("open");
//                }
//            }
//            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, parentMenus);
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//
//    /**
//     * 根据父级菜单code查找子菜单
//     * @param parentCode
//     * @return
//     */
//    @GetMapping(value = WechatRequestMapping.WxMenu.api_getChildMenus)
//    @ApiOperation(value = "根据父级菜单code查找子菜单", notes = "根据父级菜单code查找子菜单")
//    public Envelop getChildMenus(
//            @ApiParam(name = "parentCode", value = "parentCode")
//            @PathVariable(value = "parentCode", required = true) String parentCode
//    ) {
//        try {
//            return Envelop.getSuccess(WechatRequestMapping.WxMenu.message_success_find, wxMenuService.findChildMenus(parentCode));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//}

+ 188 - 188
svr/svr-base/src/main/java/com/yihu/jw/business/wx/controller/WxTemplateController.java

@ -1,188 +1,188 @@
package com.yihu.jw.business.wx.controller;
import com.yihu.jw.business.wx.WechatResponse;
import com.yihu.jw.base.wx.Miniprogram;
import com.yihu.jw.base.wx.WxTemplateDO;
import com.yihu.jw.base.wx.WxWechatDO;
import com.yihu.jw.business.wx.service.WechatService;
import com.yihu.jw.business.wx.service.WxTemplateService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.base.wx.WxTemplateVO;
import com.yihu.jw.restmodel.base.wx.WxWechatVO;
import com.yihu.jw.rm.base.WechatRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@RestController
@RequestMapping(WechatRequestMapping.api_common)
@Api(value = "微信模版相关操作", description = "微信模版相关操作")
public class WxTemplateController extends EnvelopRestController {
    @Autowired
    private WxTemplateService wxTemplateService;
    @Autowired
    private WechatService wechatService;
    @PostMapping(value = WechatRequestMapping.WxTemplate.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信模版", notes = "创建微信模版")
    public Envelop createWxTemplate(
            @ApiParam(name = "json_data", value = "微信模版json字符串")
            @RequestBody String jsonData) {
        try {
            WxTemplateDO WxTemplate = toEntity(jsonData, WxTemplateDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_create, wxTemplateService.createWxTemplate(WxTemplate));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WechatRequestMapping.WxTemplate.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信模版", notes = "修改微信模版")
    public Envelop updateWxTemplate(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxTemplateDO WxTemplate = toEntity(jsonData, WxTemplateDO.class);
            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_update, wxTemplateService.updateWxTemplate(WxTemplate));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WechatRequestMapping.WxTemplate.api_delete)
    @ApiOperation(value = "删除微信模版", notes = "删除微信模版")
    public Envelop deleteWxTemplate(
            @ApiParam(name = "codes", value = "codes")
            @RequestParam(value = "codes", required = true) String codes,
            @ApiParam(name = "userCode", value = "userCode")
            @RequestParam(value = "userCode", required = true) String userCode,
            @ApiParam(name = "userName", value = "userName")
            @RequestParam(value = "userName", required = true) String userName
    ) {
        try {
            wxTemplateService.deleteWxTemplate(codes, userCode, userName);
            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WechatRequestMapping.WxTemplate.api_getById)
    @ApiOperation(value = "根据code查找微信模版", notes = "根据code查找微信模版")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_find, wxTemplateService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WechatRequestMapping.WxTemplate.api_getWxTemplates, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信模版列表(分页)")
    public Envelop getWechats(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if(StringUtils.isBlank(sorts)){
            sorts = "-updateTime";
        }
        //得到微信列表数据
        List<WxWechatDO> wechats = wechatService.search(fields, filters, sorts, page, size);
        for(WxWechatDO wechat:wechats){
            List<WxTemplateDO> wxTemplates = wxTemplateService.findByWxId(wechat.getId());
            if (wxTemplates.size()>0){
                wechat.setState("closed");
            }else{
                wechat.setState("open");
            }
        }
        //获取总数
        long count=wechatService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WxWechatVO> mwechats = convertToModels(wechats, new ArrayList<>(wechats.size()), WxWechatVO.class, fields);
        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxMenu.message_success_find_functions,mwechats, page, size,count);
    }
    @GetMapping(value = WechatRequestMapping.WxTemplate.api_getWxTemplatesNoPage)
    @ApiOperation(value = "获取微信模版列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WxTemplateDO> list = wxTemplateService.search(fields,filters,sorts);
        //封装返回格式
        List<WxTemplateVO> mWxTemplateVOs = convertToModels(list, new ArrayList<>(list.size()), WxTemplateVO.class, fields);
        return Envelop.getSuccessList(WechatRequestMapping.WxTemplate.message_success_find_functions,mWxTemplateVOs);
    }
    @GetMapping(value = WechatRequestMapping.WxTemplate.api_sendTemplateMessage)
    @ApiOperation(value = "发送微信模板消息")
    @ResponseBody
    public Envelop sendTemplateMessage(
            @ApiParam(name="openid",value="微信用户的openid")
            @RequestParam String openid,
            @ApiParam(name="templateCode",value = "模板code")
            @RequestParam String templateCode,
            @ApiParam(name="url",value="模板跳转链接")
            @RequestParam(required = false) String url,
            @ApiParam(name="appid",value="所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)")
            @RequestParam(required = false) String appid,
            @ApiParam(name="pagepath",value="所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)")
            @RequestParam(required = false) String pagepath,
            @ApiParam(name="data",value="json字符串")
            @RequestParam String data
    ){
        try {
            Miniprogram miniprogram = null;
            if(StringUtils.isNotBlank(appid)&&StringUtils.isNotBlank(pagepath)){
                miniprogram = new Miniprogram();
                miniprogram.setAppid(appid);
                miniprogram.setPagepath(pagepath);
            }
            JSONObject jsonObject = wxTemplateService.sendTemplateMessage(openid, templateCode, url, data, miniprogram);
            String errcode = jsonObject.get("errcode").toString();
            WechatResponse wechatResponse = new WechatResponse(Integer.valueOf(errcode));
            String msg = wechatResponse.getMsg();
            return Envelop.getSuccess("成功",msg);
        }catch (Exception exception) {
            return Envelop.getSuccess("error", exception);
        }
    }
}
//package com.yihu.jw.business.wx.controller;
//
//import com.yihu.jw.business.wx.WechatResponse;
//import com.yihu.jw.base.wx.Miniprogram;
//import com.yihu.jw.base.wx.WxTemplateDO;
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.service.WechatService;
//import com.yihu.jw.business.wx.service.WxTemplateService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.restmodel.base.wx.WxTemplateVO;
//import com.yihu.jw.restmodel.base.wx.WxWechatVO;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.json.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//@RestController
//@RequestMapping(WechatRequestMapping.api_common)
//@Api(value = "微信模版相关操作", description = "微信模版相关操作")
//public class WxTemplateController extends EnvelopRestController {
//    @Autowired
//    private WxTemplateService wxTemplateService;
//
//    @Autowired
//    private WechatService wechatService;
//
//    @PostMapping(value = WechatRequestMapping.WxTemplate.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建微信模版", notes = "创建微信模版")
//    public Envelop createWxTemplate(
//            @ApiParam(name = "json_data", value = "微信模版json字符串")
//            @RequestBody String jsonData) {
//        try {
//            WxTemplateDO WxTemplate = toEntity(jsonData, WxTemplateDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_create, wxTemplateService.createWxTemplate(WxTemplate));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @PutMapping(value = WechatRequestMapping.WxTemplate.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改微信模版", notes = "修改微信模版")
//    public Envelop updateWxTemplate(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            WxTemplateDO WxTemplate = toEntity(jsonData, WxTemplateDO.class);
//            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_update, wxTemplateService.updateWxTemplate(WxTemplate));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @DeleteMapping(value = WechatRequestMapping.WxTemplate.api_delete)
//    @ApiOperation(value = "删除微信模版", notes = "删除微信模版")
//    public Envelop deleteWxTemplate(
//            @ApiParam(name = "codes", value = "codes")
//            @RequestParam(value = "codes", required = true) String codes,
//            @ApiParam(name = "userCode", value = "userCode")
//            @RequestParam(value = "userCode", required = true) String userCode,
//            @ApiParam(name = "userName", value = "userName")
//            @RequestParam(value = "userName", required = true) String userName
//    ) {
//        try {
//            wxTemplateService.deleteWxTemplate(codes, userCode, userName);
//            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_delete );
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @GetMapping(value = WechatRequestMapping.WxTemplate.api_getById)
//    @ApiOperation(value = "根据code查找微信模版", notes = "根据code查找微信模版")
//    public Envelop findById(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id
//    ) {
//        try {
//            return Envelop.getSuccess(WechatRequestMapping.WxTemplate.message_success_find, wxTemplateService.findById(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//    @RequestMapping(value = WechatRequestMapping.WxTemplate.api_getWxTemplates, method = RequestMethod.GET)
//    @ApiOperation(value = "获取微信模版列表(分页)")
//    public Envelop getWechats(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        if(StringUtils.isBlank(sorts)){
//            sorts = "-updateTime";
//        }
//
//        //得到微信列表数据
//        List<WxWechatDO> wechats = wechatService.search(fields, filters, sorts, page, size);
//        for(WxWechatDO wechat:wechats){
//            List<WxTemplateDO> wxTemplates = wxTemplateService.findByWxId(wechat.getId());
//            if (wxTemplates.size()>0){
//                wechat.setState("closed");
//            }else{
//                wechat.setState("open");
//            }
//        }
//        //获取总数
//        long count=wechatService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<WxWechatVO> mwechats = convertToModels(wechats, new ArrayList<>(wechats.size()), WxWechatVO.class, fields);
//        return Envelop.getSuccessListWithPage(WechatRequestMapping.WxMenu.message_success_find_functions,mwechats, page, size,count);
//
//    }
//
//
//    @GetMapping(value = WechatRequestMapping.WxTemplate.api_getWxTemplatesNoPage)
//    @ApiOperation(value = "获取微信模版列表(不分页)")
//    public Envelop getList(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        //得到list数据
//        List<WxTemplateDO> list = wxTemplateService.search(fields,filters,sorts);
//        //封装返回格式
//        List<WxTemplateVO> mWxTemplateVOs = convertToModels(list, new ArrayList<>(list.size()), WxTemplateVO.class, fields);
//        return Envelop.getSuccessList(WechatRequestMapping.WxTemplate.message_success_find_functions,mWxTemplateVOs);
//    }
//
//    @GetMapping(value = WechatRequestMapping.WxTemplate.api_sendTemplateMessage)
//    @ApiOperation(value = "发送微信模板消息")
//    @ResponseBody
//    public Envelop sendTemplateMessage(
//            @ApiParam(name="openid",value="微信用户的openid")
//            @RequestParam String openid,
//            @ApiParam(name="templateCode",value = "模板code")
//            @RequestParam String templateCode,
//            @ApiParam(name="url",value="模板跳转链接")
//            @RequestParam(required = false) String url,
//            @ApiParam(name="appid",value="所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)")
//            @RequestParam(required = false) String appid,
//            @ApiParam(name="pagepath",value="所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)")
//            @RequestParam(required = false) String pagepath,
//            @ApiParam(name="data",value="json字符串")
//            @RequestParam String data
//    ){
//        try {
//            Miniprogram miniprogram = null;
//            if(StringUtils.isNotBlank(appid)&&StringUtils.isNotBlank(pagepath)){
//                miniprogram = new Miniprogram();
//                miniprogram.setAppid(appid);
//                miniprogram.setPagepath(pagepath);
//            }
//            JSONObject jsonObject = wxTemplateService.sendTemplateMessage(openid, templateCode, url, data, miniprogram);
//            String errcode = jsonObject.get("errcode").toString();
//            WechatResponse wechatResponse = new WechatResponse(Integer.valueOf(errcode));
//            String msg = wechatResponse.getMsg();
//            return Envelop.getSuccess("成功",msg);
//        }catch (Exception exception) {
//            return Envelop.getSuccess("error", exception);
//        }
//    }
//}

+ 27 - 27
svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WechatDao.java

@ -1,27 +1,27 @@
package com.yihu.jw.business.wx.dao;
import com.yihu.jw.base.wx.WxWechatDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public interface WechatDao extends PagingAndSortingRepository<WxWechatDO, String>, JpaSpecificationExecutor<WxWechatDO> {
    @Query("from WxWechatDO w where w.appId = ?1 and w.status!=-1")
    WxWechatDO findByAppId(String appId);
    @Query("from WxWechatDO w where w.appId = ?1 and w.id!= ?2 and w.status!=-1")
    WxWechatDO findByAppIdExcludeId(String appId, String id);
    @Query("from WxWechatDO w where w.id = ?1 and w.status!=-1")
    WxWechatDO findById(String id);
    @Query("from WxWechatDO w where w.status!=-1")
    List<WxWechatDO> findAll();
}
//package com.yihu.jw.business.wx.dao;
//
//import com.yihu.jw.base.wx.WxWechatDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by Administrator on 2017/5/20 0020.
// */
//public interface WechatDao extends PagingAndSortingRepository<WxWechatDO, String>, JpaSpecificationExecutor<WxWechatDO> {
//
//    @Query("from WxWechatDO w where w.appId = ?1 and w.status!=-1")
//    WxWechatDO findByAppId(String appId);
//
//
//    @Query("from WxWechatDO w where w.appId = ?1 and w.id!= ?2 and w.status!=-1")
//    WxWechatDO findByAppIdExcludeId(String appId, String id);
//
//    @Query("from WxWechatDO w where w.id = ?1 and w.status!=-1")
//    WxWechatDO findById(String id);
//
//    @Query("from WxWechatDO w where w.status!=-1")
//    List<WxWechatDO> findAll();
//}

+ 17 - 17
svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxAccessTokenDao.java

@ -1,17 +1,17 @@
package com.yihu.jw.business.wx.dao;
import com.yihu.jw.base.wx.WxAccessTokenDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/18 0018.
 */
public interface WxAccessTokenDao extends PagingAndSortingRepository<WxAccessTokenDO, String>, JpaSpecificationExecutor<WxAccessTokenDO> {
    @Query("from WxAccessTokenDO w where w.wechatId =?1 order by w.addTimestamp desc")
    List<WxAccessTokenDO> getWxAccessTokenById(String wechatId);
}
//package com.yihu.jw.business.wx.dao;
//
//import com.yihu.jw.base.wx.WxAccessTokenDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by Administrator on 2017/5/18 0018.
// */
//public interface WxAccessTokenDao extends PagingAndSortingRepository<WxAccessTokenDO, String>, JpaSpecificationExecutor<WxAccessTokenDO> {
//
//    @Query("from WxAccessTokenDO w where w.wechatId =?1 order by w.addTimestamp desc")
//    List<WxAccessTokenDO> getWxAccessTokenById(String wechatId);
//}

+ 15 - 15
svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxGraphicMessageDao.java

@ -1,15 +1,15 @@
package com.yihu.jw.business.wx.dao;
import com.yihu.jw.base.wx.WxGraphicMessageDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public interface WxGraphicMessageDao extends PagingAndSortingRepository<WxGraphicMessageDO, String>, JpaSpecificationExecutor<WxGraphicMessageDO> {
    @Query("from WxGraphicMessageDO w where w.id =?1 and w.status!=-1")
    WxGraphicMessageDO findById(String id);
}
//package com.yihu.jw.business.wx.dao;
//
//import com.yihu.jw.base.wx.WxGraphicMessageDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by Administrator on 2017/5/20 0020.
// */
//public interface WxGraphicMessageDao extends PagingAndSortingRepository<WxGraphicMessageDO, String>, JpaSpecificationExecutor<WxGraphicMessageDO> {
//
//    @Query("from WxGraphicMessageDO w where w.id =?1 and w.status!=-1")
//    WxGraphicMessageDO findById(String id);
//}

+ 47 - 47
svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxMenuDao.java

@ -1,47 +1,47 @@
package com.yihu.jw.business.wx.dao;
import com.yihu.jw.base.wx.WxMenuDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
public interface WxMenuDao  extends PagingAndSortingRepository<WxMenuDO, String>, JpaSpecificationExecutor<WxMenuDO> {
    @Query("from WxMenuDO m where m.id = ?1 and m.status = 1")
    WxMenuDO findById(String id);
    @Query("from WxMenuDO m where m.wechatId =?1 and m.status = 1 order  by m.supMenuid ,m.sort")
    List<WxMenuDO> findByWechatId(String wechatId);
    @Query("from WxMenuDO m where m.wechatId = ?1 and  m.supMenuid= ?2 and m.status =1 order by m.sort")
    List<WxMenuDO> findChildMenus(String wechatId, String supMenuid);
    @Query("from WxMenuDO m where  m.supMenuid= ?1 and m.status =1 order by m.sort")
    List<WxMenuDO> findChildMenus( String supMenuid);
    /**
     * 根据wechatId判断父菜单的sort是否重复
     * @param wechatId
     * @param sort
     */
    @Query("from WxMenuDO m where m.wechatId = ?1 and m.status =1 and m.sort =?2 and m.supMenuid ='0' and m.id != ?3")
    WxMenuDO findByWechatIdExcludeSortFromParent(String wechatId, Integer sort,String id);
    /**
     * 根据wechatId,supMenucode判断子菜单的sort是否重复
     * @param wechatId
     * @param sort
     */
    @Query("from WxMenuDO m where m.wechatId = ?1 and m.status =1 and m.sort =?2 and m.supMenuid =?3 and m.id != ?4")
    WxMenuDO findByWechatIdExcludeSortFromChild(String wechatId, Integer sort,String supMenuid,String id);
    @Query("from WxMenuDO m where m.wechatId =?1 and m.status = 1 and  m.supMenuid = '0' order by m.supMenuid ,m.sort")
    List<WxMenuDO> findParentMenuByWechatId(String wechatId);
}
//package com.yihu.jw.business.wx.dao;
//
//import com.yihu.jw.base.wx.WxMenuDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//public interface WxMenuDao  extends PagingAndSortingRepository<WxMenuDO, String>, JpaSpecificationExecutor<WxMenuDO> {
//
//
//    @Query("from WxMenuDO m where m.id = ?1 and m.status = 1")
//    WxMenuDO findById(String id);
//
//    @Query("from WxMenuDO m where m.wechatId =?1 and m.status = 1 order  by m.supMenuid ,m.sort")
//    List<WxMenuDO> findByWechatId(String wechatId);
//
//    @Query("from WxMenuDO m where m.wechatId = ?1 and  m.supMenuid= ?2 and m.status =1 order by m.sort")
//    List<WxMenuDO> findChildMenus(String wechatId, String supMenuid);
//
//    @Query("from WxMenuDO m where  m.supMenuid= ?1 and m.status =1 order by m.sort")
//    List<WxMenuDO> findChildMenus( String supMenuid);
//
//    /**
//     * 根据wechatId判断父菜单的sort是否重复
//     * @param wechatId
//     * @param sort
//     */
//    @Query("from WxMenuDO m where m.wechatId = ?1 and m.status =1 and m.sort =?2 and m.supMenuid ='0' and m.id != ?3")
//    WxMenuDO findByWechatIdExcludeSortFromParent(String wechatId, Integer sort,String id);
//
//    /**
//     * 根据wechatId,supMenucode判断子菜单的sort是否重复
//     * @param wechatId
//     * @param sort
//     */
//    @Query("from WxMenuDO m where m.wechatId = ?1 and m.status =1 and m.sort =?2 and m.supMenuid =?3 and m.id != ?4")
//    WxMenuDO findByWechatIdExcludeSortFromChild(String wechatId, Integer sort,String supMenuid,String id);
//
//    @Query("from WxMenuDO m where m.wechatId =?1 and m.status = 1 and  m.supMenuid = '0' order by m.supMenuid ,m.sort")
//    List<WxMenuDO> findParentMenuByWechatId(String wechatId);
//
//}

+ 21 - 21
svr/svr-base/src/main/java/com/yihu/jw/business/wx/dao/WxTemplateDao.java

@ -1,21 +1,21 @@
package com.yihu.jw.business.wx.dao;
import com.yihu.jw.base.wx.WxTemplateDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public interface WxTemplateDao extends PagingAndSortingRepository<WxTemplateDO, String>, JpaSpecificationExecutor<WxTemplateDO> {
    @Query("from WxTemplateDO w where w.id = ?1 and w.status =1")
    WxTemplateDO findById(String id);
    @Query("from WxTemplateDO w where w.wechatId = ?1 and w.status =1")
    List<WxTemplateDO> findByWxId(String wechatId);
}
//package com.yihu.jw.business.wx.dao;
//
//import com.yihu.jw.base.wx.WxTemplateDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by Administrator on 2017/5/20 0020.
// */
//public interface WxTemplateDao extends PagingAndSortingRepository<WxTemplateDO, String>, JpaSpecificationExecutor<WxTemplateDO> {
//
//
//    @Query("from WxTemplateDO w where w.id = ?1 and w.status =1")
//    WxTemplateDO findById(String id);
//
//    @Query("from WxTemplateDO w where w.wechatId = ?1 and w.status =1")
//    List<WxTemplateDO> findByWxId(String wechatId);
//}

+ 114 - 114
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WechatService.java

@ -1,114 +1,114 @@
package com.yihu.jw.business.wx.service;
import com.yihu.jw.base.wx.WxWechatDO;
import com.yihu.jw.business.wx.dao.WechatDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rm.base.WechatRequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.util.*;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
@Service
public class WechatService extends BaseJpaService<WxWechatDO, WechatDao> {
    @Autowired
    private WechatDao wechatDao;
    @Transient
    public WxWechatDO createWechat(WxWechatDO wechat) {
        String code = UUID.randomUUID().toString().replaceAll("-", "");
        wechat.setId(code);
        if (StringUtils.isEmpty(wechat.getSaasId())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getStatus())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_status_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getType())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_type_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getName())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        WxWechatDO wechatTem = wechatDao.findByAppId(wechat.getAppId());
        if (wechatTem != null) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_exist, ExceptionCode.common_error_params_code);
        }
        return wechatDao.save(wechat);
    }
    @Transient
    public WxWechatDO updateWxchat(WxWechatDO wechat) {
        if (StringUtils.isEmpty(wechat.getSaasId())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getStatus())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_status_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getType())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_type_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getName())) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        WxWechatDO wechat1 = findById(wechat.getId());
        if (wechat1 == null) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
        }
        WxWechatDO wechatTem = wechatDao.findByAppIdExcludeId(wechat.getAppId(), wechat.getId());
        if (wechatTem != null) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_exist, ExceptionCode.common_error_params_code);
        }
        return wechatDao.save(wechat);
    }
    public WxWechatDO findById(String id) {
        return wechatDao.findById(id);
    }
    @Transient
    public void deleteWechat(String ids, String userId, String userName) {
        if (!StringUtils.isEmpty(ids)) {
            String[] codeArray = ids.split(",");
            for (String code : codeArray) {
                WxWechatDO wxWechat = wechatDao.findById(code);
                if (wxWechat == null) {
                    throw new ApiException(WechatRequestMapping.WxConfig.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
                }
                wxWechat.setStatus(-1);
                wxWechat.setUpdateUser(userId);
                wxWechat.setUpdateUserName(userName);
                wechatDao.save(wxWechat);
            }
        }
    }
    public List<WxWechatDO> findAll() {
        return wechatDao.findAll();
    }
    /**
     * key为code ,value为微信名字
     *
     * @return
     */
    public Map<String, String> getAllWechatConfig() {
        List<WxWechatDO> wechats = findAll();
        Map<String, String> map = new HashMap<>();
        if (null != wechats) {
            for (WxWechatDO wx : wechats) {
                map.put(wx.getId(), wx.getName());
            }
        }
        return map;
    }
}
//package com.yihu.jw.business.wx.service;
//
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.dao.WechatDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import javax.persistence.Transient;
//import java.util.*;
//
///**
// * Created by Administrator on 2017/5/20 0020.
// */
//@Service
//public class WechatService extends BaseJpaService<WxWechatDO, WechatDao> {
//
//    @Autowired
//    private WechatDao wechatDao;
//
//    @Transient
//    public WxWechatDO createWechat(WxWechatDO wechat) {
//        String code = UUID.randomUUID().toString().replaceAll("-", "");
//        wechat.setId(code);
//        if (StringUtils.isEmpty(wechat.getSaasId())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wechat.getStatus())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_status_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wechat.getType())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_type_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wechat.getName())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        WxWechatDO wechatTem = wechatDao.findByAppId(wechat.getAppId());
//        if (wechatTem != null) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_exist, ExceptionCode.common_error_params_code);
//        }
//        return wechatDao.save(wechat);
//    }
//
//    @Transient
//    public WxWechatDO updateWxchat(WxWechatDO wechat) {
//        if (StringUtils.isEmpty(wechat.getSaasId())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_saasId_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wechat.getStatus())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_status_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wechat.getType())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_type_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wechat.getName())) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        WxWechatDO wechat1 = findById(wechat.getId());
//        if (wechat1 == null) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
//        }
//        WxWechatDO wechatTem = wechatDao.findByAppIdExcludeId(wechat.getAppId(), wechat.getId());
//        if (wechatTem != null) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_exist, ExceptionCode.common_error_params_code);
//        }
//        return wechatDao.save(wechat);
//    }
//
//
//    public WxWechatDO findById(String id) {
//        return wechatDao.findById(id);
//    }
//
//    @Transient
//    public void deleteWechat(String ids, String userId, String userName) {
//        if (!StringUtils.isEmpty(ids)) {
//            String[] codeArray = ids.split(",");
//            for (String code : codeArray) {
//                WxWechatDO wxWechat = wechatDao.findById(code);
//                if (wxWechat == null) {
//                    throw new ApiException(WechatRequestMapping.WxConfig.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//                }
//                wxWechat.setStatus(-1);
//                wxWechat.setUpdateUser(userId);
//                wxWechat.setUpdateUserName(userName);
//                wechatDao.save(wxWechat);
//            }
//        }
//    }
//
//    public List<WxWechatDO> findAll() {
//        return wechatDao.findAll();
//    }
//
//    /**
//     * key为code ,value为微信名字
//     *
//     * @return
//     */
//    public Map<String, String> getAllWechatConfig() {
//        List<WxWechatDO> wechats = findAll();
//        Map<String, String> map = new HashMap<>();
//        if (null != wechats) {
//            for (WxWechatDO wx : wechats) {
//                map.put(wx.getId(), wx.getName());
//            }
//        }
//        return map;
//    }
//}

+ 96 - 96
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxAccessTokenService.java

@ -1,96 +1,96 @@
package com.yihu.jw.business.wx.service;
import com.yihu.jw.base.wx.WxAccessTokenDO;
import com.yihu.jw.base.wx.WxWechatDO;
import com.yihu.jw.business.wx.dao.WechatDao;
import com.yihu.jw.business.wx.dao.WxAccessTokenDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by Administrator on 2017/5/18 0018.
 */
@Service
public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAccessTokenDao> {
    private Logger logger= LoggerFactory.getLogger(WxAccessTokenService.class);
    @Autowired
    private WxAccessTokenDao wxAccessTokenDao;
    @Autowired
    private WechatDao wechatDao;
    /**
     * 根据wechatCode查找最新一条
     * @param wechatId
     * @return
     */
    public WxAccessTokenDO getWxAccessTokenById(String wechatId) {
        try {
            //根据wechatCode查找出appid和appSecret
            WxWechatDO wxWechat = wechatDao.findById(wechatId);
            if(wxWechat==null){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
            }
            List<WxAccessTokenDO> wxAccessTokens =  wxAccessTokenDao.getWxAccessTokenById(wechatId);
            if(wxAccessTokens!=null&&wxAccessTokens.size()>0){
                for (WxAccessTokenDO accessToken : wxAccessTokens) {
                    if ((System.currentTimeMillis() - accessToken.getAddTimestamp()) < (accessToken.getExpiresIn() * 1000)) {
                        return accessToken;
                    } else {
                        wxAccessTokenDao.delete(accessToken);
                        break;
                    }
                }
            }
            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
            String appId="";
            String appSecret="";
            appId = wxWechat.getAppId();
            appSecret = wxWechat.getAppSecret();
            if (StringUtils.isEmpty(appId)){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_is_null, ExceptionCode.common_error_params_code);
            }
            if (StringUtils.isEmpty(appSecret)){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appSecret_is_null, ExceptionCode.common_error_params_code);
            }
            String params = "grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
            String result = HttpUtil.sendGet(token_url, params);
            logger.info("--------------微信返回结果:"+result+"---------------");
            JSONObject json = new JSONObject(result);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();
                String expires_in = json.get("expires_in").toString();
                WxAccessTokenDO newaccessToken = new WxAccessTokenDO();
                newaccessToken.setAccessToken(token);
                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
                newaccessToken.setAddTimestamp(System.currentTimeMillis());
                newaccessToken.setCzrq(new Date());
                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
                newaccessToken.setWechatId(wechatId);
                wxAccessTokenDao.save(newaccessToken);
                return newaccessToken;
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
//package com.yihu.jw.business.wx.service;
//
//import com.yihu.jw.base.wx.WxAccessTokenDO;
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.dao.WechatDao;
//import com.yihu.jw.business.wx.dao.WxAccessTokenDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import com.yihu.jw.util.HttpUtil;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import java.util.Date;
//import java.util.List;
//import java.util.UUID;
//
///**
// * Created by Administrator on 2017/5/18 0018.
// */
//@Service
//public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAccessTokenDao> {
//
//
//    private Logger logger= LoggerFactory.getLogger(WxAccessTokenService.class);
//
//    @Autowired
//    private WxAccessTokenDao wxAccessTokenDao;
//
//    @Autowired
//    private WechatDao wechatDao;
//
//    /**
//     * 根据wechatCode查找最新一条
//     * @param wechatId
//     * @return
//     */
//    public WxAccessTokenDO getWxAccessTokenById(String wechatId) {
//        try {
//            //根据wechatCode查找出appid和appSecret
//            WxWechatDO wxWechat = wechatDao.findById(wechatId);
//            if(wxWechat==null){
//                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
//            }
//            List<WxAccessTokenDO> wxAccessTokens =  wxAccessTokenDao.getWxAccessTokenById(wechatId);
//            if(wxAccessTokens!=null&&wxAccessTokens.size()>0){
//                for (WxAccessTokenDO accessToken : wxAccessTokens) {
//                    if ((System.currentTimeMillis() - accessToken.getAddTimestamp()) < (accessToken.getExpiresIn() * 1000)) {
//                        return accessToken;
//                    } else {
//                        wxAccessTokenDao.delete(accessToken);
//                        break;
//                    }
//                }
//            }
//            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
//            String appId="";
//            String appSecret="";
//            appId = wxWechat.getAppId();
//            appSecret = wxWechat.getAppSecret();
//            if (StringUtils.isEmpty(appId)){
//                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_is_null, ExceptionCode.common_error_params_code);
//            }
//            if (StringUtils.isEmpty(appSecret)){
//                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appSecret_is_null, ExceptionCode.common_error_params_code);
//            }
//            String params = "grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
//            String result = HttpUtil.sendGet(token_url, params);
//            logger.info("--------------微信返回结果:"+result+"---------------");
//            JSONObject json = new JSONObject(result);
//            if (json.has("access_token")) {
//                String token = json.get("access_token").toString();
//                String expires_in = json.get("expires_in").toString();
//                WxAccessTokenDO newaccessToken = new WxAccessTokenDO();
//                newaccessToken.setAccessToken(token);
//                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
//                newaccessToken.setAddTimestamp(System.currentTimeMillis());
//                newaccessToken.setCzrq(new Date());
//                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
//                newaccessToken.setWechatId(wechatId);
//                wxAccessTokenDao.save(newaccessToken);
//                return newaccessToken;
//            } else {
//                return null;
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            return null;
//        }
//    }
//}

+ 177 - 177
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxGraphicMessageService.java

@ -1,177 +1,177 @@
package com.yihu.jw.business.wx.service;
import com.yihu.jw.base.wx.WxGraphicMessageDO;
import com.yihu.jw.business.wx.dao.WxGraphicMessageDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.util.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
@Service
public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessageDO, WxGraphicMessageDao> {
    @Autowired
    private WxGraphicMessageDao wxGraphicMessageDao;
    @Transient
    public WxGraphicMessageDO createWxGraphicMessage(WxGraphicMessageDO wxGraphicMessage) {
        String code = UUID.randomUUID().toString().replaceAll("-", "");
        wxGraphicMessage.setId(code);
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_status_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getTitle())) {
            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_title_is_null, ExceptionCode.common_error_params_code);
        }
        WxGraphicMessageDO wxGraphicMessageTem = wxGraphicMessageDao.findById(wxGraphicMessage.getId());
        if (wxGraphicMessageTem != null) {
            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_id_exist, ExceptionCode.common_error_params_code);
        }
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    @Transient
    public WxGraphicMessageDO updateWxGraphicMessage(WxGraphicMessageDO wxGraphicMessage) {
        if (StringUtils.isEmpty(wxGraphicMessage.getId())) {
            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_status_is_null, ExceptionCode.common_error_params_code);
        }
        //根据id查找
        WxGraphicMessageDO wxGraphicMessage1 = findById(wxGraphicMessage.getId());
        if(wxGraphicMessage1==null){
            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_wxGraphicMessage_is_no_exist, ExceptionCode.common_error_params_code);
        }
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    public WxGraphicMessageDO findById(String id) {
      return wxGraphicMessageDao.findById(id);
    }
    @Transient
    public void deleteWxGraphicMessage(String codes, String userCode, String userName) {
        if(!StringUtils.isEmpty(codes)){
            String[] codeArray = codes.split(",");
            for(String code:codeArray){
                WxGraphicMessageDO wxGraphicMessage = findById(code);
                wxGraphicMessage.setStatus(-1);
                wxGraphicMessage.setUpdateUser(userCode);
                wxGraphicMessage.setUpdateUserName(userName);
                wxGraphicMessageDao.save(wxGraphicMessage);
            }
        }
    }
    private String replyNewsMessage(String toUser,String fromUser,List<Map<String,String>> articles) throws Exception {
        if(articles == null || articles.size() < 1){
            throw new Exception("图文信息不能为空!");
        }
        StringBuilder result = new StringBuilder();
        result.append("<xml>");
        result.append("<ToUserName>" + toUser + "</ToUserName>");
        result.append("<FromUserName>" + fromUser + "</FromUserName>");
        result.append("<CreateTime>" + new Date().getTime() + "</CreateTime>");
        result.append("<MsgType>news</MsgType>");
        result.append("<ArticleCount>" + articles.size() + "</ArticleCount>");
        result.append("<Articles>");
        for(Map<String,String>  article : articles){
            result.append("<item>");
            result.append("<Title>" +  article.get("Title") +"</Title>");
            result.append("<Description>" + article.get("Description") + "</Description>");
            result.append("<PicUrl>" + article.get("PicUrl") + "</PicUrl>");
            result.append("<Url>" + article.get("Url") + "</Url>");
            result.append("</item>");
        }
        result.append("</Articles>");
        result.append("</xml>");
        return result.toString();
    }
    /**
     * 发送图文消息
     * @param codes
     * @param request
     * @return
     */
    public String sendGraphicMessages(String codes, HttpServletRequest request) {
        try {
            // xml请求解析
            Map<String, String> requestMap = MessageUtil.parseXml(request);
            //用户openid
            String fromUserName = requestMap.get("FromUserName");
            //微信公众号
            String toUserName = requestMap.get("ToUserName");
            // 图文信息
            List<Map<String,String>> articles =  new ArrayList<>();
            if(codes!=null){
                String[] codeArray = codes.split(",");
                for(String code: codeArray){
                    WxGraphicMessageDO graphicMessage = findById(code);
                    Map<String,String> article = new HashMap<>();
                    article.put("Url",graphicMessage.getUrl());
                    article.put("Title", graphicMessage.getTitle());
                    article.put("Description",graphicMessage.getDescription());
                    article.put("PicUrl",graphicMessage.getPicUrl());
                    articles.add(article);
                }
            }
            // 构建回复消息XML
            return replyNewsMessage(fromUserName, toUserName, articles);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }
    }
    /**
     * 发送图文消息
     * @param ids
     * @param fromUserName   用户的openId
     * @param toUserName
     * @return
     */
    public String sendGraphicMessages(String ids, String fromUserName,String toUserName) {
        try {
        // 图文信息
            List<Map<String,String>> articles =  new ArrayList<>();
            if(ids!=null){
                String[] codeArray = ids.split(",");
                for(String id: codeArray){
                    WxGraphicMessageDO graphicMessage = findById(id);
                    Map<String,String> article = new HashMap<>();
                    article.put("Url",graphicMessage.getUrl());
                    article.put("Title", graphicMessage.getTitle());
                    article.put("Description",graphicMessage.getDescription());
                    article.put("PicUrl",graphicMessage.getPicUrl());
                    articles.add(article);
                }
            }
            // 构建回复消息XML
            return replyNewsMessage(fromUserName, toUserName, articles);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }
    }
}
//package com.yihu.jw.business.wx.service;
//
//import com.yihu.jw.base.wx.WxGraphicMessageDO;
//import com.yihu.jw.business.wx.dao.WxGraphicMessageDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import com.yihu.jw.util.MessageUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import javax.persistence.Transient;
//import javax.servlet.http.HttpServletRequest;
//import java.util.*;
//
///**
// * Created by Administrator on 2017/5/20 0020.
// */
//@Service
//public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessageDO, WxGraphicMessageDao> {
//
//    @Autowired
//    private WxGraphicMessageDao wxGraphicMessageDao;
//
//    @Transient
//    public WxGraphicMessageDO createWxGraphicMessage(WxGraphicMessageDO wxGraphicMessage) {
//        String code = UUID.randomUUID().toString().replaceAll("-", "");
//        wxGraphicMessage.setId(code);
//        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
//            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_status_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wxGraphicMessage.getTitle())) {
//            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_title_is_null, ExceptionCode.common_error_params_code);
//        }
//        WxGraphicMessageDO wxGraphicMessageTem = wxGraphicMessageDao.findById(wxGraphicMessage.getId());
//        if (wxGraphicMessageTem != null) {
//            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_id_exist, ExceptionCode.common_error_params_code);
//        }
//        return wxGraphicMessageDao.save(wxGraphicMessage);
//    }
//
//    @Transient
//    public WxGraphicMessageDO updateWxGraphicMessage(WxGraphicMessageDO wxGraphicMessage) {
//        if (StringUtils.isEmpty(wxGraphicMessage.getId())) {
//            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
//            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_status_is_null, ExceptionCode.common_error_params_code);
//        }
//
//        //根据id查找
//        WxGraphicMessageDO wxGraphicMessage1 = findById(wxGraphicMessage.getId());
//        if(wxGraphicMessage1==null){
//            throw new ApiException(WechatRequestMapping.WxGraphicMessage.message_fail_wxGraphicMessage_is_no_exist, ExceptionCode.common_error_params_code);
//        }
//        return wxGraphicMessageDao.save(wxGraphicMessage);
//    }
//
//    public WxGraphicMessageDO findById(String id) {
//      return wxGraphicMessageDao.findById(id);
//    }
//
//    @Transient
//    public void deleteWxGraphicMessage(String codes, String userCode, String userName) {
//        if(!StringUtils.isEmpty(codes)){
//            String[] codeArray = codes.split(",");
//            for(String code:codeArray){
//                WxGraphicMessageDO wxGraphicMessage = findById(code);
//                wxGraphicMessage.setStatus(-1);
//                wxGraphicMessage.setUpdateUser(userCode);
//                wxGraphicMessage.setUpdateUserName(userName);
//                wxGraphicMessageDao.save(wxGraphicMessage);
//            }
//        }
//    }
//
//
//
//    private String replyNewsMessage(String toUser,String fromUser,List<Map<String,String>> articles) throws Exception {
//        if(articles == null || articles.size() < 1){
//            throw new Exception("图文信息不能为空!");
//        }
//
//        StringBuilder result = new StringBuilder();
//        result.append("<xml>");
//        result.append("<ToUserName>" + toUser + "</ToUserName>");
//        result.append("<FromUserName>" + fromUser + "</FromUserName>");
//        result.append("<CreateTime>" + new Date().getTime() + "</CreateTime>");
//        result.append("<MsgType>news</MsgType>");
//        result.append("<ArticleCount>" + articles.size() + "</ArticleCount>");
//        result.append("<Articles>");
//
//        for(Map<String,String>  article : articles){
//            result.append("<item>");
//            result.append("<Title>" +  article.get("Title") +"</Title>");
//            result.append("<Description>" + article.get("Description") + "</Description>");
//            result.append("<PicUrl>" + article.get("PicUrl") + "</PicUrl>");
//            result.append("<Url>" + article.get("Url") + "</Url>");
//            result.append("</item>");
//        }
//
//        result.append("</Articles>");
//        result.append("</xml>");
//
//        return result.toString();
//    }
//
//    /**
//     * 发送图文消息
//     * @param codes
//     * @param request
//     * @return
//     */
//    public String sendGraphicMessages(String codes, HttpServletRequest request) {
//        try {
//            // xml请求解析
//            Map<String, String> requestMap = MessageUtil.parseXml(request);
//            //用户openid
//            String fromUserName = requestMap.get("FromUserName");
//            //微信公众号
//            String toUserName = requestMap.get("ToUserName");
//            // 图文信息
//            List<Map<String,String>> articles =  new ArrayList<>();
//            if(codes!=null){
//                String[] codeArray = codes.split(",");
//                for(String code: codeArray){
//                    WxGraphicMessageDO graphicMessage = findById(code);
//                    Map<String,String> article = new HashMap<>();
//                    article.put("Url",graphicMessage.getUrl());
//                    article.put("Title", graphicMessage.getTitle());
//                    article.put("Description",graphicMessage.getDescription());
//                    article.put("PicUrl",graphicMessage.getPicUrl());
//                    articles.add(article);
//                }
//            }
//            // 构建回复消息XML
//            return replyNewsMessage(fromUserName, toUserName, articles);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return e.getMessage();
//        }
//    }
//
//    /**
//     * 发送图文消息
//     * @param ids
//     * @param fromUserName   用户的openId
//     * @param toUserName
//     * @return
//     */
//    public String sendGraphicMessages(String ids, String fromUserName,String toUserName) {
//        try {
//        // 图文信息
//            List<Map<String,String>> articles =  new ArrayList<>();
//            if(ids!=null){
//                String[] codeArray = ids.split(",");
//                for(String id: codeArray){
//                    WxGraphicMessageDO graphicMessage = findById(id);
//                    Map<String,String> article = new HashMap<>();
//                    article.put("Url",graphicMessage.getUrl());
//                    article.put("Title", graphicMessage.getTitle());
//                    article.put("Description",graphicMessage.getDescription());
//                    article.put("PicUrl",graphicMessage.getPicUrl());
//                    articles.add(article);
//                }
//            }
//            // 构建回复消息XML
//            return replyNewsMessage(fromUserName, toUserName, articles);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return e.getMessage();
//        }
//    }
//
//}

+ 357 - 356
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxMenuService.java

@ -1,356 +1,357 @@
package com.yihu.jw.business.wx.service;
import com.yihu.jw.base.wx.WxAccessTokenDO;
import com.yihu.jw.base.wx.WxMenuDO;
import com.yihu.jw.base.wx.WxWechatDO;
import com.yihu.jw.business.wx.dao.WxMenuDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxMenuService extends BaseJpaService<WxMenuDO, WxMenuDao> {
    private Logger logger= LoggerFactory.getLogger(WxMenuService.class);
    @Autowired
    private WxMenuDao wxMenuDao;
    @Autowired
    private WechatService wechatService;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 将菜单保存至数据库
     * @param wxMenu
     * @return
     */
    public WxMenuDO createWxMenu(WxMenuDO wxMenu) {
        String code = UUID.randomUUID().toString().replaceAll("-", "");
        wxMenu.setId(code);
        if(canSaveOrUpata(wxMenu)){
            return wxMenuDao.save(wxMenu);
        }
        return null;
    }
    @Transient
    public WxMenuDO updateWxMenu(WxMenuDO wxMenu) {
        if (StringUtils.isEmpty(wxMenu.getId())) {
            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if(canSaveOrUpata(wxMenu)){
            WxMenuDO wxMenu1 = findById(wxMenu.getId());
            if(wxMenu1==null){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_WxMenu_is_no_exist, ExceptionCode.common_error_params_code);
            }
            return wxMenuDao.save(wxMenu);
        }
        return null;
    }
    @Transient
    public void deleteWxMenu(String ids, String userId, String userName) {
        if(!StringUtils.isEmpty(ids)) {
            String[] codeArray = ids.split(",");
            for (String code : codeArray) {
                WxMenuDO wxMenu = wxMenuDao.findById(code);
                if (wxMenu == null) {
                    continue;
                }
                String supMenucode = wxMenu.getSupMenuid();
                if (StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
                    List<WxMenuDO> childMenus = findChildMenus(wxMenu.getWechatId(), wxMenu.getId());
                    if (childMenus != null) {
                        for (WxMenuDO wxmenu : childMenus) {
                            wxmenu.setStatus(-1);
                            wxmenu.setUpdateUser(userId);
                            wxmenu.setUpdateUserName(userName);
                            wxMenuDao.save(wxmenu);
                        }
                    }
                }
                wxMenu.setStatus(-1);
                wxMenu.setUpdateUser(userId);
                wxMenu.setUpdateUserName(userName);
                wxMenuDao.save(wxMenu);
            }
        }
    }
    @Transient
    public void delete(String codes,String userCode) {
        if(!StringUtils.isEmpty(codes)) {
            String[] codeArray = codes.split(",");
            for (String code : codeArray) {
                WxMenuDO wxMenu = wxMenuDao.findById(code);
                if (wxMenu == null) {
                    continue;
                }
                String supMenucode = wxMenu.getSupMenuid();
                if (StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
                    List<WxMenuDO> childMenus = findChildMenus(wxMenu.getWechatId(), wxMenu.getId());
                    if (childMenus != null) {
                        for (WxMenuDO wxmenu : childMenus) {
                            wxmenu.setStatus(-1);
                            wxmenu.setUpdateUser(userCode);
                            wxMenuDao.save(wxmenu);
                        }
                    }
                }
                wxMenu.setStatus(-1);
                wxMenu.setUpdateUser(userCode);
                wxMenuDao.save(wxMenu);
            }
        }
    }
    public WxMenuDO findById(String id) {
        return wxMenuDao.findById(id);
    }
    /**
     * 根据wechatCode查找所有父菜单
     * @param wechatCode
     * @return
     */
    public List<WxMenuDO> findParentMenuByWechatCode(String wechatCode){
        List<WxMenuDO> parentMenus = wxMenuDao.findParentMenuByWechatId(wechatCode);
        return parentMenus;
    }
    /**
     * 根据wechatCode在微信公众号创建菜单
     * @param wechatId
     * @return JSONObject
     */
    public JSONObject createWechatMenu(String wechatId) {
        WxWechatDO wechat = wechatService.findById(wechatId);
        if(wechat==null){
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
        }
        //首先根据wechatCode获取菜单,然后封装成json字符串
        List<WxMenuDO> menus = wxMenuDao.findByWechatId(wechatId);
        if(menus==null){
            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_WxMenu_is_no_exist, ExceptionCode.common_error_params_code);
        }
        String menuJsonString = getMenuToString(menus, wechatId);
        logger.info("-----------------微信菜单json字符串:"+ menuJsonString+"--------------------");
        WxAccessTokenDO wxAccessTokenByCode = wxAccessTokenService.getWxAccessTokenById(wechatId);
        String token = wxAccessTokenByCode.getAccessToken();
        // 请求微信接口创建菜单
        String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + token;
        String jsonStr = HttpUtil.sendPost(url, menuJsonString);
        logger.info("------------------创建微信菜单,微信返回结果:"+jsonStr+"---------------------");
        JSONObject result = new JSONObject(jsonStr);
        return result;
    }
    private String getMenuToString(List<WxMenuDO> menus,String wechatCode){
        String menuJsonStr = "";
        List<WxMenuDO> parentMenus = new ArrayList<WxMenuDO>();//存储父菜单
        if(menus!=null){
            menuJsonStr = "{\"button\":[{";
            for(WxMenuDO wxMenu:menus){
                if(StringUtils.isEmpty(wxMenu.getSupMenuid())){//说明是父菜单
                    parentMenus.add(wxMenu);
                }
            }
        }
        int j = 0;
        for(WxMenuDO menu:parentMenus){//遍历父菜单
            if(j==0){
                j++;
            }else{
                menuJsonStr += ",{";
            }
            menuJsonStr = getString(menuJsonStr, menu);
            //查找是否有子菜单
            List<WxMenuDO> childMenus = findChildMenus(wechatCode, menu.getId());
            if(childMenus!=null){
                int i =0;
                menuJsonStr += ",\"sub_button\":[{";
                for(WxMenuDO childMenu:childMenus){
                    if(i==0){
                        i++;
                    }else{
                        menuJsonStr += ",{";
                    }
                    menuJsonStr = getString(menuJsonStr, childMenu);
                    menuJsonStr += "}";
                }
                menuJsonStr += "]}";
            }
        }
        menuJsonStr += "]}";
        return menuJsonStr;
    }
    private String getString(String menuJsonStr, WxMenuDO menu) {
        menuJsonStr += "\"name\":\""+ menu.getName()+"\"";
        if(!StringUtils.isEmpty(menu.getType())){
            menuJsonStr += ",\"type\":\"" + menu.getType()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getMenuKey())){
            menuJsonStr += ",\"key\":\"" + menu.getMenuKey()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getUrl())){
            menuJsonStr += ",\"url\":\"" + menu.getUrl()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getMediaId())){
            menuJsonStr += ",\"media_id\":\"" + menu.getMediaId()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getAppid())){
            menuJsonStr += ",\"appid\":\"" + menu.getAppid()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getPagepath())){
            menuJsonStr += ",\"pagepath\":\"" + menu.getPagepath()+"\"";
        }
        return menuJsonStr;
    }
    /**
     * 查找子菜单
     * @param wechatCode
     * @param sup_menucode
     * @return
     */
    public List<WxMenuDO> findChildMenus(String wechatCode,String sup_menucode ){
        return wxMenuDao.findChildMenus(wechatCode,sup_menucode);
    }
    public List<WxMenuDO> findChildMenus(String parentCode ){
        return wxMenuDao.findChildMenus(parentCode);
    }
    private boolean canSaveOrUpata(WxMenuDO wxMenu){
        String wechatCode = wxMenu.getWechatId();
        String supMenucode = wxMenu.getSupMenuid();
        if(StringUtils.isEmpty(wechatCode)){
            WxMenuDO parentMenuCode = findById(supMenucode);
            wechatCode = parentMenuCode.getWechatId();
            wxMenu.setWechatId(wechatCode);
        }
        String name = wxMenu.getName();
        if (StringUtils.isEmpty(name)) {
            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getStatus())) {
            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_status_is_null, ExceptionCode.common_error_params_code);
        }
        if(StringUtils.isEmpty(wxMenu.getSort())){
            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_sort_is_null, ExceptionCode.common_error_params_code);
        }
        //根据wechatCode查找是否存在微信配置
        WxWechatDO wxWechat = wechatService.findById(wechatCode);
        if(wxWechat==null){
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
        }
        if (!"0".equals(supMenucode)) {//不为0,说明是子菜单,判断父菜单是否存在
            //说明是子菜单
            //判断父菜单是否存在
            WxMenuDO parentMenuCode = findById(supMenucode);
            if(parentMenuCode==null){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_supMenuId_is_no_exist, ExceptionCode.common_error_params_code);
            }
            //查询已经存在的子菜单条数
            List<WxMenuDO> childMenus = findChildMenus(wechatCode, supMenucode);
            if(childMenus.size()==5){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_childMenu_is_to_much, ExceptionCode.common_error_params_code);
            }
            if(name.getBytes().length>60){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_name_is_to_long, ExceptionCode.common_error_params_code);
            }
            if(StringUtils.isEmpty(wxMenu.getType())){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_type_is_null, ExceptionCode.common_error_params_code);
            }
        }else{
            //查找父菜单
            List<WxMenuDO> parentMenus = findParentMenuByWechatCode(wechatCode);
            if(parentMenus!=null){
                if(parentMenus.size()==3){
                    throw new ApiException(WechatRequestMapping.WxMenu.message_fail_parentMenu_is_to_much, ExceptionCode.common_error_params_code);
                }
            }
            //说明是父菜单
            if(name.getBytes().length>16){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_name_is_to_long, ExceptionCode.common_error_params_code);
            }
        }
        String type1=wxMenu.getType();
        if(type1==null){
            type1="";
        }
        String type = type1.toUpperCase();
        if("click".equals(type)){
            String key = wxMenu.getMenuKey();
            if(StringUtils.isEmpty(key)){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_key_is_null, ExceptionCode.common_error_params_code);
            }
            if(key.getBytes().length>128){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_key_is_toLong, ExceptionCode.common_error_params_code);
            }
        }
        String url = wxMenu.getUrl();
        if("view".equals(type)){
            if(StringUtils.isEmpty(url)){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_null, ExceptionCode.common_error_params_code);
            }
            if(url.getBytes().length>128){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_toLong, ExceptionCode.common_error_params_code);
            }
        }
        if("miniprogram".equals(type)){
            if(StringUtils.isEmpty(url)){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_null, ExceptionCode.common_error_params_code);
            }
            if(url.getBytes().length>128){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_toLong, ExceptionCode.common_error_params_code);
            }
            if(StringUtils.isEmpty(wxMenu.getAppid())){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_appid_is_null, ExceptionCode.common_error_params_code);
            }
            if(StringUtils.isEmpty(wxMenu.getPagepath())){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_pagepath_is_null, ExceptionCode.common_error_params_code);
            }
        }
        if("media_id".equals(type)||"view_limited".equals(type)){
            if(StringUtils.isEmpty(wxMenu.getMediaId())){
                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_mediaId_is_null, ExceptionCode.common_error_params_code);
            }
        }
        WxMenuDO wxMenuTemp = null;
        if(StringUtils.isEmpty(wxMenu.getSupMenuid())){//如果是空,则为父菜单
            //判断sort是否重复
            wxMenuTemp = wxMenuDao.findByWechatIdExcludeSortFromParent(wxMenu.getWechatId(), wxMenu.getSort(),wxMenu.getId());
        }else{//子菜单
            wxMenuTemp = wxMenuDao.findByWechatIdExcludeSortFromChild(wxMenu.getWechatId(), wxMenu.getSort(), wxMenu.getSupMenuid(), wxMenu.getId());
        }
        if(null!=wxMenuTemp){
            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_sort_is_repeat, ExceptionCode.common_error_params_code);
        }
        wxMenu.setUpdateTime(new Date());
        return true;
    }
}
//package com.yihu.jw.business.wx.service;
//
//import com.yihu.jw.base.wx.WxAccessTokenDO;
//import com.yihu.jw.base.wx.WxMenuDO;
//import com.yihu.jw.base.wx.WxWechatDO;
//import com.yihu.jw.business.wx.dao.WxMenuDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import com.yihu.jw.util.HttpUtil;
//import org.json.JSONException;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import javax.persistence.Transient;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.UUID;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//@Service
//public class WxMenuService extends BaseJpaService<WxMenuDO, WxMenuDao> {
//
//    private Logger logger= LoggerFactory.getLogger(WxMenuService.class);
//
//    @Autowired
//    private WxMenuDao wxMenuDao;
//
//    @Autowired
//    private WechatService wechatService;
//
//    @Autowired
//    private WxAccessTokenService wxAccessTokenService;
//
//    /**
//     * 将菜单保存至数据库
//     * @param wxMenu
//     * @return
//     */
//    public WxMenuDO createWxMenu(WxMenuDO wxMenu) {
//        String code = UUID.randomUUID().toString().replaceAll("-", "");
//        wxMenu.setId(code);
//        if(canSaveOrUpata(wxMenu)){
//            return wxMenuDao.save(wxMenu);
//        }
//        return null;
//    }
//
//    @Transient
//    public WxMenuDO updateWxMenu(WxMenuDO wxMenu) {
//        if (StringUtils.isEmpty(wxMenu.getId())) {
//            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if(canSaveOrUpata(wxMenu)){
//            WxMenuDO wxMenu1 = findById(wxMenu.getId());
//            if(wxMenu1==null){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_WxMenu_is_no_exist, ExceptionCode.common_error_params_code);
//            }
//            return wxMenuDao.save(wxMenu);
//        }
//        return null;
//    }
//
//    @Transient
//    public void deleteWxMenu(String ids, String userId, String userName) {
//        if(!StringUtils.isEmpty(ids)) {
//            String[] codeArray = ids.split(",");
//            for (String code : codeArray) {
//                WxMenuDO wxMenu = wxMenuDao.findById(code);
//                if (wxMenu == null) {
//                    continue;
//                }
//                String supMenucode = wxMenu.getSupMenuid();
//                if (StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
//                    List<WxMenuDO> childMenus = findChildMenus(wxMenu.getWechatId(), wxMenu.getId());
//                    if (childMenus != null) {
//                        for (WxMenuDO wxmenu : childMenus) {
//                            wxmenu.setStatus(-1);
//                            wxmenu.setUpdateUser(userId);
//                            wxmenu.setUpdateUserName(userName);
//                            wxMenuDao.save(wxmenu);
//                        }
//                    }
//                }
//                wxMenu.setStatus(-1);
//                wxMenu.setUpdateUser(userId);
//                wxMenu.setUpdateUserName(userName);
//                wxMenuDao.save(wxMenu);
//            }
//        }
//    }
//
//    @Transient
//    public void delete(String codes,String userCode) {
//        if(!StringUtils.isEmpty(codes)) {
//            String[] codeArray = codes.split(",");
//            for (String code : codeArray) {
//                WxMenuDO wxMenu = wxMenuDao.findById(code);
//                if (wxMenu == null) {
//                    continue;
//                }
//                String supMenucode = wxMenu.getSupMenuid();
//                if (StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
//                    List<WxMenuDO> childMenus = findChildMenus(wxMenu.getWechatId(), wxMenu.getId());
//                    if (childMenus != null) {
//                        for (WxMenuDO wxmenu : childMenus) {
//                            wxmenu.setStatus(-1);
//                            wxmenu.setUpdateUser(userCode);
//                            wxMenuDao.save(wxmenu);
//                        }
//                    }
//                }
//                wxMenu.setStatus(-1);
//                wxMenu.setUpdateUser(userCode);
//                wxMenuDao.save(wxMenu);
//            }
//        }
//    }
//
//    public WxMenuDO findById(String id) {
//        return wxMenuDao.findById(id);
//    }
//    /**
//     * 根据wechatCode查找所有父菜单
//     * @param wechatCode
//     * @return
//     */
//    public List<WxMenuDO> findParentMenuByWechatCode(String wechatCode){
//        List<WxMenuDO> parentMenus = wxMenuDao.findParentMenuByWechatId(wechatCode);
//        return parentMenus;
//    }
//
//    /**
//     * 根据wechatCode在微信公众号创建菜单
//     * @param wechatId
//     * @return JSONObject
//     */
//    public JSONObject createWechatMenu(String wechatId) throws JSONException {
//        WxWechatDO wechat = wechatService.findById(wechatId);
//        if(wechat==null){
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
//        }
//        //首先根据wechatCode获取菜单,然后封装成json字符串
//        List<WxMenuDO> menus = wxMenuDao.findByWechatId(wechatId);
//        if(menus==null){
//            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_WxMenu_is_no_exist, ExceptionCode.common_error_params_code);
//        }
//        String menuJsonString = getMenuToString(menus, wechatId);
//        logger.info("-----------------微信菜单json字符串:"+ menuJsonString+"--------------------");
//        WxAccessTokenDO wxAccessTokenByCode = wxAccessTokenService.getWxAccessTokenById(wechatId);
//        String token = wxAccessTokenByCode.getAccessToken();
//        // 请求微信接口创建菜单
//        String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + token;
//        String jsonStr = HttpUtil.sendPost(url, menuJsonString);
//        logger.info("------------------创建微信菜单,微信返回结果:"+jsonStr+"---------------------");
//        JSONObject result = new JSONObject(jsonStr);
//        return result;
//    }
//
//    private String getMenuToString(List<WxMenuDO> menus,String wechatCode){
//        String menuJsonStr = "";
//        List<WxMenuDO> parentMenus = new ArrayList<WxMenuDO>();//存储父菜单
//        if(menus!=null){
//            menuJsonStr = "{\"button\":[{";
//            for(WxMenuDO wxMenu:menus){
//                if(StringUtils.isEmpty(wxMenu.getSupMenuid())){//说明是父菜单
//                    parentMenus.add(wxMenu);
//                }
//            }
//        }
//        int j = 0;
//        for(WxMenuDO menu:parentMenus){//遍历父菜单
//            if(j==0){
//                j++;
//            }else{
//                menuJsonStr += ",{";
//            }
//            menuJsonStr = getString(menuJsonStr, menu);
//            //查找是否有子菜单
//            List<WxMenuDO> childMenus = findChildMenus(wechatCode, menu.getId());
//            if(childMenus!=null){
//                int i =0;
//                menuJsonStr += ",\"sub_button\":[{";
//                for(WxMenuDO childMenu:childMenus){
//                    if(i==0){
//                        i++;
//                    }else{
//                        menuJsonStr += ",{";
//                    }
//                    menuJsonStr = getString(menuJsonStr, childMenu);
//                    menuJsonStr += "}";
//                }
//                menuJsonStr += "]}";
//            }
//        }
//        menuJsonStr += "]}";
//        return menuJsonStr;
//    }
//
//    private String getString(String menuJsonStr, WxMenuDO menu) {
//        menuJsonStr += "\"name\":\""+ menu.getName()+"\"";
//        if(!StringUtils.isEmpty(menu.getType())){
//            menuJsonStr += ",\"type\":\"" + menu.getType()+"\"";
//        }
//        if(!StringUtils.isEmpty(menu.getMenuKey())){
//            menuJsonStr += ",\"key\":\"" + menu.getMenuKey()+"\"";
//        }
//        if(!StringUtils.isEmpty(menu.getUrl())){
//            menuJsonStr += ",\"url\":\"" + menu.getUrl()+"\"";
//        }
//        if(!StringUtils.isEmpty(menu.getMediaId())){
//            menuJsonStr += ",\"media_id\":\"" + menu.getMediaId()+"\"";
//        }
//        if(!StringUtils.isEmpty(menu.getAppid())){
//            menuJsonStr += ",\"appid\":\"" + menu.getAppid()+"\"";
//        }
//        if(!StringUtils.isEmpty(menu.getPagepath())){
//            menuJsonStr += ",\"pagepath\":\"" + menu.getPagepath()+"\"";
//        }
//        return menuJsonStr;
//    }
//
//    /**
//     * 查找子菜单
//     * @param wechatCode
//     * @param sup_menucode
//     * @return
//     */
//    public List<WxMenuDO> findChildMenus(String wechatCode,String sup_menucode ){
//        return wxMenuDao.findChildMenus(wechatCode,sup_menucode);
//    }
//
//    public List<WxMenuDO> findChildMenus(String parentCode ){
//        return wxMenuDao.findChildMenus(parentCode);
//    }
//
//    private boolean canSaveOrUpata(WxMenuDO wxMenu){
//        String wechatCode = wxMenu.getWechatId();
//        String supMenucode = wxMenu.getSupMenuid();
//        if(StringUtils.isEmpty(wechatCode)){
//            WxMenuDO parentMenuCode = findById(supMenucode);
//            wechatCode = parentMenuCode.getWechatId();
//            wxMenu.setWechatId(wechatCode);
//        }
//        String name = wxMenu.getName();
//        if (StringUtils.isEmpty(name)) {
//            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(wxMenu.getStatus())) {
//            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_status_is_null, ExceptionCode.common_error_params_code);
//        }
//        if(StringUtils.isEmpty(wxMenu.getSort())){
//            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_sort_is_null, ExceptionCode.common_error_params_code);
//        }
//        //根据wechatCode查找是否存在微信配置
//        WxWechatDO wxWechat = wechatService.findById(wechatCode);
//        if(wxWechat==null){
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
//        }
//        if (!"0".equals(supMenucode)) {//不为0,说明是子菜单,判断父菜单是否存在
//            //说明是子菜单
//            //判断父菜单是否存在
//            WxMenuDO parentMenuCode = findById(supMenucode);
//            if(parentMenuCode==null){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_supMenuId_is_no_exist, ExceptionCode.common_error_params_code);
//            }
//
//            //查询已经存在的子菜单条数
//            List<WxMenuDO> childMenus = findChildMenus(wechatCode, supMenucode);
//            if(childMenus.size()==5){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_childMenu_is_to_much, ExceptionCode.common_error_params_code);
//            }
//            if(name.getBytes().length>60){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_name_is_to_long, ExceptionCode.common_error_params_code);
//            }
//            if(StringUtils.isEmpty(wxMenu.getType())){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_type_is_null, ExceptionCode.common_error_params_code);
//            }
//        }else{
//            //查找父菜单
//            List<WxMenuDO> parentMenus = findParentMenuByWechatCode(wechatCode);
//            if(parentMenus!=null){
//                if(parentMenus.size()==3){
//                    throw new ApiException(WechatRequestMapping.WxMenu.message_fail_parentMenu_is_to_much, ExceptionCode.common_error_params_code);
//                }
//            }
//
//            //说明是父菜单
//            if(name.getBytes().length>16){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_name_is_to_long, ExceptionCode.common_error_params_code);
//            }
//
//        }
//        String type1=wxMenu.getType();
//        if(type1==null){
//            type1="";
//        }
//        String type = type1.toUpperCase();
//        if("click".equals(type)){
//            String key = wxMenu.getMenuKey();
//            if(StringUtils.isEmpty(key)){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_key_is_null, ExceptionCode.common_error_params_code);
//            }
//            if(key.getBytes().length>128){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_key_is_toLong, ExceptionCode.common_error_params_code);
//            }
//        }
//        String url = wxMenu.getUrl();
//        if("view".equals(type)){
//            if(StringUtils.isEmpty(url)){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_null, ExceptionCode.common_error_params_code);
//            }
//            if(url.getBytes().length>128){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_toLong, ExceptionCode.common_error_params_code);
//            }
//        }
//        if("miniprogram".equals(type)){
//            if(StringUtils.isEmpty(url)){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_null, ExceptionCode.common_error_params_code);
//            }
//            if(url.getBytes().length>128){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_url_is_toLong, ExceptionCode.common_error_params_code);
//            }
//            if(StringUtils.isEmpty(wxMenu.getAppid())){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_appid_is_null, ExceptionCode.common_error_params_code);
//            }
//            if(StringUtils.isEmpty(wxMenu.getPagepath())){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_pagepath_is_null, ExceptionCode.common_error_params_code);
//            }
//        }
//        if("media_id".equals(type)||"view_limited".equals(type)){
//            if(StringUtils.isEmpty(wxMenu.getMediaId())){
//                throw new ApiException(WechatRequestMapping.WxMenu.message_fail_mediaId_is_null, ExceptionCode.common_error_params_code);
//            }
//        }
//        WxMenuDO wxMenuTemp = null;
//        if(StringUtils.isEmpty(wxMenu.getSupMenuid())){//如果是空,则为父菜单
//            //判断sort是否重复
//            wxMenuTemp = wxMenuDao.findByWechatIdExcludeSortFromParent(wxMenu.getWechatId(), wxMenu.getSort(),wxMenu.getId());
//        }else{//子菜单
//            wxMenuTemp = wxMenuDao.findByWechatIdExcludeSortFromChild(wxMenu.getWechatId(), wxMenu.getSort(), wxMenu.getSupMenuid(), wxMenu.getId());
//        }
//        if(null!=wxMenuTemp){
//            throw new ApiException(WechatRequestMapping.WxMenu.message_fail_sort_is_repeat, ExceptionCode.common_error_params_code);
//        }
//        wxMenu.setUpdateTime(new Date());
//        return true;
//    }
//}

+ 157 - 157
svr/svr-base/src/main/java/com/yihu/jw/business/wx/service/WxTemplateService.java

@ -1,157 +1,157 @@
package com.yihu.jw.business.wx.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.wx.*;
import com.yihu.jw.business.wx.dao.WxTemplateDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxTemplateService extends BaseJpaService<WxTemplateDO, WxTemplateDao> {
    private Logger logger= LoggerFactory.getLogger(WxTemplateService.class);
    @Autowired
    private WxTemplateDao wxTemplateDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WechatService wechatService;
    public WxTemplateDO createWxTemplate(WxTemplateDO wxTemplate) {
        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_templateid_is_null, ExceptionCode.common_error_params_code);
        }
        String content = wxTemplate.getContent().replace(" ","");
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_is_null, ExceptionCode.common_error_params_code);
        }
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_format_is_not_right, ExceptionCode.common_error_params_code);
        }
        return wxTemplateDao.save(wxTemplate);
    }
    public WxTemplateDO updateWxTemplate(WxTemplateDO wxTemplate) {
        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_templateid_is_null, ExceptionCode.common_error_params_code);
        }
        String content = wxTemplate.getContent().replace(" ","");
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_is_null, ExceptionCode.common_error_params_code);
        }
        String id = wxTemplate.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        WxTemplateDO wxTemplate1 = findById(id);
        if(wxTemplate1==null){
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_template_is_no_exist, ExceptionCode.common_error_params_code);
        }
        wxTemplate.setCreateTime(wxTemplate1.getCreateTime());
        wxTemplate.setUpdateTime(new Date());
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_format_is_not_right, ExceptionCode.common_error_params_code);
        }
        return wxTemplateDao.save(wxTemplate);
    }
    public void deleteWxTemplate(String codes, String userCode, String userName) {
        if(!StringUtils.isEmpty(codes)) {
            String[] codeArray = codes.split(",");
            for (String code : codeArray) {
                WxTemplateDO wxTemplate = wxTemplateDao.findById(code);
                if (wxTemplate == null) {
                    throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
                }
                wxTemplate.setStatus(-1);
                wxTemplate.setUpdateUser(userCode);
                wxTemplate.setUpdateUserName(userName);
                wxTemplateDao.save(wxTemplate);
            }
        }
    }
    public WxTemplateDO findById(String id) {
        WxTemplateDO wxTemplate = wxTemplateDao.findById(id);
        return wxTemplate;
    }
    public JSONObject sendTemplateMessage(String openid, String templateId, String url, String data,Miniprogram miniprogram) {
        try {
            //首先根据wechatTemplate获取微信模版
            WxTemplateDO wxTemplate = findById(templateId);
            if(wxTemplate==null){
                throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_template_is_no_exist, ExceptionCode.common_error_params_code);
            }
            String wechatCode =  wxTemplate.getWechatId();
            String content = wxTemplate.getContent().replaceAll(" ", "");//{{result.DATA}}领奖金额:{{withdrawMoney.DATA}   }领奖  时间:{ {withdrawTime.DATA} }银行信息:{ {cardInfo.DATA} }到账时间:{{arrivedTime.DATA}}{{remark.DATA}}
            String[] contentArray = content.split("\\{\\{");
            //将result,withdrawMoney,withdrawTime,cardInfo,arrivedTime等字符串放入contentList中
            List<String> contentList = new ArrayList<>();
            for(int i=1;i<contentArray.length;i++){
                contentList.add(contentArray[i].substring(0,contentArray[i].indexOf(".")));
            }
            ObjectMapper mapper = new ObjectMapper();
            ////将data转为对象
            Map<String, WechatTemplateDataDO> dataMap = mapper.readValue(data, new TypeReference<LinkedHashMap<String, WechatTemplateDataDO>>() {});
            Map<String, WechatTemplateDataDO> newDataMap = new LinkedHashMap<String, WechatTemplateDataDO>();
            int j = 0;
            for (Map.Entry<String, WechatTemplateDataDO> entry : dataMap.entrySet()) {//(keyword1,WechatTemplateData)
                String key = entry.getKey();//keyword1   转为result
                newDataMap.put(contentList.get(j),entry.getValue());
                j++;
            }
            //将数据封装在WechatTemplate对象中
            WechatTemplateDO wechatTemplate = new WechatTemplateDO();
            wechatTemplate.setTouser(openid);
            wechatTemplate.setUrl(url);
            wechatTemplate.setTemplate_id(wxTemplate.getTemplateId());
            if(miniprogram!=null){
                wechatTemplate.setMiniprogram(miniprogram);
            }
            wechatTemplate.setData(newDataMap);
            String params = mapper.writeValueAsString(wechatTemplate);
            logger.info("----------------------模版消息json字符串:"+params+"------------------");
            WxAccessTokenDO wxAccessTokenByCode = wxAccessTokenService.getWxAccessTokenById(wechatCode);
            String token = wxAccessTokenByCode.getAccessToken();
            String token_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
            String result = HttpUtil.sendPost(token_url, params);
            logger.info("------------------------发送模板消息,微信返回结果:"+result+"-----------------------");
            JSONObject jsonResult = new JSONObject(result);
            return jsonResult;
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject jsonResult = new JSONObject(e);
            return jsonResult;
        }
    }
    public List<WxTemplateDO> findByWxId(String code) {
        return wxTemplateDao.findByWxId(code);
    }
}
//package com.yihu.jw.business.wx.service;
//
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.yihu.jw.base.wx.*;
//import com.yihu.jw.business.wx.dao.WxTemplateDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.base.mysql.query.BaseJpaService;
//import com.yihu.jw.rm.base.WechatRequestMapping;
//import com.yihu.jw.util.HttpUtil;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//
//import java.util.*;
//
///**
// * Created by Administrator on 2017/5/19 0019.
// */
//@Service
//public class WxTemplateService extends BaseJpaService<WxTemplateDO, WxTemplateDao> {
//
//    private Logger logger= LoggerFactory.getLogger(WxTemplateService.class);
//
//    @Autowired
//    private WxTemplateDao wxTemplateDao;
//
//    @Autowired
//    private WxAccessTokenService wxAccessTokenService;
//
//    @Autowired
//    private WechatService wechatService;
//
//    public WxTemplateDO createWxTemplate(WxTemplateDO wxTemplate) {
//        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_templateid_is_null, ExceptionCode.common_error_params_code);
//        }
//        String content = wxTemplate.getContent().replace(" ","");
//        if (StringUtils.isEmpty(content)) {
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_is_null, ExceptionCode.common_error_params_code);
//        }
//        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_format_is_not_right, ExceptionCode.common_error_params_code);
//        }
//        return wxTemplateDao.save(wxTemplate);
//    }
//
//    public WxTemplateDO updateWxTemplate(WxTemplateDO wxTemplate) {
//        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_templateid_is_null, ExceptionCode.common_error_params_code);
//        }
//        String content = wxTemplate.getContent().replace(" ","");
//        if (StringUtils.isEmpty(content)) {
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_is_null, ExceptionCode.common_error_params_code);
//        }
//        String id = wxTemplate.getId();
//        if (StringUtils.isEmpty(id)) {
//            throw new ApiException(WechatRequestMapping.WxConfig.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        WxTemplateDO wxTemplate1 = findById(id);
//        if(wxTemplate1==null){
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_template_is_no_exist, ExceptionCode.common_error_params_code);
//        }
//        wxTemplate.setCreateTime(wxTemplate1.getCreateTime());
//        wxTemplate.setUpdateTime(new Date());
//        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
//            throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_content_format_is_not_right, ExceptionCode.common_error_params_code);
//        }
//        return wxTemplateDao.save(wxTemplate);
//    }
//
//    public void deleteWxTemplate(String codes, String userCode, String userName) {
//        if(!StringUtils.isEmpty(codes)) {
//            String[] codeArray = codes.split(",");
//            for (String code : codeArray) {
//                WxTemplateDO wxTemplate = wxTemplateDao.findById(code);
//                if (wxTemplate == null) {
//                    throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//                }
//                wxTemplate.setStatus(-1);
//                wxTemplate.setUpdateUser(userCode);
//                wxTemplate.setUpdateUserName(userName);
//                wxTemplateDao.save(wxTemplate);
//            }
//        }
//    }
//
//
//    public WxTemplateDO findById(String id) {
//        WxTemplateDO wxTemplate = wxTemplateDao.findById(id);
//        return wxTemplate;
//    }
//
//    public JSONObject sendTemplateMessage(String openid, String templateId, String url, String data,Miniprogram miniprogram) {
//        try {
//            //首先根据wechatTemplate获取微信模版
//            WxTemplateDO wxTemplate = findById(templateId);
//            if(wxTemplate==null){
//                throw new ApiException(WechatRequestMapping.WxTemplate.message_fail_template_is_no_exist, ExceptionCode.common_error_params_code);
//            }
//            String wechatCode =  wxTemplate.getWechatId();
//            String content = wxTemplate.getContent().replaceAll(" ", "");//{{result.DATA}}领奖金额:{{withdrawMoney.DATA}   }领奖  时间:{ {withdrawTime.DATA} }银行信息:{ {cardInfo.DATA} }到账时间:{{arrivedTime.DATA}}{{remark.DATA}}
//            String[] contentArray = content.split("\\{\\{");
//
//            //将result,withdrawMoney,withdrawTime,cardInfo,arrivedTime等字符串放入contentList中
//            List<String> contentList = new ArrayList<>();
//            for(int i=1;i<contentArray.length;i++){
//                contentList.add(contentArray[i].substring(0,contentArray[i].indexOf(".")));
//            }
//
//            ObjectMapper mapper = new ObjectMapper();
//            ////将data转为对象
//            Map<String, WechatTemplateDataDO> dataMap = mapper.readValue(data, new TypeReference<LinkedHashMap<String, WechatTemplateDataDO>>() {});
//            Map<String, WechatTemplateDataDO> newDataMap = new LinkedHashMap<String, WechatTemplateDataDO>();
//            int j = 0;
//            for (Map.Entry<String, WechatTemplateDataDO> entry : dataMap.entrySet()) {//(keyword1,WechatTemplateData)
//                String key = entry.getKey();//keyword1   转为result
//                newDataMap.put(contentList.get(j),entry.getValue());
//                j++;
//            }
//
//            //将数据封装在WechatTemplate对象中
//            WechatTemplateDO wechatTemplate = new WechatTemplateDO();
//            wechatTemplate.setTouser(openid);
//            wechatTemplate.setUrl(url);
//            wechatTemplate.setTemplate_id(wxTemplate.getTemplateId());
//            if(miniprogram!=null){
//                wechatTemplate.setMiniprogram(miniprogram);
//            }
//            wechatTemplate.setData(newDataMap);
//
//            String params = mapper.writeValueAsString(wechatTemplate);
//            logger.info("----------------------模版消息json字符串:"+params+"------------------");
//
//            WxAccessTokenDO wxAccessTokenByCode = wxAccessTokenService.getWxAccessTokenById(wechatCode);
//            String token = wxAccessTokenByCode.getAccessToken();
//            String token_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
//            String result = HttpUtil.sendPost(token_url, params);
//            logger.info("------------------------发送模板消息,微信返回结果:"+result+"-----------------------");
//
//            JSONObject jsonResult = new JSONObject(result);
//            return jsonResult;
//        } catch (Exception e) {
//            e.printStackTrace();
//            JSONObject jsonResult = new JSONObject();
//            return jsonResult;
//        }
//    }
//
//    public List<WxTemplateDO> findByWxId(String code) {
//        return wxTemplateDao.findByWxId(code);
//    }
//}

+ 3 - 3
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -56,10 +56,10 @@ public class IotProductController extends EnvelopRestController {
            if(size == null){
                size = 10;
            }
            String filters = "";
            String semicolon = "del=1;";
            String filters = "del=1;";
            String semicolon = "";
            if(StringUtils.isNotBlank(name)){
                filters = "name?"+name+" g1;registerCertificate?"+name+" g1";
                filters += "name?"+name+" g1;registerCertificate?"+name+" g1";
                semicolon = ";";
            }
            if(StringUtils.isNotBlank(companyId)){

+ 6 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java

@ -2,9 +2,11 @@ package com.yihu.iot.dao.device;
import com.yihu.jw.iot.device.IotDeviceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -21,6 +23,10 @@ public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, St
    @Query("select count(*) from IotDeviceDO w where w.purchaseId =?1 and w.del=1")
    int countByPurchaseId(String purchaseId);
    @Modifying
    @Query("update IotDeviceDO w set w.nextQualityTime=?1 where w.purchaseId =?2 and w.del=1")
    int updateQualityTime(Date nextQualityTime, String purchaseId);
    @Query("select count(*) from IotDeviceDO w where w.orderId =?1 and w.del=1")
    int countByOrderId(String orderId);

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceQualityInspectionPlanDao.java

@ -27,4 +27,7 @@ public interface IotDeviceQualityInspectionPlanDao extends PagingAndSortingRepos
    @Query(value = "SELECT a.* from iot_device_quality_inspection_plan a WHERE a.purchase_id = ?1 and a.status=?2 and a.del=1 ORDER BY a.plan_time desc limit 1",nativeQuery = true)
    IotDeviceQualityInspectionPlanDO findLastByPurchaseId(String purchaseId,String status);
    @Query(value = "SELECT a.* from iot_device_quality_inspection_plan a WHERE a.purchase_id = ?1 and a.status=?2 and a.del=1 ORDER BY a.plan_time asc limit 1",nativeQuery = true)
    IotDeviceQualityInspectionPlanDO findFirstByPurchaseId(String purchaseId,String status);
}

+ 12 - 3
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -1,6 +1,7 @@
package com.yihu.iot.service.device;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
@ -43,12 +44,15 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    private JdbcTemplate jdbcTempalte;
    @Autowired
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private IotDeviceDao iotDeviceDao;
    /**
     * 新增
     * @param iotDeviceQualityInspectionPlan
     * @return
     */
    @Transactional
    public IotDeviceQualityInspectionPlanDO create(IotDeviceQualityInspectionPlanDO iotDeviceQualityInspectionPlan) {
        IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(iotDeviceQualityInspectionPlan.getPurchaseId());
@ -62,12 +66,14 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
        iotDeviceQualityInspectionPlan.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
        iotDeviceQualityInspectionPlan.setDel(1);
        //更新采购清单的质检信息
        if(StringUtils.isBlank(purchaseDO.getQualityStatus())
        if(StringUtils.isBlank(purchaseDO.getQualityStatus())||purchaseDO.getQualityStatus().equals(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue())
                ||(iotDeviceQualityInspectionPlan.getPlanTime().getTime()-purchaseDO.getNextQualityTime().getTime())<0){
            purchaseDO.setQualityStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
            purchaseDO.setNextQualityTime(iotDeviceQualityInspectionPlan.getPlanTime());
            purchaseDO.setQualityLeader(iotDeviceQualityInspectionPlan.getQualityLeader());
            iotOrderPurchaseDao.save(purchaseDO);
            iotDeviceDao.updateQualityTime(iotDeviceQualityInspectionPlan.getPlanTime(),purchaseDO.getId());
        }
        return iotDeviceQualityInspectionPlanDao.save(iotDeviceQualityInspectionPlan);
@ -98,7 +104,7 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
     * @param purchaseId
     */
    public void completePlanByPurchaseId(String purchaseId,String time){
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findLastByPurchaseId(purchaseId,IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findFirstByPurchaseId(purchaseId,IotDeviceQualityInspectionPlanDO.QualityPlanStatus.create.getValue());
        if(planDO!=null){
            planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            planDO.setActualTime(DateUtil.strToDate(time));
@ -120,15 +126,17 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
        if(list==null||list.size()==0){
            IotDeviceQualityInspectionPlanDO last = iotDeviceQualityInspectionPlanDao.findLastByPurchaseId(purchaseId,IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(purchaseId);
            purchaseDO.setQualityStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            if(last==null){
                purchaseDO.setNextQualityTime(null);
                purchaseDO.setQualityLeader(null);
                purchaseDO.setQualityStatus(null);
            }else{
                purchaseDO.setNextQualityTime(last.getPlanTime());
                purchaseDO.setQualityLeader(last.getQualityLeader());
                purchaseDO.setQualityStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            }
            iotOrderPurchaseDao.save(purchaseDO);
            iotDeviceDao.updateQualityTime(purchaseDO.getNextQualityTime(),purchaseDO.getId());
        }else {
            IotDeviceQualityInspectionPlanDO last = list.get(0);
            IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(purchaseId);
@ -136,6 +144,7 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
            purchaseDO.setNextQualityTime(last.getPlanTime());
            purchaseDO.setQualityLeader(last.getQualityLeader());
            iotOrderPurchaseDao.save(purchaseDO);
            iotDeviceDao.updateQualityTime(purchaseDO.getNextQualityTime(),purchaseDO.getId());
        }
    }

+ 8 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -63,6 +63,7 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
     * @param iotDevice
     * @return
     */
    @Transactional
    public IotDeviceDO create(IotDeviceDO iotDevice) {
        if(iotDevice.getPurchaseId()!=null){
@ -188,8 +189,8 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
     * @return
     */
    public Envelop<IotDeviceVO> queryPage(String sn,String hospital,String orderId,String purcharseId,Integer page,Integer size) throws Exception{
        String filters = "";
        String semicolon = "del=1;";
        String filters = "del=1;";
        String semicolon = "";
        if(StringUtils.isNotBlank(orderId)){
            filters += semicolon +"orderId="+orderId;
            semicolon = ";";
@ -406,6 +407,11 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
            IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findByDeviceId(iotDeviceVO.getId());
            if(planDO!=null){
                iotDeviceVO.setQualityStatus(qualityStatusMap.get(planDO.getStatus()));//质检状态
            }else if(StringUtils.isNotBlank(iotDeviceVO.getPurchaseId())){
                IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(iotDeviceVO.getPurchaseId());
                if(purchaseDO!=null&&StringUtils.isNotBlank(purchaseDO.getQualityStatus())){
                    iotDeviceVO.setQualityStatus(qualityStatusMap.get(purchaseDO.getQualityStatus()));//质检状态
                }
            }
            //数据来源
            if(StringUtils.isNotBlank(iotDeviceVO.getPurchaseId())){

+ 179 - 0
svr/svr-rehabilitation/pom.xml

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.yihu.jw</groupId>
		<artifactId>svr-lib-parent-pom</artifactId>
		<version>1.0.0</version>
		<relativePath>../../svr-lib-parent-pom/pom.xml</relativePath>
	</parent>
	<groupId>com.yihu.rehabilitation</groupId>
	<artifactId>svr-rehabilitation</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>
	<dependencies>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-entity</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-request-mapping</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-exception</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.base</groupId>
			<artifactId>common-swagger</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-rest-model</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-util</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.base</groupId>
			<artifactId>common-data-mysql</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.base</groupId>
			<artifactId>common-log</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu.base</groupId>
			<artifactId>common-data-fastdfs</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<!--tomcat 启动时 打开注释 start-->
			<!-- <exclusions>
				 <exclusion>
					 <groupId>org.springframework.boot</groupId>
					 <artifactId>spring-boot-starter-tomcat</artifactId>
				 </exclusion>
			 </exclusions>-->
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat</groupId>
			<artifactId>tomcat-servlet-api</artifactId>
			<version>8.5.28</version>
			<scope>provided</scope>
			<!--tomcat 启动时 打开注释 end-->
		</dependency>
		<!--tomcat 启动时 注释下列配置 start-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</dependency>
		<!--tomcat 启动时 注释下列配置 end-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-aop</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-logging</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-test-autoconfigure</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
		</dependency>
		<dependency>
			<groupId>com.yihu</groupId>
			<artifactId>common-data-es-starter</artifactId>
			<version>1.0.1</version>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>common-util</artifactId>
			<version>1.0.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.3.2</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.15-beta1</version>
		</dependency>
	</dependencies>
	<build>
		<finalName>svr-rehabilitation</finalName>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin </artifactId>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

+ 0 - 0
svr/svr-rehabilitation/readme.MD


+ 16 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/SvrRehabilitationApplication.java

@ -0,0 +1,16 @@
package com.yihu.rehabilitation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
@EnableJpaAuditing
@SpringBootApplication
@ComponentScan(basePackages={"com"})
public class SvrRehabilitationApplication {
	public static void main(String[] args) {
		SpringApplication.run(SvrRehabilitationApplication.class, args);
	}
}

+ 49 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/SwaggerConfig.java

@ -0,0 +1,49 @@
package com.yihu.rehabilitation.config;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
@ComponentScan("com.yihu.rehabilitation.**")
public class SwaggerConfig {
    public static final String rehabilitation_API = "rehabilitation";
    @Bean
    public Docket rehabilitationAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(rehabilitation_API)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(false)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/" + RehabilitationRequestMapping.api_rehabilitation_common + "/.*")
                ))
                .build()
                .apiInfo(rehabilitationApiInfo());
    }
    private ApiInfo rehabilitationApiInfo() {
        ApiInfo rehabilitationInfo = new ApiInfo("基卫2.0API",
                "基卫2.0API,提供基础卫生相关服务。",
                "1.0",
                "No terms of service",
                "wenfujian@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return rehabilitationInfo;
    }
}

+ 29 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/HibernateProperties.java

@ -0,0 +1,29 @@
package com.yihu.rehabilitation.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
@RefreshScope
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 58 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/RehabilitationJpa.java

@ -0,0 +1,58 @@
package com.yihu.rehabilitation.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
/**
 * Created by humingfen on 2018/4/27.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "rehabilitationEntityManagerFactory",
        transactionManagerRef = "rehabilitationTransactionManager",
        basePackages = {"com.yihu.rehabilitation.dao"})   //设置Repository所在位置
public class RehabilitationJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "rehabilitationEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.jw.rehabilitation");
        emfb.setPersistenceUnitName("rehabilitation");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        Properties properties = hibernateProperties.hibProperties();
        properties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImprovedNamingStrategy");
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "rehabilitationTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("rehabilitationEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 117 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationInformationController.java

@ -0,0 +1,117 @@
package com.yihu.rehabilitation.controller;
import com.yihu.jw.rehabilitation.RehabilitationInformationDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationInformationVO;
import com.yihu.rehabilitation.service.RehabilitationInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
/**
 * @author humingfen on 2018/4/25.
 */
@RestController
@RequestMapping(value = RehabilitationRequestMapping.Information.information)
@Api(tags = "就诊信息相关操作", description = "就诊信息相关操作")
public class RehabilitationInformationController extends EnvelopRestController {
    @Autowired
    private RehabilitationInformationService rehabilitationInformationService;
    @GetMapping(value = RehabilitationRequestMapping.Information.findInformationPage)
    @ApiOperation(value = "分页查找就诊信息", notes = "分页查找就诊信息")
    public Envelop<RehabilitationInformationVO> findInformationPage(@ApiParam(name = "hospital", value = "就诊医院名称", defaultValue = "")
                                                 @RequestParam(value = "hospital", required = false) String hospital,
                                                 @ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                                 @RequestParam(value = "patientId", required = false) String patientId,
                                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                 @RequestParam(value = "page", required = false) Integer page,
                                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                 @RequestParam(value = "size", required = false) Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return rehabilitationInformationService.queryPage(page, size, patientId, hospital);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    
    @PostMapping(value = RehabilitationRequestMapping.Information.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建就诊信息", notes = "创建就诊信息")
    public Envelop<RehabilitationInformationVO> create(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                                           @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            RehabilitationInformationDO informationDO = toEntity(jsonData, RehabilitationInformationDO.class);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_create, rehabilitationInformationService.create(informationDO));
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Information.findInformationById)
    @ApiOperation(value = "根据id查找就诊信息", notes = "根据id查找就诊信息")
    public Envelop<RehabilitationInformationDO> findById(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id) {
        try {
            RehabilitationInformationDO informationDO = rehabilitationInformationService.findById(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, informationDO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Information.findInformationByPatientId)
    @ApiOperation(value = "根据patientId查找就诊信息", notes = "根据patientId查找就诊信息")
    public Envelop<RehabilitationInformationDO> findByPatientId(@ApiParam(name = "patientId", value = "patientId")
                                                           @RequestParam(value = "patientId", required = true) String patientId) {
        try {
            RehabilitationInformationDO informationDO = rehabilitationInformationService.findByPatientId(patientId);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, informationDO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.Information.api_update)
    @ApiOperation(value = "修改就诊信息", notes = "修改就诊信息(记得传入修改id)")
    public Envelop<RehabilitationInformationVO> updateInformation(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                            @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            RehabilitationInformationDO informationDO = toEntity(jsonData, RehabilitationInformationDO.class);
            rehabilitationInformationService.update(informationDO);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.Information.api_delete)
    @ApiOperation(value = "删除就诊信息", notes = "删除就诊信息")
    public Envelop<RehabilitationInformationVO> delInformation(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id) {
        try {
            rehabilitationInformationService.delete(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 99 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPerformanceController.java

@ -0,0 +1,99 @@
package com.yihu.rehabilitation.controller;
import com.yihu.jw.rehabilitation.RehabilitationPerformanceDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationPerformanceVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.service.RehabilitationPerformanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author humingfen on 2018/5/2.
 */
@RestController
@RequestMapping(value = RehabilitationRequestMapping.Performance.performance)
@Api(tags = "康复计划执行情况相关操作", description = "康复计划执行情况相关操作")
public class RehabilitationPerformanceController extends EnvelopRestController {
    @Autowired
    private RehabilitationPerformanceService performanceService;
    @GetMapping(value = RehabilitationRequestMapping.Performance.findPerformancePage)
    @ApiOperation(value = "分页查找康复计划执行情况", notes = "分页查找康复计划执行情况")
    public Envelop<RehabilitationPerformanceVO> findPerformancePage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                                              @RequestParam(value = "patientId", required = false) String patientId,
                                                              @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                              @RequestParam(value = "page", required = false) Integer page,
                                                              @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                              @RequestParam(value = "size", required = false) Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return performanceService.queryPerformancePage(page, size, patientId);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Performance.api_create)
    @ApiOperation(value = "创建康复计划执行情况", notes = "创建康复计划执行情况")
    public Envelop<RehabilitationPerformanceDO> createPerformance(@ApiParam(name = "jsonData", value = "基本信息Json", defaultValue = "")
                                                            @RequestParam(value = "jsonData", required = false) String jsonData) {
        try {
            RehabilitationPerformanceDO performanceDO = toEntity(jsonData, RehabilitationPerformanceDO.class);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_create, performanceService.create(performanceDO));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Performance.findPerformanceById)
    @ApiOperation(value = "根据id查找康复计划执行情况", notes = "根据id查找康复计划执行情况")
    public Envelop<RehabilitationPerformanceDO> findById(@ApiParam(name = "id", value = "id")
                                                      @RequestParam(value = "id", required = true) String id) {
        try {
            RehabilitationPerformanceDO performanceDO = performanceService.findById(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, performanceDO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.Performance.api_update)
    @ApiOperation(value = "修改康复计划执行情况", notes = "修改康复计划执行情况(记得传入修改id)")
    public Envelop updatePerformance(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                  @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            RehabilitationPerformanceDO PerformanceDO = toEntity(jsonData, RehabilitationPerformanceDO.class);
            performanceService.update(PerformanceDO);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.Performance.api_delete)
    @ApiOperation(value = "删除康复计划执行情况", notes = "删除康复计划执行情况")
    public Envelop delPerformance(@ApiParam(name = "id", value = "id")
                               @RequestParam(value = "id", required = true) String id) {
        try {
            performanceService.delete(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 119 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPlanningController.java

@ -0,0 +1,119 @@
package com.yihu.rehabilitation.controller;
import com.yihu.jw.rehabilitation.RehabilitationPlanningDO;
import com.yihu.jw.rehabilitation.RehabilitationTreatmentProgramDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationPlanningVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.service.RehabilitationPlanningService;
import com.yihu.rehabilitation.service.RehabilitationTreatmentProgramService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author humingfen on 2018/5/2.
 */
@RestController
@RequestMapping(value = RehabilitationRequestMapping.Planning.planning)
@Api(tags = "康复计划相关操作", description = "康复计划相关操作")
public class RehabilitationPlanningController extends EnvelopRestController {
    @Autowired
    private RehabilitationPlanningService planningService;
    @Autowired
    private RehabilitationTreatmentProgramService TreatmentProgramService;
    @GetMapping(value = RehabilitationRequestMapping.Planning.findPlanningPage)
    @ApiOperation(value = "分页查找康复计划", notes = "分页查找康复计划")
    public Envelop<RehabilitationPlanningVO> findPlanningPage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                                                              @RequestParam(value = "patientId", required = false) String patientId,
                                                              @ApiParam(name = "programId", value = "康复计划id", defaultValue = "")
                                                                              @RequestParam(value = "programId", required = false) String programId,
                                                              @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                              @RequestParam(value = "page", required = false) Integer page,
                                                              @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                              @RequestParam(value = "size", required = false) Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return planningService.queryPlanningPage(page, size, patientId, programId);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Planning.api_create)
    @ApiOperation(value = "创建康复计划", notes = "创建康复计划")
    public Envelop<RehabilitationPlanningDO> createPlanning(@ApiParam(name = "jsonData", value = "基本信息Json", defaultValue = "")
                                                                            @RequestParam(value = "jsonData", required = false) String jsonData) {
        try {
            RehabilitationPlanningDO planningDO = toEntity(jsonData, RehabilitationPlanningDO.class);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_create, planningService.create(planningDO));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Planning.findPlanningById)
    @ApiOperation(value = "根据id查找治疗方案", notes = "根据id查找治疗方案")
    public Envelop<RehabilitationPlanningDO> findById(@ApiParam(name = "id", value = "id")
                                                              @RequestParam(value = "id", required = true) String id) {
        try {
            RehabilitationPlanningDO planningDO = planningService.findById(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, planningDO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.Planning.findTreatmentByProgramId)
    @ApiOperation(value = "根据programId查找治疗方案", notes = "根据programId查找治疗方案")
    public Envelop<RehabilitationPlanningDO> findTreatmentByProgramId(@ApiParam(name = "programId", value = "programId")
                                                      @RequestParam(value = "programId", required = true) String programId) {
        try {
            RehabilitationTreatmentProgramDO treatmentProgramDO = TreatmentProgramService.findById(programId);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, treatmentProgramDO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.Planning.api_update)
    @ApiOperation(value = "修改治疗方案", notes = "修改治疗方案(记得传入修改id)")
    public Envelop updatePlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                          @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            RehabilitationPlanningDO planningDO = toEntity(jsonData, RehabilitationPlanningDO.class);
            planningService.update(planningDO);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.Planning.api_delete)
    @ApiOperation(value = "删除治疗方案", notes = "删除治疗方案")
    public Envelop delPlanning(@ApiParam(name = "id", value = "id")
                                       @RequestParam(value = "id", required = true) String id) {
        try {
            planningService.delete(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 103 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationTreatmentProgramController.java

@ -0,0 +1,103 @@
package com.yihu.rehabilitation.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.rehabilitation.RehabilitationTreatmentProgramDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationTreatmentProgramVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.service.RehabilitationTreatmentProgramService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author humingfen on 2018/4/27.
 */
@RestController
@RequestMapping(value = RehabilitationRequestMapping.TreatmentProgram.treatmentProgram)
@Api(tags = "治疗方案相关操作", description = "治疗方案相关操作")
public class RehabilitationTreatmentProgramController extends EnvelopRestController {
    @Autowired
    private RehabilitationTreatmentProgramService treatmentProgramService;
    @GetMapping(value = RehabilitationRequestMapping.TreatmentProgram.findTreatmentProgramPage)
    @ApiOperation(value = "分页查找治疗方案", notes = "分页查找治疗方案")
    public Envelop<RehabilitationTreatmentProgramVO> findTreatmentProgramPage(@ApiParam(name = "name", value = "方案名称", defaultValue = "")
                                                                    @RequestParam(value = "name", required = false) String name,
                                                                         @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                    @RequestParam(value = "page", required = false) Integer page,
                                                                         @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                    @RequestParam(value = "size", required = false) Integer size){
        try {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            return treatmentProgramService.queryTreatmentPage(page, size, name);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.TreatmentProgram.api_create)
    @ApiOperation(value = "创建治疗方案", notes = "创建治疗方案")
    public Envelop<RehabilitationTreatmentProgramDO> createTreatmentProgram(@ApiParam(name = "jsonData", value = "方案基本信息Json", defaultValue = "")
                                                                         @RequestParam(value = "jsonData", required = false) String jsonData) {
        try {
            RehabilitationTreatmentProgramDO infos = new ObjectMapper().readValue(jsonData, new TypeReference<RehabilitationTreatmentProgramDO>(){});
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_create, treatmentProgramService.create(infos));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.TreatmentProgram.findTreatmentProgramById)
    @ApiOperation(value = "根据id查找治疗方案", notes = "根据id查找治疗方案")
    public Envelop<RehabilitationTreatmentProgramDO> findById(@ApiParam(name = "id", value = "id")
                                                         @RequestParam(value = "id", required = true) String id) {
        try {
            RehabilitationTreatmentProgramDO treatmentProgramDO = treatmentProgramService.findById(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_find, treatmentProgramDO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.TreatmentProgram.api_update)
    @ApiOperation(value = "修改治疗方案", notes = "修改治疗方案(记得传入修改id)")
    public Envelop updateTreatmentProgram(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                                                  @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            RehabilitationTreatmentProgramDO treatmentProgramDO = toEntity(jsonData, RehabilitationTreatmentProgramDO.class);
            treatmentProgramService.update(treatmentProgramDO);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.TreatmentProgram.api_delete)
    @ApiOperation(value = "删除治疗方案", notes = "删除治疗方案")
    public Envelop delTreatmentProgram(@ApiParam(name = "id", value = "id")
                                                               @RequestParam(value = "id", required = true) String id) {
        try {
            treatmentProgramService.delete(id);
            return Envelop.getSuccess(RehabilitationRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 16 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationInformationDao.java

@ -0,0 +1,16 @@
package com.yihu.rehabilitation.dao;
import com.yihu.jw.rehabilitation.RehabilitationInformationDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface RehabilitationInformationDao extends PagingAndSortingRepository<RehabilitationInformationDO, String>,
        JpaSpecificationExecutor<RehabilitationInformationDO> {
    @Query("from RehabilitationInformationDO w where w.id =?1 ")
    RehabilitationInformationDO findById(String id);
    @Query("from RehabilitationInformationDO w where w.patientId =?1 order by dischargeTime desc")
    RehabilitationInformationDO findByPatientId(String patientId);
}

+ 13 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationPerformanceDao.java

@ -0,0 +1,13 @@
package com.yihu.rehabilitation.dao;
import com.yihu.jw.rehabilitation.RehabilitationPerformanceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface RehabilitationPerformanceDao extends PagingAndSortingRepository<RehabilitationPerformanceDO, String>,
        JpaSpecificationExecutor<RehabilitationPerformanceDO> {
    @Query("from RehabilitationPerformanceDO w where w.id = ?1")
    RehabilitationPerformanceDO findById(String id);
}

+ 13 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationPlanningDao.java

@ -0,0 +1,13 @@
package com.yihu.rehabilitation.dao;
import com.yihu.jw.rehabilitation.RehabilitationPlanningDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface RehabilitationPlanningDao extends PagingAndSortingRepository<RehabilitationPlanningDO, String>,
        JpaSpecificationExecutor<RehabilitationPlanningDO> {
    @Query("from RehabilitationPlanningDO w where w.id = ?1")
    RehabilitationPlanningDO findById(String id);
}

+ 13 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/RehabilitationTreatmentProgramDao.java

@ -0,0 +1,13 @@
package com.yihu.rehabilitation.dao;
import com.yihu.jw.rehabilitation.RehabilitationTreatmentProgramDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface RehabilitationTreatmentProgramDao extends PagingAndSortingRepository<RehabilitationTreatmentProgramDO, String>,
        JpaSpecificationExecutor<RehabilitationTreatmentProgramDO> {
    @Query("from RehabilitationTreatmentProgramDO w where w.id = ?1")
    RehabilitationTreatmentProgramDO findById(String id);
}

+ 112 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationInformationService.java

@ -0,0 +1,112 @@
package com.yihu.rehabilitation.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rehabilitation.RehabilitationInformationDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationInformationVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.dao.RehabilitationInformationDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author humingfen on 2018/4/25.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RehabilitationInformationService extends BaseJpaService<RehabilitationInformationDO, RehabilitationInformationDao> {
    @Autowired
    private RehabilitationInformationDao rehabilitationInformationDao;
    @Autowired
    private JdbcTemplate jdbcTempalte;
    /**
     * 按类型分页查找
     * @param page
     * @param size
     * @param patientId
     * @param hospital
     * @return
     */
    public Envelop<RehabilitationInformationVO> queryPage(Integer page, Integer size, String patientId, String hospital){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT w.* from rehabilitation_information w where 1 = 1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT w.id) count from rehabilitation_information w where 1 = 1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(patientId)){
            sql.append(" and w.patientId = ? ");
            sqlCount.append(" and w.patientId = '%").append(patientId).append("%' ");
            args.add('%'+ patientId + '%');
        }
        if(StringUtils.isNotBlank(hospital)){
            sql.append(" and w.hospital like ? ");
            sqlCount.append(" and w.hospital like '%").append(hospital).append("%' ");
            args.add('%'+ hospital + '%');
        }
        sql.append("order by w.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<RehabilitationInformationDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(RehabilitationInformationDO.class));
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        //DO转VO
        List<RehabilitationInformationVO> informationVOList = convertToModels(list,new ArrayList<>(list.size()), RehabilitationInformationVO.class);
        return Envelop.getSuccessListWithPage(RehabilitationRequestMapping.Common.message_success_find_functions,informationVOList, page, size,count);
    }
    /**
     * 新增
     * @param informationDO
     * @return
     */
    public RehabilitationInformationDO create(RehabilitationInformationDO informationDO) {
        informationDO.setSaasId(getCode());
        informationDO = rehabilitationInformationDao.save(informationDO);
        return informationDO;
    }
    /**
     * 按id查找
     * @param id
     * @return
     */
    public RehabilitationInformationDO findById(String id) {
        RehabilitationInformationDO informationDO = rehabilitationInformationDao.findById(id);
        return informationDO;
    }
    /**
     * 按patientId查找
     * @param patientId
     * @return
     */
    public RehabilitationInformationDO findByPatientId(String patientId) {
        RehabilitationInformationDO informationDO = rehabilitationInformationDao.findByPatientId(patientId);
        return informationDO;
    }
    /**
     * 修改
     * @param informationDO
     */
    public void update(RehabilitationInformationDO informationDO){
        RehabilitationInformationDO oldInformationDO = rehabilitationInformationDao.findById(informationDO.getId());
        oldInformationDO.setHospital(informationDO.getHospital());
        oldInformationDO.setDepartmen(informationDO.getDepartmen());
        oldInformationDO.setSummary(informationDO.getSummary());
        oldInformationDO.setAdvice(informationDO.getAdvice());
        oldInformationDO.setDisease(informationDO.getDisease());
        oldInformationDO.setDischargeTime(informationDO.getDischargeTime());
        rehabilitationInformationDao.save(oldInformationDO);
    }
}

+ 77 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationPerformanceService.java

@ -0,0 +1,77 @@
package com.yihu.rehabilitation.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rehabilitation.RehabilitationPerformanceDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationPerformanceVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.dao.RehabilitationPerformanceDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * @author humingfen on 2018/5/2.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RehabilitationPerformanceService extends BaseJpaService<RehabilitationPerformanceDO, RehabilitationPerformanceDao>  {
    @Autowired
    private RehabilitationPerformanceDao performanceDao;
    /**
     * 分页查找康复计划执行情况
     * @param page
     * @param size
     * @param patientId
     * @return
     * @throws ParseException
     */
    public Envelop<RehabilitationPerformanceVO> queryPerformancePage(Integer page, Integer size, String patientId) throws ParseException {
        String filters = "";
        String semicolon = "";
        if(StringUtils.isNotBlank(patientId)){
            filters = "createUser="+patientId+"";
            semicolon = ";";
        }
        String sorts = "-updateTime";
        //得到list数据
        List<RehabilitationPerformanceDO> list = search(null, filters, sorts, page, size);
        //获取总数
        long count = getCount(filters);
        //DO转VO
        List<RehabilitationPerformanceVO> PerformanceVOs = convertToModels(list,new ArrayList<>(list.size()), RehabilitationPerformanceVO.class);
        return Envelop.getSuccessListWithPage(RehabilitationRequestMapping.Common.message_success_find_functions,PerformanceVOs, page, size,count);
    }
    public RehabilitationPerformanceDO create(RehabilitationPerformanceDO performanceDO) {
        performanceDO.setSaasId(getCode());
        performanceDO.setStatus(0);
        performanceDO = performanceDao.save(performanceDO);
        return performanceDO;
    }
    public RehabilitationPerformanceDO findById(String id) {
        RehabilitationPerformanceDO performanceDO = performanceDao.findById(id);
        return performanceDO;
    }
    /**
     * 修改
     * @param performanceDO
     */
    public void update(RehabilitationPerformanceDO performanceDO){
        RehabilitationPerformanceDO oldPerformanceDO = performanceDao.findById(performanceDO.getId());
        oldPerformanceDO.setProgramId(performanceDO.getProgramId());
        oldPerformanceDO.setStartTime(performanceDO.getStartTime());
        oldPerformanceDO.setEndTime(performanceDO.getEndTime());
        oldPerformanceDO.setDescription(performanceDO.getDescription());
        performanceDao.save(oldPerformanceDO);
    }
}

+ 78 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationPlanningService.java

@ -0,0 +1,78 @@
package com.yihu.rehabilitation.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rehabilitation.RehabilitationPlanningDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationPlanningVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.dao.RehabilitationPlanningDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class RehabilitationPlanningService extends BaseJpaService<RehabilitationPlanningDO, RehabilitationPlanningDao> {
    @Autowired
    private RehabilitationPlanningDao planningDao;
    /**
     * 分页查找康复计划
     * @param page
     * @param size
     * @param patientId
     * @return
     * @throws ParseException
     */
    public Envelop<RehabilitationPlanningVO> queryPlanningPage(Integer page, Integer size, String patientId, String programId) throws ParseException {
        String filters = "";
        String semicolon = "";
        if(StringUtils.isNotBlank(patientId)){
            filters = "patientId="+patientId+"";
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(programId)){
            filters += semicolon + "programId="+programId+"";
            semicolon = ";";
        }
        String sorts = "-updateTime";
        //得到list数据
        List<RehabilitationPlanningDO> list = search(null, filters, sorts, page, size);
        //获取总数
        long count = getCount(filters);
        //DO转VO
        List<RehabilitationPlanningVO> planningVOs = convertToModels(list,new ArrayList<>(list.size()), RehabilitationPlanningVO.class);
        return Envelop.getSuccessListWithPage(RehabilitationRequestMapping.Common.message_success_find_functions,planningVOs, page, size,count);
    }
    public RehabilitationPlanningDO create(RehabilitationPlanningDO PlanningDO) {
        PlanningDO.setSaasId(getCode());
        PlanningDO = planningDao.save(PlanningDO);
        return PlanningDO;
    }
    public RehabilitationPlanningDO findById(String id) {
        RehabilitationPlanningDO planningDO = planningDao.findById(id);
        return planningDO;
    }
    /**
     * 修改
     * @param planningDO
     */
    public void update(RehabilitationPlanningDO planningDO){
        RehabilitationPlanningDO oldPlanningDO = planningDao.findById(planningDO.getId());
        oldPlanningDO.setPatientId(planningDO.getPatientId());
        oldPlanningDO.setProgramId(planningDO.getProgramId());
        oldPlanningDO.setRecheckTime(planningDO.getRecheckTime());
        oldPlanningDO.setDescription(planningDO.getDescription());
        planningDao.save(oldPlanningDO);
    }
}

+ 77 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/service/RehabilitationTreatmentProgramService.java

@ -0,0 +1,77 @@
package com.yihu.rehabilitation.service;
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.rehabilitation.RehabilitationTreatmentProgramDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationTreatmentProgramVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.dao.RehabilitationTreatmentProgramDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * @author humingfen on 2018/4/27.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RehabilitationTreatmentProgramService extends BaseJpaService<RehabilitationTreatmentProgramDO, RehabilitationTreatmentProgramDao> {
    @Autowired
    private RehabilitationTreatmentProgramDao treatmentProgramDao;
    /**
     * 分页查找健康档案
     * @param page
     * @param size
     * @param name
     * @return
     * @throws ParseException
     */
    public Envelop<RehabilitationTreatmentProgramVO> queryTreatmentPage(Integer page, Integer size, String name) throws ParseException {
        String filters = "";
        String semicolon = "";
        if(StringUtils.isNotBlank(name)){
            filters = "name?"+name+"";
            semicolon = ";";
        }
        String sorts = "-updateTime";
        //得到list数据
        List<RehabilitationTreatmentProgramDO> list = search(null, filters, sorts, page, size);
        //获取总数
        long count = getCount(filters);
        //DO转VO
        List<RehabilitationTreatmentProgramVO> treatmentProgramVOs = convertToModels(list,new ArrayList<>(list.size()), RehabilitationTreatmentProgramVO.class);
        return Envelop.getSuccessListWithPage(RehabilitationRequestMapping.Common.message_success_find_functions,treatmentProgramVOs, page, size,count);
    }
    public RehabilitationTreatmentProgramDO create(RehabilitationTreatmentProgramDO treatmentProgramDO) {
        treatmentProgramDO.setSaasId(getCode());
        treatmentProgramDO = treatmentProgramDao.save(treatmentProgramDO);
        return treatmentProgramDO;
    }
    public RehabilitationTreatmentProgramDO findById(String id) {
        RehabilitationTreatmentProgramDO treatmentProgramDO = treatmentProgramDao.findById(id);
        return treatmentProgramDO;
    }
    /**
     * 修改
     * @param treatmentProgramDO
     */
    public void update(RehabilitationTreatmentProgramDO treatmentProgramDO){
        RehabilitationTreatmentProgramDO oldTreatmentProgramDO = treatmentProgramDao.findById(treatmentProgramDO.getId());
        oldTreatmentProgramDO.setName(treatmentProgramDO.getName());
        oldTreatmentProgramDO.setFrequency(treatmentProgramDO.getFrequency());
        oldTreatmentProgramDO.setTimesDaily(treatmentProgramDO.getTimesDaily());
        oldTreatmentProgramDO.setDescription(treatmentProgramDO.getDescription());
        treatmentProgramDao.save(oldTreatmentProgramDO);
    }
}

+ 88 - 0
svr/svr-rehabilitation/src/main/resources/application.yml

@ -0,0 +1,88 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主  git上 svr-base ->  git application ->本地 appliction ->本地 bootstarp
server:
  port: 10055
spring:
  application:
    name:  svr-rehabilitation  #注册到发现服务的id 如果id一样 eurika会自动做负载
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    max-idle: 50 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 30000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 50 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  data:
    elasticsearch: #ElasticsearchProperties
      cluster-name: jkzl #默认即为elasticsearch  集群名
      cluster-nodes: 172.19.103.68:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      local: false #是否本地连接
      properties: # Additional properties used to configure the client.
        enable: true
  # JEST (Elasticsearch HTTP client) (JestProperties)
  elasticsearch:
    jest:
      uris: http://172.19.103.68:9200
#      uris: http://172.19.103.68:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
#      username: # Login user.
#      password: # Login password.
#      proxy.port:  # Proxy port the HTTP client should use.
#      proxy.host:  # Proxy host the HTTP client should use.
#hibernate 配置
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
fast-dfs:
  tracker-server: 172.19.103.54:22122 #服务器地址
  connect-timeout: 2 #链接超时时间
  network-timeout: 30
  charset: ISO8859-1 #编码
  http:
    tracker-http-port: 80
    anti-steal-token: no
    secret-key: FastDFS1234567890
  pool: #连接池大小
    init-size: 5
    max-size: 20
    wait-time: 500
---
spring:
  profiles: jwdev
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/rehabilitation?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: root
    password: 123456
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
---
spring:
  profiles: jwtest
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
---
spring:
  profiles: jwprod
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/

+ 6 - 0
svr/svr-rehabilitation/src/main/resources/banner.txt

@ -0,0 +1,6 @@
                                               .__          ___.   .__.__  .__  __          __  .__
  _________  _________          _______   ____ |  |__ _____ \_ |__ |__|  | |__|/  |______ _/  |_|__| ____   ____
 /  ___/\  \/ /\_  __ \  ______ \_  __ \_/ __ \|  |  \\__  \ | __ \|  |  | |  \   __\__  \\   __\  |/  _ \ /    \
 \___ \  \   /  |  | \/ /_____/  |  | \/\  ___/|   Y  \/ __ \| \_\ \  |  |_|  ||  |  / __ \|  | |  (  <_> )   |  \
/____  >  \_/   |__|             |__|    \___  >___|  (____  /___  /__|____/__||__| (____  /__| |__|\____/|___|  /
     \/                                      \/     \/     \/    \/                      \/                    \/

+ 46 - 0
svr/svr-rehabilitation/src/main/resources/bootstrap.yml

@ -0,0 +1,46 @@
##优先读取 boostarap配置 然后在读取application。yml的配置
spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
      discovery:
        enabled: true #使用发现服务
        service-id: svr-configurations #配置服务的名字
---
spring:
  profiles: jwdev
##发现服务的地址
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwtest
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwprod
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/

+ 61 - 0
svr/svr-wlyy-archives/src/main/java/com/yihu/jw/util/ReflectUtil.java

@ -0,0 +1,61 @@
package com.yihu.jw.util;
import com.alibaba.fastjson.JSON;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.persistence.Column;
/**
 * Created by Trick on 2018/4/25.
 */
public class ReflectUtil {
    /**
     * 将jdbcTemplate查询的map结果集 反射生成对应的bean
     * @param clazz 意向反射的实体.clazz
     * @param jdbcMapResult 查询结果集  key is UpperCase
     * @return
     * @see
     */
    public static <T> T reflect(Class<T> clazz, Map<String, Object> jdbcMapResult)
    {
        //获得
        Field[] fields = clazz.getDeclaredFields();
        //存放field和column对应关系,该关系来自于实体类的 @Column配置
        Map<String/*field name in modelBean*/, String/*column in db*/> fieldHasColumnAnnoMap = new LinkedHashMap<String, String>();
        Annotation[] annotations = null;
        for (Field field : fields)
        {
            annotations = field.getAnnotations();
            for (Annotation an : annotations)
            {
                if (an instanceof Column)
                {
                    Column column = (Column)an;
                    fieldHasColumnAnnoMap.put(field.getName(), column.name());
                }
            }
        }
        //存放field name 和 对应的来自map的该field的属性值,用于后续reflect成ModelBean
        Map<String, Object> conCurrent = new LinkedHashMap<String, Object>();
        for (Map.Entry<String, String> en : fieldHasColumnAnnoMap.entrySet())
        {
            //将column大写。因为jdbcMapResult key is UpperCase
            String key = en.getValue().toUpperCase();
            //获得map的该field的属性值
            Object value = jdbcMapResult.get(key);
            //确保value有效性,防止JSON reflect时异常
            if (value != null)
            {
                conCurrent.put(en.getKey(), jdbcMapResult.get(key));
            }
        }
        //fastjson reflect to modelbean
        return JSON.parseObject(JSON.toJSONString(conCurrent), clazz);
    }
}

+ 125 - 0
svr/svr-wlyy-specialist/pom.xml

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>svr-lib-parent-pom</artifactId>
        <version>1.0.0</version>
        <relativePath>../../svr-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.specialist</groupId>
    <artifactId>svr-wlyy-specialist</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-request-mapping</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-mysql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-log</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <!--zipkin支持分布式追踪系统-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>
    </dependencies>
</project>

+ 1 - 0
svr/svr-wlyy-specialist/readme.MD

@ -0,0 +1 @@
svr-wlyy-archives i健康公共业务后台-建档服务

+ 18 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/SvrWlyySpecialistApplication.java

@ -0,0 +1,18 @@
package com.yihu.jw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication(exclude = OAuth2AutoConfiguration.class)
@ComponentScan(basePackages = {"com"})
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class SvrWlyySpecialistApplication {
    public static void main(String[] args) {
        SpringApplication.run(SvrWlyySpecialistApplication.class, args);
    }
}

+ 51 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/config/SwaggerConfig.java

@ -0,0 +1,51 @@
package com.yihu.jw.config;
import com.yihu.jw.rm.archives.PatientArchivesMapping;
import com.yihu.jw.rm.wlyy.WlyyRequestMapping;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
@ComponentScan("com.yihu.jw.**")
public class SwaggerConfig {
    public static final String archives_API = "archives";
    @Bean
    public Docket wlyyAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(archives_API)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(false)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/" + PatientArchivesMapping.api_archives_common + "/.*")
                ))
                .build()
                .apiInfo(wlyyApiInfo());
    }
    private ApiInfo wlyyApiInfo() {
        ApiInfo wlyyInfo = new ApiInfo("基卫2.0API",
                "基卫2.0API,提供基础卫生相关服务。",
                "1.0",
                "No terms of service",
                "wenfujian@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return wlyyInfo;
    }
}

+ 29 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/config/jpa/HibernateProperties.java

@ -0,0 +1,29 @@
package com.yihu.jw.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
@RefreshScope
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 58 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/config/jpa/WlyySpecialistJpa.java

@ -0,0 +1,58 @@
package com.yihu.jw.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "wlyySpecialistEntityManagerFactory",
        transactionManagerRef = "wlyySpecialistTransactionManager",
        basePackages = {"com.yihu.jw.dao"})   //设置Repository所在位置
public class WlyySpecialistJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "wlyySpecialistEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.jw.entity");
        emfb.setPersistenceUnitName("specialist");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        Properties properties = hibernateProperties.hibProperties();
        properties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImprovedNamingStrategy");
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyySpecialistTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("wlyySpecialistEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 109 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -0,0 +1,109 @@
package com.yihu.jw.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.specialist.SpecialistArticleDO;
import com.yihu.jw.entity.specialist.SpecialistConsultDO;
import com.yihu.jw.entity.specialist.SpecialistDO;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.specialist.SpecialistPatientRelationVO;
import com.yihu.jw.rm.archives.PatientArchivesMapping;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.service.SpecialistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by Trick on 2018/4/25.
 */
@RestController
@RequestMapping(SpecialistMapping.api_specialist_common)
@Api(tags = "专科医生相关操作", description = "专科医生相关操作")
public class SpecialistController extends EnvelopRestController {
    @Autowired
    private SpecialistService specialistService;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = SpecialistMapping.specialist.createSpecialists)
    @ApiOperation(value = "创建专科医生")
    public Envelop<Boolean> createSpecialists(@ApiParam(name = "specialists", value = "专科医生实体")
                                                  @RequestParam(value = "code", required = false)String specialists){
        try {
            List<SpecialistDO> infos = new ObjectMapper().readValue(specialists, new TypeReference<List<SpecialistDO>>(){});
            return specialistService.createSpecialists(infos);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.specialist.createSpecialistRelation)
    @ApiOperation(value = "创建专科医生与患者匹配关系")
    public Envelop<Boolean> createSpecialistPatientRelation(@ApiParam(name = "specialistPatientRelation", value = "实体JSON")
                                                                @RequestParam(value = "specialistPatientRelation", required = false)String specialistPatientRelation){
        try {
            SpecialistPatientRelationDO ps = toEntity(specialistPatientRelation, SpecialistPatientRelationDO.class);
            return specialistService.createSpecialistsPatientRelation(ps);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.specialist.createConsult)
    @ApiOperation(value = "创建专科医生咨询")
    public Envelop<Boolean> createSpscialistConsult(@ApiParam(name = "specialistConsult", value = "专科医生咨询实体JSON")
                                                        @RequestParam(value = "specialistConsult", required = false)String specialistConsult){
        try {
            SpecialistConsultDO ps = toEntity(specialistConsult, SpecialistConsultDO.class);
            return specialistService.createSpscialistConsult(ps);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.specialist.createArticle)
    @ApiOperation(value = "创建专科医生健康文章")
    public Envelop<Boolean> createSpecialistArticle(@ApiParam(name = "specialistArticle", value = "专科医生健康文章JSON")
                                                        @RequestParam(value = "specialistArticle", required = false)String specialistArticle){
        try {
            SpecialistArticleDO ps = toEntity(specialistArticle, SpecialistArticleDO.class);
            return specialistService.createSpecialistArticle(ps);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.specialist.findSpecialistPatientRelation)
    @ApiOperation(value = "获取专科医生关系列表")
    public Envelop<SpecialistPatientRelationVO> findSpecialistPatientRelation(@ApiParam(name = "doctor", value = "专科医生ID")
                                                                                  @RequestParam(value = "doctor", required = false)String doctor,
                                                                              @ApiParam(name = "page", value = "第几页,从1开始")
                                                                              @RequestParam(value = "page", required = false)Integer page,
                                                                              @ApiParam(name = "size", value = ",每页分页大小")
                                                                                  @RequestParam(value = "size", required = false)Integer size){
        try {
            return specialistService.findSpecialistPatientRelation(doctor,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 12 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/PatientHospitalRecordDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.specialist.PatientHospitalRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/4/25.
 */
public interface PatientHospitalRecordDao extends PagingAndSortingRepository<PatientHospitalRecordDO, String>,
        JpaSpecificationExecutor<PatientHospitalRecordDO> {
}

+ 12 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistArticleDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.specialist.SpecialistArticleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/4/25.
 */
public interface SpecialistArticleDao extends PagingAndSortingRepository<SpecialistArticleDO, String>,
        JpaSpecificationExecutor<SpecialistArticleDO> {
}

+ 12 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistConsultDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.specialist.SpecialistConsultDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/4/25.
 */
public interface SpecialistConsultDao extends PagingAndSortingRepository<SpecialistConsultDO, String>,
        JpaSpecificationExecutor<SpecialistConsultDO> {
}

+ 12 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.specialist.SpecialistDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/4/25.
 */
public interface SpecialistDao extends PagingAndSortingRepository<SpecialistDO, String>,
        JpaSpecificationExecutor<SpecialistDO> {
}

+ 0 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java


Some files were not shown because too many files changed in this diff