Przeglądaj źródła

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

LiTaohong 6 lat temu
rodzic
commit
37906b2659
21 zmienionych plików z 730 dodań i 93 usunięć
  1. 33 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/InterfaceDO.java
  2. 26 6
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/InterfaceErrorCodeDO.java
  3. 58 7
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/InterfaceParamDO.java
  4. 11 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  5. 24 12
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/InterfaceErrorCodeVO.java
  6. 24 17
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/InterfaceParamVO.java
  7. 34 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/InterfaceVO.java
  8. 107 0
      common/common-util/src/main/java/com/yihu/jw/util/security/RandomValidateCode.java
  9. 5 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/InterfaceDao.java
  10. 9 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/InterfaceErrorCodeDao.java
  11. 10 1
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/InterfaceParamDao.java
  12. 121 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/InterfaceEndpoint.java
  13. 81 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/module/InterfaceService.java
  14. 74 25
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/LoginController.java
  15. 4 4
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java
  16. 49 12
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/UserController.java
  17. 1 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/facility/FacilityDao.java
  18. 20 0
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/User.java
  19. 2 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityService.java
  20. 36 4
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/UserService.java
  21. 1 1
      svr/svr-healthy-house/src/main/resources/application.yml

+ 33 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/InterfaceDO.java

@ -5,6 +5,8 @@ import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/**
/**
 * 接口
 * 接口
@ -25,6 +27,10 @@ public class InterfaceDO extends UuidIdentityEntity {
    private String remark;//接口说明
    private String remark;//接口说明
    private String url;//https请求地址
    private String url;//https请求地址
    private List<InterfaceParamDO> entryParams;//入参
    private List<InterfaceParamDO> outParams;//出参
    private List<InterfaceErrorCodeDO> errorCodes;//错误说明
    @Column(name = "name")
    @Column(name = "name")
    public String getName() {
    public String getName() {
        return name;
        return name;
@ -114,4 +120,31 @@ public class InterfaceDO extends UuidIdentityEntity {
    public void setUrl(String url) {
    public void setUrl(String url) {
        this.url = url;
        this.url = url;
    }
    }
    @Transient
    public List<InterfaceParamDO> getEntryParams() {
        return entryParams;
    }
    public void setEntryParams(List<InterfaceParamDO> entryParams) {
        this.entryParams = entryParams;
    }
    @Transient
    public List<InterfaceParamDO> getOutParams() {
        return outParams;
    }
    public void setOutParams(List<InterfaceParamDO> outParams) {
        this.outParams = outParams;
    }
    @Transient
    public List<InterfaceErrorCodeDO> getErrorCodes() {
        return errorCodes;
    }
    public void setErrorCodes(List<InterfaceErrorCodeDO> errorCodes) {
        this.errorCodes = errorCodes;
    }
}
}

+ 26 - 6
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/InterfaceErrorCodeDO.java

@ -16,8 +16,10 @@ public class InterfaceErrorCodeDO extends UuidIdentityEntity {
    private String interfaceId;//接口id
    private String interfaceId;//接口id
    private String name;//错误码名称
    private String name;//错误码名称
    private String describe;//错误码描述
    private String description;//错误码描述
    private String solution;//解决方案
    private String solution;//解决方案
    private Integer sort;//排序
    private Integer del;//删除标志
    @Column(name = "interface_id")
    @Column(name = "interface_id")
    public String getInterfaceId() {
    public String getInterfaceId() {
@ -37,13 +39,13 @@ public class InterfaceErrorCodeDO extends UuidIdentityEntity {
        this.name = name;
        this.name = name;
    }
    }
    @Column(name = "describe")
    public String getDescribe() {
        return describe;
    @Column(name = "description")
    public String getDescription() {
        return description;
    }
    }
    public void setDescribe(String describe) {
        this.describe = describe;
    public void setDescription(String description) {
        this.description = description;
    }
    }
    @Column(name = "solution")
    @Column(name = "solution")
@ -54,4 +56,22 @@ public class InterfaceErrorCodeDO extends UuidIdentityEntity {
    public void setSolution(String solution) {
    public void setSolution(String solution) {
        this.solution = solution;
        this.solution = solution;
    }
    }
    @Column(name = "sort")
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}
}

+ 58 - 7
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/InterfaceParamDO.java

@ -13,16 +13,49 @@ import javax.persistence.Table;
@Entity
@Entity
@Table(name = "base_interface_param")
@Table(name = "base_interface_param")
public class InterfaceParamDO extends UuidIdentityEntity {
public class InterfaceParamDO extends UuidIdentityEntity {
    
    /**
     *
     */
    public enum Type{
        entry("入参",1),
        out("出参",2);
        private String name;
        private Integer value;
        Type(String name, Integer value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public Integer getValue() {
            return value;
        }
        public void setValue(Integer value) {
            this.value = value;
        }
    }
    private String interfaceId;//接口id
    private String interfaceId;//接口id
    private String name;//参数名
    private String name;//参数名
    private Integer paramType;//参数类型
    private Integer paramType;//参数类型
    private Integer dataType;//数据类型
    private Integer dataType;//数据类型
    private Integer isRequire;//是否必填(1是,0否)
    private Integer isRequire;//是否必填(1是,0否)
    private Integer maxLength;//最大长度
    private Integer maxLength;//最大长度
    private String describe;//描述
    private String description;//描述
    private String example;//示例
    private String example;//示例
    private Integer type;//类型(1入参,2出参)
    private Integer type;//类型(1入参,2出参)
    private Integer sort;//排序
    private Integer del;//删除标志
    @Column(name = "interface_id")
    @Column(name = "interface_id")
    public String getInterfaceId() {
    public String getInterfaceId() {
@ -78,13 +111,13 @@ public class InterfaceParamDO extends UuidIdentityEntity {
        this.maxLength = maxLength;
        this.maxLength = maxLength;
    }
    }
    @Column(name = "describe")
    public String getDescribe() {
        return describe;
    @Column(name = "description")
    public String getDescription() {
        return description;
    }
    }
    public void setDescribe(String describe) {
        this.describe = describe;
    public void setDescription(String description) {
        this.description = description;
    }
    }
    @Column(name = "example")
    @Column(name = "example")
@ -104,4 +137,22 @@ public class InterfaceParamDO extends UuidIdentityEntity {
    public void setType(Integer type) {
    public void setType(Integer type) {
        this.type = type;
        this.type = type;
    }
    }
    @Column(name = "sort")
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}
}

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

@ -18,6 +18,7 @@ public class BaseRequestMapping {
        public static final String UPDATE = "/update";
        public static final String UPDATE = "/update";
        public static final String PAGE = "/page";
        public static final String PAGE = "/page";
        public static final String LIST = "/list";
        public static final String LIST = "/list";
        public static final String FINDBYID = "/findById";
    }
    }
    /**
    /**
@ -60,6 +61,16 @@ public class BaseRequestMapping {
        public static final String FIND_ALL  = "/findAll";
        public static final String FIND_ALL  = "/findAll";
    }
    }
    /**
     * 接口
     */
    public static class Interface extends Basic {
        public static final String PREFIX  = "/interface";
        public static final String STATUS  = "/status";
        public static final String IS_NAME_EXIST  = "/isNameExist";
        public static final String FIND_ALL  = "/findAll";
    }
    /**
    /**
     * 功能
     * 功能
     */
     */

