Browse Source

Merge branch 'dev' of yeshijie/jw2.0 into dev

yeshijie 6 years ago
parent
commit
660bf930ba
16 changed files with 1073 additions and 3 deletions
  1. 28 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/ModuleDO.java
  2. 170 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/SaasInterfaceDO.java
  3. 87 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/SaasInterfaceErrorCodeDO.java
  4. 137 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/SaasInterfaceParamDO.java
  5. 13 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/role/MenuDO.java
  6. 84 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/SaasInterfaceErrorCodeVO.java
  7. 134 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/SaasInterfaceParamVO.java
  8. 167 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/SaasInterfaceVO.java
  9. 10 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/MenuVO.java
  10. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/ModuleDao.java
  11. 14 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasInterfaceDao.java
  12. 15 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasInterfaceErrorCodeDao.java
  13. 13 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasInterfaceParamDao.java
  14. 7 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasModuleDao.java
  15. 7 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasTypeModuleDao.java
  16. 183 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/module/ModuleService.java

+ 28 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/ModuleDO.java

@ -103,6 +103,34 @@ public class ModuleDO extends UuidIdentityEntityWithOperator {
		}
	}
    public enum End {
        have("有子节点", 0),
        no("没有子节点", 1);
        private String name;
        private Integer value;
        End(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 name;
	//模块连接

+ 170 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/SaasInterfaceDO.java

@ -0,0 +1,170 @@
package com.yihu.jw.entity.base.module;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/**
 * 租户接口
 * @author yeshijie on 2018/10/11.
 */
@Entity
@Table(name = "base_saas_interface")
public class SaasInterfaceDO extends UuidIdentityEntity {
    private String name;//接口名称
    private String saasId;//saas_id
    private String interfaceId;//接口id
    private String moduleId;//模块id
    private String moduleName;//模块名称
    private String methodName;//方法名
    private Integer protocolType;//协议类型(2restful,1webservice)
    private Integer openLevel;//开发程度(1公开,2私有)
    private Integer checkLevel;//审计程度(1审计,2不审计)
    private Integer status;//状态(1生效中,0已失效)
    private String remark;//接口说明
    private String url;//https请求地址
    private List<SaasInterfaceParamDO> entryParams;//入参
    private List<SaasInterfaceParamDO> outParams;//出参
    private List<SaasInterfaceErrorCodeDO> errorCodes;//错误说明
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "interface_id")
    public String getInterfaceId() {
        return interfaceId;
    }
    public void setInterfaceId(String interfaceId) {
        this.interfaceId = interfaceId;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "module_id")
    public String getModuleId() {
        return moduleId;
    }
    public void setModuleId(String moduleId) {
        this.moduleId = moduleId;
    }
    @Column(name = "module_name")
    public String getModuleName() {
        return moduleName;
    }
    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }
    @Column(name = "method_name")
    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
    @Column(name = "protocol_type")
    public Integer getProtocolType() {
        return protocolType;
    }
    public void setProtocolType(Integer protocolType) {
        this.protocolType = protocolType;
    }
    @Column(name = "open_level")
    public Integer getOpenLevel() {
        return openLevel;
    }
    public void setOpenLevel(Integer openLevel) {
        this.openLevel = openLevel;
    }
    @Column(name = "check_level")
    public Integer getCheckLevel() {
        return checkLevel;
    }
    public void setCheckLevel(Integer checkLevel) {
        this.checkLevel = checkLevel;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Transient
    public List<SaasInterfaceParamDO> getEntryParams() {
        return entryParams;
    }
    public void setEntryParams(List<SaasInterfaceParamDO> entryParams) {
        this.entryParams = entryParams;
    }
    @Transient
    public List<SaasInterfaceParamDO> getOutParams() {
        return outParams;
    }
    public void setOutParams(List<SaasInterfaceParamDO> outParams) {
        this.outParams = outParams;
    }
    @Transient
    public List<SaasInterfaceErrorCodeDO> getErrorCodes() {
        return errorCodes;
    }
    public void setErrorCodes(List<SaasInterfaceErrorCodeDO> errorCodes) {
        this.errorCodes = errorCodes;
    }
}

+ 87 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/SaasInterfaceErrorCodeDO.java

@ -0,0 +1,87 @@
package com.yihu.jw.entity.base.module;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 接口错误说明
 * @author yeshijie on 2018/10/11.
 */
@Entity
@Table(name = "base_saas_interface_error_code")
public class SaasInterfaceErrorCodeDO extends UuidIdentityEntity {
    private String saasId;//saas_id
    private String saasInterfaceId;//接口id
    private String name;//错误码名称
    private String description;//错误码描述
    private String solution;//解决方案
    private Integer sort;//排序
    private Integer del;//删除标志
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "saas_interface_id")
    public String getSaasInterfaceId() {
        return saasInterfaceId;
    }
    public void setSaasInterfaceId(String saasInterfaceId) {
        this.saasInterfaceId = saasInterfaceId;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name = "solution")
    public String getSolution() {
        return solution;
    }
    public void setSolution(String 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;
    }
}

