ソースを参照

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

Trick 6 年 前
コミット
2fb3e8b892
22 ファイル変更284 行追加162 行削除
  1. 1 1
      business/base-service/src/main/java/com/yihu/jw/message/service/MessageService.java
  2. 1 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java
  3. 1 1
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  4. 23 79
      common/common-entity/src/main/java/com/yihu/jw/entity/base/login/BaseLoginLogDO.java
  5. 1 1
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  6. 9 0
      server/svr-authentication/pom.xml
  7. 39 16
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  8. 15 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/login/dao/BaseLoginLogDao.java
  9. 32 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/login/service/BaseLoginLogService.java
  10. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserSimple.java
  11. 70 11
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  12. 5 0
      server/svr-authentication/src/main/resources/application.yml
  13. 1 0
      svr/svr-base/src/main/java/com/yihu/jw/base/enums/SystemDictEnum.java
  14. 2 7
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  15. 14 14
      svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java
  16. 7 2
      svr/svr-patient/pom.xml
  17. 6 5
      svr/svr-patient/sql/sql
  18. 4 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientFamilyMemberDao.java
  19. 6 3
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java
  20. 43 19
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java
  21. 2 2
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientFamilyMemberService.java
  22. 1 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/personal_Info/PatientService.java

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/message/service/MessageService.java

@ -120,7 +120,7 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> {
    public List<Map<String, Object>> applyMessageList(String patient, String msgTypeCode){
        String sql = "select m.* from base_message m join patient_apply_for_log l on m.relation_data=l.id where  m.msg_type_code='"+msgTypeCode+"' and m.receiver='"+patient+"'";
        String sql = "select m.* from base_message m join patient_apply_for_log l on m.relation_data=l.id where  m.read_state=0 and m.msg_type_code='"+msgTypeCode+"' and m.receiver='"+patient+"'";
        return jdbcTemplate.queryForList(sql);
//        return messageDao.applyMessageList(patient,failureTime,msgTypeCode);
    }

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java

@ -40,4 +40,5 @@ public interface BasePatientDao extends PagingAndSortingRepository<BasePatientDO
    @Query(" update BasePatientDO a set a.openid=?2 where a.id=?1 ")
    int updateOpenId(String id, String openId);
    BasePatientDO findByIdAndDel(String id,String del);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -171,7 +171,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    public BasePatientDO findByIdAndDel(String patient) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        if(basePatientDO==null){
            throw new Exception("not patient");
            throw new Exception("用户不存在");
        }
        return basePatientDO;
    }