+ 24 - 12
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/InterfaceErrorCodeVO.java

@ -3,20 +3,19 @@ package com.yihu.jw.restmodel.base.module;
import com.yihu.jw.restmodel.UuidIdentityVO;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModel;
import javax.persistence.Column;
/**
/**
 * @author yeshijie on 2018/9/28.
 * @author yeshijie on 2018/9/28.
 */
 */
@ApiModel(value = "InterfaceVO", description = "接口错误说明")
@ApiModel(value = "InterfaceErrorCodeVO", description = "接口错误说明")
public class InterfaceErrorCodeVO extends UuidIdentityVO {
public class InterfaceErrorCodeVO extends UuidIdentityVO {
    private String interfaceId;//接口id
    private String interfaceId;//接口id
    private String name;//错误码名称
    private String name;//错误码名称
    private String describe;//错误码描述
    private String description;//错误码描述
    private String solution;//解决方案
    private String solution;//解决方案
    private Integer sort;//排序
    private Integer del;//删除标志
    @Column(name = "interface_id")
    public String getInterfaceId() {
    public String getInterfaceId() {
        return interfaceId;
        return interfaceId;
    }
    }
@ -25,7 +24,6 @@ public class InterfaceErrorCodeVO extends UuidIdentityVO {
        this.interfaceId = interfaceId;
        this.interfaceId = interfaceId;
    }
    }
    @Column(name = "name")
    public String getName() {
    public String getName() {
        return name;
        return name;
    }
    }
@ -34,16 +32,14 @@ public class InterfaceErrorCodeVO extends UuidIdentityVO {
        this.name = name;
        this.name = name;
    }
    }
    @Column(name = "describe")
    public String getDescribe() {
        return describe;
    public String getDescription() {
        return description;
    }
    }
    public void setDescribe(String describe) {
        this.describe = describe;
    public void setDescription(String description) {
        this.description = description;
    }
    }
    @Column(name = "solution")
    public String getSolution() {
    public String getSolution() {
        return solution;
        return solution;
    }
    }
@ -51,4 +47,20 @@ public class InterfaceErrorCodeVO extends UuidIdentityVO {
    public void setSolution(String solution) {
    public void setSolution(String solution) {
        this.solution = solution;
        this.solution = solution;
    }
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}
}

+ 24 - 17
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/InterfaceParamVO.java

@ -3,12 +3,10 @@ package com.yihu.jw.restmodel.base.module;
import com.yihu.jw.restmodel.UuidIdentityVO;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModel;
import javax.persistence.Column;
/**
/**
 * @author yeshijie on 2018/9/28.
 * @author yeshijie on 2018/9/28.
 */
 */
@ApiModel(value = "InterfaceVO", description = "接口入参出参")
@ApiModel(value = "InterfaceParamVO", description = "接口入参出参")
public class InterfaceParamVO extends UuidIdentityVO {
public class InterfaceParamVO extends UuidIdentityVO {
    
    
    private String interfaceId;//接口id
    private String interfaceId;//接口id
@ -17,11 +15,12 @@ public class InterfaceParamVO extends UuidIdentityVO {
    private Integer dataType;//数据类型
    private Integer dataType;//数据类型
    private Integer isRequire;//是否必填(1是,0否)
    private Integer isRequire;//是否必填(1是,0否)
    private Integer maxLength;//最大长度
    private Integer maxLength;//最大长度
    private String describe;//描述
    private String description;//描述
    private String example;//示例
    private String example;//示例
    private Integer type;//类型(1入参,2出参)
    private Integer type;//类型(1入参,2出参)
    private Integer sort;//排序
    private Integer del;//删除标志
    @Column(name = "interface_id")
    public String getInterfaceId() {
    public String getInterfaceId() {
        return interfaceId;
        return interfaceId;
    }
    }
@ -30,7 +29,6 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.interfaceId = interfaceId;
        this.interfaceId = interfaceId;
    }
    }
    @Column(name = "name")
    public String getName() {
    public String getName() {
        return name;
        return name;
    }
    }
@ -39,7 +37,6 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.name = name;
        this.name = name;
    }
    }
    @Column(name = "param_type")
    public Integer getParamType() {
    public Integer getParamType() {
        return paramType;
        return paramType;
    }
    }
@ -48,7 +45,6 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.paramType = paramType;
        this.paramType = paramType;
    }
    }
    @Column(name = "data_type")
    public Integer getDataType() {
    public Integer getDataType() {
        return dataType;
        return dataType;
    }
    }
@ -57,7 +53,6 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.dataType = dataType;
        this.dataType = dataType;
    }
    }
    @Column(name = "is_require")
    public Integer getIsRequire() {
    public Integer getIsRequire() {
        return isRequire;
        return isRequire;
    }
    }
@ -66,7 +61,6 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.isRequire = isRequire;
        this.isRequire = isRequire;
    }
    }
    @Column(name = "max_length")
    public Integer getMaxLength() {
    public Integer getMaxLength() {
        return maxLength;
        return maxLength;
    }
    }
@ -75,16 +69,14 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.maxLength = maxLength;
        this.maxLength = maxLength;
    }
    }
    @Column(name = "describe")
    public String getDescribe() {
        return describe;
    public String getDescription() {
        return description;
    }
    }
    public void setDescribe(String describe) {
        this.describe = describe;
    public void setDescription(String description) {
        this.description = description;
    }
    }
    @Column(name = "example")
    public String getExample() {
    public String getExample() {
        return example;
        return example;
    }
    }