+ 137 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/SaasInterfaceParamDO.java

@ -0,0 +1,137 @@
package com.yihu.jw.entity.base.module;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 接口入参出参
 * @author yeshijie on 2018/10/11.
 */
@Entity
@Table(name = "base_saas_interface_param")
public class SaasInterfaceParamDO extends UuidIdentityEntity {
    private String saasId;//saas_id
    private String saasInterfaceId;//接口id
    private String name;//参数名
    private Integer paramType;//参数类型
    private Integer dataType;//数据类型
    private Integer isRequire;//是否必填(1是,0否)
    private Integer maxLength;//最大长度
    private String description;//描述
    private String example;//示例
    private Integer type;//类型(1入参,2出参)
    private Integer sort;//排序
    private Integer del;//删除标志
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "saas_interface_id")
    public String getSaasInterfaceId() {
        return saasInterfaceId;
    }
    public void setSaasInterfaceId(String saasInterfaceId) {
        this.saasInterfaceId = saasInterfaceId;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "param_type")
    public Integer getParamType() {
        return paramType;
    }
    public void setParamType(Integer paramType) {
        this.paramType = paramType;
    }
    @Column(name = "data_type")
    public Integer getDataType() {
        return dataType;
    }
    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }
    @Column(name = "is_require")
    public Integer getIsRequire() {
        return isRequire;
    }
    public void setIsRequire(Integer isRequire) {
        this.isRequire = isRequire;
    }
    @Column(name = "max_length")
    public Integer getMaxLength() {
        return maxLength;
    }
    public void setMaxLength(Integer maxLength) {
        this.maxLength = maxLength;
    }
    @Column(name = "description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name = "example")
    public String getExample() {
        return example;
    }
    public void setExample(String example) {
        this.example = example;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer 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;
    }
}

+ 13 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/role/MenuDO.java

