Browse Source

通用构件

trick9191 6 years ago
parent
commit
64d7d9d20e
100 changed files with 9006 additions and 347 deletions
  1. 75 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseCityDO.java
  2. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseProvinceDO.java
  3. 101 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseStreetDO.java
  4. 88 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseTownDO.java
  5. 88 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHealthProblemDO.java
  6. 75 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHospitalDeptDO.java
  7. 127 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictIcd10DO.java
  8. 75 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictJobTitleDO.java
  9. 88 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDO.java
  10. 390 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java
  11. 127 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorHospitalDO.java
  12. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDictDO.java
  13. 0 35
      common/common-entity/src/main/java/com/yihu/jw/entity/base/message/MessageDo.java
  14. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/message/MqMessageDO.java
  15. 16 15
      common/common-entity/src/main/java/com/yihu/jw/entity/base/message/MessageSubscriberDO.java
  16. 341 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrg.java
  17. 288 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  18. 227 116
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  19. 4 4
      common/common-entity/src/main/java/com/yihu/jw/entity/base/role/RoleDO.java
  20. 2 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/sms/SmsDO.java
  21. 32 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/statistics/JobConfigDO.java
  22. 90 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/statistics/JobLogDO.java
  23. 101 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/team/BaseTeamDO.java
  24. 35 16
      common/common-entity/src/main/java/com/yihu/jw/entity/base/team/BaseTeamMemberDO.java
  25. 8 8
      common/common-entity/src/main/java/com/yihu/jw/entity/base/user/UserDO.java
  26. 22 1
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationOperateRecordsDO.java
  27. 141 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  28. 8 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java
  29. 71 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseCityVO.java
  30. 115 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseDoctorHospitalVO.java
  31. 60 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseDoctorRoleDictVO.java
  32. 335 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseDoctorVO.java
  33. 236 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseOrgVO.java
  34. 412 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BasePatientVO.java
  35. 60 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseProvinceVO.java
  36. 93 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseStreetVO.java
  37. 71 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseTeamMemberVO.java
  38. 93 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseTeamVO.java
  39. 82 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseTownVO.java
  40. 82 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictHealthProblemVO.java
  41. 71 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictHospitalDeptVO.java
  42. 115 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictIcd10VO.java
  43. 71 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictJobTitleVO.java
  44. 82 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineVO.java
  45. 54 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/MqMessageSubscriberVO.java
  46. 59 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/MqMessageVO.java
  47. 3 3
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/RoleVO.java
  48. 2 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/servicePackage/ServicePackageDetailsVO.java
  49. 17 15
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/servicePackage/ServicePackagePropvalueDO.java
  50. 3 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/SmsVO.java
  51. 9 6
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/user/UserVO.java
  52. 20 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/PatientSignInfoVO.java
  53. 0 10
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/Envelop.java
  54. 19 14
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java
  55. 6 6
      server/svr-authentication/pom.xml
  56. 26 1
      server/svr-authentication/src/main/java/com/yihu/AuthServer.java
  57. 0 14
      server/svr-authentication/src/main/java/com/yihu/jw/oauth2/config/WlyyAuthorizationServerConfigurerAdapter.java
  58. 0 49
      server/svr-authentication/src/main/java/com/yihu/jw/oauth2/config/WlyyWebSecurityConfigurerAdapter.java
  59. 0 10
      server/svr-authentication/src/main/java/com/yihu/jw/oauth2/model/WlyyUserDetails.java
  60. 0 10
      server/svr-authentication/src/main/java/com/yihu/jw/oauth2/model/WlyyUserSimple.java
  61. 69 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/config/WlyyWebSecurityConfigurerAdapter.java
  62. 228 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/SaltUser.java
  63. 17 12
      server/svr-authentication/src/main/java/com/yihu/jw/oauth2/core/WlyyUserDetailsService.java
  64. 42 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/Captcha.java
  65. 53 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/Oauth2Envelop.java
  66. 31 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/PublicKey.java
  67. 220 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserDetails.java
  68. 165 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserSimple.java
  69. 65 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/common/WlyyOAuth2AccessToken.java
  70. 100 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/config/WlyyAuthorizationServerConfigurerAdapter.java
  71. 49 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/jdbc/WlyyJdbcUserSecurityService.java
  72. 58 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/redis/WlyyRedisVerifyCodeService.java
  73. 327 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  74. 60 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/client/WlyyJdbcClientRedirectUriService.java
  75. 699 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyAuthorizationEndpoint.java
  76. 387 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  77. 251 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyTokenEndpoint.java
  78. 148 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/error/WlyyOAuth2ExceptionTranslator.java
  79. 134 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/web/authentication/WlyyAuthenticationFailureHandler.java
  80. 18 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/web/endpoint/BaseLoginEndpoint.java
  81. 38 0
      server/svr-authentication/src/main/resources/application.yml
  82. 29 0
      server/svr-authentication/src/main/resources/banner.txt
  83. 32 0
      server/svr-authentication/src/main/resources/bootstrap.yml
  84. 356 0
      sql/init.sql
  85. 4 0
      svr/svr-base/pom.xml
  86. 112 0
      svr/svr-base/src/main/java/com/yihu/jw/base/activemq/ConsumerRunner.java
  87. 60 0
      svr/svr-base/src/main/java/com/yihu/jw/base/activemq/MessageManager.java
  88. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseCityDao.java
  89. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseDoctorDao.java
  90. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseDoctorHospitalDao.java
  91. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseDoctorRoleDictDao.java
  92. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseOrgDao.java
  93. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BasePatientDao.java
  94. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseProvinceDao.java
  95. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseStreetDao.java
  96. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseTeamDao.java
  97. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseTeamMemberDao.java
  98. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseTownDao.java
  99. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/DictHealthProblemDao.java
  100. 0 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/DictHospitalDeptDao.java

+ 75 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseCityDO.java

@ -0,0 +1,75 @@
package com.yihu.jw.entity.base.area;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 城市字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "base_city")
public class BaseCityDO extends IntegerIdentityEntity {
    /**
	* 省编码
	*/
    private String province;
    /**
	* 城市编码
	*/
    private String code;
    /**
	* 城市名称
	*/
    private String name;
    /**
	* 创建时间
	*/
    private Date createTime;
	@Column(name = "province")
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseProvinceDO.java

@ -0,0 +1,62 @@
package com.yihu.jw.entity.base.area;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 省字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "base_province")
public class BaseProvinceDO extends IntegerIdentityEntity {
    /**
	* 省份编码
	*/
    private String code;
    /**
	* 省份名称
	*/
    private String name;
    /**
	* 创建时间
	*/
    private Date createTime;
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 101 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseStreetDO.java

@ -0,0 +1,101 @@
package com.yihu.jw.entity.base.area;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 街道字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "base_street")
public class BaseStreetDO extends IntegerIdentityEntity {
    /**
	* 省标识
	*/
    private String province;
    /**
	* 市标识
	*/
    private String city;
    /**
	* 区县标识
	*/
    private String town;
    /**
	* 街道标识
	*/
    private String code;
    /**
	* 街道名称
	*/
    private String name;
    /**
	* 创建时间
	*/
    private Date createTime;
	@Column(name = "province")
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
	@Column(name = "city")
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
	@Column(name = "town")
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 88 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseTownDO.java

@ -0,0 +1,88 @@
package com.yihu.jw.entity.base.area;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 区县字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "base_town")
public class BaseTownDO extends IntegerIdentityEntity {
    /**
	* 省编码
	*/
    private String province;
    /**
	* 城市编码
	*/
    private String city;
    /**
	* 区县编码
	*/
    private String code;
    /**
	* 区县名称
	*/
    private String name;
    /**
	* 创建时间
	*/
    private Date createTime;
	@Column(name = "province")
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
	@Column(name = "city")
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 88 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHealthProblemDO.java

@ -0,0 +1,88 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康问题字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "dict_health_problem")
public class DictHealthProblemDO extends IntegerIdentityEntity {
    /**
	* saas配置id,null标识公共字典
	*/
    private String saasId;
    /**
	* 字典编码
	*/
    private String code;
    /**
	* 字典名称
	*/
    private String name;
    /**
	* 描述
	*/
    private String description;
    /**
	* 创建时间
	*/
    private Date createTime;
	@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 = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 75 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHospitalDeptDO.java

@ -0,0 +1,75 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 医院科室字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "dict_hospital_dept")
public class DictHospitalDeptDO extends IntegerIdentityEntity {
    /**
	* saas配置id,null标识公共字典
	*/
    private String saasId;
    /**
	* 科室标识
	*/
    private String code;
    /**
	* 科室名称
	*/
    private String name;
    /**
	* 创建时间
	*/
    private Date createTime;
	@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 = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 127 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictIcd10DO.java

@ -0,0 +1,127 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * ICD10字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "dict_icd10")
public class DictIcd10DO extends IntegerIdentityEntity {
    /**
	* saas配置id,null标识公共字典
	*/
    private String saasId;
    /**
	* icd10字典编码
	*/
    private String code;
    /**
	* icd10字典名称
	*/
    private String name;
    /**
	* 字典名称拼音首字母
	*/
    private String phoneticCode;
    /**
	* 是否慢病
	*/
    private String chronicFlag;
    /**
	* 是否传染病
	*/
    private String infectiousFlag;
    /**
	* 描述
	*/
    private String description;
    /**
	* 创建时间
	*/
    private Date createTime;
	@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 = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "phonetic_code")
    public String getPhoneticCode() {
        return phoneticCode;
    }
    public void setPhoneticCode(String phoneticCode) {
        this.phoneticCode = phoneticCode;
    }
	@Column(name = "chronic_flag")
    public String getChronicFlag() {
        return chronicFlag;
    }
    public void setChronicFlag(String chronicFlag) {
        this.chronicFlag = chronicFlag;
    }
	@Column(name = "infectious_flag")
    public String getInfectiousFlag() {
        return infectiousFlag;
    }
    public void setInfectiousFlag(String infectiousFlag) {
        this.infectiousFlag = infectiousFlag;
    }
	@Column(name = "description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 75 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictJobTitleDO.java

@ -0,0 +1,75 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 职称字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "dict_job_title")
public class DictJobTitleDO extends IntegerIdentityEntity {
    /**
	* saas配置id,null标识公共字典
	*/
    private String saasId;
    /**
	* 职称标识
	*/
    private String code;
    /**
	* 职称名
	*/
    private String name;
    /**
	* 创建时间
	*/
    private Date createTime;
	@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 = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 88 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictMedicineDO.java

@ -0,0 +1,88 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 药品字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "dict_medicine")
public class DictMedicineDO extends IntegerIdentityEntity {
    /**
	* saas配置id,null标识公共字典
	*/
    private String saasId;
    /**
	* 药品编码
	*/
    private String code;
    /**
	* 药品名称
	*/
    private String name;
    /**
	* 药品类型:1健康记录
	*/
    private String type;
    /**
	* 创建时间
	*/
    private Date createTime;
	@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 = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 390 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -0,0 +1,390 @@
package com.yihu.jw.entity.base.doctor;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* 医生基础信息实体
*
* @author litaohong on  2018年08月31日
*
*/
@Entity
@Table(name = "base_doctor")
public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    /**
	* 机构id
	*/
    private String orgId;
    /**
	* 密码
	*/
    private String password;
    /**
	* 
	*/
    private String salt;
    /**
	* 姓名
	*/
    private String name;
    /**
	* 性别(1男,2女) 用国家标准字典
	*/
    private String sex;
    /**
	* 医生专长
	*/
    private String expertise;
    /**
	* 医生介绍
	*/
    private String introduce;
    /**
	*  身份证
	*/
    private String idcard;
    /**
	* 生日
	*/
    private Date birthday;
    /**
	* 头像http地址
	*/
    private String photo;
    /**
	* 手机号
	*/
    private String mobile;
    /**
	* 医生二维码
	*/
    private String qrcode;
    /**
	* 省代码
	*/
    private String provinceCode;
    /**
	* 省名称
	*/
    private String provinceName;
    /**
	* 市代码
	*/
    private String cityCode;
    /**
	* 市名称
	*/
    private String cityName;
    /**
	* 区县代码
	*/
    private String townCode;
    /**
	* 区县名称
	*/
    private String townName;
    /**
	* 街道代码
	*/
    private String streetCode;
    /**
	* 街道名称
	*/
    private String streetName;
    /**
	* 资格是否认证通过,1是,0否
	*/
    private String iscertified;
    /**
	* 是否是名医,1是,0否
	*/
    private String isFamous;
    /**
	* 是否提示设置密码  1 提示过 0未提示
	*/
    private String isPasswordPrompt;
    /**
	* 名称拼音首字母
	*/
    private String spell;
    /**
	* CA证书过期时间
	*/
    private Date certifiedOvertime;
    /**
	* CA证书编号
	*/
    private String certificateNum;
    /**
	* 
	*/
    private String openid;
    /**
	* 作废标识,1正常,0作废
	*/
    private String del;
	@Column(name = "org_id")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
	@Column(name = "password")
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
	@Column(name = "salt")
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "sex")
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
	@Column(name = "expertise")
    public String getExpertise() {
        return expertise;
    }
    public void setExpertise(String expertise) {
        this.expertise = expertise;
    }
	@Column(name = "introduce")
    public String getIntroduce() {
        return introduce;
    }
    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }
	@Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "birthday")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
	@Column(name = "photo")
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
	@Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
	@Column(name = "qrcode")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
	@Column(name = "province_code")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
	@Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
	@Column(name = "city_code")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
	@Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
	@Column(name = "town_code")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
	@Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
	@Column(name = "street_code")
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
	@Column(name = "street_name")
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
	@Column(name = "iscertified")
    public String getIscertified() {
        return iscertified;
    }
    public void setIscertified(String iscertified) {
        this.iscertified = iscertified;
    }
	@Column(name = "is_famous")
    public String getIsFamous() {
        return isFamous;
    }
    public void setIsFamous(String isFamous) {
        this.isFamous = isFamous;
    }
	@Column(name = "is_password_prompt")
    public String getIsPasswordPrompt() {
        return isPasswordPrompt;
    }
    public void setIsPasswordPrompt(String isPasswordPrompt) {
        this.isPasswordPrompt = isPasswordPrompt;
    }
	@Column(name = "spell")
    public String getSpell() {
        return spell;
    }
    public void setSpell(String spell) {
        this.spell = spell;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "certified_overtime")
    public Date getCertifiedOvertime() {
        return certifiedOvertime;
    }
    public void setCertifiedOvertime(Date certifiedOvertime) {
        this.certifiedOvertime = certifiedOvertime;
    }
	@Column(name = "certificate_num")
    public String getCertificateNum() {
        return certificateNum;
    }
    public void setCertificateNum(String certificateNum) {
        this.certificateNum = certificateNum;
    }
	@Column(name = "openid")
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 127 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorHospitalDO.java

@ -0,0 +1,127 @@
package com.yihu.jw.entity.base.doctor;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 医生职业信息实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "base_doctor_hospital")
public class BaseDoctorHospitalDO extends IntegerIdentityEntity {
    /**
	* 医院标识
	*/
    private String hospCode;
    /**
	* 医院名称
	*/
    private String hospName;
    /**
	* 医生角色标识
	*/
    private String roleCode;
    /**
	* 医院角色名称
	*/
    private String roleName;
    /**
	* 职称代码
	*/
    private String jobTitleCode;
    /**
	* 职称名称
	*/
    private String jobTitleName;
    /**
	* 作废标识,1正常,0作废
	*/
    private String del;
    /**
	* 
	*/
    private Date createTime;
	@Column(name = "hosp_code")
    public String getHospCode() {
        return hospCode;
    }
    public void setHospCode(String hospCode) {
        this.hospCode = hospCode;
    }
	@Column(name = "hosp_name")
    public String getHospName() {
        return hospName;
    }
    public void setHospName(String hospName) {
        this.hospName = hospName;
    }
	@Column(name = "role_code")
    public String getRoleCode() {
        return roleCode;
    }
    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }
	@Column(name = "role_name")
    public String getRoleName() {
        return roleName;
    }
    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
	@Column(name = "job_title_code")
    public String getJobTitleCode() {
        return jobTitleCode;
    }
    public void setJobTitleCode(String jobTitleCode) {
        this.jobTitleCode = jobTitleCode;
    }
	@Column(name = "job_title_name")
    public String getJobTitleName() {
        return jobTitleName;
    }
    public void setJobTitleName(String jobTitleName) {
        this.jobTitleName = jobTitleName;
    }
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDictDO.java

@ -0,0 +1,62 @@
package com.yihu.jw.entity.base.doctor;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 医生角色字典实体
 * 
 * @author litaohong on  2018年08月31日
 *
 */
@Entity
@Table(name = "base_doctor_role_dict")
public class BaseDoctorRoleDictDO extends IntegerIdentityEntity {
    /**
	* 角色code
	*/
    private String code;
    /**
	* 角色名称:全科医生、专科医生、健康管理师、管理员等
	*/
    private String name;
    /**
	* 作废标识,1正常,0作废
	*/
    private String del;
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 0 - 35
common/common-entity/src/main/java/com/yihu/jw/entity/base/message/MessageDo.java

@ -1,35 +0,0 @@
package com.yihu.jw.entity.base.message;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by progr1mmer on 2018/8/14.
 */@Entity
@Table(name = "base_message")
public class MessageDo extends IntegerIdentityEntity {
    private String topic; //消息主题
    private String template; //消息模板
    @Column(name = "topic", nullable = false)
    public String getTopic() {
        return topic;
    }
    public void setTopic(String topic) {
        this.topic = topic;
    }
    @Column(name = "template", nullable = false)
    public String getTemplate() {
        return template;
    }
    public void setTemplate(String template) {
        this.template = template;
    }
}

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/message/MqMessageDO.java

@ -0,0 +1,62 @@
package com.yihu.jw.entity.base.message;
import com.yihu.jw.entity.UuidIdentityEntity;
import org.springframework.stereotype.Component;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Entity - 基于MQ的消息推送
 * Created by progr1mmer on 2018/8/30.
 */
@Entity
@Table(name = "base_mq_message")
public class MqMessageDO extends UuidIdentityEntity {
    //主题
    private String topic;
    //名称
    private String name;
    //备注
    private String remark;
    //模板
    private String template;
    @Column(name = "topic", nullable = false)
    public String getTopic() {
        return topic;
    }
    public void setTopic(String topic) {
        this.topic = topic;
    }
    @Column(name = "name", nullable = false)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "template")
    public String getTemplate() {
        return template;
    }
    public void setTemplate(String template) {
        this.template = template;
    }
}

+ 16 - 15
common/common-entity/src/main/java/com/yihu/jw/entity/base/message/MessageSubscriberDO.java

@ -1,33 +1,25 @@
package com.yihu.jw.entity.base.message;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Entity - 基于MQ的消息推送订阅者
 * Created by progr1mmer on 2018/8/14.
 */
@Entity
@Table(name = "base_message_subscriber")
public class MessageSubscriberDO extends IntegerIdentityEntity {
@Table(name = "base_mq_message_subscriber")
public class MqMessageSubscriberDO extends UuidIdentityEntity {
    private Integer messageId; //消息ID
    private String saasId; //saas id
    private String topic; //主题
    private String url; //推送地址
    private String remark; //备注
    @Column(name = "message_id")
    public Integer getMessageId() {
        return messageId;
    }
    public void setMessageId(Integer messageId) {
        this.messageId = messageId;
    }
    @Column(name = "saas_id", length = 50)
    @Column(name = "saas_id", nullable = false, length = 50)
    public String getSaasId() {
        return saasId;
    }
@ -36,7 +28,16 @@ public class MessageSubscriberDO extends IntegerIdentityEntity {
        this.saasId = saasId;
    }
    @Column(name = "url")
    @Column(name = "topic", nullable = false)
    public String getTopic() {
        return topic;
    }
    public void setTopic(String topic) {
        this.topic = topic;
    }
    @Column(name = "url", nullable = false)
    public String getUrl() {
        return url;
    }

+ 341 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrg.java

@ -0,0 +1,341 @@
/**
 *  @author  
 *  @create 2018-08-29 12:41:02 
*/
package com.yihu.jw.entity.base.org;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Table;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
@Entity
@Table(name = "base_org")
public class BaseOrg extends UuidIdentityEntityWithOperator {
/**
* saas化配置
*/
private String saasid;
/**
* 省份标识
*/
private String provinceCode;
/**
* 城市标识
*/
private String cityCode;
/**
* 区县标识
*/
private String townCode;
/**
* 机构名称
*/
private String name;
/**
* 机构别名
*/
private String alias;
/**
* 机构名称拼音首字母
*/
private String spell;
/**
* 机构类型: 1.  医疗机构2.  企事业单位3.  政府机关4.  社会团体 5.药店 0.  部门 6.单位或者独立子公司7.基层机构 8.专业公共机构
*/
private String type;
/**
* 机构简介
*/
private String brief;
/**
* 机构详细地址
*/
private String address;
/**
* 机构图片
*/
private String photo;
/**
* 经度
*/
private String longitude;
/**
* 纬度
*/
private String latitude;
/**
* 法人
*/
private String legalperson;
/**
* 机构管理员
*/
private String orgAdmin;
/**
* 机构网址
*/
private String orgUrl;
/**
* 机构简介
*/
private String intro;
/**
* 机构二维码
*/
private String qrcode;
/**
* 作废标识,1正常,0作废
*/
private String del;
@Column(name = "saasid")
public String getSaasid()
{
    return saasid;
}
public void setSaasid(String saasid)
{
    this.saasid = saasid;
}
@Column(name = "province_code")
public String getProvinceCode()
{
    return provinceCode;
}
public void setProvinceCode(String provinceCode)
{
    this.provinceCode = provinceCode;
}
@Column(name = "city_code")
public String getCityCode()
{
    return cityCode;
}
public void setCityCode(String cityCode)
{
    this.cityCode = cityCode;
}
@Column(name = "town_code")
public String getTownCode()
{
    return townCode;
}
public void setTownCode(String townCode)
{
    this.townCode = townCode;
}
@Column(name = "name")
public String getName()
{
    return name;
}
public void setName(String name)
{
    this.name = name;
}
@Column(name = "alias")
public String getAlias()
{
    return alias;
}
public void setAlias(String alias)
{
    this.alias = alias;
}
@Column(name = "spell")
public String getSpell()
{
    return spell;
}
public void setSpell(String spell)
{
    this.spell = spell;
}
@Column(name = "type")
public String getType()
{
    return type;
}
public void setType(String type)
{
    this.type = type;
}
@Column(name = "brief")
public String getBrief()
{
    return brief;
}
public void setBrief(String brief)
{
    this.brief = brief;
}
@Column(name = "address")
public String getAddress()
{
    return address;
}
public void setAddress(String address)
{
    this.address = address;
}
@Column(name = "photo")
public String getPhoto()
{
    return photo;
}
public void setPhoto(String photo)
{
    this.photo = photo;
}
@Column(name = "longitude")
public String getLongitude()
{
    return longitude;
}
public void setLongitude(String longitude)
{
    this.longitude = longitude;
}
@Column(name = "latitude")
public String getLatitude()
{
    return latitude;
}
public void setLatitude(String latitude)
{
    this.latitude = latitude;
}
@Column(name = "legalperson")
public String getLegalperson()
{
    return legalperson;
}
public void setLegalperson(String legalperson)
{
    this.legalperson = legalperson;
}
@Column(name = "org_admin")
public String getOrgAdmin()
{
    return orgAdmin;
}
public void setOrgAdmin(String orgAdmin)
{
    this.orgAdmin = orgAdmin;
}
@Column(name = "org_url")
public String getOrgUrl()
{
    return orgUrl;
}
public void setOrgUrl(String orgUrl)
{
    this.orgUrl = orgUrl;
}
@Column(name = "intro")
public String getIntro()
{
    return intro;
}
public void setIntro(String intro)
{
    this.intro = intro;
}
@Column(name = "qrcode")
public String getQrcode()
{
    return qrcode;
}
public void setQrcode(String qrcode)
{
    this.qrcode = qrcode;
}
@Column(name = "del")
public String getDel()
{
    return del;
}
public void setDel(String del)
{
    this.del = del;
}
}

+ 288 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -0,0 +1,288 @@
package com.yihu.jw.entity.base.org;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 机构信息实体
 *
 * @author litaohong on  2018年08月31日
 */
@Entity
@Table(name = "base_org")
public class BaseOrgDO extends UuidIdentityEntityWithOperator {
    /**
     * saas化配置
     */
    private String saasid;
    /**
     * 省份标识
     */
    private String provinceCode;
    /**
     * 城市标识
     */
    private String cityCode;
    /**
     * 区县标识
     */
    private String townCode;
    /**
     * 机构名称
     */
    private String name;
    /**
     * 机构别名
     */
    private String alias;
    /**
     * 机构名称拼音首字母
     */
    private String spell;
    /**
     * 机构类型: 1.  医疗机构2.  企事业单位3.  政府机关4.  社会团体 5.药店 0.  部门 6.单位或者独立子公司7.基层机构 8.专业公共机构
     */
    private String type;
    /**
     * 机构简介
     */
    private String brief;
    /**
     * 机构详细地址
     */
    private String address;
    /**
     * 机构图片
     */
    private String photo;
    /**
     * 经度
     */
    private String longitude;
    /**
     * 纬度
     */
    private String latitude;
    /**
     * 法人
     */
    private String legalperson;
    /**
     * 机构管理员
     */
    private String orgAdmin;
    /**
     * 机构网址
     */
    private String orgUrl;
    /**
     * 机构简介
     */
    private String intro;
    /**
     * 机构二维码
     */
    private String qrcode;
    /**
     * 作废标识,1正常,0作废
     */
    private String del;
    @Column(name = "saasid")
    public String getSaasid() {
        return saasid;
    }
    public void setSaasid(String saasid) {
        this.saasid = saasid;
    }
    @Column(name = "province_code")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    @Column(name = "city_code")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
    @Column(name = "town_code")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "alias")
    public String getAlias() {
        return alias;
    }
    public void setAlias(String alias) {
        this.alias = alias;
    }
    @Column(name = "spell")
    public String getSpell() {
        return spell;
    }
    public void setSpell(String spell) {
        this.spell = spell;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "brief")
    public String getBrief() {
        return brief;
    }
    public void setBrief(String brief) {
        this.brief = brief;
    }
    @Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "photo")
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    @Column(name = "longitude")
    public String getLongitude() {
        return longitude;
    }
    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }
    @Column(name = "latitude")
    public String getLatitude() {
        return latitude;
    }
    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }
    @Column(name = "legalperson")
    public String getLegalperson() {
        return legalperson;
    }
    public void setLegalperson(String legalperson) {
        this.legalperson = legalperson;
    }
    @Column(name = "org_admin")
    public String getOrgAdmin() {
        return orgAdmin;
    }
    public void setOrgAdmin(String orgAdmin) {
        this.orgAdmin = orgAdmin;
    }
    @Column(name = "org_url")
    public String getOrgUrl() {
        return orgUrl;
    }
    public void setOrgUrl(String orgUrl) {
        this.orgUrl = orgUrl;
    }
    @Column(name = "intro")
    public String getIntro() {
        return intro;
    }
    public void setIntro(String intro) {
        this.intro = intro;
    }
    @Column(name = "qrcode")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
    @Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 227 - 116
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -1,367 +1,478 @@
package com.yihu.jw.entity.base.patient;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/8/31.
 */