@ -93,7 +85,6 @@ public class InterfaceParamVO extends UuidIdentityVO {
        this.example = example;
        this.example = example;
    }
    }
    @Column(name = "type")
    public Integer getType() {
    public Integer getType() {
        return type;
        return type;
    }
    }
@ -101,4 +92,20 @@ public class InterfaceParamVO extends UuidIdentityVO {
    public void setType(Integer type) {
    public void setType(Integer type) {
        this.type = type;
        this.type = type;
    }
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}
}

+ 34 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/InterfaceVO.java

@ -4,6 +4,8 @@ import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
/**
 * @author yeshijie on 2018/9/28.
 * @author yeshijie on 2018/9/28.
 */
 */
@ -28,9 +30,16 @@ public class InterfaceVO extends UuidIdentityVO {
    private Integer status;
    private Integer status;
    @ApiModelProperty(value = "接口说明", example = "明")
    @ApiModelProperty(value = "接口说明", example = "明")
    private String remark;
    private String remark;
    @ApiModelProperty(value = "https请求地址", example = "https://")
    @ApiModelProperty(value = "https请求地址", example = "")
    private String url;
    private String url;
    @ApiModelProperty(value = "入参", example = "")
    private List<InterfaceParamVO> entryParams;
    @ApiModelProperty(value = "出参", example = "")
    private List<InterfaceParamVO> outParams;
    @ApiModelProperty(value = "错误说明", example = "")
    private List<InterfaceErrorCodeVO> errorCodes;
    public String getName() {
    public String getName() {
        return name;
        return name;
    }
    }
@ -110,4 +119,28 @@ public class InterfaceVO extends UuidIdentityVO {
    public void setUrl(String url) {
    public void setUrl(String url) {
        this.url = url;
        this.url = url;
    }
    }
    public List<InterfaceParamVO> getEntryParams() {
        return entryParams;
    }
    public void setEntryParams(List<InterfaceParamVO> entryParams) {
        this.entryParams = entryParams;
    }
    public List<InterfaceParamVO> getOutParams() {
        return outParams;
    }
    public void setOutParams(List<InterfaceParamVO> outParams) {
        this.outParams = outParams;
    }
    public List<InterfaceErrorCodeVO> getErrorCodes() {
        return errorCodes;
    }
    public void setErrorCodes(List<InterfaceErrorCodeVO> errorCodes) {
        this.errorCodes = errorCodes;
    }
}
}

+ 107 - 0
common/common-util/src/main/java/com/yihu/jw/util/security/RandomValidateCode.java

@ -0,0 +1,107 @@
package com.yihu.jw.util.security;
/**
 * Created by progr1mmer on 2018/2/5.
 */
import javax.imageio.ImageIO;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Random;
/**
 * @author Yingjie Chen
 * @date 2016/5/24
 */
public class RandomValidateCode {
    public static final String RANDOMCODEKEY = "RANDOMVALIDATECODEKEY";//放到session中的key
    private Random random = new Random();
    private String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生的字符串
    private int width = 80;//图片宽
    private int height = 26;//图片高
    private int lineSize = 40;//干扰线数量
    private int stringNum = 4;//随机产生字符数量
    /*
     * 获得字体
     */
    private Font getFont(){
        return new Font("Fixedsys", Font.CENTER_BASELINE,18);
    }
    /*
     * 获得颜色
     */
    private Color getRandColor(int fc,int bc){
        if(fc > 255)
            fc = 255;
        if(bc > 255)
            bc = 255;
        int r = fc + random.nextInt(bc-fc-16);
        int g = fc + random.nextInt(bc-fc-14);
        int b = fc + random.nextInt(bc-fc-18);
        return new Color(r,g,b);
    }
    /**
     * 生成随机图片
     */
    public void getRandcode(HttpServletRequest request,
                            HttpServletResponse response) {
        HttpSession session = request.getSession();
        //BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
        BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_BGR);
        Graphics g = image.getGraphics();//产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
        g.fillRect(0, 0, width, height);
        g.setFont(new Font("Times New Roman",Font.ROMAN_BASELINE,18));
        g.setColor(getRandColor(110, 133));
        //绘制干扰线
        for(int i=0;i<=lineSize;i++){
            drowLine(g);
        }
        //绘制随机字符
        String randomString = "";
        for(int i = 1; i <= stringNum; i++){
            randomString= drowString(g, randomString,i);
        }
        session.removeAttribute(RANDOMCODEKEY);
        session.setAttribute(RANDOMCODEKEY, randomString);
        System.out.println(randomString);
        response.addCookie(new Cookie(RANDOMCODEKEY,randomString));
        g.dispose();
        try {
            ImageIO.write(image, "JPEG", response.getOutputStream());//将内存中的图片通过流动形式输出到客户端
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /*
     * 绘制字符串
     */
    private String drowString(Graphics g,String randomString,int i){
        g.setFont(getFont());
        g.setColor(new Color(random.nextInt(101),random.nextInt(111),random.nextInt(121)));
        String rand = String.valueOf(getRandomString(random.nextInt(randString.length())));
        randomString +=rand;
        g.translate(random.nextInt(3), random.nextInt(3));
        g.drawString(rand, 13*i, 16);
        return randomString;
    }
    /*
     * 绘制干扰线
     */
    private void drowLine(Graphics g){
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(13);
        int yl = random.nextInt(15);
        g.drawLine(x, y, x+xl, y+yl);
    }
    /*
     * 获取随机的字符
     */
    public String getRandomString(int num){
        return String.valueOf(randString.charAt(num));
    }
}

+ 5 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/InterfaceDao.java

@ -2,6 +2,8 @@ package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.InterfaceDO;
import com.yihu.jw.entity.base.module.InterfaceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
/**
@ -11,4 +13,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface InterfaceDao extends PagingAndSortingRepository<InterfaceDO, String>, JpaSpecificationExecutor<InterfaceDO> {
public interface InterfaceDao extends PagingAndSortingRepository<InterfaceDO, String>, JpaSpecificationExecutor<InterfaceDO> {
    @Modifying
    @Query("update InterfaceDO p set p.status=?2 where p.id=?1")
    void updateStatus(String id,Integer status);
}
}

+ 9 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/InterfaceErrorCodeDao.java

@ -2,13 +2,22 @@ package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.InterfaceErrorCodeDO;
import com.yihu.jw.entity.base.module.InterfaceErrorCodeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
/**
 * 接口错误说明
 * 接口错误说明
 * @author yeshijie on 2018/9/28.
 * @author yeshijie on 2018/9/28.
 */
 */
public interface InterfaceErrorCodeDao extends PagingAndSortingRepository<InterfaceErrorCodeDO, String>, JpaSpecificationExecutor<InterfaceErrorCodeDO> {
public interface InterfaceErrorCodeDao extends PagingAndSortingRepository<InterfaceErrorCodeDO, String>, JpaSpecificationExecutor<InterfaceErrorCodeDO> {
    @Query("from InterfaceErrorCodeDO w where w.interfaceId =?1 and w.del=1")
    List<InterfaceErrorCodeDO> findByInterfaceId(String interfaceId);
    @Modifying
    @Query("delete from InterfaceErrorCodeDO p where p.interfaceId=?1")
    void deleteByInterfaceId(String interfaceId);
}
}

+ 10 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/InterfaceParamDao.java

@ -2,13 +2,22 @@ package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.InterfaceParamDO;
import com.yihu.jw.entity.base.module.InterfaceParamDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
/**
 * 接口入参出参
 * 接口入参出参
 * @author yeshijie on 2018/9/28.
 * @author yeshijie on 2018/9/28.
 */
 */
public interface InterfaceParamDao extends PagingAndSortingRepository<InterfaceParamDO, String>, JpaSpecificationExecutor<InterfaceParamDO> {
public interface InterfaceParamDao extends PagingAndSortingRepository<InterfaceParamDO, String>, JpaSpecificationExecutor<InterfaceParamDO> {
    