@ -23,6 +23,10 @@ public class MenuDO extends UuidIdentityEntityWithOperator {
	 * 请求路径
	 */
	private String url;
	/**
	 * 菜单图标
	 */
	private String icon;
	/**
	 * 请求方式
	 */
@ -107,6 +111,15 @@ public class MenuDO extends UuidIdentityEntityWithOperator {
		this.url = url;
	}
	@Column(name = "icon")
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	@Column(name = "method")
	public String getMethod() {
		return method;

+ 84 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/SaasInterfaceErrorCodeVO.java

@ -0,0 +1,84 @@
package com.yihu.jw.restmodel.base.module;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * 接口错误说明
 * @author yeshijie on 2018/9/28.
 */
@ApiModel(value = "SaasInterfaceErrorCodeVO", description = "接口错误说明")
public class SaasInterfaceErrorCodeVO extends UuidIdentityVO {
    @ApiModelProperty(value = "saas_id", example = "saas_id")
    private String saasId;
    @ApiModelProperty(value = "接口id", example = "接口id")
    private String saasInterfaceId;
    @ApiModelProperty(value = "错误码名称", example = "错误码名称")
    private String name;
    @ApiModelProperty(value = "错误码描述", example = "错误码描述")
    private String description;
    @ApiModelProperty(value = "解决方案", example = "解决方案")
    private String solution;
    @ApiModelProperty(value = "排序", example = "1")
    private Integer sort;
    @ApiModelProperty(value = "删除标志", example = "1")
    private Integer del;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getSaasInterfaceId() {
        return saasInterfaceId;
    }
    public void setSaasInterfaceId(String saasInterfaceId) {
        this.saasInterfaceId = saasInterfaceId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getSolution() {
        return solution;
    }
    public void setSolution(String 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;
    }
}

+ 134 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/SaasInterfaceParamVO.java

@ -0,0 +1,134 @@
package com.yihu.jw.restmodel.base.module;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * 接口入参出参
 * @author yeshijie on 2018/10/11.
 */
@ApiModel(value = "SaasInterfaceParamVO", description = "接口入参出参")
public class SaasInterfaceParamVO extends UuidIdentityVO {
    @ApiModelProperty(value = "saas_id", example = "saas_id")
    private String saasId;
    @ApiModelProperty(value = "接口id", example = "接口id")
    private String saasInterfaceId;
    @ApiModelProperty(value = "参数名", example = "user")
    private String name;
    @ApiModelProperty(value = "参数类型", example = "HEADER")
    private Integer paramType;
    @ApiModelProperty(value = "数据类型", example = "VERCHAR")
    private Integer dataType;
    @ApiModelProperty(value = "是否必填(1是,0否)", example = "1")
    private Integer isRequire;
    @ApiModelProperty(value = "最大长度", example = "1")
    private Integer maxLength;
    @ApiModelProperty(value = "描述", example = "")
    private String description;
    @ApiModelProperty(value = "示例", example = "")
    private String example;
    @ApiModelProperty(value = "类型(1入参,2出参)", example = "1")
    private Integer type;
    @ApiModelProperty(value = "排序", example = "1")
    private Integer sort;
    @ApiModelProperty(value = "删除标志", example = "1")
    private Integer del;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getSaasInterfaceId() {
        return saasInterfaceId;
    }
    public void setSaasInterfaceId(String saasInterfaceId) {
        this.saasInterfaceId = saasInterfaceId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getParamType() {
        return paramType;
    }
    public void setParamType(Integer paramType) {
        this.paramType = paramType;
    }
    public Integer getDataType() {
        return dataType;
    }
    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }
    public Integer getIsRequire() {
        return isRequire;
    }
    public void setIsRequire(Integer isRequire) {
        this.isRequire = isRequire;
    }
    public Integer getMaxLength() {
        return maxLength;
    }
    public void setMaxLength(Integer maxLength) {
        this.maxLength = maxLength;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getExample() {
        return example;
    }
    public void setExample(String example) {
        this.example = example;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer 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;
    }
}

+ 167 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/module/SaasInterfaceVO.java

@ -0,0 +1,167 @@
package com.yihu.jw.restmodel.base.module;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
 * 租户接口
 * @author yeshijie on 2018/10/11.
 */
@ApiModel(value = "SaasInterfaceVO", description = "租户接口")
public class SaasInterfaceVO extends UuidIdentityVO {
    @ApiModelProperty(value = "saas_id", example = "saas_id")
    private String saasId;
    @ApiModelProperty(value = "接口id", example = "接口id")
    private String interfaceId;
    @ApiModelProperty(value = "接口名称", example = "接口1")
    private String name;
    @ApiModelProperty(value = "模块id", example = "模块1d")
    private String moduleId;
    @ApiModelProperty(value = "模块名称", example = "模块名称")
    private String moduleName;
    @ApiModelProperty(value = "方法名", example = "方法1")
    private String methodName;
    @ApiModelProperty(value = "协议类型(2restful,1webservice)", example = "1")
    private Integer protocolType;
    @ApiModelProperty(value = "开发程度(1公开,2私有)", example = "1")
    private Integer openLevel;
    @ApiModelProperty(value = "审计程度(1审计,2不审计)", example = "1")
    private Integer checkLevel;
    @ApiModelProperty(value = "状态(1生效中,0已失效)", example = "1")
    private Integer status;
    @ApiModelProperty(value = "接口说明", example = "明")
    private String remark;
    @ApiModelProperty(value = "https请求地址", example = "")
    private String url;
    @ApiModelProperty(value = "入参", example = "")
    private List<SaasInterfaceParamVO> entryParams;
    @ApiModelProperty(value = "出参", example = "")
    private List<SaasInterfaceParamVO> outParams;
    @ApiModelProperty(value = "错误说明", example = "")
    private List<SaasInterfaceErrorCodeVO> errorCodes;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getInterfaceId() {
        return interfaceId;
    }
    public void setInterfaceId(String interfaceId) {
        this.interfaceId = interfaceId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getModuleId() {
        return moduleId;
    }
    public void setModuleId(String moduleId) {
        this.moduleId = moduleId;
    }
    public String getModuleName() {
        return moduleName;
    }
    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }
    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
    public Integer getProtocolType() {
        return protocolType;
    }
    public void setProtocolType(Integer protocolType) {
        this.protocolType = protocolType;
    }
    public Integer getOpenLevel() {
        return openLevel;
    }
    public void setOpenLevel(Integer openLevel) {
        this.openLevel = openLevel;
    }
    public Integer getCheckLevel() {
        return checkLevel;
    }
    public void setCheckLevel(Integer checkLevel) {
        this.checkLevel = checkLevel;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public List<SaasInterfaceParamVO> getEntryParams() {
        return entryParams;
    }
    public void setEntryParams(List<SaasInterfaceParamVO> entryParams) {
        this.entryParams = entryParams;
    }
    public List<SaasInterfaceParamVO> getOutParams() {
        return outParams;
    }
    public void setOutParams(List<SaasInterfaceParamVO> outParams) {
        this.outParams = outParams;
    }
    public List<SaasInterfaceErrorCodeVO> getErrorCodes() {
        return errorCodes;
    }
    public void setErrorCodes(List<SaasInterfaceErrorCodeVO> errorCodes) {
        this.errorCodes = errorCodes;
    }
}

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/role/MenuVO.java

@ -17,6 +17,8 @@ public class MenuVO extends UuidIdentityVOWithOperator {
    private String name;
    @ApiModelProperty(value = "请求路径", example = "/usr/var")
    private String url;
    @ApiModelProperty(value = "菜单图标", example = "icon")
    private String icon;
//    @ApiModelProperty(value = "请求方式", example = "get,post")
//    private String method;
    @ApiModelProperty(value = "排序", example = "1")
@ -46,6 +48,14 @@ public class MenuVO extends UuidIdentityVOWithOperator {
        this.url = url;
    }
    public String getIcon() {
        return icon;
    }
    public void setIcon(String icon) {
        this.icon = icon;
    }
    public Integer getSort() {
        return sort;
    }

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/ModuleDao.java

@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Dao - 模块
 * Created by chenweida on 2017/5/19.
@ -18,4 +20,6 @@ public interface ModuleDao extends PagingAndSortingRepository<ModuleDO, String>,
    @Query("select count(*) from ModuleDO a where a.name = ?1 ")
    int isExistName(String name);
    List<ModuleDO> findByParentId(String parentId);
}

+ 14 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasInterfaceDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.SaasInterfaceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 租户接口
 * @author yeshijie on 2018/10/11.
 */
public interface SaasInterfaceDao extends PagingAndSortingRepository<SaasInterfaceDO, String>, JpaSpecificationExecutor<SaasInterfaceDO> {
}

+ 15 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasInterfaceErrorCodeDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.SaasInterfaceErrorCodeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 接口错误说明
 * @author yeshijie on 2018/10/11.
 */
public interface SaasInterfaceErrorCodeDao extends PagingAndSortingRepository<SaasInterfaceErrorCodeDO, String>,
        JpaSpecificationExecutor<SaasInterfaceErrorCodeDO> {
}

+ 13 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasInterfaceParamDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.SaasInterfaceParamDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 接口入参出参
 * @author yeshijie on 2018/10/11.
 */
public interface SaasInterfaceParamDao extends PagingAndSortingRepository<SaasInterfaceParamDO, String>, JpaSpecificationExecutor<SaasInterfaceParamDO> {
}

+ 7 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasModuleDao.java

@ -2,6 +2,8 @@ package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.SaasModuleDO;
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;
/**
@ -10,5 +12,10 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface SaasModuleDao extends PagingAndSortingRepository<SaasModuleDO, String>, JpaSpecificationExecutor<SaasModuleDO> {
    @Query("select count(*) from SaasModuleDO a where a.moduleId = ?1 ")
    int isExistModule(String moduleId);
    @Modifying
    @Query("delete from SaasModuleDO p where p.moduleId=?1 ")
    void deleteByModuleId(String moduleId);
}

+ 7 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/module/SaasTypeModuleDao.java

@ -2,6 +2,8 @@ package com.yihu.jw.base.dao.module;
import com.yihu.jw.entity.base.module.SaasTypeModuleDO;
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;
/**
@ -10,5 +12,10 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface SaasTypeModuleDao extends PagingAndSortingRepository<SaasTypeModuleDO, String>, JpaSpecificationExecutor<SaasTypeModuleDO> {
    @Query("select count(*) from SaasTypeModuleDO a where a.moduleId = ?1 ")
    int isExistModule(String moduleId);
    @Modifying
    @Query("delete from SaasTypeModuleDO p where p.moduleId=?1 ")
    void deleteByModuleId(String moduleId);
}

+ 183 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/module/ModuleService.java

@ -2,13 +2,25 @@ package com.yihu.jw.base.service.module;
import com.yihu.jw.base.contant.CommonContant;
import com.yihu.jw.base.dao.module.ModuleDao;
import com.yihu.jw.base.dao.module.SaasModuleDao;
import com.yihu.jw.base.dao.module.SaasTypeModuleDao;
import com.yihu.jw.base.dao.saas.SaasDao;
import com.yihu.jw.base.dao.saas.SaasTypeDictDao;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.module.SaasModuleDO;
import com.yihu.jw.entity.base.module.SaasTypeModuleDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
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.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Service - 模块
 * Created by chenweida on 2017/5/19.
@ -18,6 +30,14 @@ public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
    @Autowired
    private ModuleDao moduleDao;
    @Autowired
    private SaasModuleDao saasModuleDao;
    @Autowired
    private SaasTypeModuleDao saasTypeModuleDao;
    @Autowired
    private SaasTypeDictDao saasTypeDictDao;
    @Autowired
    private SaasDao saasDao;
    /**
     * 新增模块
@ -29,13 +49,128 @@ public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
        if(StringUtils.isBlank(moduleDO.getParentId())){
            moduleDO.setParentId(CommonContant.DEFAULT_PARENTID);
        }
        moduleDO.setDel(1);
        moduleDO.setIsEnd(1);
        moduleDao.save(moduleDO);
        //父节点设置非根节点
        if(!CommonContant.DEFAULT_PARENTID.equals(moduleDO.getParentId())){
            ModuleDO parentModule = moduleDao.findOne(moduleDO.getParentId());
            if(ModuleDO.End.no.getValue().equals(parentModule.getIsEnd())){
                parentModule.setIsEnd(ModuleDO.End.have.getValue());
                moduleDao.save(parentModule);
            }
        }
        //若新增某必选业务模块,则需为所有已创建的租户和租户类型添加此业务模块
        addSubModule(moduleDO);
        return moduleDO;
    }
    /**
     * 新增模块时,新增租户和租户类型的模块
     * @param moduleDO
     */
    public void addSubModule(ModuleDO moduleDO){
        if (ModuleDO.Must.must.getValue().equals(moduleDO.getIsMust())){
            //判断父模块是否必选
            boolean parentIsMust = true;
            ModuleDO parentModule = null;
            if(!CommonContant.DEFAULT_PARENTID.equals(moduleDO.getParentId())){
                parentModule = moduleDao.findOne(moduleDO.getParentId());
                if(ModuleDO.Must.nonMust.getValue().equals(parentModule.getIsMust())){
                    parentIsMust = false;
                }
            }
        }
            //租户类型
            Iterable<SaasTypeDictDO> saasTypeDictDOs = saasTypeDictDao.findAll();
            List<SaasTypeModuleDO> saasTypeModuleDOList = new ArrayList<>(16);
            while (saasTypeDictDOs.iterator().hasNext()){
                SaasTypeDictDO saasTypeDictDO = saasTypeDictDOs.iterator().next();
                SaasTypeModuleDO saasTypeModuleDO = new SaasTypeModuleDO();
                saasTypeModuleDO.setCreateTime(new Date());
                saasTypeModuleDO.setDel(moduleDO.getDel());
                saasTypeModuleDO.setStatus(moduleDO.getStatus());
                saasTypeModuleDO.setIsEnd(moduleDO.getIsEnd());
                saasTypeModuleDO.setIsMust(moduleDO.getIsMust());
                saasTypeModuleDO.setModuleId(moduleDO.getId());
                saasTypeModuleDO.setParentModuleId(moduleDO.getParentId());
                saasTypeModuleDO.setName(moduleDO.getName());
                saasTypeModuleDO.setRemark(moduleDO.getRemark());
                saasTypeModuleDO.setSaasTypeId(saasTypeDictDO.getId());
                saasTypeModuleDO.setType(moduleDO.getType());
                saasTypeModuleDO.setUrl(moduleDO.getUrl());
                saasTypeModuleDOList.add(saasTypeModuleDO);
        return moduleDO;
                //父模块非必选
                if(!parentIsMust){
                    int count = saasTypeModuleDao.isExistModule(parentModule.getId());
                    if(count==0){
                        SaasTypeModuleDO typeModuleDO = new SaasTypeModuleDO();
                        typeModuleDO.setCreateTime(new Date());
                        typeModuleDO.setDel(parentModule.getDel());
                        typeModuleDO.setStatus(parentModule.getStatus());
                        typeModuleDO.setIsEnd(parentModule.getIsEnd());
                        typeModuleDO.setIsMust(parentModule.getIsMust());
                        typeModuleDO.setModuleId(parentModule.getId());
                        typeModuleDO.setParentModuleId(parentModule.getParentId());
                        typeModuleDO.setName(parentModule.getName());
                        typeModuleDO.setRemark(parentModule.getRemark());
                        typeModuleDO.setSaasTypeId(saasTypeDictDO.getId());
                        typeModuleDO.setType(parentModule.getType());
                        typeModuleDO.setUrl(parentModule.getUrl());
                        saasTypeModuleDOList.add(typeModuleDO);
                    }
                }
            }
            saasTypeModuleDao.save(saasTypeModuleDOList);
            //租户
            Iterable<SaasDO> saasDOs = saasDao.findAll();
            List<SaasModuleDO> saasModuleDOList = new ArrayList<>(16);
            while (saasDOs.iterator().hasNext()){
                SaasDO saasDO = saasDOs.iterator().next();
                SaasModuleDO saasModuleDO = new SaasModuleDO();
                saasModuleDO.setCreateTime(new Date());
                saasModuleDO.setDel(moduleDO.getDel());
                saasModuleDO.setStatus(moduleDO.getStatus());
                saasModuleDO.setIsEnd(moduleDO.getIsEnd());
                saasModuleDO.setIsMust(moduleDO.getIsMust());
                saasModuleDO.setModuleId(moduleDO.getId());
                saasModuleDO.setParentModuleId(moduleDO.getParentId());
                saasModuleDO.setName(moduleDO.getName());
                saasModuleDO.setRemark(moduleDO.getRemark());
                saasModuleDO.setSaasId(saasDO.getId());
                saasModuleDO.setType(moduleDO.getType());
                saasModuleDO.setUrl(moduleDO.getUrl());
                saasModuleDOList.add(saasModuleDO);
                //父模块非必选
                if(!parentIsMust){
                    int count = saasModuleDao.isExistModule(parentModule.getId());
                    if(count==0){
                        SaasModuleDO saasModule = new SaasModuleDO();
                        saasModule.setCreateTime(new Date());
                        saasModule.setDel(parentModule.getDel());
                        saasModule.setStatus(parentModule.getStatus());
                        saasModule.setIsEnd(parentModule.getIsEnd());
                        saasModule.setIsMust(parentModule.getIsMust());
                        saasModule.setModuleId(parentModule.getId());
                        saasModule.setParentModuleId(parentModule.getParentId());
                        saasModule.setName(parentModule.getName());
                        saasModule.setRemark(parentModule.getRemark());
                        saasModule.setSaasId(saasDO.getId());
                        saasModule.setType(parentModule.getType());
                        saasModule.setUrl(parentModule.getUrl());
                        saasModuleDOList.add(saasModule);
                    }
                }
            }
            saasModuleDao.save(saasModuleDOList);
        }
    }
    /**
@ -45,9 +180,54 @@ public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
     */
    @Transactional(rollbackFor = Exception.class)
    public void updateStatus(String id,Integer status){
        moduleDao.updateStatus(id,status);
        ModuleDO moduleDO = moduleDao.findOne(id);
        //若原业务模块为失效/生效,操作生效/失效后的变更逻辑如以下流程图所示
        if(ModuleDO.Status.available.getValue().equals(status)){
            //生效
            available(moduleDO);
        }else {
            //失效
            unavailable(moduleDO);
        }
    }
    /**
     * 生效
     * @param moduleDO
     */
    public void available(ModuleDO moduleDO){
        moduleDO.setStatus(ModuleDO.Status.unAvailable.getValue());
        moduleDao.save(moduleDO);
        addSubModule(moduleDO);
        ModuleDO parentModule = moduleDao.findOne(moduleDO.getParentId());
        if(ModuleDO.Status.unAvailable.getValue().equals(parentModule.getStatus())){
            available(moduleDO);
        }
    }
    /**
     * 失效
     * @param moduleDO
     */
    public void unavailable(ModuleDO moduleDO){
        //把本身失效
        moduleDO.setStatus(ModuleDO.Status.unAvailable.getValue());
        moduleDao.save(moduleDO);
        saasTypeModuleDao.deleteByModuleId(moduleDO.getId());
        saasModuleDao.deleteByModuleId(moduleDO.getId());
        //把子类失效
        List<ModuleDO> moduleDOList = moduleDao.findByParentId(moduleDO.getId());
        moduleDOList.forEach(module->{
            if(ModuleDO.Status.available.getValue().equals(module.getStatus())){
                unavailable(moduleDO);
            }
        });
    }
    /**