* 居民信息实体
*
* @author litaohong on  2018年08月31日
*
*/
@Entity
@Table(name = "base_patient")
public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String saasId;//saas配置id
    private String idcard;//身份证号
    private String password;//登录密码
    private String salt;//
    private String name;//姓名
    private String birthday;//生日
    private Integer sex;//性别,1男,2女
    private String mobile;//手机号
    private String phone;//联系电话
    private String ssc;//社保卡号
    private String photo;//头像http地址
    private String provinceCode;//省编码
    private String cityCode;//市编码',
    private String townCode;//区县编码',
    private String streetCode;//街道编码',
    private String address;//具体详细地址',
    private String disease;//疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病',
    private String diseaseCondition;//病情:0绿标,1黄标,2红标,3重点关注,',
    private String points;//总积分',
    private String recordAmount;//病历总数',
    private String openid;//微信编号',
    private String patientStatus;//用户状态:1正常,0禁用,-1恶意注册,2审核中',
    private String mobileRemarks;//联系方式备注【基卫】',
    private Date openidTime;//'第一次添加open的时间',
    private String sickVillage;//居委会代码',
    private String sickVillageName;//,
    private String principalCode;//绑定电子社保卡主体(共济为操作人code)',
    private String sicardStatus;//是否绑定电子社保卡 (0否 1是)',
    private Date sicardTime;//电子社保卡绑定时间',
    private Integer isWxtag;//是否分配过微信标签',
    private String wxtagid;//微信tagId',
    private String standardStatus;//居民预警状态:0为标准,1为预警状态',
    private String medicareNumber;//医疗保险号',
    private String unionid;//开发平台唯一标识',
    private String del;//作废标识,1正常,0作废'
    @Column(name = "saasId")
    /**
	* saas配置id
	*/
    private String saasId;
    /**
	* 身份证号
	*/
    private String idcard;
    /**
	* 登录密码
	*/
    private String password;
    /**
	*
	*/
    private String salt;
    /**
	* 姓名
	*/
    private String name;
    /**
	* 生日
	*/
    private Date birthday;
    /**
	* 性别,1男,2女
	*/
    private String sex;
    /**
	* 手机号
	*/
    private String mobile;
    /**
	* 联系电话
	*/
    private String phone;
    /**
	* 社保卡号
	*/
    private String ssc;
    /**
	* 头像http地址
	*/
    private String photo;
    /**
	* 省编码
	*/
    private String provinceCode;
    /**
	* 市编码
	*/
    private String cityCode;
    /**
	* 区县编码
	*/
    private String townCode;
    /**
	* 街道编码
	*/
    private String streetCode;
    /**
	* 具体详细地址
	*/
    private String address;
    /**
	* 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	*/
    private String disease;
    /**
	* 病情:0绿标,1黄标,2红标,3重点关注,
	*/
    private String diseaseCondition;
    /**
	* 总积分
	*/
    private String points;
    /**
	* 病历总数
	*/
    private String recordAmount;
    /**
	* 微信编号
	*/
    private String openid;
    /**
	* 用户状态:1正常,0禁用,-1恶意注册,2审核中
	*/
    private String patientStatus;
    /**
	* 联系方式备注【基卫】
	*/
    private String mobileRemarks;
    /**
	* 第一次添加open的时间
	*/
    private Date openidTime;
    /**
	* 居委会代码
	*/
    private String sickVillage;
    /**
	*
	*/
    private String sickVillageName;
    /**
	* 绑定电子社保卡主体(共济为操作人code)
	*/
    private String principalCode;
    /**
	* 是否绑定电子社保卡 (0否 1是)
	*/
    private String sicardStatus;
    /**
	* 电子社保卡绑定时间
	*/
    private Date sicardTime;
    /**
	* 是否分配过微信标签
	*/
    private Integer isWxtag;
    /**
	* 微信tagId
	*/
    private String wxtagid;
    /**
	* 居民预警状态:0为标准,1为预警状态
	*/
    private Integer standardStatus;
    /**
	* 医疗保险号
	*/
    private String medicareNumber;
    /**
	* unionId 开发平台唯一标识
	*/
    private String unionid;
    /**
	* 作废标识,1正常,0作废
	*/
    private String del;
	@Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "idcard")
	@Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "password")
	@Column(name = "password")
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    @Column(name = "salt")
	@Column(name = "salt")
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
    @Column(name = "name")
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "birthday")
    public String getBirthday() {
	@Column(name = "birthday")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    @Column(name = "sex")
    public Integer getSex() {
	@Column(name = "sex")
    public String getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
    public void setSex(String sex) {
        this.sex = sex;
    }
    @Column(name = "mobile")
	@Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "phone")
	@Column(name = "phone")
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    @Column(name = "ssc")
	@Column(name = "ssc")
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    @Column(name = "photo")
	@Column(name = "photo")
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    @Column(name = "province_code")
	@Column(name = "province_code")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    @Column(name = "city_code")
	@Column(name = "city_code")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
    @Column(name = "town_code")
	@Column(name = "town_code")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    @Column(name = "street_code")
	@Column(name = "street_code")
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
    @Column(name = "address")
	@Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "disease")
	@Column(name = "disease")
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    @Column(name = "disease_condition")
	@Column(name = "disease_condition")
    public String getDiseaseCondition() {
        return diseaseCondition;
    }
    public void setDiseaseCondition(String diseaseCondition) {
        this.diseaseCondition = diseaseCondition;
    }
    @Column(name = "points")
	@Column(name = "points")
    public String getPoints() {
        return points;
    }
    public void setPoints(String points) {
        this.points = points;
    }
    @Column(name = "record_amount")
	@Column(name = "record_amount")
    public String getRecordAmount() {
        return recordAmount;
    }
    public void setRecordAmount(String recordAmount) {
        this.recordAmount = recordAmount;
    }
    @Column(name = "openid")
	@Column(name = "openid")
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    @Column(name = "patient_status")
	@Column(name = "patient_status")
    public String getPatientStatus() {
        return patientStatus;
    }
    public void setPatientStatus(String patientStatus) {
        this.patientStatus = patientStatus;
    }
    @Column(name = "mobile_remarks")
	@Column(name = "mobile_remarks")
    public String getMobileRemarks() {
        return mobileRemarks;
    }
    public void setMobileRemarks(String mobileRemarks) {
        this.mobileRemarks = mobileRemarks;
    }
    @Column(name = "openid_time")
	@Column(name = "openid_time")
    public Date getOpenidTime() {
        return openidTime;
    }
    public void setOpenidTime(Date openidTime) {
        this.openidTime = openidTime;
    }
    @Column(name = "sick_village")
	@Column(name = "sick_village")
    public String getSickVillage() {
        return sickVillage;
    }
    public void setSickVillage(String sickVillage) {
        this.sickVillage = sickVillage;
    }
    @Column(name = "sick_village_name")
	@Column(name = "sick_village_name")
    public String getSickVillageName() {
        return sickVillageName;
    }
    public void setSickVillageName(String sickVillageName) {
        this.sickVillageName = sickVillageName;
    }
    @Column(name = "principal_code")
	@Column(name = "principal_code")
    public String getPrincipalCode() {
        return principalCode;
    }
    public void setPrincipalCode(String principalCode) {
        this.principalCode = principalCode;
    }
    @Column(name = "sicard_status")
	@Column(name = "sicard_status")
    public String getSicardStatus() {
        return sicardStatus;
    }
    public void setSicardStatus(String sicardStatus) {
        this.sicardStatus = sicardStatus;
    }
    @Column(name = "sicard_time")
	@Column(name = "sicard_time")
    public Date getSicardTime() {
        return sicardTime;
    }
    public void setSicardTime(Date sicardTime) {
        this.sicardTime = sicardTime;
    }
    @Column(name = "is_wxtag")
	@Column(name = "is_wxtag")
    public Integer getIsWxtag() {
        return isWxtag;
    }
    public void setIsWxtag(Integer isWxtag) {
        this.isWxtag = isWxtag;
    }
    @Column(name = "wxtagid")
	@Column(name = "wxtagid")
    public String getWxtagid() {
        return wxtagid;
    }
    public void setWxtagid(String wxtagid) {
        this.wxtagid = wxtagid;
    }
    @Column(name = "standard_status")
    public String getStandardStatus() {
	@Column(name = "standard_status")
    public Integer getStandardStatus() {
        return standardStatus;
    }
    public void setStandardStatus(String standardStatus) {
    public void setStandardStatus(Integer standardStatus) {
        this.standardStatus = standardStatus;
    }
    @Column(name = "medicare_number")
	@Column(name = "medicare_number")
    public String getMedicareNumber() {
        return medicareNumber;
    }
    public void setMedicareNumber(String medicareNumber) {
        this.medicareNumber = medicareNumber;
    }
    @Column(name = "unionid")
	@Column(name = "unionid")
    public String getUnionid() {
        return unionid;
    }
    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }
    @Column(name = "del")
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}
}

+ 4 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/base/role/RoleDO.java

@ -19,7 +19,7 @@ public class RoleDO extends UuidIdentityEntityWithOperator {
	//备注
	private String remark;
	//是否系统管理员
	private Boolean isSystem;
	private Boolean system;
	@Column(name = "name", length = 50)
	public String getName() {
@ -39,12 +39,12 @@ public class RoleDO extends UuidIdentityEntityWithOperator {
		this.remark = remark;
	}
	@Column(name = "is_system")
	@Column(name = "system")
	public Boolean getSystem() {
		return isSystem;
		return system;
	}
	public void setSystem(Boolean system) {
		isSystem = system;
		this.system = system;
	}
}

+ 2 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/sms/SmsDO.java

@ -1,5 +1,6 @@
package com.yihu.jw.entity.base.sms;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.*;
@ -85,6 +86,7 @@ public class SmsDO extends UuidIdentityEntity {
	}
	@Column(name = "deadline", nullable = false)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getDeadline() {
		return deadline;
	}

+ 32 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/statistics/JobConfigDO.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
/**
@ -16,6 +17,7 @@ import java.io.Serializable;
public class JobConfigDO extends UuidIdentityEntity implements Serializable {
    private String saasId;
    private String quotaId;//指标id
    private String jobName;//任务名称
    private String jobInfo;//任务描述
    private String jobType;//任务类型(0--单次执行  1--周期执行 2--监听任务)
@ -33,6 +35,9 @@ public class JobConfigDO extends UuidIdentityEntity implements Serializable {
    private String timeLevel;//1增量 2到达量 3生成到达量也生成增量
    private Integer incrementInterval;//增量时间间隔1天,2周,3月
    private String startTime;
    private String endTime;
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
@ -42,6 +47,15 @@ public class JobConfigDO extends UuidIdentityEntity implements Serializable {
        this.saasId = saasId;
    }
    @Column(name = "quota_id")
    public String getQuotaId() {
        return quotaId;
    }
    public void setQuotaId(String quotaId) {
        this.quotaId = quotaId;
    }
    @Column(name = "job_name")
    public String getJobName() {
        return jobName;
@ -182,4 +196,22 @@ public class JobConfigDO extends UuidIdentityEntity implements Serializable {
    public void setIncrementInterval(Integer incrementInterval) {
        this.incrementInterval = incrementInterval;
    }
    @Transient
    public String getStartTime() {
        return startTime;
    }
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
    @Transient
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
}

+ 90 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/statistics/JobLogDO.java

@ -0,0 +1,90 @@
package com.yihu.jw.entity.base.statistics;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * job执行日志表
 * @author yeshijie on 2018/9/3.
 */
@Entity
@Table(name = "base_quota")
public class JobLogDO extends UuidIdentityEntity implements Serializable {
    private String saasId;//
    private Date jobStartTime;//任务开始执行时间
    private Date jobEndTime;//任务结束时间
    private String jobId;//任务id
    private String jobContent;//任务执行情况
    private String jobType;// 1成功 0失败
    private String jobName;//任务名称
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "job_start_time")
    public Date getJobStartTime() {
        return jobStartTime;
    }
    public void setJobStartTime(Date jobStartTime) {
        this.jobStartTime = jobStartTime;
    }
    @Column(name = "job_end_time")
    public Date getJobEndTime() {
        return jobEndTime;
    }
    public void setJobEndTime(Date jobEndTime) {
        this.jobEndTime = jobEndTime;
    }
    @Column(name = "job_id")
    public String getJobId() {
        return jobId;
    }
    public void setJobId(String jobId) {
        this.jobId = jobId;
    }
    @Column(name = "job_content")
    public String getJobContent() {
        return jobContent;
    }
    public void setJobContent(String jobContent) {
        this.jobContent = jobContent;
    }
    @Column(name = "job_type")
    public String getJobType() {
        return jobType;
    }
    public void setJobType(String jobType) {
        this.jobType = jobType;
    }
    @Column(name = "job_name")
    public String getJobName() {
        return jobName;
    }
    public void setJobName(String jobName) {
        this.jobName = jobName;
    }
}

+ 101 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/team/BaseTeamDO.java

@ -0,0 +1,101 @@
package com.yihu.jw.entity.base.team;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* 团队信息实体
*
* @author litaohong on  2018年08月31日
*
*/
@Entity
@Table(name = "base_team")
public class BaseTeamDO extends UuidIdentityEntityWithOperator {
    /**
	* 机构id
	*/
    private String orgId;
    /**
	* 团队名称
	*/
    private String name;
    /**
	* 领导医生标识
	*/
    private String leaderId;
    /**
	* 团队人数
	*/
    private String teamNum;
    /**
	* 团队二维码
	*/
    private String qrcode;
    /**
	* 作废标识,1正常,0作废
	*/
    private String del;
	@Column(name = "org_id")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "leader_id")
    public String getLeaderId() {
        return leaderId;
    }
    public void setLeaderId(String leaderId) {
        this.leaderId = leaderId;
    }
	@Column(name = "team_num")
    public String getTeamNum() {
        return teamNum;
    }
    public void setTeamNum(String teamNum) {
        this.teamNum = teamNum;
    }
	@Column(name = "qrcode")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 35 - 16
common/common-entity/src/main/java/com/yihu/jw/entity/base/team/BaseTeamMemberDO.java

@ -1,56 +1,75 @@
package com.yihu.jw.entity.base.team;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/8/31.
 */
* 团队成员实体
*
* @author litaohong on  2018年08月31日
*
*/
@Entity
@Table(name = "base_team_member")
public class BaseTeamMemberDO extends UuidIdentityEntityWithOperator {
    private String teamId;//团队ID',
    private String orgId;//机构标识',
    private String doctorId;//医生标识,多个医生以逗号分开',
    private String del;//作废标识,1正常,0作废',
    /**
	* 团队ID
	*/
    private String teamId;
    /**
	* 机构标识
	*/
    private String orgId;
    /**
	* 医生标识,多个医生以逗号分开
	*/
    private String doctorId;
    @Column(name = "team_id")
    /**
	* 作废标识,1正常,0作废
	*/
    private String del;
	@Column(name = "team_id")
    public String getTeamId() {
        return teamId;
    }
    public void setTeamId(String teamId) {
        this.teamId = teamId;
    }
    @Column(name = "org_id")
	@Column(name = "org_id")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
    @Column(name = "doctor_id")
	@Column(name = "doctor_id")
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    @Column(name = "del")
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}
}

+ 8 - 8
common/common-entity/src/main/java/com/yihu/jw/entity/base/user/UserDO.java