    @Query("from InterfaceParamDO w where w.interfaceId =?1 and w.del=1")
    List<InterfaceParamDO> findByInterfaceId(String interfaceId);
    @Modifying
    @Query("delete from InterfaceParamDO p where p.interfaceId=?1")
    void deleteByInterfaceId(String interfaceId);
}
}

+ 121 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/module/InterfaceEndpoint.java

@ -0,0 +1,121 @@
package com.yihu.jw.base.endpoint.module;
import com.yihu.jw.base.service.module.InterfaceService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.entity.base.module.InterfaceDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.restmodel.base.module.InterfaceVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 接口
 * @author yeshijie on 2018/9/29.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.Interface.PREFIX)
@Api(value = "接口管理", description = "接口管理服务接口", tags = {"基础服务 - 接口管理服务接口"})
public class InterfaceEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private InterfaceService interfaceService;
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    @PostMapping(value = BaseRequestMapping.Interface.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<InterfaceVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        InterfaceDO interfaceDO = toEntity(jsonData, InterfaceDO.class);
        interfaceDO = interfaceService.addInterface(interfaceDO);
        return success(interfaceDO, InterfaceVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Interface.FINDBYID)
    @ApiOperation(value = "按id查找")
    public ObjEnvelop<InterfaceVO> findById (
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) throws Exception {
        InterfaceDO interfaceDO = interfaceService.findById(id);
        return success(interfaceDO, InterfaceVO.class);
    }
    @PostMapping(value = BaseRequestMapping.Interface.STATUS)
    @ApiOperation(value = "生效/失效")
    public Envelop status(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "status", value = "1生效,0失效", required = true)
            @RequestParam(value = "status") Integer status) {
        interfaceService.updateStatus(id, status);
        return success("修改成功");
    }
    @PostMapping(value = BaseRequestMapping.Interface.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        interfaceService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.Interface.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<InterfaceVO> update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        InterfaceDO interfaceDO = toEntity(jsonData, InterfaceDO.class);
        if (null == interfaceDO.getId()) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), ObjEnvelop.class);
        }
        interfaceDO = interfaceService.addInterface(interfaceDO);
        return success(interfaceDO, InterfaceVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Interface.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<InterfaceVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<InterfaceDO> modules = interfaceService.search(fields, filters, sorts, page, size);
        int count = (int)interfaceService.getCount(filters);
        return success(modules, count, page, size, InterfaceVO.class);
    }
    @GetMapping(value = BaseRequestMapping.Interface.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<InterfaceVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<InterfaceDO> interfaceDOs = interfaceService.search(fields, filters, sorts);
        return success(interfaceDOs, InterfaceVO.class);
    }
}

+ 81 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/module/InterfaceService.java

