Browse Source

获取公钥

huangzhiyong 6 years ago
parent
commit
73161b6935

+ 15 - 0
src/main/java/com/yihu/ehr/organization/controller/OrganizationController.java

@ -24,6 +24,7 @@ import com.yihu.ehr.model.org.MOrganization;
import com.yihu.ehr.model.profile.MTemplate;
import com.yihu.ehr.model.security.MKey;
import com.yihu.ehr.model.user.MUser;
import com.yihu.ehr.organization.model.KeyModel;
import com.yihu.ehr.organization.service.OrganizationClient;
import com.yihu.ehr.redis.client.RedisUpdateClient;
import com.yihu.ehr.security.service.SecurityClient;
@ -37,6 +38,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
@ -837,4 +839,17 @@ public class OrganizationController extends BaseController {
        List<Map<String, Object>> listMap = orgClient.getOrgListTreeByAddressPid(pid);
        return listMap;
    }
    @RequestMapping(value = "/{org_code}/key", method = RequestMethod.GET)
    @ApiOperation(value = "获取机构公钥", notes = "机构公钥")
    public KeyModel getPublicKey(
            @ApiParam(name = "org_code", value = "机构代码")
            @PathVariable(value = "org_code")
                    String orgCode) {
        MKey key = securityClient.getOrgKey(orgCode);
        KeyModel model = new KeyModel();
        BeanUtils.copyProperties(key, model, "privateKey","fromDate","expiryDate");
        return model;
    }
}

+ 69 - 0
src/main/java/com/yihu/ehr/organization/model/KeyModel.java

@ -0,0 +1,69 @@
package com.yihu.ehr.organization.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * @author Sand
 * @version 1.0
 * @created 2016.03.16 16:01
 */
public class KeyModel {
    private String id;
    private String privateKey;
    private String publicKey;
    private Date fromDate;
    private Date expiryDate;
    private Integer valid;
    public Integer getValid() {
        return valid;
    }
    public void setValid(Integer valid) {
        this.valid = valid;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPrivateKey() {
        return privateKey;
    }
    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }
    public String getPublicKey() {
        return publicKey;
    }
    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getFromDate() {
        return fromDate;
    }
    public void setFromDate(Date fromDate) {
        this.fromDate = fromDate;
    }
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getExpiryDate() {
        return expiryDate;
    }
    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }
}