@ -42,9 +42,9 @@ public class UserDO extends UuidIdentityEntityWithOperator {
    //邮箱
    private String email;
    //是否可用
    private Boolean isEnabled;
    private Boolean enabled;
    //是否锁定
    private Boolean isLocked;
    private Boolean locked;
    //锁定时间
    private Date lockedDate;
    //最后登陆时间
@ -124,22 +124,22 @@ public class UserDO extends UuidIdentityEntityWithOperator {
        this.email = email;
    }
    @Column(name = "is_enabled", nullable = false)
    @Column(name = "enabled", nullable = false)
    public Boolean getEnabled() {
        return isEnabled;
        return enabled;
    }
    public void setEnabled(Boolean enabled) {
        isEnabled = enabled;
        this.enabled = enabled;
    }
    @Column(name = "is_locked", nullable = false)
    @Column(name = "locked", nullable = false)
    public Boolean getLocked() {
        return isLocked;
        return locked;
    }
    public void setLocked(Boolean locked) {
        isLocked = locked;
        this.locked = locked;
    }
    @Column(name = "locked_date")

+ 22 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationOperateRecordsDO.java

@ -20,11 +20,13 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
    private String patientName;//居民名称
    private String doctorCode;//执行医生code
    private String doctorName;//执行医生名称
    private Integer relationRecordType;//关联记录类型(1、随访记录,2、健康指导,3、健康教育)
    private Integer relationRecordType;//关联记录类型(1、随访记录,2、健康指导,3、健康教育,4、服务码)
    private String relationRecordCode;//关联记录code
    private String relationRecordImg;//相关记录图片地址,json格式
    private Date reserveTime;//服务预定完成时间
    private Date completeTime;//服务完成时间
    private Integer status;//是否确认完成(0、未确认,1、已确认)
    private String node;//服务完成笔记
    @Column(name = "saas_id")
    public String getSaasId() {
@ -80,6 +82,15 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
        this.doctorName = doctorName;
    }
    @Column(name = "node")
    public String getNode() {
        return node;
    }
    public void setNode(String node) {
        this.node = node;
    }
    @Column(name = "relation_record_type")
    public Integer getRelationRecordType() {
        return relationRecordType;
@ -98,6 +109,15 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
        this.relationRecordCode = relationRecordCode;
    }
    @Column(name = "relation_record_img")
    public String getRelationRecordImg() {
        return relationRecordImg;
    }
    public void setRelationRecordImg(String relationRecordImg) {
        this.relationRecordImg = relationRecordImg;
    }
    @Column(name = "reserve_time")
    public Date getReserveTime() {
        return reserveTime;
@ -124,4 +144,5 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 141 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -201,4 +201,145 @@ public class BaseRequestMapping {
        public static final String PREFIX = "/team";
    }
    /**
     * 城市字典
     */
    public static class BaseCity extends Basic {
        public static final String PREFIX  = "/baseCity";
    }
    /**
     * 医生基础信息
     */
    public static class BaseDoctor extends Basic {
        public static final String PREFIX  = "/baseDoctor";
    }
    /**
     * 医生职业信息
     */
    public static class BaseDoctorHospital extends Basic {
        public static final String PREFIX  = "/baseDoctorHospital";
    }
    /**
     * 医生角色字典
     */
    public static class BaseDoctorRoleDict extends Basic {
        public static final String PREFIX  = "/baseDoctorRoleDict";
    }
    /**
     * 机构信息
     */
    public static class BaseOrg extends Basic {
        public static final String PREFIX  = "/baseOrg";
    }
    /**
     * 患者信息
     */
    public static class BasePatient extends Basic {
        public static final String PREFIX  = "/basePatient";
    }
    /**
     * 省份字典
     */
    public static class BaseProvince extends Basic {
        public static final String PREFIX  = "/baseProvince";
    }
    /**
     * 团队信息
     */
    public static class BaseTeam extends Basic {
        public static final String PREFIX  = "/baseTeam";
    }
    /**
     * 街道字典
     */
    public static class BaseStreet extends Basic {
        public static final String PREFIX  = "/baseStreet";
    }
    /**
     * 团队成员
     */
    public static class BaseTeamMember extends Basic {
        public static final String PREFIX  = "/baseTeamMember";
    }
    /**
     * 区县字典
     */
    public static class BaseTown extends Basic {
        public static final String PREFIX  = "/baseTown";
    }
    /**
     * 健康问题字典
     */
    public static class DictHealthProblem extends Basic {
        public static final String PREFIX  = "/dictHealthProblem";
    }
    /**
     * 医院科室字典
     */
    public static class DictHospitalDept extends Basic {
        public static final String PREFIX  = "/dictHospitalDept";
    }
    /**
     * ICD10字典
     */
    public static class DictIcd10 extends Basic {
        public static final String PREFIX  = "/dictIcd10";
    }
    /**
     * 职称字典
     */
    public static class DictJobTitle extends Basic {
        public static final String PREFIX  = "/dictJobTitle";
    }
    /**
     * 药品字典
     */
    public static class DictMedicine extends Basic {
        public static final String PREFIX  = "/dictMedicine";
    }
    /**
     * 基于MQ的消息推送
     */
    public static class MqMessage extends Basic {
        public static final String PREFIX  = "/mq_message";
    }
    /**
     * 基于MQ的消息推送订阅者
     */
    public static class MqMessageSubscriber extends Basic {
        public static final String PREFIX  = "/mq_message_subscriber";
    }
}

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

@ -73,8 +73,15 @@ public class SpecialistMapping {
        public static final String updateStatusRehabilitationOperate = "/updateStatusRehabilitationOperate";
        public static final String patientRehabilitationDetail = "/patientRehabilitationDetail";
        public static final String recentPlanDetailRecord = "/recentPlanDetailRecord";
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String saveRehabilitationOperateRecodr="/saveRehabilitationOperateRecodr";
        public static final String updateNoteAndImageRehabilitationOperate = "/updateNoteAndImageRehabilitationOperate";
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String dailyJob = "/dailyJob";
        public static final String appCalendarPlanDetailList = "/appCalendarPlanDetailList";
        public static final String updatePlanDetailStatusById = "/updatePlanDetailStatusById";
        public static final String updatePlanStatusById = "/updatePlanStatusById";
    }
    public static class serviceItem{

+ 71 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseCityVO.java

@ -0,0 +1,71 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 城市字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseCityVO", description = "城市字典")
public class BaseCityVO extends IntegerIdentityVO{
    /**
	省编码	*/
    private String province;
    /**
	城市编码	*/
    private String code;
    /**
	城市名称	*/
    private String name;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "省编码", example = "模块1")
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
	@ApiModelProperty(value = "城市编码", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "城市名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 115 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseDoctorHospitalVO.java

@ -0,0 +1,115 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 医生职业信息vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseDoctorHospitalVO", description = "医生职业信息")
public class BaseDoctorHospitalVO extends IntegerIdentityVO{
    /**
	医院标识	*/
    private String hospCode;
    /**
	医院名称	*/
    private String hospName;
    /**
	医生角色标识	*/
    private String roleCode;
    /**
	医院角色名称	*/
    private String roleName;
    /**
	职称代码	*/
    private String jobTitleCode;
    /**
	职称名称	*/
    private String jobTitleName;
    /**
	作废标识,1正常,0作废	*/
    private String del;
    /**
		*/
    private Date createTime;
	@ApiModelProperty(value = "医院标识", example = "模块1")
    public String getHospCode() {
        return hospCode;
    }
    public void setHospCode(String hospCode) {
        this.hospCode = hospCode;
    }
	@ApiModelProperty(value = "医院名称", example = "模块1")
    public String getHospName() {
        return hospName;
    }
    public void setHospName(String hospName) {
        this.hospName = hospName;
    }
	@ApiModelProperty(value = "医生角色标识", example = "模块1")
    public String getRoleCode() {
        return roleCode;
    }
    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }
	@ApiModelProperty(value = "医院角色名称", example = "模块1")
    public String getRoleName() {
        return roleName;
    }
    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
	@ApiModelProperty(value = "职称代码", example = "模块1")
    public String getJobTitleCode() {
        return jobTitleCode;
    }
    public void setJobTitleCode(String jobTitleCode) {
        this.jobTitleCode = jobTitleCode;
    }
	@ApiModelProperty(value = "职称名称", example = "模块1")
    public String getJobTitleName() {
        return jobTitleName;
    }
    public void setJobTitleName(String jobTitleName) {
        this.jobTitleName = jobTitleName;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
	@ApiModelProperty(value = "", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 60 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseDoctorRoleDictVO.java

@ -0,0 +1,60 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 医生角色字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseDoctorRoleDictVO", description = "医生角色字典")
public class BaseDoctorRoleDictVO extends IntegerIdentityVO{
    /**
	角色code	*/
    private String code;
    /**
	角色名称:全科医生、专科医生、健康管理师、管理员等	*/
    private String name;
    /**
	作废标识,1正常,0作废	*/
    private String del;
	@ApiModelProperty(value = "角色code", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "角色名称:全科医生、专科医生、健康管理师、管理员等", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 335 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseDoctorVO.java

@ -0,0 +1,335 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 医生基础信息vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseDoctorVO", description = "医生基础信息")
public class BaseDoctorVO extends UuidIdentityVOWithOperator {
    /**
	机构id	*/
    private String orgId;
    /**
	密码	*/
    private String password;
    /**
		*/
    private String salt;
    /**
	姓名	*/
    private String name;
    /**
	性别(1男,2女) 用国家标准字典	*/
    private String sex;
    /**
	医生专长	*/
    private String expertise;
    /**
	医生介绍	*/
    private String introduce;
    /**
	 身份证	*/
    private String idcard;
    /**
	生日	*/
    private Date birthday;
    /**
	头像http地址	*/
    private String photo;
    /**
	手机号	*/
    private String mobile;
    /**
	医生二维码	*/
    private String qrcode;
    /**
	省代码	*/
    private String provinceCode;
    /**
	省名称	*/
    private String provinceName;
    /**
	市代码	*/
    private String cityCode;
    /**
	市名称	*/
    private String cityName;
    /**
	区县代码	*/
    private String townCode;
    /**
	区县名称	*/
    private String townName;
    /**
	街道代码	*/
    private String streetCode;
    /**
	街道名称	*/
    private String streetName;
    /**
	资格是否认证通过,1是,0否	*/
    private String iscertified;
    /**
	是否是名医,1是,0否	*/
    private String isFamous;
    /**
	是否提示设置密码  1 提示过 0未提示	*/
    private String isPasswordPrompt;
    /**
	名称拼音首字母	*/
    private String spell;
    /**
	CA证书过期时间	*/
    private Date certifiedOvertime;
    /**
	CA证书编号	*/
    private String certificateNum;
    /**
		*/
    private String openid;
    /**
	作废标识,1正常,0作废	*/
    private String del;
	@ApiModelProperty(value = "机构id", example = "模块1")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
	@ApiModelProperty(value = "密码", example = "模块1")
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
	@ApiModelProperty(value = "", example = "模块1")
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
	@ApiModelProperty(value = "姓名", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "性别(1男,2女) 用国家标准字典", example = "模块1")
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
	@ApiModelProperty(value = "医生专长", example = "模块1")
    public String getExpertise() {
        return expertise;
    }
    public void setExpertise(String expertise) {
        this.expertise = expertise;
    }
	@ApiModelProperty(value = "医生介绍", example = "模块1")
    public String getIntroduce() {
        return introduce;
    }
    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }
	@ApiModelProperty(value = " 身份证", example = "模块1")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
	@ApiModelProperty(value = "生日", example = "模块1")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
	@ApiModelProperty(value = "头像http地址", example = "模块1")
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
	@ApiModelProperty(value = "手机号", example = "模块1")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
	@ApiModelProperty(value = "医生二维码", example = "模块1")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
	@ApiModelProperty(value = "省代码", example = "模块1")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
	@ApiModelProperty(value = "省名称", example = "模块1")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
	@ApiModelProperty(value = "市代码", example = "模块1")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
	@ApiModelProperty(value = "市名称", example = "模块1")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
	@ApiModelProperty(value = "区县代码", example = "模块1")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
	@ApiModelProperty(value = "区县名称", example = "模块1")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
	@ApiModelProperty(value = "街道代码", example = "模块1")
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
	@ApiModelProperty(value = "街道名称", example = "模块1")
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
	@ApiModelProperty(value = "资格是否认证通过,1是,0否", example = "模块1")
    public String getIscertified() {
        return iscertified;
    }
    public void setIscertified(String iscertified) {
        this.iscertified = iscertified;
    }
	@ApiModelProperty(value = "是否是名医,1是,0否", example = "模块1")
    public String getIsFamous() {
        return isFamous;
    }
    public void setIsFamous(String isFamous) {
        this.isFamous = isFamous;
    }
	@ApiModelProperty(value = "是否提示设置密码  1 提示过 0未提示", example = "模块1")
    public String getIsPasswordPrompt() {
        return isPasswordPrompt;
    }
    public void setIsPasswordPrompt(String isPasswordPrompt) {
        this.isPasswordPrompt = isPasswordPrompt;
    }
	@ApiModelProperty(value = "名称拼音首字母", example = "模块1")
    public String getSpell() {
        return spell;
    }
    public void setSpell(String spell) {
        this.spell = spell;
    }
	@ApiModelProperty(value = "CA证书过期时间", example = "模块1")
    public Date getCertifiedOvertime() {
        return certifiedOvertime;
    }
    public void setCertifiedOvertime(Date certifiedOvertime) {
        this.certifiedOvertime = certifiedOvertime;
    }
	@ApiModelProperty(value = "CA证书编号", example = "模块1")
    public String getCertificateNum() {
        return certificateNum;
    }
    public void setCertificateNum(String certificateNum) {
        this.certificateNum = certificateNum;
    }
	@ApiModelProperty(value = "", example = "模块1")
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 236 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseOrgVO.java

@ -0,0 +1,236 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 机构信息vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseOrgVO", description = "机构信息")
public class BaseOrgVO extends UuidIdentityVOWithOperator {
    /**
	saas化配置	*/
    private String saasid;
    /**
	省份标识	*/
    private String provinceCode;
    /**
	城市标识	*/
    private String cityCode;
    /**
	区县标识	*/
    private String townCode;
    /**
	机构名称	*/
    private String name;
    /**
	机构别名	*/
    private String alias;
    /**
	机构名称拼音首字母	*/
    private String spell;
    /**
	机构类型: 1.  医疗机构2.  企事业单位3.  政府机关4.  社会团体 5.药店 0.  部门 6.单位或者独立子公司7.基层机构 8.专业公共机构	*/
    private String type;
    /**
	机构简介	*/
    private String brief;
    /**
	机构详细地址	*/
    private String address;
    /**
	机构图片	*/
    private String photo;
    /**
	经度	*/
    private String longitude;
    /**
	纬度	*/
    private String latitude;
    /**
	法人	*/
    private String legalperson;
    /**
	机构管理员	*/
    private String orgAdmin;
    /**
	机构网址	*/
    private String orgUrl;
    /**
	机构简介	*/
    private String intro;
    /**
	机构二维码	*/
    private String qrcode;
    /**
	作废标识,1正常,0作废	*/
    private String del;
	@ApiModelProperty(value = "saas化配置", example = "模块1")
    public String getSaasid() {
        return saasid;
    }
    public void setSaasid(String saasid) {
        this.saasid = saasid;
    }
	@ApiModelProperty(value = "省份标识", example = "模块1")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
	@ApiModelProperty(value = "城市标识", example = "模块1")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
	@ApiModelProperty(value = "区县标识", example = "模块1")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
	@ApiModelProperty(value = "机构名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "机构别名", example = "模块1")
    public String getAlias() {
        return alias;
    }
    public void setAlias(String alias) {
        this.alias = alias;
    }
	@ApiModelProperty(value = "机构名称拼音首字母", example = "模块1")
    public String getSpell() {
        return spell;
    }
    public void setSpell(String spell) {
        this.spell = spell;
    }
	@ApiModelProperty(value = "机构类型: 1.  医疗机构2.  企事业单位3.  政府机关4.  社会团体 5.药店 0.  部门 6.单位或者独立子公司7.基层机构 8.专业公共机构", example = "模块1")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
	@ApiModelProperty(value = "机构简介", example = "模块1")
    public String getBrief() {
        return brief;
    }
    public void setBrief(String brief) {
        this.brief = brief;
    }
	@ApiModelProperty(value = "机构详细地址", example = "模块1")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
	@ApiModelProperty(value = "机构图片", example = "模块1")
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
	@ApiModelProperty(value = "经度", example = "模块1")
    public String getLongitude() {
        return longitude;
    }
    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }
	@ApiModelProperty(value = "纬度", example = "模块1")
    public String getLatitude() {
        return latitude;
    }
    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }
	@ApiModelProperty(value = "法人", example = "模块1")
    public String getLegalperson() {
        return legalperson;
    }
    public void setLegalperson(String legalperson) {
        this.legalperson = legalperson;
    }
	@ApiModelProperty(value = "机构管理员", example = "模块1")
    public String getOrgAdmin() {
        return orgAdmin;
    }
    public void setOrgAdmin(String orgAdmin) {
        this.orgAdmin = orgAdmin;
    }
	@ApiModelProperty(value = "机构网址", example = "模块1")
    public String getOrgUrl() {
        return orgUrl;
    }
    public void setOrgUrl(String orgUrl) {
        this.orgUrl = orgUrl;
    }
	@ApiModelProperty(value = "机构简介", example = "模块1")
    public String getIntro() {
        return intro;
    }
    public void setIntro(String intro) {
        this.intro = intro;
    }
	@ApiModelProperty(value = "机构二维码", example = "模块1")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 412 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BasePatientVO.java

@ -0,0 +1,412 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 居民信息vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BasePatientVO", description = "居民信息")
public class BasePatientVO extends UuidIdentityVOWithOperator {
    /**
	saas配置id	*/
    private String saasId;
    /**
	身份证号	*/
    private String idcard;
    /**
	登录密码	*/
    private String password;
    /**
		*/
    private String salt;
    /**
	姓名	*/
    private String name;
    /**
	生日	*/
    private Date birthday;
    /**
	性别,1男,2女	*/
    private String sex;
    /**
	手机号	*/
    private String mobile;
    /**
	联系电话	*/
    private String phone;
    /**
	社保卡号	*/
    private String ssc;
    /**
	头像http地址	*/
    private String photo;
    /**
	省编码	*/
    private String provinceCode;
    /**
	市编码	*/
    private String cityCode;
    /**
	区县编码	*/
    private String townCode;
    /**
	街道编码	*/
    private String streetCode;
    /**
	具体详细地址	*/
    private String address;
    /**
	疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病	*/
    private String disease;
    /**
	病情:0绿标,1黄标,2红标,3重点关注,	*/
    private String diseaseCondition;
    /**
	总积分	*/
    private String points;
    /**
	病历总数	*/
    private String recordAmount;
    /**
	微信编号	*/
    private String openid;
    /**
	用户状态:1正常,0禁用,-1恶意注册,2审核中	*/
    private String patientStatus;
    /**
	联系方式备注【基卫】	*/
    private String mobileRemarks;
    /**
	第一次添加open的时间	*/
    private Date openidTime;
    /**
	居委会代码	*/
    private String sickVillage;
    /**
		*/
    private String sickVillageName;
    /**
	绑定电子社保卡主体(共济为操作人code)	*/
    private String principalCode;
    /**
	是否绑定电子社保卡 (0否 1是)	*/
    private String sicardStatus;
    /**
	电子社保卡绑定时间	*/
    private Date sicardTime;
    /**
	是否分配过微信标签	*/
    private Integer isWxtag;
    /**
	微信tagId	*/
    private String wxtagid;
    /**
	居民预警状态:0为标准,1为预警状态	*/
    private Integer standardStatus;
    /**
	医疗保险号	*/
    private String medicareNumber;
    /**
	unionId 开发平台唯一标识	*/
    private String unionid;
    /**
	作废标识,1正常,0作废	*/
    private String del;
	@ApiModelProperty(value = "saas配置id", example = "模块1")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@ApiModelProperty(value = "身份证号", example = "模块1")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
	@ApiModelProperty(value = "登录密码", example = "模块1")
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
	@ApiModelProperty(value = "", example = "模块1")
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
	@ApiModelProperty(value = "姓名", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "生日", example = "模块1")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
	@ApiModelProperty(value = "性别,1男,2女", example = "模块1")
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
	@ApiModelProperty(value = "手机号", example = "模块1")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
	@ApiModelProperty(value = "联系电话", example = "模块1")
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
	@ApiModelProperty(value = "社保卡号", example = "模块1")
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
	@ApiModelProperty(value = "头像http地址", example = "模块1")
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
	@ApiModelProperty(value = "省编码", example = "模块1")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
	@ApiModelProperty(value = "市编码", example = "模块1")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
	@ApiModelProperty(value = "区县编码", example = "模块1")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
	@ApiModelProperty(value = "街道编码", example = "模块1")
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
	@ApiModelProperty(value = "具体详细地址", example = "模块1")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
	@ApiModelProperty(value = "疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病", example = "模块1")
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
	@ApiModelProperty(value = "病情:0绿标,1黄标,2红标,3重点关注,", example = "模块1")
    public String getDiseaseCondition() {
        return diseaseCondition;
    }
    public void setDiseaseCondition(String diseaseCondition) {
        this.diseaseCondition = diseaseCondition;
    }
	@ApiModelProperty(value = "总积分", example = "模块1")
    public String getPoints() {
        return points;
    }
    public void setPoints(String points) {
        this.points = points;
    }
	@ApiModelProperty(value = "病历总数", example = "模块1")
    public String getRecordAmount() {
        return recordAmount;
    }
    public void setRecordAmount(String recordAmount) {
        this.recordAmount = recordAmount;
    }
	@ApiModelProperty(value = "微信编号", example = "模块1")
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
	@ApiModelProperty(value = "用户状态:1正常,0禁用,-1恶意注册,2审核中", example = "模块1")
    public String getPatientStatus() {
        return patientStatus;
    }
    public void setPatientStatus(String patientStatus) {
        this.patientStatus = patientStatus;
    }
	@ApiModelProperty(value = "联系方式备注【基卫】", example = "模块1")
    public String getMobileRemarks() {
        return mobileRemarks;
    }
    public void setMobileRemarks(String mobileRemarks) {
        this.mobileRemarks = mobileRemarks;
    }
	@ApiModelProperty(value = "第一次添加open的时间", example = "模块1")
    public Date getOpenidTime() {
        return openidTime;
    }
    public void setOpenidTime(Date openidTime) {
        this.openidTime = openidTime;
    }
	@ApiModelProperty(value = "居委会代码", example = "模块1")
    public String getSickVillage() {
        return sickVillage;
    }
    public void setSickVillage(String sickVillage) {
        this.sickVillage = sickVillage;
    }
	@ApiModelProperty(value = "", example = "模块1")
    public String getSickVillageName() {
        return sickVillageName;
    }
    public void setSickVillageName(String sickVillageName) {
        this.sickVillageName = sickVillageName;
    }
	@ApiModelProperty(value = "绑定电子社保卡主体(共济为操作人code)", example = "模块1")
    public String getPrincipalCode() {
        return principalCode;
    }
    public void setPrincipalCode(String principalCode) {
        this.principalCode = principalCode;
    }
	@ApiModelProperty(value = "是否绑定电子社保卡 (0否 1是)", example = "模块1")
    public String getSicardStatus() {
        return sicardStatus;
    }
    public void setSicardStatus(String sicardStatus) {
        this.sicardStatus = sicardStatus;
    }
	@ApiModelProperty(value = "电子社保卡绑定时间", example = "模块1")
    public Date getSicardTime() {
        return sicardTime;
    }
    public void setSicardTime(Date sicardTime) {
        this.sicardTime = sicardTime;
    }
	@ApiModelProperty(value = "是否分配过微信标签", example = "模块1")
    public Integer getIsWxtag() {
        return isWxtag;
    }
    public void setIsWxtag(Integer isWxtag) {
        this.isWxtag = isWxtag;
    }
	@ApiModelProperty(value = "微信tagId", example = "模块1")
    public String getWxtagid() {
        return wxtagid;
    }
    public void setWxtagid(String wxtagid) {
        this.wxtagid = wxtagid;
    }
	@ApiModelProperty(value = "居民预警状态:0为标准,1为预警状态", example = "模块1")
    public Integer getStandardStatus() {
        return standardStatus;
    }
    public void setStandardStatus(Integer standardStatus) {
        this.standardStatus = standardStatus;
    }
	@ApiModelProperty(value = "医疗保险号", example = "模块1")
    public String getMedicareNumber() {
        return medicareNumber;
    }
    public void setMedicareNumber(String medicareNumber) {
        this.medicareNumber = medicareNumber;
    }
	@ApiModelProperty(value = "unionId 开发平台唯一标识", example = "模块1")
    public String getUnionid() {
        return unionid;
    }
    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 60 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseProvinceVO.java

@ -0,0 +1,60 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 省字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseProvinceVO", description = "省字典")
public class BaseProvinceVO extends IntegerIdentityVO{
    /**
	省份编码	*/
    private String code;
    /**
	省份名称	*/
    private String name;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "省份编码", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "省份名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 93 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseStreetVO.java

@ -0,0 +1,93 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 街道字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseStreetVO", description = "街道字典")
public class BaseStreetVO extends IntegerIdentityVO{
    /**
	省标识	*/
    private String province;
    /**
	市标识	*/
    private String city;
    /**
	区县标识	*/
    private String town;
    /**
	街道标识	*/
    private String code;
    /**
	街道名称	*/
    private String name;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "省标识", example = "模块1")
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
	@ApiModelProperty(value = "市标识", example = "模块1")
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
	@ApiModelProperty(value = "区县标识", example = "模块1")
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
	@ApiModelProperty(value = "街道标识", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "街道名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 71 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseTeamMemberVO.java

@ -0,0 +1,71 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 团队成员vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseTeamMemberVO", description = "团队成员")
public class BaseTeamMemberVO extends UuidIdentityVOWithOperator {
    /**
	团队ID	*/
    private String teamId;
    /**
	机构标识	*/
    private String orgId;
    /**
	医生标识,多个医生以逗号分开	*/
    private String doctorId;
    /**
	作废标识,1正常,0作废	*/
    private String del;
	@ApiModelProperty(value = "团队ID", example = "模块1")
    public String getTeamId() {
        return teamId;
    }
    public void setTeamId(String teamId) {
        this.teamId = teamId;
    }
	@ApiModelProperty(value = "机构标识", example = "模块1")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
	@ApiModelProperty(value = "医生标识,多个医生以逗号分开", example = "模块1")
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 93 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseTeamVO.java

@ -0,0 +1,93 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 团队信息vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseTeamVO", description = "团队信息")
public class BaseTeamVO extends UuidIdentityVOWithOperator {
    /**
	机构id	*/
    private String orgId;
    /**
	团队名称	*/
    private String name;
    /**
	领导医生标识	*/
    private String leaderId;
    /**
	团队人数	*/
    private String teamNum;
    /**
	团队二维码	*/
    private String qrcode;
    /**
	作废标识,1正常,0作废	*/
    private String del;
	@ApiModelProperty(value = "机构id", example = "模块1")
    public String getOrgId() {
        return orgId;
    }
    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }
	@ApiModelProperty(value = "团队名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "领导医生标识", example = "模块1")
    public String getLeaderId() {
        return leaderId;
    }
    public void setLeaderId(String leaderId) {
        this.leaderId = leaderId;
    }
	@ApiModelProperty(value = "团队人数", example = "模块1")
    public String getTeamNum() {
        return teamNum;
    }
    public void setTeamNum(String teamNum) {
        this.teamNum = teamNum;
    }
	@ApiModelProperty(value = "团队二维码", example = "模块1")
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 82 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/BaseTownVO.java

@ -0,0 +1,82 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 区县字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "BaseTownVO", description = "区县字典")
public class BaseTownVO extends IntegerIdentityVO{
    /**
	省编码	*/
    private String province;
    /**
	城市编码	*/
    private String city;
    /**
	区县编码	*/
    private String code;
    /**
	区县名称	*/
    private String name;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "省编码", example = "模块1")
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
	@ApiModelProperty(value = "城市编码", example = "模块1")
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
	@ApiModelProperty(value = "区县编码", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "区县名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 82 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictHealthProblemVO.java

@ -0,0 +1,82 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 健康问题字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictHealthProblemVO", description = "健康问题字典")
public class DictHealthProblemVO extends IntegerIdentityVO{
    /**
	saas配置id,null标识公共字典	*/
    private String saasId;
    /**
	字典编码	*/
    private String code;
    /**
	字典名称	*/
    private String name;
    /**
	描述	*/
    private String description;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "saas配置id,null标识公共字典", example = "模块1")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@ApiModelProperty(value = "字典编码", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "字典名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "描述", example = "模块1")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 71 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictHospitalDeptVO.java

@ -0,0 +1,71 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 医院科室字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictHospitalDeptVO", description = "医院科室字典")
public class DictHospitalDeptVO extends IntegerIdentityVO{
    /**
	saas配置id,null标识公共字典	*/
    private String saasId;
    /**
	科室标识	*/
    private String code;
    /**
	科室名称	*/
    private String name;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "saas配置id,null标识公共字典", example = "模块1")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@ApiModelProperty(value = "科室标识", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "科室名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 115 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictIcd10VO.java

@ -0,0 +1,115 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * ICD10字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictIcd10VO", description = "ICD10字典")
public class DictIcd10VO extends IntegerIdentityVO{
    /**
	saas配置id,null标识公共字典	*/
    private String saasId;
    /**
	icd10字典编码	*/
    private String code;
    /**
	icd10字典名称	*/
    private String name;
    /**
	字典名称拼音首字母	*/
    private String phoneticCode;
    /**
	是否慢病	*/
    private String chronicFlag;
    /**
	是否传染病	*/
    private String infectiousFlag;
    /**
	描述	*/
    private String description;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "saas配置id,null标识公共字典", example = "模块1")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@ApiModelProperty(value = "icd10字典编码", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "icd10字典名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "字典名称拼音首字母", example = "模块1")
    public String getPhoneticCode() {
        return phoneticCode;
    }
    public void setPhoneticCode(String phoneticCode) {
        this.phoneticCode = phoneticCode;
    }
	@ApiModelProperty(value = "是否慢病", example = "模块1")
    public String getChronicFlag() {
        return chronicFlag;
    }
    public void setChronicFlag(String chronicFlag) {
        this.chronicFlag = chronicFlag;
    }
	@ApiModelProperty(value = "是否传染病", example = "模块1")
    public String getInfectiousFlag() {
        return infectiousFlag;
    }
    public void setInfectiousFlag(String infectiousFlag) {
        this.infectiousFlag = infectiousFlag;
    }
	@ApiModelProperty(value = "描述", example = "模块1")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 71 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictJobTitleVO.java

@ -0,0 +1,71 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 职称字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictJobTitleVO", description = "职称字典")
public class DictJobTitleVO extends IntegerIdentityVO{
    /**
	saas配置id,null标识公共字典	*/
    private String saasId;
    /**
	职称标识	*/
    private String code;
    /**
	职称名	*/
    private String name;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "saas配置id,null标识公共字典", example = "模块1")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@ApiModelProperty(value = "职称标识", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "职称名", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 82 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictMedicineVO.java

@ -0,0 +1,82 @@
package com.yihu.jw.restmodel.base.dict;
import com.yihu.jw.restmodel.IntegerIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
 * 
 * 药品字典vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  2018年08月31日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "DictMedicineVO", description = "药品字典")
public class DictMedicineVO extends IntegerIdentityVO{
    /**
	saas配置id,null标识公共字典	*/
    private String saasId;
    /**
	药品编码	*/
    private String code;
    /**
	药品名称	*/
    private String name;
    /**
	药品类型:1健康记录	*/
    private String type;
    /**
	创建时间	*/
    private Date createTime;
	@ApiModelProperty(value = "saas配置id,null标识公共字典", example = "模块1")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@ApiModelProperty(value = "药品编码", example = "模块1")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@ApiModelProperty(value = "药品名称", example = "模块1")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@ApiModelProperty(value = "药品类型:1健康记录", example = "模块1")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
	@ApiModelProperty(value = "创建时间", example = "模块1")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 54 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/MqMessageSubscriberVO.java

@ -0,0 +1,54 @@
package com.yihu.jw.restmodel.base.message;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * VO - 基于MQ的消息推送订阅者
 * Created by progr1mmer on 2018/8/14.
 */
@ApiModel(value = "MqMessageSubscriberVO", description = "基于MQ的消息推送订阅者")
public class MqMessageSubscriberVO extends UuidIdentityVO {
    @ApiModelProperty(value = "SAAS ID", example = "402803ee656498890165649ad2xaaba2")
    private String saasId;
    @ApiModelProperty(value = "主题", example = "dailyReport")
    private String topic;
    @ApiModelProperty(value = "推送地址", example = "http://www.example.com/api")
    private String url;
    @ApiModelProperty(value = "备注", example = "我是备注")
    private String remark;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getTopic() {
        return topic;
    }
    public void setTopic(String topic) {
        this.topic = topic;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 59 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/message/MqMessageVO.java

@ -0,0 +1,59 @@
package com.yihu.jw.restmodel.base.message;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * VO - 基于MQ的消息推送
 * Created by progr1mmer on 2018/9/3.
 */
@ApiModel(value = "MqMessageVO", description = "基于MQ的消息推送")
public class MqMessageVO extends UuidIdentityVO {
    //主题
    @ApiModelProperty(value = "主题", example = "dailyReport")
    private String topic;
    //名称
    @ApiModelProperty(value = "名称", example = "日常统计数据")
    private String name;
    //备注
    @ApiModelProperty(value = "备注", example = "我是备注")
    private String remark;
    //模板
    @ApiModelProperty(value = "模板")
    private String template;
    public String getTopic() {
        return topic;
    }
    public void setTopic(String topic) {
        this.topic = topic;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getTemplate() {
        return template;
    }
    public void setTemplate(String template) {
        this.template = template;
    }
}

+ 3 - 3
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/RoleVO.java

@ -16,7 +16,7 @@ public class RoleVO extends UuidIdentityVOWithOperator {
	@ApiModelProperty(value = "备注", example = "我是备注")
	private String remark;
	@ApiModelProperty(value = "是否系统管理员", example = "1")
	private Boolean isSystem;
	private Boolean system;
	public String getName() {
		return this.name;
@ -35,10 +35,10 @@ public class RoleVO extends UuidIdentityVOWithOperator {
	}
	public Boolean getSystem() {
		return isSystem;
		return system;
	}
	public void setSystem(Boolean system) {
		isSystem = system;
		this.system = system;
	}
}

+ 2 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/servicePackage/ServicePackageDetailsVO.java

@ -1,5 +1,6 @@
package com.yihu.jw.restmodel.base.servicePackage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -24,6 +25,7 @@ public class ServicePackageDetailsVO extends UuidIdentityVO {
    @ApiModelProperty(value = "创建时间")
    private Date createTime;//创建时间',
    @ApiModelProperty(value = "执行时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    private Date executionTime;//执行时间',
    @ApiModelProperty(value = "执行类型", example = "1")
    private String executionType;//执行类型(1固定时间,2固定次数(不固定时间),3长期)',

+ 17 - 15
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/servicePackage/ServicePackagePropvalueDO.java

@ -1,34 +1,41 @@
package com.yihu.jw.restmodel.base.servicePackage;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 服务包属性值表
 * @author yeshijie on 2018/8/29.
 */
@Entity
@Table(name = "base_service_package_propvalue")
public class ServicePackagePropvalueDO extends UuidIdentityEntity implements Serializable {
@ApiModel(value = "ServicePackagePropvalueDO", description = "服务包属性值表")
public class ServicePackagePropvalueVO extends UuidIdentityVO {
    @ApiModelProperty(value = "saasId")
    private String saasId;
    @ApiModelProperty(value = "类目ID")
    private Long cid;//类目ID',
    @ApiModelProperty(value = "属性 ID")
    private Long pid;//属性 ID',
    @ApiModelProperty(value = "属性名")
    private String propName;//属性名',
    @ApiModelProperty(value = "属性值ID")
    private Long vid;//属性值ID',
    @ApiModelProperty(value = "属性值")
    private String name;//属性值',
    @ApiModelProperty(value = "属性值别名")
    private String nameAlias;//属性值别名',
    @ApiModelProperty(value = "是否为父类目属性")
    private Integer isParent;//是否为父类目属性',
    @ApiModelProperty(value = "排列序号")
    private Long sortOrder;//排列序号。取值范围:大于零的整数',
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    private Integer del;//状态。可选值:1(正常),0(删除)',
    @ApiModelProperty(value = "状态。可选值:1(正常),0(删除)")
    private Integer del;//',
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
@ -53,7 +60,6 @@ public class ServicePackagePropvalueDO extends UuidIdentityEntity implements Ser
        this.pid = pid;
    }
    @Column(name = "prop_name")
    public String getPropName() {
        return propName;
    }
@ -78,7 +84,6 @@ public class ServicePackagePropvalueDO extends UuidIdentityEntity implements Ser
        this.name = name;
    }
    @Column(name = "name_alias")
    public String getNameAlias() {
        return nameAlias;
    }
@ -87,7 +92,6 @@ public class ServicePackagePropvalueDO extends UuidIdentityEntity implements Ser
        this.nameAlias = nameAlias;
    }
    @Column(name = "is_parent")
    public Integer getIsParent() {
        return isParent;
    }
@ -96,7 +100,6 @@ public class ServicePackagePropvalueDO extends UuidIdentityEntity implements Ser
        this.isParent = isParent;
    }
    @Column(name = "sort_order")
    public Long getSortOrder() {
        return sortOrder;
    }
@ -105,7 +108,6 @@ public class ServicePackagePropvalueDO extends UuidIdentityEntity implements Ser
        this.sortOrder = sortOrder;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }

+ 3 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/SmsVO.java

@ -1,5 +1,6 @@
package com.yihu.jw.restmodel.base.sms;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
@ -31,7 +32,7 @@ public class SmsVO extends UuidIdentityVO {
    @ApiModelProperty(value = "短信内容", example = "【i健康综合管理平台】您使用的是i健康综合管理平台短信模板,您的验证码是826612,请于10分钟内正确输入!")
    private String content;
    //过期时间
    @ApiModelProperty(value = "应用ID", example = "EwC0iRSrcS")
    @ApiModelProperty(value = "过期时间", example = "2018-09-03 15:34:34")
    private Date deadline;
    //验证码
    private String captcha;
@ -78,6 +79,7 @@ public class SmsVO extends UuidIdentityVO {
        this.content = content;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDeadline() {
        return deadline;
    }

+ 9 - 6
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/user/UserVO.java

@ -1,5 +1,6 @@
package com.yihu.jw.restmodel.base.user;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
@ -40,10 +41,10 @@ public class UserVO extends UuidIdentityVOWithOperator {
    private String email;
    //是否可用
    @ApiModelProperty(value = "是否可用", example = "1")
    private Boolean isEnabled;
    private Boolean enabled;
    //是否锁定
    @ApiModelProperty(value = "是否锁定", example = "1")
    private Boolean isLocked;
    private Boolean locked;
    //锁定时间
    @ApiModelProperty(value = "锁定时间", example = "2018-08-27 13:23:32")
    private Date lockedDate;
@ -119,21 +120,22 @@ public class UserVO extends UuidIdentityVOWithOperator {
    }
    public Boolean getEnabled() {
        return isEnabled;
        return enabled;
    }
    public void setEnabled(Boolean enabled) {
        isEnabled = enabled;
        this.enabled = enabled;
    }
    public Boolean getLocked() {
        return isLocked;
        return locked;
    }
    public void setLocked(Boolean locked) {
        isLocked = locked;
        this.locked = locked;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getLockedDate() {
        return lockedDate;
    }
@ -142,6 +144,7 @@ public class UserVO extends UuidIdentityVOWithOperator {
        this.lockedDate = lockedDate;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getLoginDate() {
        return loginDate;
    }

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

@ -20,6 +20,10 @@ public class PatientSignInfoVO {
    private String patient;
    @ApiModelProperty("居民")
    private String patientName;
    @ApiModelProperty("居民身份证")
    private String idcard;
    @ApiModelProperty("居民社保卡号")
    private String ssc;
    @ApiModelProperty("医生code")
    private String doctor;
    @ApiModelProperty("医生")
@ -195,4 +199,20 @@ public class PatientSignInfoVO {
    public void setHealthAssistantName(String healthAssistantName) {
        this.healthAssistantName = healthAssistantName;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
}

+ 0 - 10
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/Envelop.java

@ -20,8 +20,6 @@ public class Envelop implements Serializable {
    protected String message;
    @ApiModelProperty(value = "状态(200 - 成功)", example = "200")
    protected Integer status = EnvelopStatus.success.code;
    @ApiModelProperty(value = "错误码", example = "200")
    protected String errorCode;
    public Integer getStatus() {
        return status;
@ -39,14 +37,6 @@ public class Envelop implements Serializable {
        this.message = message;
    }
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    public static Envelop getSuccess(String message) {
        Envelop envelop = new Envelop();
        envelop.setMessage(message);

+ 19 - 14
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java

@ -1,13 +1,8 @@
package com.yihu.jw.restmodel.web.endpoint;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
@ -17,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -44,14 +40,6 @@ public abstract class EnvelopRestEndpoint {
        return envelop;
    }
    protected Envelop error(String message,String errorCode){
        Envelop envelop = new Envelop();
        envelop.setMessage(message);
        envelop.setErrorCode(errorCode);
        envelop.setStatus(-1);
        return envelop;
    }
    protected <J> ObjEnvelop<J> success(J obj){
        return success("success", obj);
    }
@ -172,6 +160,17 @@ public abstract class EnvelopRestEndpoint {
        return mixEnvelop;
    }
    protected Envelop failed (String message) {
        return failed(message, -10000);
    }
    protected Envelop failed (String message, int status) {
        Envelop envelop = new Envelop();
        envelop.setMessage(message);
        envelop.setStatus(status);
        return envelop;
    }
    protected <E extends Envelop> E failed(String message, Class<E> clazz) {
        return failed(message, -10000, clazz);
    }
@ -192,6 +191,12 @@ public abstract class EnvelopRestEndpoint {
        return entity;
    }
    protected <T> T toDateEntity(String json, Class<T> target) throws IOException {
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        T entity = objectMapper.readValue(json, target);
        return entity;
    }
    protected <T> T convertToModel(Object source, Class<T> target, String... properties) {
        if (source == null) {
            return null;

+ 6 - 6
server/svr-authentication/pom.xml

@ -55,22 +55,18 @@
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-ribbon</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
@ -81,12 +77,10 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <!-- Redis  -->
@ -106,6 +100,12 @@
        </dependency>
        <!-- JdbcTemplate-->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>utils</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
</project>

+ 26 - 1
server/svr-authentication/src/main/java/com/yihu/AuthServer.java

@ -1,7 +1,32 @@
package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/**
 * Created by progr1mmer on 2018/8/29.
 */
public class AuthServer {
@SpringBootApplication
public class AuthServer extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(AuthServer.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(AuthServer.class);
    }
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
}

+ 0 - 14
server/svr-authentication/src/main/java/com/yihu/jw/oauth2/config/WlyyAuthorizationServerConfigurerAdapter.java

@ -1,14 +0,0 @@
package com.yihu.jw.oauth2.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
/**
 *
 * Created by progr1mmer on 2018/8/29.
 */
@Configuration
@EnableAuthorizationServer
public class WlyyAuthorizationServerConfigurerAdapter extends AuthorizationServerConfigurerAdapter {
}

+ 0 - 49
server/svr-authentication/src/main/java/com/yihu/jw/oauth2/config/WlyyWebSecurityConfigurerAdapter.java

@ -1,49 +0,0 @@
package com.yihu.jw.oauth2.config;
import com.yihu.jw.oauth2.core.WlyyUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
/**
 * Config - Spring Security
 * Created by progr1mmer on 2018/8/29.
 */
@Configuration
public class WlyyWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
    @Autowired
    private AuthenticationProvider authenticationProvider;
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/oauth/**");
    }
    @Override
    protected void configure(AuthenticationManagerBuilder authBuilder) throws Exception {
        authBuilder.authenticationProvider(authenticationProvider);
    }
    @Bean
    WlyyUserDetailsService wlyyUserDetailsService(){
        return new WlyyUserDetailsService();
    }
    @Bean
    public AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService) {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(userDetailsService);
        authenticationProvider.setPasswordEncoder(new Md5PasswordEncoder());
        return authenticationProvider;
    }
}

+ 0 - 10
server/svr-authentication/src/main/java/com/yihu/jw/oauth2/model/WlyyUserDetails.java

@ -1,10 +0,0 @@
package com.yihu.jw.oauth2.model;
import java.io.Serializable;
/**
 * Model - 认证用户详细信息
 * Created by progr1mmer on 2018/8/29.
 */
public class WlyyUserDetails implements Serializable {
}

+ 0 - 10
server/svr-authentication/src/main/java/com/yihu/jw/oauth2/model/WlyyUserSimple.java

@ -1,10 +0,0 @@
package com.yihu.jw.oauth2.model;
import java.io.Serializable;
/**
 * Model - 认证用户简略信息
 * Created by progr1mmer on 2018/8/29.
 */
public class WlyyUserSimple implements Serializable {
}

+ 69 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/config/WlyyWebSecurityConfigurerAdapter.java

@ -0,0 +1,69 @@
package com.yihu.jw.security.config;
import com.yihu.jw.security.web.authentication.WlyyAuthenticationFailureHandler;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.authentication.dao.ReflectionSaltSource;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import javax.sql.DataSource;
/**
 * Config - Spring Security
 * Created by progr1mmer on 2018/8/29.
 */
@Configuration
@EnableWebSecurity
public class WlyyWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
    @Autowired
    private DataSource dataSource;
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/oauth/**");
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/login/**").permitAll()
                .antMatchers("/**").hasRole("USER")
                .and().formLogin().loginPage("/login").failureHandler(new WlyyAuthenticationFailureHandler())
                .and().logout().logoutUrl("/logout").logoutSuccessUrl("/login")
                .and().headers().frameOptions().disable()
                .and().csrf().disable();
    }
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider());
    }
    @Bean
    WlyyUserDetailsService wlyyUserDetailsService(){
        return new WlyyUserDetailsService(dataSource);
    }
    @Bean
    AuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(wlyyUserDetailsService());
        authenticationProvider.setPasswordEncoder(new Md5PasswordEncoder());
        ReflectionSaltSource reflectionSaltSource = new ReflectionSaltSource();
        reflectionSaltSource.setUserPropertyToUse("salt");
        authenticationProvider.setSaltSource(reflectionSaltSource);
        authenticationProvider.setSaltSource(reflectionSaltSource);
        return authenticationProvider;
    }
}

+ 228 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/SaltUser.java

@ -0,0 +1,228 @@
package com.yihu.jw.security.core.userdetails;
import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.Assert;
import java.io.Serializable;
import java.util.*;
/**
 * Created by progr1mmer on 2018/8/29.
 */
public class SaltUser implements UserDetails, CredentialsContainer {
    private static final long serialVersionUID = 420L;
    private String password;
    private final String username;
    private final Set<GrantedAuthority> authorities;
    private final boolean accountNonExpired;
    private final boolean accountNonLocked;
    private final boolean credentialsNonExpired;
    private final boolean enabled;
    private final String salt;
    public SaltUser(String username, String password, String salt, Collection<? extends GrantedAuthority> authorities) {
        this(username, password, salt, true, true, true, true, authorities);
    }
    public SaltUser(String username, String password, String salt, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
        if(username != null && !"".equals(username) && password != null) {
            this.username = username;
            this.password = password;
            this.salt = salt;
            this.enabled = enabled;
            this.accountNonExpired = accountNonExpired;
            this.credentialsNonExpired = credentialsNonExpired;
            this.accountNonLocked = accountNonLocked;
            this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));
        } else {
            throw new IllegalArgumentException("Cannot pass null or empty values to constructor");
        }
    }
    public Collection<GrantedAuthority> getAuthorities() {
        return this.authorities;
    }
    public String getPassword() {
        return this.password;
    }
    public String getUsername() {
        return this.username;
    }
    public String getSalt() {
        return salt;
    }
    public boolean isEnabled() {
        return this.enabled;
    }
    public boolean isAccountNonExpired() {
        return this.accountNonExpired;
    }
    public boolean isAccountNonLocked() {
        return this.accountNonLocked;
    }
    public boolean isCredentialsNonExpired() {
        return this.credentialsNonExpired;
    }
    public void eraseCredentials() {
        this.password = null;
    }
    private static SortedSet<GrantedAuthority> sortAuthorities(Collection<? extends GrantedAuthority> authorities) {
        Assert.notNull(authorities, "Cannot pass a null GrantedAuthority collection");
        SortedSet<GrantedAuthority> sortedAuthorities = new TreeSet(new SaltUser.AuthorityComparator());
        Iterator var2 = authorities.iterator();
        while(var2.hasNext()) {
            GrantedAuthority grantedAuthority = (GrantedAuthority)var2.next();
            Assert.notNull(grantedAuthority, "GrantedAuthority list cannot contain any null elements");
            sortedAuthorities.add(grantedAuthority);
        }
        return sortedAuthorities;
    }
    public boolean equals(Object rhs) {
        return rhs instanceof SaltUser?this.username.equals(((SaltUser)rhs).username):false;
    }
    public int hashCode() {
        return this.username.hashCode();
    }
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.toString()).append(": ");
        sb.append("Username: ").append(this.username).append("; ");
        sb.append("Password: [PROTECTED]; ");
        sb.append("Enabled: ").append(this.enabled).append("; ");
        sb.append("AccountNonExpired: ").append(this.accountNonExpired).append("; ");
        sb.append("credentialsNonExpired: ").append(this.credentialsNonExpired).append("; ");
        sb.append("AccountNonLocked: ").append(this.accountNonLocked).append("; ");
        if(!this.authorities.isEmpty()) {
            sb.append("Granted Authorities: ");
            boolean first = true;
            Iterator var3 = this.authorities.iterator();
            while(var3.hasNext()) {
                GrantedAuthority auth = (GrantedAuthority)var3.next();
                if(!first) {
                    sb.append(",");
                }
                first = false;
                sb.append(auth);
            }
        } else {
            sb.append("Not granted any authorities");
        }
        return sb.toString();
    }
    public static SaltUser.UserBuilder withUsername(String username) {
        return (new SaltUser.UserBuilder()).username(username);
    }
    public static class UserBuilder {
        private String username;
        private String password;
        private List<GrantedAuthority> authorities;
        private boolean accountExpired;
        private boolean accountLocked;
        private boolean credentialsExpired;
        private boolean disabled;
        private UserBuilder() {
        }
        private SaltUser.UserBuilder username(String username) {
            Assert.notNull(username, "username cannot be null");
            this.username = username;
            return this;
        }
        public SaltUser.UserBuilder password(String password) {
            Assert.notNull(password, "password cannot be null");
            this.password = password;
            return this;
        }
        public SaltUser.UserBuilder roles(String... roles) {
            List<GrantedAuthority> authorities = new ArrayList(roles.length);
            String[] var3 = roles;
            int var4 = roles.length;
            for(int var5 = 0; var5 < var4; ++var5) {
                String role = var3[var5];
                Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)");
                authorities.add(new SimpleGrantedAuthority("ROLE_" + role));
            }
            return this.authorities((List)authorities);
        }
        public SaltUser.UserBuilder authorities(GrantedAuthority... authorities) {
            return this.authorities(Arrays.asList(authorities));
        }
        public SaltUser.UserBuilder authorities(List<? extends GrantedAuthority> authorities) {
            this.authorities = new ArrayList(authorities);
            return this;
        }
        public SaltUser.UserBuilder authorities(String... authorities) {
            return this.authorities(AuthorityUtils.createAuthorityList(authorities));
        }
        public SaltUser.UserBuilder accountExpired(boolean accountExpired) {
            this.accountExpired = accountExpired;
            return this;
        }
        public SaltUser.UserBuilder accountLocked(boolean accountLocked) {
            this.accountLocked = accountLocked;
            return this;
        }
        public SaltUser.UserBuilder credentialsExpired(boolean credentialsExpired) {
            this.credentialsExpired = credentialsExpired;
            return this;
        }
        public SaltUser.UserBuilder disabled(boolean disabled) {
            this.disabled = disabled;
            return this;
        }
        public UserDetails build() {
            return new User(this.username, this.password, !this.disabled, !this.accountExpired, !this.credentialsExpired, !this.accountLocked, this.authorities);
        }
    }
    private static class AuthorityComparator implements Comparator<GrantedAuthority>, Serializable {
        private static final long serialVersionUID = 420L;
        private AuthorityComparator() {
        }
        public int compare(GrantedAuthority g1, GrantedAuthority g2) {
            return g2.getAuthority() == null?-1:(g1.getAuthority() == null?1:g1.getAuthority().compareTo(g2.getAuthority()));
        }
    }
}

+ 17 - 12
server/svr-authentication/src/main/java/com/yihu/jw/oauth2/core/WlyyUserDetailsService.java

@ -1,17 +1,20 @@
package com.yihu.jw.oauth2.core;
package com.yihu.jw.security.core.userdetails.jdbc;
import com.yihu.jw.oauth2.model.WlyyUserSimple;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
@ -20,7 +23,11 @@ import java.util.List;
 */
public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetailsService {
    private static final String DEFAULT_USER_DETAILS_STATEMENT = "SELECT * FROM user u WHERE u.username = ? OR u.mobile = ? OR u.idcard = ?";
    private static final String DEFAULT_USER_DETAILS_STATEMENT = "SELECT * FROM base_user u WHERE u.username = ? OR u.mobile = ? OR u.idcard = ?";
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
    }
    /**
     * 用户登录判读接口
@ -31,16 +38,11 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        List<UserDetails> users = this.getJdbcTemplate().query(DEFAULT_USER_DETAILS_STATEMENT, new BeanPropertyRowMapper(UserDetails.class), username, username, username);
        List<WlyyUserDetails> users = this.getJdbcTemplate().query(DEFAULT_USER_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username, username);
        if (users == null || users.size() == 0) {
            throw new UsernameNotFoundException(username);
        }
        return new User(username, users.get(0).getPassword(), getGrantedAuthorities(username));
        /*if (username.equals("admin")){
            return new User("admin", "e10adc3949ba59abbe56e057f20f883e", getGrantedAuthorities(username));
        }
        return null;*/
        return new SaltUser(username, users.get(0).getPassword(), users.get(0).getSalt(), getGrantedAuthorities(username));
    }
    private Collection<? extends GrantedAuthority> getGrantedAuthorities(String username) {
@ -49,7 +51,10 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        return authorities;
    }
    public WlyyUserSimple loadUserSimpleByUsername(String username) throws UsernameNotFoundException {
    public WlyyUserSimple authSuccess (String username) throws UsernameNotFoundException {
        //更新登陆时间
        this.getJdbcTemplate().update("update base_user u set u.login_date = ? where u.username = ? or u.mobile = ? or u.idcard = ?", new Date(), username, username, username);
        //加载用户简略信息
        List<WlyyUserSimple> users = this.getJdbcTemplate().query(DEFAULT_USER_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), username, username, username);
        if (users == null || users.size() == 0) {
            throw new UsernameNotFoundException(username);

+ 42 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/Captcha.java

@ -0,0 +1,42 @@
package com.yihu.jw.security.model;
import java.io.Serializable;
import java.util.Date;
/**
 * Model - 验证码
 * Created by progr1mmer on 2018/9/3.
 */
public class Captcha implements Serializable {
    //验证码
    private String code;
    //过期时间(秒)
    private int expiresIn;
    //请求间隔(秒)
    private int interval;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public int getExpiresIn() {
        return expiresIn;
    }
    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }
    public int getInterval() {
        return interval;
    }
    public void setInterval(int interval) {
        this.interval = interval;
    }
}

+ 53 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/Oauth2Envelop.java

@ -0,0 +1,53 @@
package com.yihu.jw.security.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.HashMap;
/**
 * Model - 认证失败信息
 * Created by progr1mmer on 2018/8/29.
 */
public class Oauth2Envelop<T> implements Serializable {
    protected String message;
    protected Integer status;
    private T obj = (T)new HashMap<>();
    public Oauth2Envelop(String message, Integer status) {
        this.message = message;
        this.status = status;
    }
    public Oauth2Envelop(String message, Integer status, T obj) {
        this.message = message;
        this.status = status;
        this.obj = obj;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    public T getObj() {
        return obj;
    }
    public void setObj(T obj) {
        this.obj = obj;
    }
}

+ 31 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/PublicKey.java

@ -0,0 +1,31 @@
package com.yihu.jw.security.model;
import java.io.Serializable;
/**
 * Model 公钥
 * Created by progr1mmer on 2018/9/3.
 */
public class PublicKey implements Serializable {
    //模
    private String modulus;
    //指数
    private String exponent;
    public String getModulus() {
        return modulus;
    }
    public void setModulus(String modulus) {
        this.modulus = modulus;
    }
    public String getExponent() {
        return exponent;
    }
    public void setExponent(String exponent) {
        this.exponent = exponent;
    }
}

+ 220 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserDetails.java

@ -0,0 +1,220 @@
package com.yihu.jw.security.model;
import java.io.Serializable;
import java.util.Date;
/**
 * Model - 认证用户详细信息
 * Created by progr1mmer on 2018/8/29.
 */
public class WlyyUserDetails implements Serializable {
    /**
     * 性别
     */
    public enum Gender {
        //男
        male,
        //女
        female
    }
    private String id;
    //创建时间
    private Date createTime;
    //创建者
    private String createUser;
    //创建者
    private String createUserName;
    //更新时间
    private Date updateTime;
    //更新者
    private String updateUser;
    //更新者
    private String updateUserName;
    //用户名
    private String username;
    //密码
    private String password;
    //密码散列值
    private String salt;
    //姓名
    private String name;
    //性别
    private Gender gender;
    //身份证号码
    private String idcard;
    //手机号码
    private String mobile;
    //邮箱
    private String email;
    //是否可用
    private Boolean enabled;
    //是否锁定
    private Boolean locked;
    //锁定时间
    private Date lockedDate;
    //最后登陆时间
    private Date loginDate;
    //登陆失败次数
    private Integer loginFailureCount;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Gender getGender() {
        return gender;
    }
    public void setGender(Gender gender) {
        this.gender = gender;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public Boolean isEnabled() {
        return enabled;
    }
    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }
    public Boolean isLocked() {
        return locked;
    }
    public void setLocked(Boolean locked) {
        this.locked = locked;
    }
    public Date getLockedDate() {
        return lockedDate;
    }
    public void setLockedDate(Date lockedDate) {
        this.lockedDate = lockedDate;
    }
    public Date getLoginDate() {
        return loginDate;
    }
    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }
    public Integer getLoginFailureCount() {
        return loginFailureCount;
    }
    public void setLoginFailureCount(Integer loginFailureCount) {
        this.loginFailureCount = loginFailureCount;
    }
}

+ 165 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserSimple.java

@ -0,0 +1,165 @@
package com.yihu.jw.security.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.Date;
/**
 * Model - 认证用户简略信息
 * Created by progr1mmer on 2018/8/29.
 */
public class WlyyUserSimple implements Serializable {
    /**
     * 性别
     */
    public enum Gender {
        //男
        male,
        //女
        female
    }
    private String id;
    //用户名
    private String username;
    //姓名
    private String name;
    //性别
    private Gender gender;
    //身份证号码
    private String idcard;
    //手机号码
    private String mobile;
    //邮箱
    private String email;
    //最后登陆时间
    private Date loginDate;
    //扩展字段
    private String user; //当前登陆凭证
    private String accessToken;
    private String refreshToken;
    private String tokenType;
    private int expiresIn;
    private String state;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Gender getGender() {
        return gender;
    }
    public void setGender(Gender gender) {
        this.gender = gender;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getLoginDate() {
        return loginDate;
    }
    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    //@JsonProperty(value = "access_token")
    public String getAccessToken() {
        return accessToken;
    }
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
    //@JsonProperty(value = "refresh_token")
    public String getRefreshToken() {
        return refreshToken;
    }
    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }
    //@JsonProperty(value = "token_type")
    public String getTokenType() {
        return tokenType;
    }
    public void setTokenType(String tokenType) {
        this.tokenType = tokenType;
    }
    //@JsonProperty(value = "expires_in")
    public int getExpiresIn() {
        return expiresIn;
    }
    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
}

+ 65 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/common/WlyyOAuth2AccessToken.java

@ -0,0 +1,65 @@
package com.yihu.jw.security.oauth2.common;
import java.io.Serializable;
/**
 * Created by progr1mmer on 2018/8/29.
 */
public class WlyyOAuth2AccessToken implements Serializable {
    private String accessToken;
    private String refreshToken;
    private String tokenType;
    private int expiresIn;
    private String scope;
    private String state;
    public String getAccessToken() {
        return accessToken;
    }
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
    public String getRefreshToken() {
        return refreshToken;
    }
    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }
    public String getTokenType() {
        return tokenType;
    }
    public void setTokenType(String tokenType) {
        this.tokenType = tokenType;
    }
    public int getExpiresIn() {
        return expiresIn;
    }
    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }
    public String getScope() {
        return scope;
    }
    public void setScope(String scope) {
        this.scope = scope;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
}

+ 100 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/config/WlyyAuthorizationServerConfigurerAdapter.java

@ -0,0 +1,100 @@
package com.yihu.jw.security.oauth2.config;
import com.yihu.jw.security.oauth2.provider.client.WlyyJdbcClientRedirectUriService;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
import org.springframework.security.oauth2.provider.code.AuthorizationCodeServices;
import org.springframework.security.oauth2.provider.code.InMemoryAuthorizationCodeServices;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory;
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import javax.sql.DataSource;
/**
 * Config - Spring Oauth2
 * Created by progr1mmer on 2018/8/29.
 */
@Configuration
@EnableAuthorizationServer
public class WlyyAuthorizationServerConfigurerAdapter extends AuthorizationServerConfigurerAdapter {
    @Autowired
    private DataSource dataSource;
    @Autowired
    private JedisConnectionFactory jedisConnectionFactory;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints.tokenStore(redisTokenStore());
        endpoints.authorizationCodeServices(authorizationCodeServices());
    }
    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.withClientDetails(clientDetailsService());
    }
    /*@Override
    public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
        security.passwordEncoder(new StandardPasswordEncoder());
    }*/
    @Bean
    @Primary
    WlyyTokenGranter wlyyTokenGranter (
            AuthenticationManager authenticationManager,
            AuthorizationServerTokenServices authorizationServerTokenServices) {
        WlyyTokenGranter tokenGranter = new WlyyTokenGranter(
                authenticationManager,
                authorizationServerTokenServices,
                authorizationCodeServices(),
                clientDetailsService(),
                new DefaultOAuth2RequestFactory(clientDetailsService()),
                wlyyRedisVerifyCodeService());
        return tokenGranter;
    }
    @Bean
    ClientDetailsService clientDetailsService() {
        return new JdbcClientDetailsService(dataSource);
    }
    @Bean
    RedisTokenStore redisTokenStore() {
        return new RedisTokenStore(jedisConnectionFactory);
    }
    @Bean
    WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService() {
        return new WlyyRedisVerifyCodeService(redisTemplate);
    }
    @Bean
    AuthorizationCodeServices authorizationCodeServices() {
        return new InMemoryAuthorizationCodeServices();
    }
    @Bean
    WlyyJdbcClientRedirectUriService wlyyJdbcClientRedirectUriService() {
        return new WlyyJdbcClientRedirectUriService(jdbcTemplate);
    }
}

+ 49 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/jdbc/WlyyJdbcUserSecurityService.java

@ -0,0 +1,49 @@
package com.yihu.jw.security.oauth2.core.jdbc;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.util.Assert;
import javax.sql.DataSource;
import java.util.List;
/**
 * Created by progr1mmer on 2018/1/8.
 */
public class WlyyJdbcUserSecurityService {
    private static final String DEFAULT_KEY_ID_SELECT_STATEMENT = "SELECT id FROM user_security WHERE public_key = ?";
    private static final String DEFAULT_USER_ID_BY_KEY_ID_SELECT_STATEMENT = "SELECT user_id FROM user_key WHERE key_id = ?";
    private static final String DEFAULT_USER_NAME_BY_USER_ID = "SELECT login_code FROM users WHERE id = ?";
    private JdbcTemplate jdbcTemplate;
    public WlyyJdbcUserSecurityService(DataSource dataSource) {
        Assert.notNull(dataSource, "DataSource required");
        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }
    public String getDefaultKeyIdSelectStatement(String publicKey) {
        List<String> keyId = jdbcTemplate.queryForList(DEFAULT_KEY_ID_SELECT_STATEMENT, new String []{publicKey}, String.class);
        if(keyId.size() <= 0) {
            throw new InsufficientAuthenticationException("Illegal authorized pk.");
        }
        return keyId.get(0);
    }
    public String getDefaultUserIdByKeyIdSelectStatement(String keyId) {
        List<String> userId =  jdbcTemplate.queryForList(DEFAULT_USER_ID_BY_KEY_ID_SELECT_STATEMENT, new String []{keyId}, String.class);
        if(userId.size() <= 0) {
            throw new InsufficientAuthenticationException("Unauthorized security key. please check you pk.");
        }
        return userId.get(0);
    }
    public String getDefaultUserNameByUserId(String userId) {
        List<String> username = jdbcTemplate.queryForList(DEFAULT_USER_NAME_BY_USER_ID, new String []{userId}, String.class);
        if(username.size() <= 0) {
            throw new InsufficientAuthenticationException("Illegal user id. please check you pk.");
        }
        return username.get(0);
    }
}

+ 58 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/redis/WlyyRedisVerifyCodeService.java

@ -0,0 +1,58 @@
package com.yihu.jw.security.oauth2.core.redis;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StringUtils;
import java.util.concurrent.TimeUnit;
/**
 * Service - 验证码缓存
 * Created by progr1mmer on 2018/4/18.
 */
public class WlyyRedisVerifyCodeService {
    private final String KEY_SUFFIX = ":code";
    private final RedisTemplate redisTemplate;
    public WlyyRedisVerifyCodeService(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
    public void store (String client_id, String username, String code, int expire) {
        String key = client_id + ":" + username + KEY_SUFFIX;
        redisTemplate.opsForValue().set(key, code);
        redisTemplate.expire(key, expire, TimeUnit.SECONDS);
        String intervalKey = key + ":" + code + "_interval";
        redisTemplate.opsForValue().set(intervalKey, 60);
        redisTemplate.expire(intervalKey, 60, TimeUnit.SECONDS);
    }
    public boolean isIntervalTimeout(String client_id, String username) {
        String key = client_id + ":" + username + KEY_SUFFIX;
        String code = (String) redisTemplate.opsForValue().get(key);
        if (null == code) {
            return true;
        }
        String intervalKey = key + ":" + code + "_interval";
        if (redisTemplate.opsForValue().get(intervalKey) != null) {
            return false;
        }
        return true;
    }
    public boolean verification (String client_id, String username, String code) {
        if (StringUtils.isEmpty(code)) {
            return false;
        }
        String key = client_id + ":" + username + KEY_SUFFIX;
        String _code = (String) redisTemplate.opsForValue().get(key);
        if (null == _code) {
            return false;
        }
        if (code.equalsIgnoreCase(_code)) {
            return true;
        }
        return false;
    }
}

+ 327 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -0,0 +1,327 @@
package com.yihu.jw.security.oauth2.provider;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import org.springframework.security.authentication.*;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;
import org.springframework.security.oauth2.common.exceptions.InvalidRequestException;
import org.springframework.security.oauth2.common.exceptions.RedirectMismatchException;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.provider.*;
import org.springframework.security.oauth2.provider.code.AuthorizationCodeServices;
import org.springframework.security.oauth2.provider.implicit.ImplicitGrantService;
import org.springframework.security.oauth2.provider.implicit.ImplicitTokenRequest;
import org.springframework.security.oauth2.provider.token.AbstractTokenGranter;
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
import org.springframework.util.Assert;
import java.util.*;
/**
 * Token授权器。
 * @author Progr1mmer
 * @created 2018.01.09
 */
public class WlyyTokenGranter implements TokenGranter {
    private final Map<String, TokenGranter> tokenGranters = new HashMap<>();
    public WlyyTokenGranter(AuthenticationManager authenticationManager,
                            AuthorizationServerTokenServices tokenServices,
                            AuthorizationCodeServices authorizationCodeServices,
                            ClientDetailsService clientDetailsService,
                            OAuth2RequestFactory requestFactory,
                            WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) {
        tokenGranters.put(WlyyAuthorizationCodeGranter.GRANT_TYPE,
                new WlyyAuthorizationCodeGranter(
                        tokenServices,
                        authorizationCodeServices,
                        clientDetailsService,
                        requestFactory
                ));
        tokenGranters.put(WlyyResourceOwnerPasswordTokenGranter.GRANT_TYPE,
                new WlyyResourceOwnerPasswordTokenGranter(
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory
                ));
        tokenGranters.put(WlyyRefreshTokenGranter.GRANT_TYPE,
                new WlyyRefreshTokenGranter(
                        tokenServices,
                        clientDetailsService,
                        requestFactory
                ));
        tokenGranters.put(WlyyImplicitTokenGranter.GRANT_TYPE,
                new WlyyImplicitTokenGranter(
                        tokenServices,
                        clientDetailsService,
                        requestFactory
                ));
        tokenGranters.put(WlyyCaptchaTokenGranter.GRANT_TYPE,
                new WlyyCaptchaTokenGranter(
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory,
                        wlyyRedisVerifyCodeService
                ));
    }
    public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
        if (tokenGranters.get(grantType) != null) {
            OAuth2AccessToken grant = tokenGranters.get(grantType).grant(grantType, tokenRequest);
            return grant;
        }
        return null;
    }
    /**
     * authorization_code模式Token授权器。
     */
    public static class WlyyAuthorizationCodeGranter extends AbstractTokenGranter {
        public static final String GRANT_TYPE = "authorization_code";
        private final AuthorizationCodeServices authorizationCodeServices;
        public WlyyAuthorizationCodeGranter(AuthorizationServerTokenServices tokenServices,
                                           AuthorizationCodeServices authorizationCodeServices,
                                           ClientDetailsService clientDetailsService,
                                           OAuth2RequestFactory requestFactory) {
            this(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        protected WlyyAuthorizationCodeGranter(AuthorizationServerTokenServices tokenServices,
                                              AuthorizationCodeServices authorizationCodeServices,
                                              ClientDetailsService clientDetailsService,
                                              OAuth2RequestFactory requestFactory,
                                              String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authorizationCodeServices = authorizationCodeServices;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = tokenRequest.getRequestParameters();
            String authorizationCode = parameters.get("code");
            String redirectUri = parameters.get(OAuth2Utils.REDIRECT_URI);
            if (authorizationCode == null) {
                throw new InvalidRequestException("An authorization code must be supplied.");
            }
            OAuth2Authentication storedAuth = authorizationCodeServices.consumeAuthorizationCode(authorizationCode);
            if (storedAuth == null) {
                throw new InvalidGrantException("Invalid authorization code: " + authorizationCode);
            }
            OAuth2Request pendingOAuth2Request = storedAuth.getOAuth2Request();
            String oauthUri;
            if (pendingOAuth2Request.getRedirectUri().indexOf("?") != -1) {
                oauthUri = pendingOAuth2Request.getRedirectUri().substring(0, pendingOAuth2Request.getRedirectUri().indexOf("?"));
            } else {
                oauthUri = pendingOAuth2Request.getRedirectUri();
            }
            // https://jira.springsource.org/browse/SECOAUTH-333
            // This might be null, if the authorization was done without the redirect_uri parameter
            String redirectUriApprovalParameter = pendingOAuth2Request.getRequestParameters().get(
                    OAuth2Utils.REDIRECT_URI);
            if ((redirectUri != null || redirectUriApprovalParameter != null)
                    && !oauthUri.equals(redirectUri)) {
                throw new RedirectMismatchException("Redirect URI mismatch.");
            }
            String pendingClientId = pendingOAuth2Request.getClientId();
            String clientId = tokenRequest.getClientId();
            if (clientId != null && !clientId.equals(pendingClientId)) {
                // just a sanity check.
                throw new InvalidClientException("Client ID mismatch");
            }
            // Secret is not required in the authorization request, so it won't be available
            // in the pendingAuthorizationRequest. We do want to check that a secret is provided
            // in the token request, but that happens elsewhere.
            Map<String, String> combinedParameters = new HashMap<String, String>(pendingOAuth2Request
                    .getRequestParameters());
            // Combine the parameters adding the new ones last so they override if there are any clashes
            combinedParameters.putAll(parameters);
            // Make a new stored request with the combined parameters
            OAuth2Request finalStoredOAuth2Request = pendingOAuth2Request.createOAuth2Request(combinedParameters);
            Authentication userAuth = storedAuth.getUserAuthentication();
            return new OAuth2Authentication(finalStoredOAuth2Request, userAuth);
        }
    }
    /**
     * password模式Token授权器。
     */
    public static class WlyyResourceOwnerPasswordTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "password";
        private final AuthenticationManager authenticationManager;
        public WlyyResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager,
                                                 AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        protected WlyyResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
                                                    ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String username = parameters.get("username");
            String password = parameters.get("password");
            // Protect from downstream leaks of password
            parameters.remove("password");
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, password);
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            try {
                userAuth = authenticationManager.authenticate(userAuth);
            }
            catch (AccountStatusException ase) {
                //covers expired, locked, disabled cases (mentioned in section 5.2, draft 31)
                throw new InvalidGrantException(ase.getMessage());
            }
            catch (BadCredentialsException e) {
                // If the username/password are wrong the spec says we should send 400/invalid grant
                throw new InvalidGrantException(e.getMessage());
            }
            if (userAuth == null || !userAuth.isAuthenticated()) {
                throw new InvalidGrantException("Could not authenticate user: " + username);
            }
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
    }
    /**
     * refresh模式Token授权器。
     */
    public static class WlyyRefreshTokenGranter extends AbstractTokenGranter {
        static final String GRANT_TYPE = "refresh_token";
        public WlyyRefreshTokenGranter(AuthorizationServerTokenServices tokenServices,
                                      ClientDetailsService clientDetailsService,
                                      OAuth2RequestFactory requestFactory) {
            super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        @Override
        protected OAuth2AccessToken getAccessToken(ClientDetails client, TokenRequest tokenRequest) {
            String refreshToken = tokenRequest.getRequestParameters().get(GRANT_TYPE);
            return getTokenServices().refreshAccessToken(refreshToken, tokenRequest);
        }
    }
    /**
     * Implicit模式Token授权器。
     */
    public static class WlyyImplicitTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "implicit";
        public WlyyImplicitTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
            this(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        protected WlyyImplicitTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService,
                                       OAuth2RequestFactory requestFactory, String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest clientToken) {
            Authentication userAuth = SecurityContextHolder.getContext().getAuthentication();
            if (userAuth == null || !userAuth.isAuthenticated()) {
                throw new InsufficientAuthenticationException("There is no currently logged in user");
            }
            Assert.state(clientToken instanceof ImplicitTokenRequest, "An ImplicitTokenRequest is required here. Caller needs to wrap the TokenRequest.");
            OAuth2Request requestForStorage = ((ImplicitTokenRequest)clientToken).getOAuth2Request();
            return new OAuth2Authentication(requestForStorage, userAuth);
        }
        @SuppressWarnings("deprecation")
        public void setImplicitGrantService(ImplicitGrantService service) {
        }
    }
    /**
     * verify_code模式Token授权器。
     */
    public static class WlyyCaptchaTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "captcha";
        private final AuthenticationManager authenticationManager;
        // Ehr Properties
        private final WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
        public WlyyCaptchaTokenGranter(AuthenticationManager authenticationManager,
                                         AuthorizationServerTokenServices tokenServices,
                                         ClientDetailsService clientDetailsService,
                                         OAuth2RequestFactory requestFactory,
                                         WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE, wlyyRedisVerifyCodeService);
        }
        protected WlyyCaptchaTokenGranter(AuthenticationManager authenticationManager,
                                            AuthorizationServerTokenServices tokenServices,
                                            ClientDetailsService clientDetailsService,
                                            OAuth2RequestFactory requestFactory,
                                            String grantType,
                                            WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.wlyyRedisVerifyCodeService = wlyyRedisVerifyCodeService;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String client_id = parameters.get("client_id");
            String username = parameters.get("username");
            String verify_code = parameters.get("captcha");
            if (!wlyyRedisVerifyCodeService.verification(client_id, username, verify_code)){
                throw new InvalidGrantException("Invalid captcha");
            }
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, verify_code, getGrantedAuthorities(username));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
        private Collection<? extends GrantedAuthority> getGrantedAuthorities(String username) {
            Collection<GrantedAuthority> authorities = new ArrayList<>(1);
            authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
            return authorities;
        }
    }
}

+ 60 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/client/WlyyJdbcClientRedirectUriService.java

@ -0,0 +1,60 @@
package com.yihu.jw.security.oauth2.provider.client;
import com.yihu.utils.network.IPInfoUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
 * Created by progr1mmer on 2017/9/19.
 */
public class WlyyJdbcClientRedirectUriService {
    private JdbcTemplate jdbcTemplate;
    public WlyyJdbcClientRedirectUriService(JdbcTemplate jdbcTemplate) {
        Assert.notNull(jdbcTemplate, "jdbcTemplate required");
        this.jdbcTemplate = jdbcTemplate;
    }
    public String loadValidUri (String clientId, String redirectUriParameter) {
        if (null == redirectUriParameter) {
            return redirectUriParameter;
        }
        if (redirectUriParameter.indexOf("?") != -1) {
            redirectUriParameter = redirectUriParameter.substring(0, redirectUriParameter.indexOf("?"));
        }
        Map<String, Object> redirects = loadRedirectUriByClientId(clientId);
        if (redirectUriParameter.equals(redirects.get("redirect_uri")) || redirectUriParameter.equals(redirects.get("redirect_out_uri"))) {
            return redirects.get("redirect_uri").toString();
        } else {
            return redirectUriParameter;
        }
    }
    public String loadAccessUri (String clientId, String redirectUriParameter) {
        if (redirectUriParameter != null) {
            return redirectUriParameter;
        }
        Map<String, Object> redirects = loadRedirectUriByClientId(clientId);
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String ip = IPInfoUtils.getIPAddress(request);
        boolean isInnerIp = IPInfoUtils.isInnerIP(ip);
        if (isInnerIp) {
            return (String) redirects.get("redirect_uri");
        } else {
            return redirects.get("redirect_out_uri") != null ? (String) redirects.get("redirect_out_uri") : (String) redirects.get("redirect_uri");
        }
    }
    private Map<String, Object> loadRedirectUriByClientId(String clientId) {
        String selectQuery = "select web_server_redirect_uri as redirect_uri, web_server_redirect_out_uri as redirect_out_uri from oauth_client_details where client_id = ?";
        Map<String, Object> resultMap = jdbcTemplate.queryForMap(selectQuery, clientId);
        return resultMap;
    }
}

+ 699 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyAuthorizationEndpoint.java

@ -0,0 +1,699 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.oauth2.provider.client.WlyyJdbcClientRedirectUriService;
import com.yihu.utils.network.IPInfoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextHolderStrategy;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.*;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.provider.*;
import org.springframework.security.oauth2.provider.approval.DefaultUserApprovalHandler;
import org.springframework.security.oauth2.provider.approval.UserApprovalHandler;
import org.springframework.security.oauth2.provider.code.AuthorizationCodeServices;
import org.springframework.security.oauth2.provider.code.InMemoryAuthorizationCodeServices;
import org.springframework.security.oauth2.provider.endpoint.*;
import org.springframework.security.oauth2.provider.implicit.ImplicitTokenRequest;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.HttpSessionRequiredException;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.support.DefaultSessionAttributeStore;
import org.springframework.web.bind.support.SessionAttributeStore;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.RedirectView;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.net.URI;
import java.security.Principal;
import java.util.*;
/**
 * authorization_code & implicit & sso Endpoint
 *
 * <p>
 * Implementation of the Authorization Endpoint from the OAuth2 specification. Accepts authorization requests, and
 * handles user approval if the grant type is authorization code. The tokens themselves are obtained from the
 * {@link WlyyTokenEndpoint Token Endpoint}, except in the implicit grant type (where they come from the Authorization
 * Endpoint via <code>response_type=token</code>.
 * {@link WlyyLoginEndpoint Login Endpoint}, in order to verify the token to obtain user information.
 *
 * </p>
 *
 * <p>
 * This endpoint should be secured so that it is only accessible to fully authenticated users (as a minimum requirement)
 * since it represents a request from a valid user to act on his or her behalf.
 * </p>
 *
 * @author Progr1mmer
 * @created on 2018/8/29.
 */
@Controller
@SessionAttributes("authorizationRequest")
public class WlyyAuthorizationEndpoint extends AbstractEndpoint {
    private final Logger LOG = LoggerFactory.getLogger(getClass());
    private AuthorizationCodeServices authorizationCodeServices = new InMemoryAuthorizationCodeServices();
    private RedirectResolver redirectResolver = new DefaultRedirectResolver();
    private UserApprovalHandler userApprovalHandler = new DefaultUserApprovalHandler();
    private SessionAttributeStore sessionAttributeStore = new DefaultSessionAttributeStore();
    private OAuth2RequestValidator oauth2RequestValidator = new DefaultOAuth2RequestValidator();
    private String userApprovalPage = "forward:/oauth/confirm_access";
    private String errorPage = "forward:/oauth/error";
    private Object implicitLock = new Object();
    private TokenStore tokenStore;
    @Autowired
    private WlyyUserDetailsService userDetailsService;
    @Autowired
    private AuthorizationServerEndpointsConfiguration authorizationServerEndpointsConfiguration;
    @Autowired
    private WlyyJdbcClientRedirectUriService wlyyJdbcClientRedirectUriService;
    @PostConstruct
    private void init() {
        AuthorizationServerEndpointsConfigurer authorizationServerEndpointsConfigurer = authorizationServerEndpointsConfiguration.getEndpointsConfigurer();
        super.setTokenGranter(authorizationServerEndpointsConfigurer.getTokenGranter());
        super.setClientDetailsService(authorizationServerEndpointsConfigurer.getClientDetailsService());
        this.tokenStore = authorizationServerEndpointsConfigurer.getTokenStore();
        this.authorizationCodeServices = authorizationServerEndpointsConfigurer.getAuthorizationCodeServices();
    }
    public void setSessionAttributeStore(SessionAttributeStore sessionAttributeStore) {
        this.sessionAttributeStore = sessionAttributeStore;
    }
    public void setErrorPage(String errorPage) {
        this.errorPage = errorPage;
    }
    @RequestMapping(value = "/oauth/authorize", method = RequestMethod.GET)
    public ModelAndView authorize(Map<String, Object> model, @RequestParam Map<String, String> parameters,
                                  SessionStatus sessionStatus, Principal principal) {
        // Pull out the authorization request first, using the OAuth2RequestFactory. All further logic should
        // query off of the authorization request instead of referring back to the parameters map. The contents of the
        // parameters map will be stored without change in the AuthorizationRequest object once it is created.
        AuthorizationRequest authorizationRequest = getOAuth2RequestFactory().createAuthorizationRequest(parameters);
        /* default approve */
        authorizationRequest.setApproved(true);
        Set<String> responseTypes = authorizationRequest.getResponseTypes();
        if (!responseTypes.contains("token") && !responseTypes.contains("code")) {
            throw new UnsupportedResponseTypeException("Unsupported response types: " + responseTypes);
        }
        if (authorizationRequest.getClientId() == null) {
            throw new InvalidClientException("A client id must be provided");
        }
        try {
            if (!(principal instanceof Authentication) || !((Authentication) principal).isAuthenticated()) {
                if (parameters.containsKey("ak")) {
                    String ak = parameters.get("ak");
                    UsernamePasswordAuthenticationToken userAuth = new UsernamePasswordAuthenticationToken("admin", "cdb7df66a1955b0ed7402e665ed0586a", new ArrayList<>());
                    SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
                    securityContext.setAuthentication(userAuth);
                    SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder.getContextHolderStrategy();
                    securityContextHolderStrategy.setContext(securityContext);
                    principal = userAuth;
                } else {
                    throw new InsufficientAuthenticationException("ak must be provided.");
                }
            }
            /*if (!(principal instanceof Authentication) || !((Authentication) principal).isAuthenticated()) {
                throw new InsufficientAuthenticationException(
                        "User must be authenticated with Spring Security before authorization can be completed.");
            }*/
            ClientDetails client = getClientDetailsService().loadClientByClientId(authorizationRequest.getClientId());
            // The resolved redirect URI is either the redirect_uri from the parameters or the one from
            // clientDetails. Either way we need to store it on the AuthorizationRequest.
            String redirectUriParameter = authorizationRequest.getRequestParameters().get(OAuth2Utils.REDIRECT_URI);
            String validUrl = wlyyJdbcClientRedirectUriService.loadValidUri(authorizationRequest.getClientId(), redirectUriParameter);
            String resolvedRedirect = redirectResolver.resolveRedirect(validUrl, client);
            if (!StringUtils.hasText(resolvedRedirect)) {
                throw new RedirectMismatchException(
                        "A redirectUri must be either supplied or preconfigured in the ClientDetails");
            }
            // (customize) If redirectUriParameter is empty
            // load internal and external network ip information to redirect
            String accessUri = wlyyJdbcClientRedirectUriService.loadAccessUri(authorizationRequest.getClientId(), redirectUriParameter);
            authorizationRequest.setRedirectUri(accessUri);
            // We intentionally only validate the parameters requested by the client (ignoring any data that may have
            // been added to the request by the manager).
            oauth2RequestValidator.validateScope(authorizationRequest, client);
            // Some systems may allow for approval decisions to be remembered or approved by default. Check for
            // such logic here, and set the approved flag on the authorization request accordingly.
            authorizationRequest = userApprovalHandler.checkForPreApproval(authorizationRequest,
                    (Authentication) principal);
            // TODO: is this call necessary?
            boolean approved = userApprovalHandler.isApproved(authorizationRequest, (Authentication) principal);
            authorizationRequest.setApproved(approved);
            // Validation is all done, so we can check for auto approval...
            if (authorizationRequest.isApproved()) {
                if (responseTypes.contains("token")) {
                    return getImplicitGrantResponse(authorizationRequest);
                }
                if (responseTypes.contains("code")) {
                    return new ModelAndView(getAuthorizationCodeResponse(authorizationRequest,
                            (Authentication) principal));
                }
            }
            // Place auth request into the model so that it is stored in the session
            // for approveOrDeny to use. That way we make sure that auth request comes from the session,
            // so any auth request parameters passed to approveOrDeny will be ignored and retrieved from the session.
            model.put("authorizationRequest", authorizationRequest);
            return getUserApprovalPageResponse(model, authorizationRequest, (Authentication) principal);
        } catch (RuntimeException e) {
            sessionStatus.setComplete();
            throw e;
        }
    }
    @RequestMapping(value = "/oauth/authorize", method = RequestMethod.POST, params = OAuth2Utils.USER_OAUTH_APPROVAL)
    public View approveOrDeny(@RequestParam Map<String, String> approvalParameters, Map<String, ?> model,
                              SessionStatus sessionStatus, Principal principal) {
        if (!(principal instanceof Authentication)) {
            sessionStatus.setComplete();
            throw new InsufficientAuthenticationException(
                    "User must be authenticated with Spring Security before authorizing an access token.");
        }
        AuthorizationRequest authorizationRequest = (AuthorizationRequest) model.get("authorizationRequest");
        if (authorizationRequest == null) {
            sessionStatus.setComplete();
            throw new InvalidRequestException("Cannot approve uninitialized authorization request.");
        }
        try {
            Set<String> responseTypes = authorizationRequest.getResponseTypes();
            authorizationRequest.setApprovalParameters(approvalParameters);
            authorizationRequest = userApprovalHandler.updateAfterApproval(authorizationRequest,
                    (Authentication) principal);
            boolean approved = userApprovalHandler.isApproved(authorizationRequest, (Authentication) principal);
            authorizationRequest.setApproved(approved);
            if (authorizationRequest.getRedirectUri() == null) {
                sessionStatus.setComplete();
                throw new InvalidRequestException("Cannot approve request when no redirect URI is provided.");
            }
            if (!authorizationRequest.isApproved()) {
                return new RedirectView(getUnsuccessfulRedirect(authorizationRequest,
                        new UserDeniedAuthorizationException("User denied access"), responseTypes.contains("token")),
                        false, true, false);
            }
            if (responseTypes.contains("token")) {
                return getImplicitGrantResponse(authorizationRequest).getView();
            }
            return getAuthorizationCodeResponse(authorizationRequest, (Authentication) principal);
        }
        finally {
            sessionStatus.setComplete();
        }
    }
    @RequestMapping(value = "/oauth/sso", method = RequestMethod.GET)
    public ModelAndView sso(Map<String, Object> model, @RequestParam Map<String, String> parameters,
                                  SessionStatus sessionStatus, Principal principal) {
        // Pull out the authorization request first, using the OAuth2RequestFactory. All further logic should
        // query off of the authorization request instead of referring back to the parameters map. The contents of the
        // parameters map will be stored without change in the AuthorizationRequest object once it is created.
        AuthorizationRequest authorizationRequest = getOAuth2RequestFactory().createAuthorizationRequest(parameters);
        /* default approve */
        authorizationRequest.setApproved(true);
        Set<String> responseTypes = authorizationRequest.getResponseTypes();
        /* Does not accept code type verification */
        if (!responseTypes.contains("token")) {
            throw new UnsupportedResponseTypeException("Unsupported response types: " + responseTypes);
        }
        /*if (!responseTypes.contains("token") && !responseTypes.contains("code")) {
            throw new UnsupportedResponseTypeException("Unsupported response types: " + responseTypes);
        }*/
        if (authorizationRequest.getClientId() == null) {
            throw new InvalidClientException("A client id must be provided");
        }
        try {
            /*
             * load verification information by token
             */
            if (!(principal instanceof Authentication) || !((Authentication) principal).isAuthenticated()) {
                if (parameters.containsKey("access_token")) {
                    String token = parameters.get("access_token");
                    OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token);
                    if (null == oAuth2AccessToken) {
                        throw new InvalidTokenException("Invalid access_token");
                    }
                    if (oAuth2AccessToken.isExpired()) {
                        throw new InvalidTokenException("Expired accessToken");
                    }
                    OAuth2Authentication authentication = tokenStore.readAuthentication(token);
                    if (authentication != null) {
                        String userName = authentication.getName();
                        UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
                        UsernamePasswordAuthenticationToken userAuth = new UsernamePasswordAuthenticationToken(userDetails.getUsername(), userDetails.getPassword(), userDetails.getAuthorities());
                        SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
                        securityContext.setAuthentication(userAuth);
                        SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder.getContextHolderStrategy();
                        securityContextHolderStrategy.setContext(securityContext);
                        principal = userAuth;
                    } else {
                        throw new InvalidTokenException("Cant not load authentication");
                    }
                } else {
                    throw new InvalidRequestException("access_token must be provided.");
                }
            }
            ClientDetails client = getClientDetailsService().loadClientByClientId(authorizationRequest.getClientId());
            // The resolved redirect URI is either the redirect_uri from the parameters or the one from
            // clientDetails. Either way we need to store it on the AuthorizationRequest.
            String redirectUriParameter = authorizationRequest.getRequestParameters().get(OAuth2Utils.REDIRECT_URI);
            String validUrl = wlyyJdbcClientRedirectUriService.loadValidUri(authorizationRequest.getClientId(), redirectUriParameter);
            String resolvedRedirect = redirectResolver.resolveRedirect(validUrl, client);
            if (!StringUtils.hasText(resolvedRedirect)) {
                throw new RedirectMismatchException(
                        "A redirectUri must be either supplied or preconfigured in the ClientDetails");
            }
            // (customize) If redirectUriParameter is empty
            // load internal and external network ip information to redirect
            String accessUri = wlyyJdbcClientRedirectUriService.loadAccessUri(authorizationRequest.getClientId(), redirectUriParameter);
            authorizationRequest.setRedirectUri(accessUri);
            // We intentionally only validate the parameters requested by the client (ignoring any data that may have
            // been added to the request by the manager).
            oauth2RequestValidator.validateScope(authorizationRequest, client);
            // Some systems may allow for approval decisions to be remembered or approved by default. Check for
            // such logic here, and set the approved flag on the authorization request accordingly.
            authorizationRequest = userApprovalHandler.checkForPreApproval(authorizationRequest,
                    (Authentication) principal);
            // TODO: is this call necessary?
            boolean approved = userApprovalHandler.isApproved(authorizationRequest, (Authentication) principal);
            authorizationRequest.setApproved(approved);
            // Validation is all done, so we can check for auto approval...
            if (authorizationRequest.isApproved()) {
                if (responseTypes.contains("token")) {
                    return getImplicitGrantResponse(authorizationRequest);
                }
                if (responseTypes.contains("code")) {
                    return new ModelAndView(getAuthorizationCodeResponse(authorizationRequest,
                            (Authentication) principal));
                }
            }
            // Place auth request into the model so that it is stored in the session
            // for approveOrDeny to use. That way we make sure that auth request comes from the session,
            // so any auth request parameters passed to approveOrDeny will be ignored and retrieved from the session.
            model.put("authorizationRequest", authorizationRequest);
            return getUserApprovalPageResponse(model, authorizationRequest, (Authentication) principal);
        } catch (RuntimeException e) {
            sessionStatus.setComplete();
            throw e;
        }
    }
    // We need explicit approval from the user.
    private ModelAndView getUserApprovalPageResponse(Map<String, Object> model,
                                                     AuthorizationRequest authorizationRequest, Authentication principal) {
        LOG.debug("Loading user approval page: " + userApprovalPage);
        model.putAll(userApprovalHandler.getUserApprovalRequest(authorizationRequest, principal));
        return new ModelAndView(userApprovalPage, model);
    }
    // We can grant a token and return it with implicit approval.
    private ModelAndView getImplicitGrantResponse(AuthorizationRequest authorizationRequest) {
        try {
            TokenRequest tokenRequest = getOAuth2RequestFactory().createTokenRequest(authorizationRequest, "implicit");
            OAuth2Request storedOAuth2Request = getOAuth2RequestFactory().createOAuth2Request(authorizationRequest);
            OAuth2AccessToken accessToken = getAccessTokenForImplicitGrant(tokenRequest, storedOAuth2Request);
            if (accessToken == null) {
                throw new UnsupportedResponseTypeException("Unsupported response type: token");
            }
            return new ModelAndView(new RedirectView(appendAccessToken(authorizationRequest, accessToken), false, true,
                    false));
        }
        catch (OAuth2Exception e) {
            return new ModelAndView(new RedirectView(getUnsuccessfulRedirect(authorizationRequest, e, true), false,
                    true, false));
        }
    }
    private OAuth2AccessToken getAccessTokenForImplicitGrant(TokenRequest tokenRequest,
                                                             OAuth2Request storedOAuth2Request) {
        OAuth2AccessToken accessToken = null;
        // These 1 method calls have to be atomic, otherwise the ImplicitGrantService can have a race condition where
        // one thread removes the token request before another has a chance to redeem it.
        synchronized (this.implicitLock) {
            accessToken = getTokenGranter().grant("implicit",
                    new ImplicitTokenRequest(tokenRequest, storedOAuth2Request));
        }
        return accessToken;
    }
    private View getAuthorizationCodeResponse(AuthorizationRequest authorizationRequest, Authentication authUser) {
        try {
            return new RedirectView(getSuccessfulRedirect(authorizationRequest,
                    generateCode(authorizationRequest, authUser)), false, true, false);
        }
        catch (OAuth2Exception e) {
            return new RedirectView(getUnsuccessfulRedirect(authorizationRequest, e, false), false, true, false);
        }
    }
    private String appendAccessToken(AuthorizationRequest authorizationRequest, OAuth2AccessToken accessToken) {
        Map<String, Object> vars = new LinkedHashMap<String, Object>();
        Map<String, String> keys = new HashMap<String, String>();
        if (accessToken == null) {
            throw new InvalidRequestException("An implicit grant could not be made");
        }
        vars.put("accessToken", accessToken.getValue());
        vars.put("tokenType", accessToken.getTokenType());
        String state = authorizationRequest.getState();
        if (state != null) {
            vars.put("state", state);
        }
        Date expiration = accessToken.getExpiration();
        if (expiration != null) {
            long expires_in = (expiration.getTime() - System.currentTimeMillis()) / 1000;
            vars.put("expiresIn", expires_in);
        }
        String originalScope = authorizationRequest.getRequestParameters().get(OAuth2Utils.SCOPE);
        if (originalScope == null || !OAuth2Utils.parseParameterList(originalScope).equals(accessToken.getScope())) {
            vars.put("scope", OAuth2Utils.formatParameterList(accessToken.getScope()));
        }
        Map<String, Object> additionalInformation = accessToken.getAdditionalInformation();
        for (String key : additionalInformation.keySet()) {
            Object value = additionalInformation.get(key);
            if (value != null) {
                keys.put("extra_" + key, key);
                vars.put("extra_" + key, value);
            }
        }
        // Do not include the refresh token (even if there is one)
        return append(authorizationRequest.getRedirectUri(), vars, keys, true);
    }
    private String generateCode(AuthorizationRequest authorizationRequest, Authentication authentication)
            throws AuthenticationException {
        try {
            OAuth2Request storedOAuth2Request = getOAuth2RequestFactory().createOAuth2Request(authorizationRequest);
            OAuth2Authentication combinedAuth = new OAuth2Authentication(storedOAuth2Request, authentication);
            String code = authorizationCodeServices.createAuthorizationCode(combinedAuth);
            return code;
        }
        catch (OAuth2Exception e) {
            if (authorizationRequest.getState() != null) {
                e.addAdditionalInformation("state", authorizationRequest.getState());
            }
            throw e;
        }
    }
    private String getSuccessfulRedirect(AuthorizationRequest authorizationRequest, String authorizationCode) {
        if (authorizationCode == null) {
            throw new IllegalStateException("No authorization code found in the current request scope.");
        }
        Map<String, String> query = new LinkedHashMap<String, String>();
        query.put("code", authorizationCode);
        String state = authorizationRequest.getState();
        if (state != null) {
            query.put("state", state);
        }
        return append(authorizationRequest.getRedirectUri(), query, false);
    }
    private String getUnsuccessfulRedirect(AuthorizationRequest authorizationRequest, OAuth2Exception failure,
                                           boolean fragment) {
        if (authorizationRequest == null || authorizationRequest.getRedirectUri() == null) {
            // we have no redirect for the user. very sad.
            throw new UnapprovedClientAuthenticationException("Authorization failure, and no redirect URI.", failure);
        }
        Map<String, String> query = new LinkedHashMap<String, String>();
        query.put("error", failure.getOAuth2ErrorCode());
        query.put("error_description", failure.getMessage());
        if (authorizationRequest.getState() != null) {
            query.put("state", authorizationRequest.getState());
        }
        if (failure.getAdditionalInformation() != null) {
            for (Map.Entry<String, String> additionalInfo : failure.getAdditionalInformation().entrySet()) {
                query.put(additionalInfo.getKey(), additionalInfo.getValue());
            }
        }
        return append(authorizationRequest.getRedirectUri(), query, fragment);
    }
    private String append(String base, Map<String, ?> query, boolean fragment) {
        return append(base, query, null, fragment);
    }
    private String append(String base, Map<String, ?> query, Map<String, String> keys, boolean fragment) {
        UriComponentsBuilder template = UriComponentsBuilder.newInstance();
        UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(base);
        URI redirectUri;
        try {
            // assume it's encoded to start with (if it came in over the wire)
            redirectUri = builder.build(true).toUri();
        }
        catch (Exception e) {
            // ... but allow client registrations to contain hard-coded non-encoded values
            redirectUri = builder.build().toUri();
            builder = UriComponentsBuilder.fromUri(redirectUri);
        }
        template.scheme(redirectUri.getScheme()).port(redirectUri.getPort()).host(redirectUri.getHost())
                .userInfo(redirectUri.getUserInfo()).path(redirectUri.getPath());
        if (fragment) {
            StringBuilder values = new StringBuilder();
            if (redirectUri.getFragment() != null) {
                String append = redirectUri.getFragment();
                values.append(append);
            }
            for (String key : query.keySet()) {
                if (values.length() > 0) {
                    values.append("&");
                }
                String name = key;
                if (keys != null && keys.containsKey(key)) {
                    name = keys.get(key);
                }
                values.append(name + "={" + key + "}");
            }
            if (values.length() > 0) {
                template.fragment(values.toString());
            }
            UriComponents encoded = template.build().expand(query).encode();
            builder.fragment(encoded.getFragment());
        }
        else {
            for (String key : query.keySet()) {
                String name = key;
                if (keys != null && keys.containsKey(key)) {
                    name = keys.get(key);
                }
                template.queryParam(name, "{" + key + "}");
            }
            template.fragment(redirectUri.getFragment());
            UriComponents encoded = template.build().expand(query).encode();
            builder.query(encoded.getQuery());
        }
        return builder.build().toUriString();
    }
    public void setUserApprovalPage(String userApprovalPage) {
        this.userApprovalPage = userApprovalPage;
    }
    public void setAuthorizationCodeServices(AuthorizationCodeServices authorizationCodeServices) {
        this.authorizationCodeServices = authorizationCodeServices;
    }
    public void setRedirectResolver(RedirectResolver redirectResolver) {
        this.redirectResolver = redirectResolver;
    }
    public void setUserApprovalHandler(UserApprovalHandler userApprovalHandler) {
        this.userApprovalHandler = userApprovalHandler;
    }
    public void setOAuth2RequestValidator(OAuth2RequestValidator oauth2RequestValidator) {
        this.oauth2RequestValidator = oauth2RequestValidator;
    }
    @SuppressWarnings("deprecation")
    public void setImplicitGrantService(
            org.springframework.security.oauth2.provider.implicit.ImplicitGrantService implicitGrantService) {
    }
    @ExceptionHandler(Exception.class)
    public ModelAndView handleGlobalException(Exception e) throws Exception {
        LOG.info(e.getMessage(), e);
        return new ModelAndView(errorPage, Collections.singletonMap("error", new OAuth2Exception(e.getMessage(), e)));
    }
    /*@ExceptionHandler(ClientRegistrationException.class)
    public ModelAndView handleClientRegistrationException(Exception e, ServletWebRequest webRequest) throws Exception {
        LOG.info("Handling ClientRegistrationException error: " + e.getMessage());
        return handleException(new BadClientCredentialsException(), webRequest);
    }
    @ExceptionHandler(OAuth2Exception.class)
    public ModelAndView handleOAuth2Exception(OAuth2Exception e, ServletWebRequest webRequest) throws Exception {
        LOG.info("Handling OAuth2 error: " + e.getSummary());
        return handleException(e, webRequest);
    }
    @ExceptionHandler(HttpSessionRequiredException.class)
    public ModelAndView handleHttpSessionRequiredException(HttpSessionRequiredException e, ServletWebRequest webRequest)
            throws Exception {
        LOG.info("Handling Session required error: " + e.getMessage());
        return handleException(new AccessDeniedException("Could not obtain authorization request from session", e),
                webRequest);
    }*/
    private ModelAndView handleException(Exception e, ServletWebRequest webRequest) throws Exception {
        ResponseEntity<OAuth2Exception> translate = getExceptionTranslator().translate(e);
        webRequest.getResponse().setStatus(translate.getStatusCode().value());
        if (e instanceof ClientAuthenticationException || e instanceof RedirectMismatchException) {
            return new ModelAndView(errorPage, Collections.singletonMap("error", translate.getBody()));
        }
        AuthorizationRequest authorizationRequest = null;
        try {
            authorizationRequest = getAuthorizationRequestForError(webRequest);
            String requestedRedirectParam = authorizationRequest.getRequestParameters().get(OAuth2Utils.REDIRECT_URI);
            String requestedRedirect = redirectResolver.resolveRedirect(requestedRedirectParam,
                    getClientDetailsService().loadClientByClientId(authorizationRequest.getClientId()));
            authorizationRequest.setRedirectUri(requestedRedirect);
            String redirect = getUnsuccessfulRedirect(authorizationRequest, translate.getBody(), authorizationRequest
                    .getResponseTypes().contains("token"));
            return new ModelAndView(new RedirectView(redirect, false, true, false));
        }
        catch (OAuth2Exception ex) {
            // If an AuthorizationRequest cannot be created from the incoming parameters it must be
            // an error. OAuth2Exception can be handled this way. Other exceptions will generate a standard 500
            // response.
            return new ModelAndView(errorPage, Collections.singletonMap("error", translate.getBody()));
        }
    }
    private AuthorizationRequest getAuthorizationRequestForError(ServletWebRequest webRequest) {
        // If it's already there then we are in the approveOrDeny phase and we can use the saved request
        AuthorizationRequest authorizationRequest = (AuthorizationRequest) sessionAttributeStore.retrieveAttribute(
                webRequest, "authorizationRequest");
        if (authorizationRequest != null) {
            return authorizationRequest;
        }
        Map<String, String> parameters = new HashMap<String, String>();
        Map<String, String[]> map = webRequest.getParameterMap();
        for (String key : map.keySet()) {
            String[] values = map.get(key);
            if (values != null && values.length > 0) {
                parameters.put(key, values[0]);
            }
        }
        try {
            return getOAuth2RequestFactory().createAuthorizationRequest(parameters);
        }
        catch (Exception e) {
            return getDefaultOAuth2RequestFactory().createAuthorizationRequest(parameters);
        }
    }
}

+ 387 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -0,0 +1,387 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.yihu.jw.security.model.Captcha;
import com.yihu.jw.security.model.PublicKey;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.model.Oauth2Envelop;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.utils.security.RSAUtils;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.*;
import org.springframework.security.oauth2.provider.*;
import org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint;
import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.PostConstruct;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * <p>
 * Endpoint for default login verify and sso login token verify
 * will return the user's basic information and token certificate
 * </p>
 *
 * @author Progr1mmer
 * @created on 2018/8/29.
 */
@RestController
public class WlyyLoginEndpoint extends AbstractEndpoint {
    private final Logger LOG = LoggerFactory.getLogger(getClass());
    private OAuth2RequestFactory oAuth2RequestFactory;
    private OAuth2RequestValidator oAuth2RequestValidator = new DefaultOAuth2RequestValidator();
    @Autowired
    private AuthenticationManager authenticationManager;
    @Autowired
    private ClientDetailsService clientDetailsService;
    @Autowired
    private WlyyTokenGranter tokenGranter;
    @Autowired
    private WlyyOAuth2ExceptionTranslator wlyyOAuth2ExceptionTranslator;
    @Autowired
    private RedisTokenStore tokenStore;
    @Autowired
    private WlyyUserDetailsService userDetailsService;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @PostConstruct
    private void init() {
        super.setTokenGranter(tokenGranter);
    }
    /**
     * 登陆
     * @param parameters
     * @param httpSession
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
        String client_id = parameters.get("client_id");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            if (parameters.get("password") != null) {
                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
            }
        } else {
            parameters.put("grant_type", "captcha");
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        if (authenticatedClient != null) {
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        }
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request.getHeader("login-device") != null && request.getHeader("login-device").equals("mobile")) {
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        }
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        return getResponse(wlyyUserSimple);
    }
    /**
     * 单点登陆第二步 - token验证
     * @param parameters
     * @return
     */
    @RequestMapping(value = "/oauth/sso", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> sso(@RequestParam Map<String, String> parameters) {
        String clientId = parameters.get("client_id");
        String accessToken = parameters.get("access_token");
        if (StringUtils.isEmpty(clientId)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(accessToken)) {
            throw new InvalidRequestException("access_token");
        }
        OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(accessToken);
        if (null == oAuth2AccessToken) {
            throw new InvalidTokenException("Invalid access_token");
        }
        if (oAuth2AccessToken.isExpired()) {
            throw new InvalidTokenException("Expired accessToken");
        }
        OAuth2Authentication authentication = tokenStore.readAuthentication(accessToken);
        if (null == authentication) {
            throw new InvalidTokenException("Cant not load authentication");
        }
        String _clientId = authentication.getOAuth2Request().getClientId();
        if (!clientId.equals(_clientId)) {
            throw new InvalidTokenException("Provided token does not belong to the request client");
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(authentication.getName());
        wlyyUserSimple.setAccessToken(oAuth2AccessToken.getValue());
        wlyyUserSimple.setTokenType(oAuth2AccessToken.getTokenType());
        wlyyUserSimple.setExpiresIn(oAuth2AccessToken.getExpiresIn());
        wlyyUserSimple.setRefreshToken(oAuth2AccessToken.getRefreshToken().getValue());
        wlyyUserSimple.setUser(authentication.getName());
        wlyyUserSimple.setState(parameters.get("state"));
        return getResponse(wlyyUserSimple);
    }
    /**
     * 登出
     * @param parameters
     * @param request
     * @return
     */
    @RequestMapping(value = "/oauth/logout", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop> logout(@RequestParam Map<String, String> parameters, HttpServletRequest request) {
        String token = request.getHeader("token");
        if (null == token) {
            token = parameters.get("token");
        }
        OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token);
        if (oAuth2AccessToken != null) {
            tokenStore.removeAccessToken(oAuth2AccessToken.getValue());
            tokenStore.removeRefreshToken(oAuth2AccessToken.getRefreshToken().getValue());
        }
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        Oauth2Envelop oauth2Envelop = new Oauth2Envelop("logout", 200);
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    /**
     * 获取公钥
     * @param httpSession
     * @param httpServletResponse
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/public_key", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<PublicKey>> publicKey (
            HttpSession httpSession,
            HttpServletResponse httpServletResponse) throws Exception {
        //生成公钥和私钥
        HashMap<String, Object> map = RSAUtils.generateKeys();
        RSAPublicKey rsaPublicKey = (RSAPublicKey) map.get("public");
        RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) map.get("private");
        PublicKey publicKey = new PublicKey();
        publicKey.setModulus(Base64.encodeBase64String(rsaPublicKey.getModulus().toByteArray()));
        publicKey.setExponent(Base64.encodeBase64String(rsaPublicKey.getPublicExponent().toByteArray()));
        httpSession.setAttribute("privateKey", rsaPrivateKey);
        //生成Cookie
        Cookie cookie = new Cookie("oauth2", UUID.randomUUID().toString());
        cookie.setMaxAge(60);
        cookie.setPath("/oauth");
        httpServletResponse.addCookie(cookie);
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        Oauth2Envelop<PublicKey> oauth2Envelop = new Oauth2Envelop<>("public_key", 200, publicKey);
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    /**
     * 获取验证码
     * @param parameters
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/captcha", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<Captcha>> captcha(@RequestParam Map<String, String> parameters) throws  Exception{
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(username)){
            throw new InvalidRequestException("username");
        }
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        //发送短信获取验证码
        HttpHeaders reqHeaders = new HttpHeaders();
        reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("clientId", client_id);
        params.add("type", "login");
        params.add("to", username);
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
        HashMap<String, Object> result = restTemplate.postForObject("http://svr-base:10020/sms_gateway/send", httpEntity, HashMap.class);
        if (200 == (Integer) result.get("status")){
            Map<String, Object> sms =  (Map)result.get("obj");
            String captcha = (String) sms.get("captcha");
            Date deadline = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse((String) sms.get("deadline"));
            Long expire = (deadline.getTime() - new Date().getTime()) / 1000;
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setExpiresIn(expire.intValue());
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, expire.intValue());
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }
        throw new IllegalStateException((String) result.get("message"));
        /*Captcha _captcha = new Captcha();
        _captcha.setCode("12345");
        _captcha.setExpiresIn(10000);
        _captcha.setInterval(60);
        wlyyRedisVerifyCodeService.store(client_id, username, "12345", 100);
        Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop("captcha", 200, _captcha);
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);*/
    }
    /**
     * 验证验证码
     * @param parameters
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/captcha", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop> captchaCheck  (@RequestParam Map<String, String> parameters) throws  Exception{
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        String captcha = parameters.get("captcha");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(username)){
            throw new InvalidRequestException("username");
        }
        if (StringUtils.isEmpty(captcha)){
            throw new InvalidRequestException("captcha");
        }
        Oauth2Envelop<Boolean> oauth2Envelop;
        if (wlyyRedisVerifyCodeService.verification(client_id, username, captcha)) {
            oauth2Envelop = new Oauth2Envelop<>("验证码正确", 200, true);
        } else {
            oauth2Envelop = new Oauth2Envelop<>("验证码错误", 200, false);
        }
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    @Override
    protected TokenGranter getTokenGranter() {
        return this.tokenGranter;
    }
    @Override
    public void afterPropertiesSet() throws Exception {
        Assert.state(clientDetailsService != null, "ClientDetailsService must be provided");
        Assert.state(authenticationManager != null, "AuthenticationManager must be provided");
        oAuth2RequestFactory = new DefaultOAuth2RequestFactory(clientDetailsService);
    }
    private ResponseEntity<Oauth2Envelop<WlyyUserSimple>> getResponse(WlyyUserSimple ehrUserSimple) {
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("login", 200, ehrUserSimple);
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    @Override
    protected WebResponseExceptionTranslator getExceptionTranslator() {
        return wlyyOAuth2ExceptionTranslator;
    }
   @ExceptionHandler(Exception.class)
    public ResponseEntity<Oauth2Envelop> handleException(Exception e) throws Exception {
        LOG.info(e.getMessage(), e);
        if (e instanceof UsernameNotFoundException) {
            return handleOAuth2Exception(new Oauth2Envelop("用户未注册!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof NoSuchClientException) {
            return handleOAuth2Exception(new Oauth2Envelop("应用未注册!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidGrantException) {
            if (e.getMessage().contains("captcha")) {
                return handleOAuth2Exception(new Oauth2Envelop("验证码有误!", HttpStatus.UNAUTHORIZED.value()), e);
            }
            return handleOAuth2Exception(new Oauth2Envelop("密码有误!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidTokenException) {
            return handleOAuth2Exception(new Oauth2Envelop("Token有误!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidRequestException) {
            return handleOAuth2Exception(new Oauth2Envelop("参数" + e.getMessage() + "缺失!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof IllegalAccessException) {
            return handleOAuth2Exception(new Oauth2Envelop("短信请求频率过快,请稍后再试!", -1), e);
        } else if (e instanceof IllegalStateException) {
            return handleOAuth2Exception(new Oauth2Envelop("短信网关请求失败!", -1), e);
        }
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }
    private ResponseEntity<Oauth2Envelop> handleOAuth2Exception(Oauth2Envelop authenticationFailed, Exception e) throws IOException {
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getMessage()));
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        return response;
    }
}

+ 251 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyTokenEndpoint.java

@ -0,0 +1,251 @@
/*
 * Copyright (c) 2015 MONKEYK Information Technology Co. Ltd
 * www.monkeyk.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * MONKEYK Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with MONKEYK Information Technology Co. Ltd.
 */
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.yihu.jw.security.model.Oauth2Envelop;
import com.yihu.jw.security.oauth2.common.WlyyOAuth2AccessToken;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.*;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.provider.*;
import org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
import org.springframework.util.StringUtils;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.*;
import javax.annotation.PostConstruct;
import java.io.IOException;
import java.security.Principal;
import java.util.*;
/**
 * <p>
 * Endpoint for token requests as described in the OAuth2 spec. Clients post requests with a <code>grant_type</code>
 * parameter (e.g. "authorization_code") and other parameters as determined by the grant type. Supported grant types are
 * handled by the provided {@link com.yihu.jw.security.oauth2.provider.WlyyTokenGranter token
 * granter}.
 * </p>
 *
 * <p>
 * Clients must be authenticated using a Spring Security {@link Authentication} to access this endpoint, and the client
 * id is extracted from the authentication token. The best way to arrange this (as per the OAuth2 spec) is to use HTTP
 * basic authentication for this endpoint with standard Spring Security support.
 * </p>
 *
 * @author Progr1mmer
 * @created on 2018/8/29.
 */
@RestController
public class WlyyTokenEndpoint extends AbstractEndpoint {
    private final Logger LOG = LoggerFactory.getLogger(getClass());
    @Autowired
    private WlyyTokenGranter tokenGranter;
    @Autowired
    private ClientDetailsService clientDetailsService;
    private OAuth2RequestValidator oAuth2RequestValidator = new DefaultOAuth2RequestValidator();
    private Set<HttpMethod> allowedRequestMethods = new HashSet<>(Arrays.asList(HttpMethod.POST));
    @PostConstruct
    private void init() {
        super.setTokenGranter(tokenGranter);
        super.setClientDetailsService(clientDetailsService);
    }
    @RequestMapping(value = "/oauth/token", method=RequestMethod.GET)
    public ResponseEntity<WlyyOAuth2AccessToken> getAccessToken(@RequestParam
            Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
        if (!allowedRequestMethods.contains(HttpMethod.GET)) {
            throw new HttpRequestMethodNotSupportedException("GET");
        }
        return postAccessToken(parameters);
    }
    @RequestMapping(value = "/oauth/token", method=RequestMethod.POST)
    public ResponseEntity<WlyyOAuth2AccessToken> postAccessToken(@RequestParam Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
        String clientId = getClientId(parameters);
        if (StringUtils.isEmpty(clientId)) {
            throw new InvalidClientException("Missing clientId");
        }
        ClientDetails authenticatedClient = getClientDetailsService().loadClientByClientId(clientId);
        TokenRequest tokenRequest = getOAuth2RequestFactory().createTokenRequest(parameters, authenticatedClient);
        /*
         * skip this step
         */
        /*if (clientId != null && !clientId.equals("")) {
            // Only validate the client details if a client authenticated during this
            // request.
            if (!clientId.equals(tokenRequest.getClientId())) {
                // double check to make sure that the client ID in the token request is the same as that in the
                // authenticated client
                throw new InvalidClientException("Given client ID does not match authenticated client");
            }
        }*/
        if (authenticatedClient != null) {
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        }
        if (!StringUtils.hasText(tokenRequest.getGrantType())) {
            throw new InvalidRequestException("Missing grant type");
        }
        if (tokenRequest.getGrantType().equals("implicit")) {
            throw new InvalidGrantException("Implicit grant type not supported from token endpoint");
        }
        if (isAuthCodeRequest(parameters)) {
            // The scope was requested or determined during the authorization step
            if (!tokenRequest.getScope().isEmpty()) {
                logger.debug("Clearing scope of incoming token request");
                tokenRequest.setScope(Collections.<String> emptySet());
            }
        }
        if (isRefreshTokenRequest(parameters)) {
            // A refresh token has its own default scopes, so we should ignore any added by the factory here.
            tokenRequest.setScope(OAuth2Utils.parseParameterList(parameters.get(OAuth2Utils.SCOPE)));
        }
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        // ----------------- Simple Result ----------------
        WlyyOAuth2AccessToken wlyyOAuth2AccessToken = new WlyyOAuth2AccessToken();
        wlyyOAuth2AccessToken.setAccessToken(token.getValue());
        wlyyOAuth2AccessToken.setTokenType(token.getTokenType());
        wlyyOAuth2AccessToken.setExpiresIn(token.getExpiresIn());
        wlyyOAuth2AccessToken.setRefreshToken(token.getRefreshToken().getValue());
        wlyyOAuth2AccessToken.setScope(org.apache.commons.lang.StringUtils.join(token.getScope(), " "));
        wlyyOAuth2AccessToken.setState(parameters.get("state"));
        // ----------------- Simple Result ----------------
        return getResponse(wlyyOAuth2AccessToken);
    }
    /**
     * @param principal the currently authentication principal
     * @return a client id if there is one in the principal
     */
    @Deprecated
    protected String getClientId(Principal principal) {
        Authentication client = (Authentication) principal;
        if (!client.isAuthenticated()) {
            throw new InsufficientAuthenticationException("The client is not authenticated.");
        }
        String clientId = client.getName();
        if (client instanceof OAuth2Authentication) {
            // Might be a client and user combined authentication
            clientId = ((OAuth2Authentication) client).getOAuth2Request().getClientId();
        }
        return clientId;
    }
    /**
     * @param parameters the request parameters (omit the basic certification)
     * @return a client id if there is one in the principal
     */
    protected String getClientId(Map<String, String> parameters) {
        return parameters.get("client_id");
    }
    /*@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
    public ResponseEntity<OAuth2Exception> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) throws Exception {
        logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
        return getExceptionTranslator().translate(e);
    }
    @ExceptionHandler(Exception.class)
    public ResponseEntity<OAuth2Exception> handleException(Exception e) throws Exception {
        logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
        return getExceptionTranslator().translate(e);
    }
    @ExceptionHandler(ClientRegistrationException.class)
    public ResponseEntity<OAuth2Exception> handleClientRegistrationException(Exception e) throws Exception {
        logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
        return getExceptionTranslator().translate(new BadClientCredentialsException());
    }
    @ExceptionHandler(OAuth2Exception.class)
    public ResponseEntity<OAuth2Exception> handleException(OAuth2Exception e) throws Exception {
        logger.info("Handling error: " + e.getClass().getSimpleName() + ", " + e.getMessage());
        return getExceptionTranslator().translate(e);
    }*/
    /**
     * @param e
     * @return
     * @throws Exception
     */
    @ExceptionHandler(Exception.class)
    public ResponseEntity<Oauth2Envelop> handleException(Exception e) throws Exception {
        LOG.info(e.getMessage(), e);
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }
    private ResponseEntity<WlyyOAuth2AccessToken> getResponse(WlyyOAuth2AccessToken accessToken) {
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        return new ResponseEntity<>(accessToken, headers, HttpStatus.OK);
    }
    /**
     * return results directly
     * @param authenticationFailed
     * @return
     * @throws IOException
     */
    private ResponseEntity<Oauth2Envelop> handleOAuth2Exception(Oauth2Envelop authenticationFailed, Exception e) throws IOException {
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getMessage()));
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        return response;
    }
    private boolean isRefreshTokenRequest(Map<String, String> parameters) {
        return "refresh_token".equals(parameters.get("grant_type")) && parameters.get("refresh_token") != null;
    }
    private boolean isAuthCodeRequest(Map<String, String> parameters) {
        return "authorization_code".equals(parameters.get("grant_type")) && parameters.get("code") != null;
    }
    public void setOAuth2RequestValidator(OAuth2RequestValidator oAuth2RequestValidator) {
        this.oAuth2RequestValidator = oAuth2RequestValidator;
    }
    public void setAllowedRequestMethods(Set<HttpMethod> allowedRequestMethods) {
        this.allowedRequestMethods = allowedRequestMethods;
    }
}

+ 148 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/error/WlyyOAuth2ExceptionTranslator.java

@ -0,0 +1,148 @@
package com.yihu.jw.security.oauth2.provider.error;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.oauth2.common.DefaultThrowableAnalyzer;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.InsufficientScopeException;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
import org.springframework.security.web.util.ThrowableAnalyzer;
import org.springframework.stereotype.Component;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import java.io.IOException;
/**
 * OAuth2异常转换
 */
@Component
public class WlyyOAuth2ExceptionTranslator implements WebResponseExceptionTranslator {
    private ThrowableAnalyzer throwableAnalyzer = new DefaultThrowableAnalyzer();
    public ResponseEntity<OAuth2Exception> translate(Exception e) throws Exception {
        // Try to extract a SpringSecurityException from the stacktrace
        Throwable[] causeChain = throwableAnalyzer.determineCauseChain(e);
        Exception ase = (OAuth2Exception) throwableAnalyzer.getFirstThrowableOfType(
                OAuth2Exception.class, causeChain);
        if (ase != null) {
            return handleOAuth2Exception((OAuth2Exception) ase);
        }
        ase = (AuthenticationException) throwableAnalyzer.getFirstThrowableOfType(AuthenticationException.class,
                causeChain);
        if (ase != null) {
            return handleOAuth2Exception(new UnauthorizedException(e.getMessage(), e));
        }
        ase = (AccessDeniedException) throwableAnalyzer
                .getFirstThrowableOfType(AccessDeniedException.class, causeChain);
        if (ase instanceof AccessDeniedException) {
            return handleOAuth2Exception(new ForbiddenException(ase.getMessage(), ase));
        }
        ase = (HttpRequestMethodNotSupportedException) throwableAnalyzer
                .getFirstThrowableOfType(HttpRequestMethodNotSupportedException.class, causeChain);
        if (ase instanceof HttpRequestMethodNotSupportedException) {
            return handleOAuth2Exception(new MethodNotAllowed(ase.getMessage(), ase));
        }
        return handleOAuth2Exception(new ServerErrorException(e.getMessage(), e));
    }
    private ResponseEntity<OAuth2Exception> handleOAuth2Exception(OAuth2Exception e) throws IOException {
        int status = e.getHttpErrorCode();
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        if (status == HttpStatus.UNAUTHORIZED.value() || (e instanceof InsufficientScopeException)) {
            headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getSummary()));
        }
        ResponseEntity<OAuth2Exception> response = new ResponseEntity<>(e, headers,
                HttpStatus.valueOf(status));
        return response;
    }
    public void setThrowableAnalyzer(ThrowableAnalyzer throwableAnalyzer) {
        this.throwableAnalyzer = throwableAnalyzer;
    }
    @SuppressWarnings("serial")
    private static class ForbiddenException extends OAuth2Exception {
        public ForbiddenException(String msg, Throwable t) {
            super(msg, t);
        }
        public String getOAuth2ErrorCode() {
            return "access_denied";
        }
        public int getHttpErrorCode() {
            return 403;
        }
    }
    @SuppressWarnings("serial")
    private static class ServerErrorException extends OAuth2Exception {
        public ServerErrorException(String msg, Throwable t) {
            super(msg, t);
        }
        public String getOAuth2ErrorCode() {
            return "server_error";
        }
        public int getHttpErrorCode() {
            return 500;
        }
    }
    @SuppressWarnings("serial")
    private static class UnauthorizedException extends OAuth2Exception {
        public UnauthorizedException(String msg, Throwable t) {
            super(msg, t);
        }
        public String getOAuth2ErrorCode() {
            return "unauthorized";
        }
        public int getHttpErrorCode() {
            return 401;
        }
    }
    @SuppressWarnings("serial")
    private static class MethodNotAllowed extends OAuth2Exception {
        public MethodNotAllowed(String msg, Throwable t) {
            super(msg, t);
        }
        public String getOAuth2ErrorCode() {
            return "method_not_allowed";
        }
        public int getHttpErrorCode() {
            return 405;
        }
    }
}

+ 134 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/web/authentication/WlyyAuthenticationFailureHandler.java

@ -0,0 +1,134 @@
package com.yihu.jw.security.web.authentication;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.WebAttributes;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.util.UrlUtils;
import org.springframework.util.Assert;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
 * Created by progr1mmer on 2018/8/29.
 */
public class WlyyAuthenticationFailureHandler implements AuthenticationFailureHandler {
    protected final Log logger = LogFactory.getLog(getClass());
    private String defaultFailureUrl;
    private boolean forwardToDestination = false;
    private boolean allowSessionCreation = true;
    private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
    public WlyyAuthenticationFailureHandler() {
    }
    public WlyyAuthenticationFailureHandler(String defaultFailureUrl) {
        setDefaultFailureUrl(defaultFailureUrl);
    }
    /**
     * Performs the redirect or forward to the {@code defaultFailureUrl} if set, otherwise
     * returns a 401 error code.
     * <p>
     * If redirecting or forwarding, {@code saveException} will be called to cache the
     * exception for use in the target view.
     */
    public void onAuthenticationFailure(HttpServletRequest request,
                                        HttpServletResponse response, AuthenticationException exception)
            throws IOException, ServletException {
        if (defaultFailureUrl == null) {
            logger.debug("No failure URL set, sending 401 Unauthorized error");
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
                    "Authentication Failed: " + exception.getMessage());
        }
        else {
            saveException(request, exception);
            if (forwardToDestination) {
                logger.debug("Forwarding to " + defaultFailureUrl);
                request.getRequestDispatcher(defaultFailureUrl)
                        .forward(request, response);
            }
            else {
                logger.debug("Redirecting to " + defaultFailureUrl);
                redirectStrategy.sendRedirect(request, response, defaultFailureUrl);
            }
        }
    }
    /**
     * Caches the {@code AuthenticationException} for use in view rendering.
     * <p>
     * If {@code forwardToDestination} is set to true, request scope will be used,
     * otherwise it will attempt to store the exception in the session. If there is no
     * session and {@code allowSessionCreation} is {@code true} a session will be created.
     * Otherwise the exception will not be stored.
     */
    protected final void saveException(HttpServletRequest request,
                                       AuthenticationException exception) {
        if (forwardToDestination) {
            request.setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
        }
        else {
            HttpSession session = request.getSession(false);
            if (session != null || allowSessionCreation) {
                request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION,
                        exception);
            }
        }
    }
    /**
     * The URL which will be used as the failure destination.
     *
     * @param defaultFailureUrl the failure URL, for example "/loginFailed.jsp".
     */
    public void setDefaultFailureUrl(String defaultFailureUrl) {
        Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl), "'"
                + defaultFailureUrl + "' is not a valid redirect URL");
        this.defaultFailureUrl = defaultFailureUrl;
    }
    protected boolean isUseForward() {
        return forwardToDestination;
    }
    /**
     * If set to <tt>true</tt>, performs a forward to the failure destination URL instead
     * of a redirect. Defaults to <tt>false</tt>.
     */
    public void setUseForward(boolean forwardToDestination) {
        this.forwardToDestination = forwardToDestination;
    }
    /**
     * Allows overriding of the behaviour when redirecting to a target URL.
     */
    public void setRedirectStrategy(RedirectStrategy redirectStrategy) {
        this.redirectStrategy = redirectStrategy;
    }
    protected RedirectStrategy getRedirectStrategy() {
        return redirectStrategy;
    }
    protected boolean isAllowSessionCreation() {
        return allowSessionCreation;
    }
    public void setAllowSessionCreation(boolean allowSessionCreation) {
        this.allowSessionCreation = allowSessionCreation;
    }
}

+ 18 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/web/endpoint/BaseLoginEndpoint.java

@ -0,0 +1,18 @@
package com.yihu.jw.security.web.endpoint;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Endpoint - 基础登陆
 * Created by progr1mmer on 2018/8/29.
 */
@RestController
public class BaseLoginEndpoint {
    @GetMapping(value = "/login")
    public String login() {
        return "Get method no support for path /login";
    }
}

+ 38 - 0
server/svr-authentication/src/main/resources/application.yml

@ -0,0 +1,38 @@
server:
  port: 10260
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 20
    max-idle: 8
    min-idle: 8
    validation-query: SELECT 1
    test-on-borrow: true
  redis:
    database: 0 # Database index used by the connection factory.
    timeout: 0 # Connection timeout in milliseconds.
    pool:
      max-active: 8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
      max-idle: 8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
      max-wait: -1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
      min-idle: 1 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
logging:
  level:
    org:
      springframework:
        security: DEBUG
---
spring:
  profiles: jwdev
  datasource:
    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
  redis:
    host: 172.19.103.47
    port: 6379
    password: redis!@456

+ 29 - 0
server/svr-authentication/src/main/resources/banner.txt

@ -0,0 +1,29 @@
                                   _oo8oo_
                                  o8888888o
                                  88" . "88
                                  (| -_- |)
                                  0\  =  /0
                                ___/'==='\___
                              .' \\|     |// '.
                             / \\|||  :  |||// \
                            / _||||| -:- |||||_ \
                           |   | \\\  -  /// |   |
                           | \_|  ''\---/''  |_/ |
                           \  .-\__  '-'  __/-.  /
                         ___'. .'  /--.--\  '. .'___
                      ."" '<  '.___\_<|>_/___.'  >' "".
                     | | :  `- \`.:`\ _ /`:.`/ -`  : | |
                     \  \ `-.   \_ __\ /__ _/   .-` /  /
                 =====`-.____`.___ \_____/ ___.`____.-`=====
                                   `=---=`
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      佛祖保佑     永不宕机     永无Bug
 __   _      ___        __    _    _____  _     ____  _     _____  _   __     __   _____  _   ___   _
( (` \ \  / | |_)      / /\  | | |  | |  | |_| | |_  | |\ |  | |  | | / /`   / /\   | |  | | / / \ | |\ |
_)_)  \_\/  |_| \     /_/--\ \_\_/  |_|  |_| | |_|__ |_| \|  |_|  |_| \_\_, /_/--\  |_|  |_| \_\_/ |_| \|

+ 32 - 0
server/svr-authentication/src/main/resources/bootstrap.yml

@ -0,0 +1,32 @@
spring:
  application:
    name: svr-authentication
  cloud:
    config:
      failFast: true
      username: jw
      password: jkzl
---
spring:
  profiles: jwdev
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: jwtest
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: jwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://172.17.110.212:1221}
      label: ${wlyy.spring.config.label:jwprod}

+ 356 - 0
sql/init.sql

@ -0,0 +1,356 @@
-- 机构信息表 
drop table IF EXISTS `base_org`;
CREATE TABLE `base_org` (
  `id` varchar(50) NOT NULL COMMENT 'uuid,uuid唯一标识,也是机构code',
  `saasid` varchar(50) NOT NULL COMMENT 'saas化配置',
  `province_code` varchar(50) DEFAULT NULL COMMENT '省份标识',
  `city_code` varchar(50) DEFAULT NULL COMMENT '城市标识',
  `town_code` varchar(50) DEFAULT NULL COMMENT '区县标识',
  `name` varchar(100) DEFAULT NULL COMMENT '机构名称',
  `alias` varchar(10) DEFAULT NULL COMMENT '机构别名',
  `spell` varchar(20) DEFAULT NULL COMMENT '机构名称拼音首字母',
  `type` char(2) DEFAULT '1' COMMENT '机构类型: 1.  医疗机构2.  企事业单位3.  政府机关4.  社会团体 5.药店 0.  部门 6.单位或者独立子公司7.基层机构 8.专业公共机构',
  `brief` varchar(300) DEFAULT NULL COMMENT '机构简介',
  `address` varchar(300) DEFAULT NULL COMMENT '机构详细地址',
  `photo` varchar(200) DEFAULT NULL COMMENT '机构图片',
  `longitude` varchar(10) DEFAULT NULL COMMENT '经度',
  `latitude` varchar(10) DEFAULT NULL COMMENT '纬度',
  `legalperson` varchar(50) DEFAULT NULL COMMENT '法人',
  `org_admin` varchar(50) DEFAULT NULL COMMENT '机构管理员',
  `org_url` varchar(200) DEFAULT NULL COMMENT '机构网址',
  `intro` text COMMENT '机构简介',
  `qrcode` varchar(30) DEFAULT NULL COMMENT '机构二维码',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `idx_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='机构信息(医院)';
-- 医生信息表
drop table IF EXISTS `base_doctor`;
CREATE TABLE `base_doctor` (
  `id` varchar(50) NOT NULL COMMENT 'uuid,uuid唯一标识',
  `org_id` varchar(100) DEFAULT NULL COMMENT '机构id',
  `password` varchar(50) NOT NULL COMMENT '密码',
  `salt` varchar(50) DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL COMMENT '姓名',
  `sex` char(2) DEFAULT NULL COMMENT '性别(1男,2女) 用国家标准字典',
  `expertise` varchar(300) DEFAULT NULL COMMENT '医生专长',
  `introduce` varchar(1500) DEFAULT NULL COMMENT '医生介绍',
  `idcard` varchar(20) DEFAULT NULL COMMENT ' 身份证',
  `birthday` date DEFAULT NULL COMMENT '生日',
  `photo` varchar(100) DEFAULT NULL COMMENT '头像http地址',
  `mobile` varchar(20) NOT NULL COMMENT '手机号',
  `qrcode` varchar(30) DEFAULT NULL COMMENT '医生二维码',
  `province_code` varchar(50) DEFAULT NULL COMMENT '省代码',
  `province_name` varchar(50) DEFAULT NULL COMMENT '省名称',
  `city_code` varchar(50) DEFAULT NULL COMMENT '市代码',
  `city_name` varchar(50) DEFAULT NULL COMMENT '市名称',
  `town_code` varchar(50) DEFAULT NULL COMMENT '区县代码',
  `town_name` varchar(50) DEFAULT NULL COMMENT '区县名称',
  `street_code` varchar(50) DEFAULT NULL COMMENT '街道代码',
  `street_name` varchar(50) DEFAULT NULL COMMENT '街道名称',
  `iscertified` varchar(1) NOT NULL DEFAULT '0' COMMENT '资格是否认证通过,1是,0否',
  `is_famous` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否是名医,1是,0否',
  `is_password_prompt` char(1) DEFAULT NULL COMMENT '是否提示设置密码  1 提示过 0未提示',
  `spell` varchar(10) DEFAULT NULL COMMENT '名称拼音首字母',
  `certified_overtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'CA证书过期时间',
  `certificate_num` varchar(100) DEFAULT NULL COMMENT 'CA证书编号',
  `openid` varchar(50) DEFAULT NULL,
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医生基本信息';
-- 医生角色字典表
drop table IF EXISTS `base_doctor_role_dict`;
CREATE TABLE `base_doctor_role_dict` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `code` varchar(50) NOT NULL COMMENT '角色code',
  `name` varchar(50) NOT NULL COMMENT '角色名称:全科医生、专科医生、健康管理师、管理员等',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_doctor_code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医生角色字典';
-- 医生角色关联表
drop table IF EXISTS `base_doctor_role`;
/*CREATE TABLE `base_doctor_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,关联表',
  `role_code` varchar(50) NOT NULL COMMENT '医生角色id',
  `doctor_id` varchar(50) NOT NULL COMMENT '医生code',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医生角色关联信息';
*/
-- 医生执业表(一个医生可在多个医院供职,角色等)
drop table IF EXISTS `base_doctor_hospital`;
CREATE TABLE `base_doctor_hospital` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `hosp_code` varchar(50) NOT NULL COMMENT '医院标识',
  `hosp_name` varchar(50) NOT NULL COMMENT '医院名称',
  `role_code` varchar(50) NOT NULL COMMENT '医生角色标识',
  `role_name` varchar(50) NOT NULL COMMENT '医院角色名称',
  `job_title_code` varchar(50) NOT NULL COMMENT '职称代码',
  `job_title_name` varchar(50) NOT NULL COMMENT '职称名称',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医生执业信息';
-- 居民信息表
drop table IF EXISTS `base_patient`;
CREATE TABLE `base_patient` (
  `id` varchar(50) NOT NULL   COMMENT 'uuid,uuid唯一标识',
  `saas_id` varchar(100) DEFAULT NULL COMMENT 'saas配置id',
  `idcard` varchar(50) NOT NULL COMMENT '身份证号',
  `password` varchar(50) DEFAULT NULL COMMENT '登录密码',
  `salt` varchar(50) DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL COMMENT '姓名',
  `birthday` date DEFAULT NULL COMMENT '生日',
  `sex` varchar(100) DEFAULT NULL COMMENT '性别,1男,2女',
  `mobile` varchar(100) DEFAULT NULL COMMENT '手机号',
  `phone` varchar(200) DEFAULT NULL COMMENT '联系电话',
  `ssc` varchar(50) DEFAULT NULL COMMENT '社保卡号',
  `photo` varchar(100) DEFAULT NULL COMMENT '头像http地址',
  `province_code` varchar(50) DEFAULT NULL COMMENT '省编码',
  `city_code` varchar(50) DEFAULT NULL COMMENT '市编码',
  `town_code` varchar(50) DEFAULT NULL COMMENT '区县编码',
  `street_code` varchar(50) DEFAULT NULL COMMENT '街道编码',
  `address` varchar(200) DEFAULT NULL COMMENT '具体详细地址',
  `disease` varchar(100) DEFAULT NULL COMMENT '疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病',
  `disease_condition` varchar(100) DEFAULT NULL COMMENT '病情:0绿标,1黄标,2红标,3重点关注,',
  `points` varchar(100) DEFAULT NULL COMMENT '总积分',
  `record_amount` varchar(100) DEFAULT NULL COMMENT '病历总数',
  `openid` varchar(50) DEFAULT NULL COMMENT '微信编号',
  `patient_status` varchar(100) DEFAULT NULL COMMENT '用户状态:1正常,0禁用,-1恶意注册,2审核中',
  `mobile_remarks` varchar(200) DEFAULT NULL COMMENT '联系方式备注【基卫】',
  `openid_time` datetime DEFAULT NULL COMMENT '第一次添加open的时间',
  `sick_village` varchar(50) DEFAULT NULL COMMENT '居委会代码',
  `sick_village_name` varchar(100) DEFAULT NULL,
  `principal_code` varchar(50) DEFAULT NULL COMMENT '绑定电子社保卡主体(共济为操作人code)',
  `sicard_status` varchar(100) DEFAULT NULL COMMENT '是否绑定电子社保卡 (0否 1是)',
  `sicard_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '电子社保卡绑定时间',
  `is_wxtag` int(1) DEFAULT NULL COMMENT '是否分配过微信标签',
  `wxtagid` varchar(100) DEFAULT NULL COMMENT '微信tagId',
  `standard_status` tinyint(4) DEFAULT NULL COMMENT '居民预警状态:0为标准,1为预警状态',
  `medicare_number` varchar(50) DEFAULT NULL COMMENT '医疗保险号',
  `unionid` varchar(50) DEFAULT NULL COMMENT 'unionId 开发平台唯一标识',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_patient_idcard` (`idcard`),
  KEY `idx_mobile` (`mobile`) USING BTREE,
  KEY `idx_openid` (`openid`) USING BTREE,
  KEY `idx_name` (`name`),
  KEY `idx_principal_code` (`principal_code`) USING BTREE,
  KEY `idx_unionid` (`unionid`) USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='居民信息(居民就是患者)';
-- 团队信息
drop table IF EXISTS `base_team`;
CREATE TABLE `base_team` (
  `id` varchar(50) NOT NULL   COMMENT '主键,团队uuid标识',
  `org_id` varchar(50) DEFAULT NULL COMMENT '机构id',
  `name` varchar(50) DEFAULT NULL COMMENT '团队名称',
  `leader_id` varchar(50) NOT NULL COMMENT '领导医生标识',
  `team_num` varchar(50) NOT NULL COMMENT '团队人数',
  `qrcode` varchar(50) DEFAULT NULL COMMENT '团队二维码',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团队信息';
drop table IF EXISTS `base_team_member`;
CREATE TABLE `base_team_member` (
  `id` varchar(50) NOT NULL    COMMENT 'uuid',
  `team_id` varchar(100) NOT NULL COMMENT '团队ID',
  `org_id` varchar(100) NOT NULL COMMENT '机构标识',
  `doctor_id` varchar(500) NOT NULL COMMENT '医生标识,多个医生以逗号分开',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  `create_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人',
  `create_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '创建人名',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_user` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人',
  `update_user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '修改人名',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARSET=utf8mb4 COMMENT='团队成员';
-- 基础人口信息
drop table IF EXISTS `base_people_num`;
CREATE TABLE `base_people_num` (
  `id` varchar(50) NOT NULL DEFAULT '' COMMENT '主键(uuid),基础人口信息uuid',
  `saas_id`  varchar(100) NOT NULL COMMENT 'saas化的id',
  `province_code` varchar(50) DEFAULT NULL COMMENT '所属省代码',
  `city_code` varchar(50) DEFAULT NULL COMMENT '所属市代码',
  `district_code` varchar(50) DEFAULT NULL COMMENT '所属区代码',
  `name` varchar(200) DEFAULT NULL COMMENT '所属具体名称',
  `num` int(10) DEFAULT NULL COMMENT '人口数',
  `type` varchar(2) DEFAULT NULL COMMENT '类别 0是省,1是市,2是区,3是机构',
  `year` int(10) DEFAULT NULL COMMENT '每年的人口数',
  `gxy_num` int(10) DEFAULT  '0' COMMENT '高血压发病数',
  `tnb_num` int(10) DEFAULT  '0' COMMENT '糖尿病发病数',
  `six_five_num` int(10) DEFAULT  '0' COMMENT '65岁以上老年人口数',
  `gxy_task_num` int(10) DEFAULT  '0' COMMENT '高血压任务数',
  `tnb_task_num` int(10) DEFAULT  '0' COMMENT '糖尿病任务数',
  `six_five_task_num` int(10) DEFAULT  '0' COMMENT '65岁以上老年人口任务数',
  `task_num` int(10) DEFAULT  '0' COMMENT '户籍人口任务数',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='基础人口基数信息';
-- 行政区划数据  4个表 ---start----
-- 省
drop table IF EXISTS `base_province`;
CREATE TABLE `base_province` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `code` varchar(50) NOT NULL COMMENT '省份编码',
  `name` varchar(50) NOT NULL COMMENT '省份名称',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='省份字典';
-- 城市
drop table IF EXISTS `base_city`;
CREATE TABLE `base_city` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `province` varchar(10) DEFAULT NULL COMMENT '省编码',
  `code` varchar(50) DEFAULT NULL COMMENT '城市编码',
  `name` varchar(50) DEFAULT NULL COMMENT '城市名称',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_dm_city_province` (`province`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='城市字典';
-- 城镇区县
drop table IF EXISTS `base_town`;
CREATE TABLE `base_town` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `province` varchar(50) DEFAULT NULL COMMENT '省编码',
  `city` varchar(50) DEFAULT NULL COMMENT '城市编码',
  `code` varchar(50) DEFAULT NULL COMMENT '区县编码',
  `name` varchar(50) DEFAULT NULL COMMENT '区县名称',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_dm_town` (`city`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区县字典';
-- 街道
drop table IF EXISTS `base_street`;
CREATE TABLE `base_street` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `province` varchar(50) DEFAULT NULL COMMENT '省标识',
  `city` varchar(50) DEFAULT NULL COMMENT '市标识',
  `town` varchar(50) DEFAULT NULL COMMENT '区县标识',
  `code` varchar(50) DEFAULT NULL COMMENT '街道标识',
  `name` varchar(100) DEFAULT NULL COMMENT '街道名称',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_dm_street` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='街道字典';
-- 行政区划数据  4个表 ---end----
-- 职称表
drop table IF EXISTS `dict_job_title`;
create table `dict_job_title`(
`id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
`saas_id` varchar(100) DEFAULT NULL COMMENT 'saas配置id,null标识公共字典',
`code` varchar(50) default NULL COMMENT '职称标识',
`name` varchar(20) default NULL COMMENT '职称名',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
 KEY `idx_job_title_code` (`code`),
primary key (id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='职称字典';
-- 药品
drop table IF EXISTS `dict_medicine`;
create table `dict_medicine`(
`id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
`saas_id` varchar(100) DEFAULT NULL COMMENT 'saas配置id,null标识公共字典',
`code` varchar(100) not null COMMENT '药品编码',
`name` varchar(50) not null COMMENT '药品名称',
`type` char(1) default NULL COMMENT '药品类型:1健康记录',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
primary key (id),
key `idx_medicine_code` (`code`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='药品字典';
-- ICD10表
drop table IF EXISTS `dict_icd10`;
CREATE TABLE `dict_icd10` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `saas_id` varchar(100) DEFAULT NULL COMMENT 'saas配置id,null标识公共字典',
  `code` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT 'icd10字典编码',
  `name` varchar(200) CHARACTER SET utf8 DEFAULT NULL COMMENT 'icd10字典名称',
  `phonetic_code` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '字典名称拼音首字母',
  `chronic_flag` varchar(1) CHARACTER SET utf8 DEFAULT NULL COMMENT '是否慢病',
  `infectious_flag` varchar(1) CHARACTER SET utf8 DEFAULT NULL COMMENT '是否传染病',
  `description` varchar(200) CHARACTER SET utf8 DEFAULT NULL COMMENT '描述',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  key `idx_icd10_code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4  COMMENT='ICD10字典';
-- 健康问题表
drop table IF EXISTS `dict_health_problem`;
CREATE TABLE `dict_health_problem` (
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `saas_id` varchar(100) DEFAULT NULL COMMENT 'saas配置id,null标识公共字典',
  `code` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '字典编码',
  `name` varchar(200) CHARACTER SET utf8 DEFAULT NULL COMMENT '字典名称',
  `description` varchar(200) CHARACTER SET utf8 DEFAULT NULL COMMENT '描述',
  key `idx_hea_problem_code` (`code`),
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='健康问题字典';
-- 标准科室
drop table IF EXISTS `dict_hospital_dept`;
create table `dict_hospital_dept`
(
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长,字典型',
  `saas_id` varchar(100) DEFAULT NULL COMMENT 'saas配置id,null标识公共字典',
  `code` varchar(50) not null COMMENT '科室标识',
  `name` varchar(50) not null COMMENT '科室名称',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  key `idx_hos_dept_code` (`code`),
  primary key (id)
)
  ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院科室字典';

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

@ -58,6 +58,10 @@
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>

+ 112 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/activemq/ConsumerRunner.java

@ -0,0 +1,112 @@
package com.yihu.jw.base.activemq;
import com.yihu.utils.context.SpringContext;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.util.Assert;
import org.springframework.web.client.RestTemplate;
import javax.jms.*;
import javax.jms.IllegalStateException;
import java.util.Set;
/**
 * Runner - 消息执行者
 * Created by progr1mmer on 2018/8/2.
 */
public class ConsumerRunner implements Runnable, ExceptionListener {
    private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
    private final String topic;
    private Set<String> pushUrl;
    private QueueConnection connection;
    private Session session;
    private MessageConsumer consumer;
    private RestTemplate restTemplate;
    public ConsumerRunner(String topic, Set<String> pushUrl) {
        Assert.notNull(topic, "Topic cannot be null");
        this.topic = topic;
        this.pushUrl = pushUrl;
        init();
    }
    private void init() {
        try {
            ActiveMQConnectionFactory connectionFactory = SpringContext.getService(ActiveMQConnectionFactory.class);
            // Create a Connection
            connection = connectionFactory.createQueueConnection();
            connection.start();
            connection.setExceptionListener(this);
            // Create a Session
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            // Create the destination (Topic or Queue)
            Destination destination = session.createQueue(topic);
            // Create a MessageConsumer from the Session to the Topic or Queue
            consumer = session.createConsumer(destination);
            restTemplate = new RestTemplate();
        } catch (JMSException e) {
            LOGGER.error("Failed to init ConsumerRunner", e);
        }
    }
    private void recover() throws JMSException {
        ActiveMQConnectionFactory connectionFactory = SpringContext.getService(ActiveMQConnectionFactory.class);
        // Create a Connection
        connection = connectionFactory.createQueueConnection();
        connection.start();
        connection.setExceptionListener(this);
        // Create a Session
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        // Create the destination (Topic or Queue)
        Destination destination = session.createQueue(topic);
        // Create a MessageConsumer from the Session to the Topic or Queue
        consumer = session.createConsumer(destination);
        if (null == restTemplate) {
            restTemplate = new RestTemplate();
        }
    }
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
                // Wait for a message
                Message message = consumer.receive(1000);
                if (message != null) {
                    if (message instanceof TextMessage) {
                        TextMessage textMessage = (TextMessage) message;
                        String text = textMessage.getText();
                        for (String url : pushUrl) {
                            String result = restTemplate.postForObject(url, new HttpEntity<>(text), String.class);
                            LOGGER.info(result);
                        }
                    } else {
                        for (String url : pushUrl) {
                            String result = restTemplate.postForObject(url, new HttpEntity<>(message), String.class);
                            LOGGER.info(result);
                        }
                    }
                }
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
                if (e instanceof IllegalStateException) {
                    try {
                        recover();
                    } catch (JMSException jme) {
                        LOGGER.error("Failed to recover ConsumerRunner", jme);
                    }
                }
            }
        }
    }
    @Override
    public void onException(JMSException e) {
        LOGGER.error("ConsumerRunner onException", e);
    }
}

+ 60 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/activemq/MessageManager.java

@ -0,0 +1,60 @@
package com.yihu.jw.base.activemq;
import com.yihu.jw.base.service.message.MqMessageService;
import com.yihu.jw.base.service.message.MqMessageSubscriberService;
import com.yihu.jw.entity.base.message.MqMessageDO;
import com.yihu.jw.entity.base.message.MqMessageSubscriberDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Pattern;
/**
 * Component - ActiveMQ消息订阅初始化
 * Created by progr1mmer on 2018/8/30.
 */
@Component
public class MessageManager {
    private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
    private static final Pattern PATTERN  = Pattern.compile("^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\\\/])+(\\\\?{0,1}(([A-Za-z0-9-~]+\\\\={0,1})([A-Za-z0-9-~]*)\\\\&{0,1})*)$");
    private ExecutorService executorService;
    @Autowired
    private MqMessageService mqMessageService;
    @Autowired
    private MqMessageSubscriberService mqMessageSubscriberService;
    public void initConsumer() {
        try {
            Map<String, Set<String>> groups = new HashMap<>();
            List<MqMessageDO> mqMessageDos = mqMessageService.search("");
            for (MqMessageDO mqMessageDo : mqMessageDos) {
                List<MqMessageSubscriberDO> mqMessageSubscriberDOS = mqMessageSubscriberService.search("topic=" + mqMessageDo.getTopic());
                Set<String> subUrl = new HashSet<>();
                mqMessageSubscriberDOS.forEach(item -> {
                    if (item.getUrl() != null && PATTERN.matcher(item.getUrl()).find()) {
                        subUrl.add(item.getUrl());
                    } else {
                        LOGGER.error("[Topic: " + item.getTopic() + "] Illegal url: " + item.getUrl() + " of " + item.getSaasId());
                    }
                });
                groups.put(mqMessageDo.getTopic(), subUrl);
            }
            executorService = Executors.newFixedThreadPool(groups.size());
            for (String key : groups.keySet()) {
                executorService.execute(new ConsumerRunner(key, groups.get(key)));
            }
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
            System.exit(-1);
        }
    }
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseCityDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.area.BaseCityDO;
/**
 * 
 * 城市字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseCityDao extends PagingAndSortingRepository<BaseCityDO, Integer>, JpaSpecificationExecutor<BaseCityDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseDoctorDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
/**
 * 
 * 医生基础信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO, String>, JpaSpecificationExecutor<BaseDoctorDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseDoctorHospitalDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
/**
 * 
 * 医生职业信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorHospitalDao extends PagingAndSortingRepository<BaseDoctorHospitalDO, Integer>, JpaSpecificationExecutor<BaseDoctorHospitalDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseDoctorRoleDictDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDictDO;
/**
 * 
 * 医生角色字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorRoleDictDao extends PagingAndSortingRepository<BaseDoctorRoleDictDO, Integer>, JpaSpecificationExecutor<BaseDoctorRoleDictDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseOrgDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.org.BaseOrgDO;
/**
 * 
 * 机构信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String>, JpaSpecificationExecutor<BaseOrgDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BasePatientDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.patient.BasePatientDO;
/**
 * 
 * 居民信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BasePatientDao extends PagingAndSortingRepository<BasePatientDO, String>, JpaSpecificationExecutor<BasePatientDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseProvinceDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.area.BaseProvinceDO;
/**
 * 
 * 省字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseProvinceDao extends PagingAndSortingRepository<BaseProvinceDO, Integer>, JpaSpecificationExecutor<BaseProvinceDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseStreetDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.area.BaseStreetDO;
/**
 * 
 * 街道字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseStreetDao extends PagingAndSortingRepository<BaseStreetDO, Integer>, JpaSpecificationExecutor<BaseStreetDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseTeamDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.team.BaseTeamDO;
/**
 * 
 * 团队信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseTeamDao extends PagingAndSortingRepository<BaseTeamDO, String>, JpaSpecificationExecutor<BaseTeamDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseTeamMemberDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
/**
 * 
 * 团队成员 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseTeamMemberDao extends PagingAndSortingRepository<BaseTeamMemberDO, String>, JpaSpecificationExecutor<BaseTeamMemberDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/BaseTownDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.area.BaseTownDO;
/**
 * 
 * 区县字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseTownDao extends PagingAndSortingRepository<BaseTownDO, Integer>, JpaSpecificationExecutor<BaseTownDO>  {
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/DictHealthProblemDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.dict.DictHealthProblemDO;
/**
 * 
 * 健康问题字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface DictHealthProblemDao extends PagingAndSortingRepository<DictHealthProblemDO, Integer>, JpaSpecificationExecutor<DictHealthProblemDO>  {
}

+ 0 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/DictHospitalDeptDao.java


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