@ -1,9 +1,19 @@
package com.yihu.jw.base.service.module;
package com.yihu.jw.base.service.module;
import com.yihu.jw.base.dao.module.InterfaceDao;
import com.yihu.jw.base.dao.module.InterfaceDao;
import com.yihu.jw.base.dao.module.InterfaceErrorCodeDao;
import com.yihu.jw.base.dao.module.InterfaceParamDao;
import com.yihu.jw.entity.base.module.InterfaceDO;
import com.yihu.jw.entity.base.module.InterfaceDO;
import com.yihu.jw.entity.base.module.InterfaceErrorCodeDO;
import com.yihu.jw.entity.base.module.InterfaceParamDO;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
/**
 * 接口
 * 接口
@ -12,5 +22,76 @@ import org.springframework.stereotype.Service;
@Service
@Service
public class InterfaceService extends BaseJpaService<InterfaceDO, InterfaceDao> {
public class InterfaceService extends BaseJpaService<InterfaceDO, InterfaceDao> {
    @Autowired
    private InterfaceDao interfaceDao;
    @Autowired
    private InterfaceParamDao interfaceParamDao;
    @Autowired
    private InterfaceErrorCodeDao interfaceErrorCodeDao;
    /**
     * 返回接口
     * @param id
     * @return
     */
    public InterfaceDO findById(String id){
        InterfaceDO interfaceDO = interfaceDao.findOne(id);
        List<InterfaceParamDO> paramDOList = interfaceParamDao.findByInterfaceId(id);
        List<InterfaceParamDO> entryParams = paramDOList.stream()
                .filter(interfaceParamDO -> InterfaceParamDO.Type.entry.getValue().equals(interfaceParamDO.getType()))
                .collect(Collectors.toList());
        List<InterfaceParamDO> outParams = paramDOList.stream()
                .filter(interfaceParamDO -> InterfaceParamDO.Type.out.getValue().equals(interfaceParamDO.getType()))
                .collect(Collectors.toList());
        List<InterfaceErrorCodeDO> errorCodeDOList = interfaceErrorCodeDao.findByInterfaceId(id);
        interfaceDO.setErrorCodes(errorCodeDOList);
        interfaceDO.setEntryParams(entryParams);
        interfaceDO.setOutParams(outParams);
        return interfaceDO;
    }
    /**
     * 新增接口
     * @param interfaceDO
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public InterfaceDO addInterface(InterfaceDO interfaceDO){
        if(StringUtils.isNotBlank(interfaceDO.getId())){
            interfaceParamDao.deleteByInterfaceId(interfaceDO.getId());
            interfaceErrorCodeDao.deleteByInterfaceId(interfaceDO.getId());
        }
        List<InterfaceParamDO> entryParams = interfaceDO.getEntryParams();
        List<InterfaceParamDO> outParams = interfaceDO.getOutParams();
        List<InterfaceErrorCodeDO> errorCodes = interfaceDO.getErrorCodes();
        interfaceDao.save(interfaceDO);
        entryParams.forEach(interfaceParamDO -> {
            interfaceParamDO.setInterfaceId(interfaceDO.getId());
        });
        outParams.forEach(interfaceParamDO -> {
            interfaceParamDO.setInterfaceId(interfaceDO.getId());
        });
        errorCodes.forEach(interfaceErrorCodeDO -> {
            interfaceErrorCodeDO.setInterfaceId(interfaceDO.getId());
        });
        interfaceParamDao.save(entryParams);
        interfaceParamDao.save(outParams);
        interfaceErrorCodeDao.save(errorCodes);
        return interfaceDO;
    }
    /**
     * 设置生效和失效
     * @param id
     * @param status
     */
    @Transactional(rollbackFor = Exception.class)
    public void updateStatus(String id,Integer status){
        interfaceDao.updateStatus(id,status);
    }
}
}

+ 74 - 25
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/LoginController.java

@ -7,6 +7,7 @@ import com.yihu.jw.healthyhouse.service.user.LoginService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.security.RandomValidateCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.HashMap;
@ -45,24 +47,38 @@ public class LoginController extends EnvelopRestEndpoint {
            @ApiParam(name = "msgType", value = "消息类型(login:登录验证,checkPhone:验证安全手机,resetPhone:重设安全手机", required = true)@RequestParam(required = true, name = "msgType") String msgType,
            @ApiParam(name = "msgType", value = "消息类型(login:登录验证,checkPhone:验证安全手机,resetPhone:重设安全手机", required = true)@RequestParam(required = true, name = "msgType") String msgType,
            @ApiParam(name = "username", value = "手机账号", required = true)@RequestParam(required = true, name = "username") String username ) throws  Exception{
            @ApiParam(name = "username", value = "手机账号", required = true)@RequestParam(required = true, name = "username") String username ) throws  Exception{
        if (StringUtils.isEmpty(clientId)) {
        if (StringUtils.isEmpty(clientId)) {
            throw new InvalidRequestException("clientId");
            failed("clientId 为空!");
        }
        }
        if (StringUtils.isEmpty(username)){
        if (StringUtils.isEmpty(username)){
            throw new InvalidRequestException("username");
            failed("username 为空!");
        }
        }
        //验证请求间隔超时,防止频繁获取验证码
        //验证请求间隔超时,防止频繁获取验证码
//        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(clientId, username)) {
//            throw new IllegalAccessException("SMS request frequency is too fast");
//        }
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(clientId, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        //发送短信获取验证码
        //发送短信获取验证码
        ResponseEntity<HashMap> result = loginService.sendDemoSms(clientId,msgType,username);
        ResponseEntity<HashMap> result = loginService.sendSms(clientId,msgType,username);
        return result;
        return result;
    }
    }
    @PostMapping("/captcha/check")
    @ApiOperation(value = "验证短信验证码")
    public Envelop checkCaptcha(
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "登录账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha) throws ManageException, ParseException {
        if (wlyyRedisVerifyCodeService.verification(clientId, username, captcha)) {
            return success("验证码正确");
        } else {
            return failed("验证码错误");
        }
    }
    @PostMapping("/mobile/login")
    @PostMapping("/mobile/login")
    @ApiOperation(value = "【普通用户】-手机登录注册")
    @ApiOperation(value = "【普通用户】-手机登录注册")
    public ObjEnvelop<User> mobileLogin(
    public Envelop mobileLogin(
            HttpServletRequest request,
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
@ -76,26 +92,22 @@ public class LoginController extends EnvelopRestEndpoint {
            return success(user);
            return success(user);
        } else {
        } else {
            return ObjEnvelop.getError("验证码错误");
            return failed("验证码错误");
        }
        }
    }
    }
    @PostMapping("/ijk/login")
    @PostMapping("/ijk/login")
    @ApiOperation(value = "【普通用户】-i健康用户登陆")
    @ApiOperation(value = "【普通用户】-i健康用户登陆")
    public ObjEnvelop ijkLogin(
    public Envelop ijkLogin(
            HttpServletRequest request,
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
            @ApiParam(name = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
        User user = loginService.iJklogin(request,clientId,username, password);
        User user = loginService.iJklogin(request,clientId,username, password);
        if (user !=null) {
        if (user !=null) {
            ObjEnvelop envelop = new ObjEnvelop();
            envelop.setStatus(200);
            envelop.setMessage("登录成功");
            envelop.setObj(user);
            return envelop;
            return success("登录成功",user);
        }else {
        }else {
            return ObjEnvelop.getError("登录失败");
            return failed("登录失败");
        }
        }
    }
    }
@ -106,10 +118,10 @@ public class LoginController extends EnvelopRestEndpoint {
            @ApiParam(name = "userCode", value = "用户code", required = true)@RequestParam(required = true, name = "userCode") String userCode) {
            @ApiParam(name = "userCode", value = "用户code", required = true)@RequestParam(required = true, name = "userCode") String userCode) {
        try {
        try {
            //修改用户状态  离线
            //修改用户状态  离线
           return ObjEnvelop.getSuccess("登出成功");
           return success("登出成功");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return ObjEnvelop.getError("登出成功:" + e.getMessage(), -1);
            return failed("登出失败");
        }
        }
    }
    }