+ 23 - 79
common/common-entity/src/main/java/com/yihu/jw/entity/base/login/BaseLoginLogDO.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.base.login;// default package
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.*;
@ -13,40 +14,13 @@ import java.util.Date;
@Table(name = "base_login_log")
public class BaseLoginLogDO extends UuidIdentityEntity implements java.io.Serializable {
	private String loginType;//'1 短信登录  2 密码登录'
	private String userId;//'登录用户主键 患者code或者医生code'
	private String saasId;//'saas配置id'
	private String userType;//'1 患者 2医生 '
	private Date createTime;
	private Integer tokenId;//'tokenid'
	private String type;//'1 成功 2失败'
	private String errorMessage;//'错误信息'
	private String phone;//'电话号码'
	private String userAgent;//wlyyusersimple json串
	private String openid;//微信openid
	private String loginType;
	// Constructors
	/** default constructor */
	public BaseLoginLogDO() {
	}
	/** minimal constructor */
	public BaseLoginLogDO(Integer id, Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "login_type", length = 2)
	public String getLoginType() {
		return this.loginType;
	}
	public void setLoginType(String loginType) {
		this.loginType = loginType;
	}
	@Column(name = "user_id", length = 100)
	@Column(name="user_id")
	public String getUserId() {
		return userId;
	}
@ -55,70 +29,40 @@ public class BaseLoginLogDO extends UuidIdentityEntity implements java.io.Serial
		this.userId = userId;
	}
	@Column(name = "saas_id", length = 100)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "user_type", length = 2)
	public String getUserType() {
		return this.userType;
	}
	public void setUserType(String userType) {
		this.userType = userType;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	@Column(name="create_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return this.createTime;
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "token_id")
	public Integer getTokenId() {
		return this.tokenId;
	@Column(name="user_agent")
	public String getUserAgent() {
		return userAgent;
	}
	public void setTokenId(Integer tokenId) {
		this.tokenId = tokenId;
	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}
	@Column(name = "type", length = 1)
	public String getType() {
		return this.type;
	@Column(name="openid")
	public String getOpenid() {
		return openid;
	}
	public void setType(String type) {
		this.type = type;
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	@Column(name = "error_message", length = 1000)
	public String getErrorMessage() {
		return this.errorMessage;
	}
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}
	@Column(name = "phone", length = 20)
	public String getPhone() {
		return this.phone;
	@Column(name="login_type")
	public String getLoginType() {
		return loginType;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	public void setLoginType(String loginType) {
		this.loginType = loginType;
	}
}

+ 1 - 1
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -62,7 +62,7 @@ public class BasicZuulFilter extends ZuulFilter {
        logger.info("BasicZuulFilter:"+url);
        //内部微服务有不需要认证的地址请在URL上追加/open/来进行过滤,如/api/v1.0/open/**,不要在此继续追加!!!
        if (url.contains("/auth/")//验证服务
                || url.contains("/base/wechat/")//微信
                || url.contains("/base/wechat")//微信
                || url.contains("/patient/wxBase/")//微信
                || url.contains("/patient/wx/")//微信页面不拦截
                || url.contains("/basePatient/regist")//注册

+ 9 - 0
server/svr-authentication/pom.xml

@ -109,6 +109,15 @@
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>

+ 39 - 16
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -6,6 +6,7 @@ import com.yihu.jw.security.model.WlyyUserSimple;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
@ -20,6 +21,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.sql.DataSource;
import java.sql.Timestamp;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -39,6 +41,12 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Value("${user.autoUnlockTime}")
    private Integer autoUnlockTime;//自动解锁时间 以分钟计算
    @Value("${user.reflashFailedCountTime}")
    private Integer reflashFailedCountTime;//将失败次数重置为0 ,以分钟计算
    @Value("${user.tryLoginTimes}")
    private Integer tryLoginTimes;//失败重试次数
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
@ -60,7 +68,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        }
        if (users.get(0).isLocked()) {
            Date date = users.get(0).getLockedDate();
            if (new Date().after(DateUtils.addMinutes(date, 5))) {
            if (new Date().after(DateUtils.addMinutes(date, autoUnlockTime))) {
                //解除锁定
                unlocked(username);
                users.get(0).setLocked(false);
@ -137,33 +145,48 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        //获取失败次数
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String username = request.getParameter("username");
        Integer loginFailureCount = getLoginFailureCount(username);
        Map<String,Object> map = getLoginFailureCount(username);
        Integer loginFailureCount = Integer.valueOf(map.get("login_failure_count").toString());
        Object timeObj = map.get("last_login_failure_time");
        if(timeObj == null){
            loginFailureCount = 0;
        }else{
            Timestamp timestamp = (Timestamp) timeObj;
            //判断是否得重置登陆次数
            Date date = new Date(timestamp.getTime());
            if (new Date().after(DateUtils.addMinutes(date, reflashFailedCountTime))) {
                //重置登陆次数
                loginFailureCount = 0;
            }
        }
        loginFailureCount ++;
        if (loginFailureCount >= 5) {
        if (loginFailureCount >= tryLoginTimes) {
            locked(username);
            return "账号已被锁定,请5分钟后重试!";
            return "账号已被锁定,请"+autoUnlockTime+"分钟后重试!";
        } else {
            addFailureCount(username,loginFailureCount);
            return "账号或密码错误,还可以再试" + (5 - loginFailureCount) + "次!";
            return "账号或密码错误,还可以再试" + (tryLoginTimes - loginFailureCount) + "次!";
        }
    }
    /**
     * 获取失败次数
     * 获取失败次数 返回 map  key1: login_failure_count   失败次数
     *                       key2: last_login_failure_time 上次登录失败时间 /可能为null
     *
     * @param username
     * @return
     */
    public Integer getLoginFailureCount(String username){
    public Map<String, Object> getLoginFailureCount(String username){
        Map<String, Object> result = new HashMap<>();
        String loginType = getLogintype();
        Integer loginFailureCount = 0;
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
            loginFailureCount = this.getJdbcTemplate().queryForObject("select u.login_failure_count from base_user u where u.username = ? or u.mobile = ? or u.idcard = ?", Integer.class, username, username, username);
            result = this.getJdbcTemplate().queryForMap("select u.login_failure_count,u.last_login_failure_time from base_user u where u.username = ? or u.mobile = ? or u.idcard = ?", username, username, username);
        }else if("2".equals(loginType)){//2.为医生账号
            loginFailureCount = this.getJdbcTemplate().queryForObject("select d.login_failure_count from base_doctor d where d.mobile = ? or d.idcard = ?", Integer.class, username, username);
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ?", username, username);
        }else if("3".equals(loginType)){ //3.患者账号
            loginFailureCount = this.getJdbcTemplate().queryForObject("select p.login_failure_count from base_patient p where p.mobile = ? or p.idcard = ?", Integer.class, username, username);
        } //...
        return loginFailureCount;
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?",username, username);
        }
        return result;
    }
    /**
@ -193,13 +216,13 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        String loginType = getLogintype();
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
            //更新失败次数
            this.getJdbcTemplate().update("update base_user u set u.login_failure_count = ? where u.username = ? or u.mobile = ? or u.idcard = ?", loginFailureCount, username, username, username);
            this.getJdbcTemplate().update("update base_user u set u.login_failure_count = ? ,u.last_login_failure_time = ? where u.username = ? or u.mobile = ? or u.idcard = ?", loginFailureCount,new Date(), username, username, username);
        }else if("2".equals(loginType)){//2.为医生账号
            //更新失败次数
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = ? where d.mobile = ? or d.idcard = ?", loginFailureCount, username, username);
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = ?, d.last_login_failure_time = ?  where d.mobile = ? or d.idcard = ?", loginFailureCount,new Date(), username, username);
        }else if("3".equals(loginType)){ //3.患者账号
            //更新失败次数
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = ? where p.mobile = ? or p.idcard = ?", loginFailureCount, username, username);
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = ? ,p.last_login_failure_time = ? where p.mobile = ? or p.idcard = ?", loginFailureCount,new Date(),username, username);
        } //...
    }

+ 15 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/login/dao/BaseLoginLogDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.security.login.dao;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseLoginLogDao extends PagingAndSortingRepository<BaseLoginLogDO, String>, JpaSpecificationExecutor<BaseLoginLogDO> {
    @Query("from BaseLoginLogDO l where l.openid=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByOpenId(String openid);
}

+ 32 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/login/service/BaseLoginLogService.java

@ -0,0 +1,32 @@
package com.yihu.jw.security.login.service;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.security.login.dao.BaseLoginLogDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
@Service
public class BaseLoginLogService<T, R extends CrudRepository> extends BaseJpaService<BaseLoginLogDO, BaseLoginLogDao> {
    @Autowired
    private BaseLoginLogDao baseLoginLogDao;
    /**
     * 根据openid 获取最新的一条数据
     * @param openid
     * @return
     */
    public BaseLoginLogDO findByOpenId(String openid) {
        List<BaseLoginLogDO> loginLogs = baseLoginLogDao.findByOpenId(openid);
        if(!CollectionUtils.isEmpty(loginLogs)){
            return loginLogs.get(0);
        }
        return null;
    }
}

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

@ -23,7 +23,7 @@ WlyyUserSimple implements Serializable {
        female
    }
    private String id;
    private String id; //对应患者,医生等表中的id字段
    //用户名
    private String username;
    //姓名

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

@ -1,7 +1,10 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.login.service.BaseLoginLogService;
import com.yihu.jw.security.model.*;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
@ -84,6 +87,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private BaseLoginLogService baseLoginLogService;
    @PostConstruct
    private void init() {
@ -142,11 +147,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        在网关处通过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 (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());
        }
@ -157,14 +162,27 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        //更新患者openId
        if(!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && "3".equalsIgnoreCase(loginType)){
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        if(!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && "3".equals(loginType)){
            baseLoginLogDO.setOpenid(openid);
            userDetailsService.updateOpenId(openid,wlyyUserSimple.getId());
        }
        if (parameters.get("password") != null) {
            //使用密码登录成功后, 更新失败次数为 0
            userDetailsService.addFailureCount(username,0);
        }
        userDetailsService.setRolePhth(loginType,token,wlyyUserSimple.getId(),redisTemplate);
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogService.save(baseLoginLogDO);
        return getResponse(wlyyUserSimple);
    }
@ -209,6 +227,27 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return getResponse(wlyyUserSimple);
    }
    /**
     *
     * @param openid
     * @return
     */
    @RequestMapping(value = "/oauth/getByOpenId", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> getByOpenId( @RequestParam(value = "openid", required = true) String openid) {
        BaseLoginLogDO loginLog = baseLoginLogService.findByOpenId(openid);
        if(loginLog== null){
            throw new UsernameNotFoundException("can't find login log by openod: "+openid);
        }
        String userAgent = loginLog.getUserAgent();
        WlyyUserSimple wlyyUserSimple = JSONObject.parseObject(userAgent, WlyyUserSimple.class);
        String accessToken = wlyyUserSimple.getAccessToken();
        OAuth2Authentication authentication = tokenStore.readAuthentication(accessToken);
        if (null == authentication) {
            throw new InvalidTokenException("Cant not load authentication");
        }
        return getResponse(wlyyUserSimple);
    }
    /**
     * 登出
     * @param parameters
@ -323,7 +362,17 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }
        throw new IllegalStateException((String) result.get("message"));
        String message = (String) result.get("message");
        try {
            JSONObject jsonStr = JSONObject.parseObject(message);
            if(jsonStr.containsKey("Message")){
                message = jsonStr.getString("Message");
            }
        } catch (Exception e) {
        }
        throw new IllegalStateException(message);
        /*Captcha _captcha = new Captcha();
        _captcha.setCode("12345");
        _captcha.setExpiresIn(10000);
@ -451,7 +500,17 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            String loginType = parameters.get("login_type");
            userDetailsService.setRolePhth(loginType,token,wlyyUserSimple.getId(),redisTemplate);
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            String openid = parameters.get("openid");
            if(!StringUtils.isEmpty(openid) && "undefined".equalsIgnoreCase(openid)){
                baseLoginLogDO.setOpenid(openid);
            }
            baseLoginLogService.save(baseLoginLogDO);
            return getResponse(wlyyUserSimple);
        }
        return null;
@ -501,13 +560,13 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        } else if (e instanceof InvalidGrantException) {
            return handleOAuth2Exception(new Oauth2Envelop(invalidGrantMessage((InvalidGrantException)e), HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidTokenException) {
            return handleOAuth2Exception(new Oauth2Envelop("Token有误!", HttpStatus.UNAUTHORIZED.value()), e);
            return handleOAuth2Exception(new Oauth2Envelop("Token有误/过期!", HttpStatus.FORBIDDEN.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);
        }
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }

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

@ -17,6 +17,11 @@ spring:
      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 settings only has an effect if it is positive.
user:
  autoUnlockTime: 5  #账户锁定后,自动解锁时间  以分钟计算
  reflashFailedCountTime: 5 #将失败次数重置为0
  tryLoginTimes: 5 #失败重试次数
#logging:
#  level:

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/enums/SystemDictEnum.java

@ -10,3 +10,4 @@ import org.apache.commons.lang3.StringUtils;
public enum SystemDictEnum {
    Icd10Dict, HospitalDeptDict, JobTitleDict, HealthProblemDict, DiseaseDict, MedicineDict,SystemDict;
}

+ 2 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -107,20 +107,15 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        //医生基本信息
        BaseDoctorDO doctors = baseDoctorDao.findOne(doctorId);
        if(null == doctors){
            result.put("msg","doctor not exist for id:" + doctorId);
            result.put("msg","医生不存在:" + doctorId);
            result.put("response",ConstantUtils.FAIL);
            return result;
        }
        //医生归属业务模块角色信息
        //医生归属业务模块角色信息,非必填,数据可有可没有
        String[] paramNames = {"doctorCode"};
        Object[] paramValue = {doctorId};
        List<BaseDoctorRoleDO> roleList = baseDoctorRoleService.findByFields(paramNames,paramValue);
        if(CollectionUtils.isEmpty(roleList)){
            result.put("msg","doctor role not exist for id:" + doctorId);
            result.put("response",ConstantUtils.FAIL);
            return result;
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("doctor",doctors);
        jsonObject.put("role",roleList);

+ 14 - 14
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java

@ -76,23 +76,23 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictIcd10Service.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictHospitalDeptService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictJobTitleService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictHealthProblemService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictMedicineService.queryAll(saasId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = dictDiseaseService.queryAll(saasId, creatPage(page, size, sorts));
        } else {
            jsonObject = this.queryAll(saasId, createPage(page, size, sorts));
            jsonObject = this.queryAll(saasId, creatPage(page, size, sorts));
        }
        jsonArray.add(jsonObject);
        return jsonArray;
@ -123,23 +123,23 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        if (SystemDictEnum.Icd10Dict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictIcd10Service.queryAll(userId, createPage(page, size, sorts));
            jsonObject = dictIcd10Service.queryAll(userId, creatPage(page, size, sorts));
        } else if (SystemDictEnum.HospitalDeptDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHospitalDeptService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictHospitalDeptService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.JobTitleDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictJobTitleService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictJobTitleService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.HealthProblemDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictHealthProblemService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictHealthProblemService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.MedicineDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictMedicineService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictMedicineService.queryAll("", creatPage(page, size, sorts));
        } else if (SystemDictEnum.DiseaseDict == SystemDictEnum.valueOf(type)) {
            jsonObject = dictDiseaseService.queryAll("", createPage(page, size, sorts));
            jsonObject = dictDiseaseService.queryAll("", creatPage(page, size, sorts));
        } else {
            jsonObject = this.queryAll("", createPage(page, size, sorts));
            jsonObject = this.queryAll("", creatPage(page, size, sorts));
        }
        jsonArray.add(jsonObject);
        return jsonArray;

+ 7 - 2
svr/svr-patient/pom.xml

@ -196,9 +196,14 @@
            <version>2.0.0</version>
            <scope>compile</scope>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>junit</groupId>-->
            <!--<artifactId>junit</artifactId>-->
        <!--</dependency>-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
            <version>1.3.2</version>
        </dependency>
    </dependencies>

+ 6 - 5
svr/svr-patient/sql/sql

@ -6,10 +6,10 @@ create table `patient_medicare_card`
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长',
  `code` varchar(50) not null COMMENT '卡标识',
  `parent_type` varchar(1) DEFAULT NULL COMMENT '卡的大类(A-医疗卡,B-优惠券,C-银行卡,unknow-其他)',
  `type` varchar(1) DEFAULT NULL COMMENT '卡的小类:医疗卡包含 A_01 医保卡,A_02 电子社保卡 A_03 电子就诊卡等等',
  `type` varchar(10) DEFAULT NULL COMMENT '卡的小类:医疗卡包含 A_01 医保卡,A_02 电子社保卡 A_03 电子就诊卡等等',
  `patient_code` varchar(50) not null COMMENT '居民标识',
  `password` varchar(50)  null COMMENT '绑定密码',
  `wx_openid` varchar(50)  null COMMENT '微信openid,有些卡会绑定微信',
  `city_code` varchar(50)  null COMMENT '医社保卡缴交的城市',
  `org_code` varchar(50)  null COMMENT '机构code,就诊卡跟医院关联',
  `remark` varchar(50)  null COMMENT '备注',
  `del` varchar(50) not null COMMENT '状态,0-解除绑定,1-绑定中',
@ -40,7 +40,7 @@ create table `feedback`
  `id` int(11) NOT NULL AUTO_INCREMENT  COMMENT '表id,自增长',
  `type` varchar(1) DEFAULT NULL COMMENT '问题类型(功能异常-无法使用功能,功能优化-不好用、界面难看,新功能建议-你希望有什么功能,其他-其他任何问题)',
  `feedback_content` varchar(100) not null COMMENT '反馈内容,问题和建议',
  `img` varchar(1000) not null COMMENT '图片,存图片地址,逗号分割',
  `img` varchar(1000) DEFAULT null COMMENT '图片,存图片地址,逗号分割',
  `mobile` varchar(11) not null COMMENT '联系手机号码',
  primary key (id)
)
@ -56,7 +56,7 @@ create table `account_appeal`
  `name` varchar(10) not null COMMENT '申诉人姓名',
  `idcard` varchar(18) not null COMMENT '申诉人身份证号码',
  `mobile` varchar(11) not null COMMENT '申诉人手机号码',
  `img` varchar(1000) not null COMMENT '身份证正反面照片,存地址,逗号分割',
  `img` varchar(1000) DEFAULT null COMMENT '身份证正反面照片,存地址,逗号分割',
  primary key (id)
)
  ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='账号申诉';
@ -104,8 +104,9 @@ alter table base_patient drop column ssc;
alter table base_patient drop column disease;
alter table base_patient drop column disease_condition;
alter table base_patient drop column principal_code;
alter table base_patient add column principal_code varchar(50) DEFAULT NULL;
alter table base_patient drop column sicard_status;
alter table base_patient drop column sicard_time;
alter table base_patient drop column is_wxtag;
alter table base_patient drop column wxtagid;
alter table base_patient drop column medicare_number;
alter table base_patient drop column medicare_number;

+ 4 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientFamilyMemberDao.java

@ -39,5 +39,9 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<BaseP
    @Query("update BasePatientFamilyMemberDO m set m.del = ?1 where m.id=?2 ")
    int updateDelById(Integer del,String id);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.del = ?1 where m.patient=?2 and m.familyMember=?3 ")
    int updateDelByPatientAndFamilyMember(Integer del,String patient,String familyPatientId);
    BasePatientFamilyMemberDO findByPatientAndFamilyMemberAndDel(String patient,String familyMember,Integer del);
}

+ 6 - 3
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java

@ -228,10 +228,13 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = PatientRequestMapping.MyFamily.cancelBindFamily)
    @ApiOperation(value = "解除绑定家人")
    public Envelop cancelBindFamily(
            @ApiParam(name = "familyMemberId", value = "familyMemberId", required = true)
            @RequestParam(value = "familyMemberId",required = true) String familyMemberId) throws Exception {
            @ApiParam(name = "patientId", value = "申请人patient的Id", required = true)
            @RequestParam(value = "patientId",required = true) String patientId,
            @ApiParam(name = "familyPatientId", value = "家人patient的id", required = true)
            @RequestParam(value = "familyPatientId",required = true) String familyPatientId) throws Exception {
        try{
            myFamilyService.cancelBindFamily(familyMemberId);
            myFamilyService.cancelBindFamily(patientId,familyPatientId);
            myFamilyService.cancelBindFamily(familyPatientId,patientId);
            return success();
        }catch (Exception e){
            e.printStackTrace();

+ 43 - 19
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java

@ -60,12 +60,15 @@ public class MyFamilyService {
            m.put("key",(i+1));
            map.put((i+1)+"",m);
        }
        if(sex==1){//男(自己、配偶、父亲、母亲、岳父、岳母、女婿、儿媳、子女)
            map.remove("4");//公公
            map.remove("5");//婆婆
        }else if(sex==2){//女(自己、配偶、父亲、母亲、公公、婆婆、女婿、儿媳、子女)
            map.remove("6");//岳父
            map.remove("7");//岳母
        if(sex!=null){
            if(sex==1){//男(自己、配偶、父亲、母亲、岳父、岳母、女婿、儿媳、子女)
                map.remove("4");//公公
                map.remove("5");//婆婆
            }else if(sex==2){//女(自己、配偶、父亲、母亲、公公、婆婆、女婿、儿媳、子女)
                map.remove("6");//岳父
                map.remove("7");//岳母
            }
        }
        List<BasePatientFamilyMemberDO> list = patientFamilyMemberService.getByPatientAndFamilyRelation(patient,null);
@ -104,7 +107,7 @@ public class MyFamilyService {
            }
        }
        //生成社保卡号
        if(!StringUtils.isEmpty(principalNum)){
        if(!StringUtils.isEmpty(principalNum)&&!patientMedicareCardService.existsByCodeAndDel(principalNum)){
            PatientMedicareCardDO medicareCardDO = new PatientMedicareCardDO();
            medicareCardDO.setCode(principalNum);
            medicareCardDO.setParentType(PatientMedicareCardDO.ParentType.CareCard.getType());
@ -183,13 +186,28 @@ public class MyFamilyService {
     */
    public Map<String,Object> signBindFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult,
                                              String familyName,String principalNum,String idcard) throws Exception{
        //判断身份证号和社保卡号重复问题
        if(patientService.existsByIdcard(idcard)){
            throw new Exception("填写身份证已存在!");
        }
        if(patientMedicareCardService.existsByCodeAndDel(principalNum)){
            throw new Exception("填写社保卡号已存在!");
        BasePatientDO familyPatient2 = patientService.findByMobileAndDel(familyMobile);
        if(familyPatient2!=null){
            if(!idcard.equals(familyPatient2.getIdcard())){
                throw new Exception("填写身份证有误!");
            }
            if(!StringUtils.isEmpty(principalNum)){
                PatientMedicareCardDO card = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),familyPatient2.getId(),"1");
                if(card!=null&&!principalNum.equals(card.getCode())){
                    throw new Exception("填写社保卡号有误!");
                }
            }
        }else{
            //判断身份证号和社保卡号重复问题
            if(patientService.existsByIdcard(idcard)){
                throw new Exception("填写身份证已存在!");
            }
            if(patientMedicareCardService.existsByCodeAndDel(principalNum)){
                throw new Exception("填写社保卡号已存在!");
            }
        }
        if(isAdult==1){
            Map<String,Object> p = bindingMyFamily(patient, familyMobile, platform,familyBindRole,familyName,principalNum,idcard);
@ -319,6 +337,9 @@ public class MyFamilyService {
     */
    @Transactional(rollbackFor = Exception.class)
    public Map<String,Object> scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{
        if(applyPatient.equals(familyPatient)){
            throw new Exception("非家人操作!");
        }
        Map<String,Object> map = new HashedMap();
        if(status==3){
            BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
@ -479,7 +500,7 @@ public class MyFamilyService {
        List<Map<String,Object>> resultList = new LinkedList<>();
        //已绑定的
        List<BasePatientFamilyMemberDO> bindList = patientFamilyMemberService.getByPatientAndFamilyMember(patient);
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);//绑定人
//        BasePatientDO patientDO = patientService.findByIdAndDel(patient);//绑定人
        for(BasePatientFamilyMemberDO one:bindList){
            Map<String,Object> map = new HashedMap();
            BasePatientDO familyMember = patientService.findByIdAndDel(one.getFamilyMember());
@ -488,6 +509,7 @@ public class MyFamilyService {
            map.put("nonage",this.nonageByIdcard(familyMember.getIdcard()));//1成年,2未成年
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(one.getFamilyRelation()-1));//角色名称
            map.put("role",one.getFamilyRelation());//角色
            map.put("mobile",familyMember.getMobile());//手机号码
            map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
            map.put("familyMemberId",one.getId());
@ -506,6 +528,7 @@ public class MyFamilyService {
            map.put("nonage",this.nonageByIdcard(familyMember.getIdcard()));//1成年,2未成年
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")-1));//角色名称
            map.put("role",Integer.valueOf(one.get("family_bind_role")+""));//角色
            map.put("mobile",familyMember.getMobile());//手机号码
            //有效期
            Date failurTime = (Date)one.get("failure_time");
@ -530,6 +553,7 @@ public class MyFamilyService {
            map.put("photo",familyMember.getPhoto());//头像
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(Integer.valueOf(one.get("family_bind_role")+"")-1));//角色名称
            map.put("role",Integer.valueOf(one.get("family_bind_role")+""));//角色
            map.put("mobile",familyMember.getMobile());//手机号码
            Integer status = null;
            if("1".equals(one.get("status")+"")||"2".equals(one.get("status")+"")){
@ -562,7 +586,7 @@ public class MyFamilyService {
            patientApplyLog = patientApplyLogService.findById(Integer.valueOf(relationData));
            if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()){
                BaseMessageDO msg = messageService.findById(Integer.valueOf(one.get("id")+""));
                msg.setReadonly(1);
                msg.setReadState(1);
                msg.setReadTime(new Date());
                messageService.save(msg);
               continue;
@ -584,7 +608,7 @@ public class MyFamilyService {
            map.put("explain","您的"+role.get(converRole-1)+createPatient.getName()+"邀请您绑定家人账号");
            result.add(map);
            BaseMessageDO msg = messageService.findById(Integer.valueOf(one.get("id")+""));
            msg.setReadonly(1);
            msg.setReadState(1);
            msg.setReadTime(new Date());
            messageService.save(msg);
        }
@ -606,12 +630,12 @@ public class MyFamilyService {
    /**
     * 解除绑定
     * @param familyMemberId
     * @param patient
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public void cancelBindFamily(String familyMemberId) throws Exception{
        int i = patientFamilyMemberService.cancelBindFamily(familyMemberId);
    public void cancelBindFamily(String patient,String familyPatientId) throws Exception{
        int i = patientFamilyMemberService.cancelBindFamily(patient,familyPatientId);
        if(i<0){
            throw new Exception("update data failur !");
        }

+ 2 - 2
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientFamilyMemberService.java

@ -52,8 +52,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
        return patientFamilyMemberDao.getByPatientAndFamilyMember(patient);
    }
    public Integer cancelBindFamily(String id){
        return patientFamilyMemberDao.updateDelById(0,id);
    public Integer cancelBindFamily(String patient,String familyPatientId){
        return patientFamilyMemberDao.updateDelByPatientAndFamilyMember(0,patient,familyPatientId);
    }
    public Integer updateAuthorizeById(Integer isAuthorize,String id){

+ 1 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/personal_Info/PatientService.java

@ -268,6 +268,7 @@ public class PatientService extends BasePatientService<BasePatientDO, BasePatien
        patientBrief.setLiveCityCode(patientDetail.getLiveCityCode());
        patientBrief.setLiveCityName(patientDetail.getLiveCityName());
        patientBrief.setLiveTownCode(patientDetail.getLiveTownCode());
        patientBrief.setLiveTownName(patientDetail.getLiveTownName());
        patientBrief.setLiveStreetCode(patientDetail.getLiveStreetCode());
        patientBrief.setLiveStreetName(patientDetail.getLiveStreetName());
        patientBrief.setAddress(patientDetail.getAddress());