@ -118,31 +130,68 @@ public class LoginController extends EnvelopRestEndpoint {
    @PostMapping("/mobile/manage/login")
    @PostMapping("/mobile/manage/login")
    @ApiOperation(value = "【管理员】-手机验证登录")
    @ApiOperation(value = "【管理员】-手机验证登录")
    public ObjEnvelop administratorMobileLogin(
    public Envelop administratorMobileLogin(
            HttpServletRequest request,
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha) throws ManageException, ParseException {
            @ApiParam(name = "captcha", value = "短信验证码", required = true)@RequestParam(required = true, name = "captcha") String captcha) throws ParseException {
        if (wlyyRedisVerifyCodeService.verification(clientId, username, captcha)) {
        if (wlyyRedisVerifyCodeService.verification(clientId, username, captcha)) {
            User user = loginService.managerPhoneLogin(request,username);
            return ObjEnvelop.getSuccess("登录成功",user);
            User user = null;
            try {
                user = loginService.managerPhoneLogin(request,username);
            } catch (ManageException e) {
                return failed(e.getMessage());
            }
            return success("登录成功",user);
        } else {
        } else {
            return ObjEnvelop.getError("验证码错误");
            return failed("验证码错误");
        }
        }
    }
    }
    @PostMapping("/manage/login")
    @PostMapping("/manage/login")
    @ApiOperation(value = "【管理员】-用户账号登陆")
    @ApiOperation(value = "【管理员】-用户账号登陆")
    public ObjEnvelop administratorLogin(
    public Envelop administratorLogin(
            HttpServletRequest request,
            HttpServletRequest request,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "clientId", value = "应用id", required = true)@RequestParam(required = true, name = "clientId") String clientId,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "username", value = "账号", required = true)@RequestParam(required = true, name = "username") String username,
            @ApiParam(name = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
            @ApiParam(name = "password", value = "密码", required = true)@RequestParam(required = true, name = "password") String password) throws ManageException {
        User user = loginService.managerLogin(request,clientId,username, password);
        User user = loginService.managerLogin(request,clientId,username, password);
        if (user !=null) {
        if (user !=null) {
            return ObjEnvelop.getSuccess("登录成功",user);
            return success("登录成功",user);
        }else {
            return failed("登录失败");
        }
    }
    @GetMapping(value = "/getRandomImageCode")
    @ApiOperation(value = "修改密码时生成图形验证码",notes = "修改密码时生成图形验证码")
    public Envelop getImageCode (HttpServletRequest request, HttpServletResponse response)throws Exception{
        try {
            response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
            response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expire", 0);
            RandomValidateCode randomValidateCode = new RandomValidateCode();
            randomValidateCode.getRandcode(request, response);//输出验证码图片方法
            return success("获取验证码成功");
        } catch (Exception e) {
            return failed("获取验证码失败");
        }
    }
    @PostMapping(value = "/checkRandomImageCode")
    @ApiOperation(value = "检验图片验证码",notes = "检验图片验证码")
    public Envelop checkImageCode(@ApiParam(name = "code",value = "输入的验证码")@RequestParam(value = "code",required = true)String code,
                                     HttpServletRequest request){
        if (StringUtils.isEmpty(code)){
            return failed("请输入验证码!");
        }
        String codeRescource = String.valueOf(request.getSession().getAttribute(RandomValidateCode.RANDOMCODEKEY));
        if (code.toLowerCase().equals(codeRescource.toLowerCase())){
            request.getSession().removeAttribute(RandomValidateCode.RANDOMCODEKEY);
            return success("验证码正确!");
        }else {
        }else {
            return ObjEnvelop.getError("登录失败");
            return failed("验证码错误!");
        }
        }
    }
    }

+ 4 - 4
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesController.java

@ -287,7 +287,7 @@ public class FacilitiesController extends EnvelopRestEndpoint {
    @PostMapping(value = "/batchImport")
    @PostMapping(value = "/batchImport")
    @ApiOperation(value = "设施列表导入(经纬度重复的不导入)")
    @ApiOperation(value = "设施列表导入(经纬度重复的不导入)")
    public ObjEnvelop importData(
    public Envelop importData(
            @ApiParam(name = "file", value = "文件", required = true)
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            @RequestPart(value = "file") MultipartFile file,
            HttpServletRequest request) throws IOException, ManageException {
            HttpServletRequest request) throws IOException, ManageException {
@ -298,13 +298,13 @@ public class FacilitiesController extends EnvelopRestEndpoint {
            List<FacilityMsg> dataList = excelReader.getCorrectLs();
            List<FacilityMsg> dataList = excelReader.getCorrectLs();
            if (dataList.size() > 0) {
            if (dataList.size() > 0) {
                Map<String, Object> result = facilityService.batchInsertFacility(dataList);
                Map<String, Object> result = facilityService.batchInsertFacility(dataList);
                return ObjEnvelop.getSuccess("导入成功!", result);
                return success("导入成功!", result);
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            throw new ManageException("导入设施列表异常!", e);
            throw new ManageException("导入设施列表异常!", e);
        }
        }
        return ObjEnvelop.getError("导入失败");
        return failed("导入失败");
    }
    }
    @ApiOperation(value = "获取设施列表--不分页(app)", responseContainer = "List")
    @ApiOperation(value = "获取设施列表--不分页(app)", responseContainer = "List")
@ -358,7 +358,7 @@ public class FacilitiesController extends EnvelopRestEndpoint {
        String filters = "createTime>=" + todayStart + ";createTime<=" + todayEnd;
        String filters = "createTime>=" + todayStart + ";createTime<=" + todayEnd;
        long countCreatedFacilitieToday = facilityService.getCount(filters);
        long countCreatedFacilitieToday = facilityService.getCount(filters);
        map.put("countCreatedFacilitieToday", countCreatedFacilitieToday);
        map.put("countCreatedFacilitieToday", countCreatedFacilitieToday);
        return ObjEnvelop.getSuccess("获取成功", map);
        return success("获取成功", map);
    }
    }

+ 49 - 12
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/UserController.java

@ -2,6 +2,7 @@ package com.yihu.jw.healthyhouse.controller.user;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.cache.WlyyRedisVerifyCodeService;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.service.user.UserService;
import com.yihu.jw.healthyhouse.service.user.UserService;
@ -16,6 +17,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import jxl.write.Colour;
import jxl.write.Colour;
import jxl.write.WritableCellFormat;
import jxl.write.WritableCellFormat;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.spi.ErrorCode;
import org.apache.log4j.spi.ErrorCode;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -75,7 +77,7 @@ public class UserController  extends EnvelopRestEndpoint {
    public ObjEnvelop userDetail(
    public ObjEnvelop userDetail(
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ) {
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ) {
        User user = userService.findById(userId);
        User user = userService.findById(userId);
        return ObjEnvelop.getSuccess("获取成功",user);
        return success("获取成功",user);
    }
    }
@ -83,7 +85,7 @@ public class UserController  extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取用户统计信息")
    @ApiOperation(value = "获取用户统计信息")
    public ObjEnvelop usedFacilityCount() {
    public ObjEnvelop usedFacilityCount() {
        Map<String, Long> userStatistics = userService.findUserStatistics();
        Map<String, Long> userStatistics = userService.findUserStatistics();
        return ObjEnvelop.getSuccess("获取成功",userStatistics);
        return success("获取成功",userStatistics);
    }
    }
    @ApiOperation(value = "新增/更新(idy已存在)用户信息")
    @ApiOperation(value = "新增/更新(idy已存在)用户信息")
@ -108,7 +110,7 @@ public class UserController  extends EnvelopRestEndpoint {
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
        userService.updateStatus(userId,operator, HouseUserContant.activated_lock,reason);
        userService.updateStatus(userId,operator, HouseUserContant.activated_lock,reason);
        return ObjEnvelop.getSuccess("冻结成功");
        return success("冻结成功");
    }
    }
@ -118,7 +120,7 @@ public class UserController  extends EnvelopRestEndpoint {
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "userId", value = "用户id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
            @ApiParam(name = "operator", value = "操作者ID", required = true)@RequestParam(required = true, name = "operator") String operator ) throws ManageException {
        userService.updateStatus(userId,operator, HouseUserContant.activated_active,null);
        userService.updateStatus(userId,operator, HouseUserContant.activated_active,null);
        return ObjEnvelop.getSuccess("激活成功");
        return success("激活成功");
    }
    }
    @PostMapping("/updatePwd")
    @PostMapping("/updatePwd")
@ -129,7 +131,7 @@ public class UserController  extends EnvelopRestEndpoint {
            @ApiParam(name = "newPwd", value = "新密码", required = true)@RequestParam(required = true, name = "newPwd") String newPwd ) throws ManageException {
            @ApiParam(name = "newPwd", value = "新密码", required = true)@RequestParam(required = true, name = "newPwd") String newPwd ) throws ManageException {
        userService.updatePwd(userId,oldPwd,newPwd);
        userService.updatePwd(userId,oldPwd,newPwd);
        return ObjEnvelop.getSuccess("更新密码成功");
        return success("更新密码成功");
    }
    }
    @PostMapping("/updatePhone")
    @PostMapping("/updatePhone")
@ -143,20 +145,21 @@ public class UserController  extends EnvelopRestEndpoint {
        //验证码
        //验证码
        if (wlyyRedisVerifyCodeService.verification(clientId, newPhone, captcha)) {
        if (wlyyRedisVerifyCodeService.verification(clientId, newPhone, captcha)) {
            userService.updateSecurePhone(userId,newPhone);
            userService.updateSecurePhone(userId,newPhone);
            return ObjEnvelop.getSuccess("更新安全手机号码成功");
            return success("更新安全手机号码成功");
        } else {
        } else {
            return ObjEnvelop.getError("验证码错误");
            return failed("验证码错误");
        }
        }
    }
    }
    @PostMapping("/checkIdCardNo")
    @PostMapping("/checkIdCardNo")
    @ApiOperation(value = "用户身份证号码认证")
    @ApiOperation(value = "用户实名认证")
    public Envelop checkIdCardNo(
    public Envelop checkIdCardNo(
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "userId", value = "用户Id", required = true)@RequestParam(required = true, name = "userId") String userId ,
            @ApiParam(name = "name", value = "用户姓名", required = true)@RequestParam(required = true, name = "name") String name ,
            @ApiParam(name = "idCardNo", value = "身份证号码", required = true)@RequestParam(required = true, name = "idCardNo") String idCardNo ) throws ManageException {
            @ApiParam(name = "idCardNo", value = "身份证号码", required = true)@RequestParam(required = true, name = "idCardNo") String idCardNo ) throws ManageException {
        userService.checkIdCardNo(userId, idCardNo);
        return ObjEnvelop.getSuccess("身份证认证完成!");
        userService.checkIdCardNo(userId,name,idCardNo);
        return success("用户实名认证完成!");
    }
    }
    @GetMapping("/existence")
    @GetMapping("/existence")
@ -164,8 +167,42 @@ public class UserController  extends EnvelopRestEndpoint {
    public Envelop existence(
    public Envelop existence(
            @ApiParam(name = "telephone", value = "管理员账号", required = true)@RequestParam(required = true, name = "telephone") String telephone  ) throws ManageException {
            @ApiParam(name = "telephone", value = "管理员账号", required = true)@RequestParam(required = true, name = "telephone") String telephone  ) throws ManageException {
        userService.checkManageUser( telephone);
        return ObjEnvelop.getSuccess("该管理员账号存在!");
        boolean b = userService.checkManageUser(telephone);
        if (b) {
            return success("该管理员账号存在!",b);
        }else {
            return success("该管理员账号不存在!",b);
        }
    }
    @GetMapping("/findUserByPhoneOrName")
    @ApiOperation(value = "根据手机号或者用户查询用户",notes = "找回密码时验证")
    public Envelop findUserByPhoneOrName(
            @ApiParam(name = "loginName", value = "管理员登录账号", required = true)@RequestParam(required = true, name = "loginName") String loginName  ) throws ManageException {
        User user = userService.findByLoginCodeAndUserType(loginName, LoginInfo.USER_TYPE_SUPER_AdminManager);
        if (user != null) {
            return success("该管理员账号存在!",user);
        }else {
            return success("该管理员账号不存在!",user);
        }
    }
    @PostMapping(value = "/resetPassWord")
    @ApiOperation(value = "重设密码", notes = "根基传入的用户id和新的密码重设用户的密码")
    public Envelop resetPassWord(
            @ApiParam(name = "userId", value = "用户ID", defaultValue = "")
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "password", value = "密码", defaultValue = "")
            @RequestParam(value = "password") String password) {
        try {
            String resetPwd = userService.resetPwd(userId, password);
            return success("重设密码成功",password);
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
    }
    }

+ 1 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/facility/FacilityDao.java

@ -18,7 +18,7 @@ public interface FacilityDao extends JpaRepository<Facility, String> {
    Facility findById(String id);
    Facility findById(String id);
    Facility findByLongitudeAndLatitude(double longitude, double latitude);
    List<Facility> findByLongitudeAndLatitude(double longitude, double latitude);
    Facility findByCode(String code);
    Facility findByCode(String code);

+ 20 - 0
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/User.java

@ -69,6 +69,10 @@ public class User extends UuidIdentityEntityWithOperator {
    @Column(name = "ijk_authentication")
    @Column(name = "ijk_authentication")
    private String ijkAuthentication;//i健康认证
    private String ijkAuthentication;//i健康认证
    @Column(name = "organization_code")
    private String organizationCode;//机构编码
    @Column(name = "organization_name")
    private String organizationName;//机构名称
    public String getLoginCode() {
    public String getLoginCode() {
        return loginCode;
        return loginCode;
@ -254,6 +258,22 @@ public class User extends UuidIdentityEntityWithOperator {
        this.ijkAuthentication = ijkAuthentication;
        this.ijkAuthentication = ijkAuthentication;
    }
    }
    public String getOrganizationCode() {
        return organizationCode;
    }
    public void setOrganizationCode(String organizationCode) {
        this.organizationCode = organizationCode;
    }
    public String getOrganizationName() {
        return organizationName;
    }
    public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
    }
    @Transient
    @Transient
    public String getAddress() {
    public String getAddress() {
        String address = "";
        String address = "";

+ 2 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/facility/FacilityService.java

@ -57,8 +57,8 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
    public boolean isHasFacility(double longitude,double latitude){
    public boolean isHasFacility(double longitude,double latitude){
        boolean flag = false;
        boolean flag = false;
        Facility facility = facilityDao.findByLongitudeAndLatitude(longitude, latitude);
        if (facility!=null) {
        List<Facility> facilitys = facilityDao.findByLongitudeAndLatitude(longitude, latitude);
        if (facilitys!=null && facilitys.size()>0) {
            flag = true;
            flag = true;
        }
        }
        return flag;
        return flag;

+ 36 - 4
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/user/UserService.java

@ -204,6 +204,13 @@ public class UserService extends BaseJpaService<User, UserDao> {
    }
    }
    /**
     *  修改密码
     * @param userId    用户ID
     * @param oldPwd    原密码
     * @param newPwd    新密码
     * @throws ManageException
     */
    @Transactional
    @Transactional
    public void updatePwd(String userId, String oldPwd,String newPwd) throws ManageException {
    public void updatePwd(String userId, String oldPwd,String newPwd) throws ManageException {
        User user = findById(userId);
        User user = findById(userId);
@ -222,6 +229,26 @@ public class UserService extends BaseJpaService<User, UserDao> {
        userDao.save(user);
        userDao.save(user);
    }
    }
    /**
     *  重设密码
     * @param userId    用户ID
     * @param newPwd    新密码
     * @throws ManageException
     */
    @Transactional
    public String resetPwd(String userId, String newPwd) throws ManageException {
        User user = findById(userId);
        if (user==null) {
            throw new ManageException("该账号不存在");
        }
        String password = MD5.GetMD5Code(newPwd + user.getSalt());
        user.setPassword(password);
        userDao.save(user);
        return newPwd;
    }
    @Transactional
    @Transactional
    public void updateSecurePhone(String userId, String phone) throws ManageException {
    public void updateSecurePhone(String userId, String phone) throws ManageException {
        User user = findById(userId);
        User user = findById(userId);
@ -258,12 +285,13 @@ public class UserService extends BaseJpaService<User, UserDao> {
    }
    }
    /**
    /**
     *  用户身份证认证
     *  用户实名认证
     * @param userId    用户ID
     * @param userId    用户ID
     * @param name  用户姓名
     * @param idCardNo  身份证
     * @param idCardNo  身份证
     * @throws ManageException
     * @throws ManageException
     */
     */
    public void checkIdCardNo(String userId, String idCardNo) throws ManageException {
    public void checkIdCardNo(String userId,String name, String idCardNo) throws ManageException {
        User user1 = findById(userId);
        User user1 = findById(userId);
        if (user1==null) {
        if (user1==null) {
            throw new ManageException("该账号不存在");
            throw new ManageException("该账号不存在");
@ -273,6 +301,8 @@ public class UserService extends BaseJpaService<User, UserDao> {
        }
        }
        // 更新身份证验证字段
        // 更新身份证验证字段
        user1.setRealnameAuthentication(UserConstant.AUTHORIZED);
        user1.setRealnameAuthentication(UserConstant.AUTHORIZED);
        user1.setIdCardNo(idCardNo);
        user1.setName(name);
        userDao.save(user1);
        userDao.save(user1);
    }
    }
@ -281,10 +311,12 @@ public class UserService extends BaseJpaService<User, UserDao> {
     * @param userCode   登录账号
     * @param userCode   登录账号
     * @throws ManageException
     * @throws ManageException
     */
     */
    public void checkManageUser(String userCode) throws ManageException {
    public boolean checkManageUser(String userCode) throws ManageException {
        User user1 = findByLoginCodeAndUserType(userCode, LoginInfo.USER_TYPE_SUPER_AdminManager);
        User user1 = findByLoginCodeAndUserType(userCode, LoginInfo.USER_TYPE_SUPER_AdminManager);
        if (user1==null) {
        if (user1==null) {
            throw new ManageException("该管理员账号不存在");
            return false;
        }else {
            return true;
        }
        }
    }
    }

+ 1 - 1
svr/svr-healthy-house/src/main/resources/application.yml

@ -80,7 +80,7 @@ fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://172.19.103.54:80/
# 短信发送地址
# 短信发送地址
jw:
jw:
  smsUrl: http://svr-base-hzy:10020/sms_gateway/send
  smsUrl: http://svr-base:10020/sms_gateway/send
---
---
spring:
spring: