Jelajahi Sumber

基础服务结构

Progr1mmer 6 tahun lalu
induk
melakukan
edb805de07
33 mengubah file dengan 688 tambahan dan 847 penghapusan
  1. 2 2
      common/common-entity/src/main/java/com/yihu/jw/entity/AssignedIdentityEntity.java
  2. 3 2
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  3. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntity.java
  4. 2 0
      common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperator.java
  5. 25 59
      common/common-entity/src/main/java/com/yihu/jw/entity/base/function/FunctionDO.java
  6. 14 23
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/ModuleDO.java
  7. 1 10
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/OrganizationDO.java
  8. 2 2
      common/common-entity/src/main/java/com/yihu/jw/entity/base/saas/SaasDO.java
  9. 8 3
      common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictDO.java
  10. 9 2
      common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictEntryDO.java
  11. 10 34
      common/common-entity/src/main/java/com/yihu/jw/entity/base/theme/ThemeDO.java
  12. 47 83
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  13. 12 8
      common/common-web/src/main/java/com/yihu/jw/web/endpoint/EnvelopRestEndpoint.java
  14. 1 1
      common/common-web/src/main/java/com/yihu/jw/web/model/MixEnvelop.java
  15. 89 0
      common/common-web/src/main/java/com/yihu/jw/web/model/PageEnvelop.java
  16. 1 1
      svr/svr-base/src/main/java/com/yihu/SvrBaseApplication.java
  17. 12 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/ModuleDao.java
  18. 2 8
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/SaasDao.java
  19. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/SystemDictDao.java
  20. 10 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/ThemeDao.java
  21. 94 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/ModuleEndpoint.java
  22. 61 72
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/SaasEndpoint.java
  23. 93 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/SystemDictEndpoint.java
  24. 106 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/ThemeEndpoint.java
  25. 52 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/ModuleService.java
  26. 5 50
      svr/svr-base/src/main/java/com/yihu/jw/base/service/SaasService.java
  27. 5 2
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictService.java
  28. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/ThemeService.java
  29. 0 162
      svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/ModuleController.java
  30. 0 17
      svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/FunctionDao.java
  31. 0 28
      svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/ModuleDao.java
  32. 1 135
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/FunctionService.java
  33. 0 141
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/ModuleService.java

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/AssignedIdentityEntity.java

@ -16,8 +16,8 @@ public abstract class AssignedIdentityEntity implements Serializable {
    protected String id;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "assigned")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "assigned")
    @Column(name = "id", unique = true, nullable = false)
    public String getId() {
        return id;

+ 3 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -7,6 +7,7 @@ import javax.persistence.*;
import java.io.Serializable;
/**
 * Integer类型的主键基类
 * Created by progr1mmer on 2018/8/13.
 */
@MappedSuperclass
@ -16,8 +17,8 @@ public abstract class IntegerIdentityEntity implements Serializable {
    protected Integer id;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "identity")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntity.java

@ -27,6 +27,7 @@ public abstract class UuidIdentityEntity implements Serializable {
	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	@Column(name = "id", unique = true, nullable = false)
	public String getId() {
		return id;
	}

+ 2 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithOperator.java

@ -31,11 +31,13 @@ public abstract class UuidIdentityEntityWithOperator extends UuidIdentityEntity
	protected Date createTime;
	//创建者
	protected String createUser;
	//创建者
	protected String createUserName;
	//更新时间
	protected Date updateTime;
	//更新者
	protected String updateUser;
	//更新者
	protected String updateUserName;
	@CreatedDate

+ 25 - 59
common/common-entity/src/main/java/com/yihu/jw/entity/base/function/FunctionDO.java

@ -1,4 +1,4 @@
package com.yihu.jw.entity.base.function;// default package
package com.yihu.jw.entity.base.function;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
@ -7,33 +7,25 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;
/**
 * WlyyFunction entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "base_function")
public class FunctionDO extends UuidIdentityEntityWithOperator implements java.io.Serializable {
    // Fields
    private String name; //功能名称
    private String url;//功能对应的后台url路径
    private String saasId; // saasid
    private String parentCode; //父功能code
    private Integer status; //状态 -1 删除 0 禁用 可用
    private String remark; //备注
    private List<FunctionDO> children = new ArrayList<>();
    private String text;//用于jstree显示
    // Constructors
    /**
     * default constructor
     */
    public FunctionDO() {
    }
public class FunctionDO extends UuidIdentityEntityWithOperator {
    //功能名称
    private String name;
    //网关url前缀
    private String prefix;
    //功能对应的后台url路径
    private String url;
    //备注
    private String remark;
    //用于jstree显示
    private String text;
    @Column(name = "name", length = 200)
    public String getName() {
@ -44,42 +36,16 @@ public class FunctionDO extends UuidIdentityEntityWithOperator implements java.i
        this.name = name;
    }
    @Column(name = "saas_id", length = 100)
    public String getSaasId() {
        return this.saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "parent_code", length = 100)
    public String getParentCode() {
        return this.parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    @Column(name = "status", precision = 2, scale = 0)
    public Integer getStatus() {
        return this.status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "remark", length = 1000)
    public String getRemark() {
        return this.remark;
    @Column(name = "prefix")
    public String getPrefix() {
        return prefix;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
@ -88,13 +54,13 @@ public class FunctionDO extends UuidIdentityEntityWithOperator implements java.i
        this.url = url;
    }
    @Transient
    public List<FunctionDO> getChildren() {
        return children;
    @Column(name = "remark")
    public String getRemark() {
        return this.remark;
    }
    public void setChildren(List<FunctionDO> children) {
        this.children = children;
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Transient

+ 14 - 23
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/ModuleDO.java

@ -17,34 +17,25 @@ import java.util.List;
public class ModuleDO extends UuidIdentityEntityWithOperator {
    public enum Status {
        delete,
        disable,
        available;
		disable,
		available,
		delete
    }
	private String saasId; //关联 Saas id
	private String name; //模块名称
	private String parentId; //父id
	private Status status; //0删除 1禁用 2可用
	private String remark; //备注
	private String state ;  //closed:表示有子节点   open:表示没有子节点
	//模块名称
	private String name;
	//父id
	private String parentId;
	//0-禁用,1-可用,2-不可用
	private Status status;
	//备注
	private String remark;
	//closed-表示有子节点,open-表示没有子节点
	private String state ;
	private List<ModuleDO> children = new ArrayList<>();
	// Constructors
	/** default constructor */
	public ModuleDO() {
	}
    @Column(name = "saas_id", length = 100)
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "name", length = 200)
    public String getName() {
        return this.name;
@ -54,7 +45,7 @@ public class ModuleDO extends UuidIdentityEntityWithOperator {
        this.name = name;
    }
    @Column(name = "parent_id", length = 100)
    @Column(name = "parent_id", length = 50)
	public String getParentId() {
		return parentId;
	}

+ 1 - 10
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/OrganizationDO.java

@ -10,9 +10,8 @@ import javax.persistence.Table;
 */
@Entity
@Table(name = "base_organization")
public class OrganizationDO extends UuidIdentityEntity {
public class Organization extends UuidIdentityEntity {
    private String saasId; //SAAS ID
    private String name; //名称
    private String code; //编码
    private String logo; //图片URL
@ -28,14 +27,6 @@ public class OrganizationDO extends UuidIdentityEntity {
    private Integer community; //社区
    private String communityName; //社区名称
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/base/saas/SaasDO.java

@ -16,10 +16,10 @@ import javax.persistence.Table;
public class SaasDO extends UuidIdentityEntityWithOperator {
    public enum Status {
        delete,
        auditWait,
        auditPassed,
        auditNotPassed
        auditNotPassed,
		delete
    }
	public enum Type {

+ 8 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictDO.java

@ -1,7 +1,8 @@
package com.yihu.jw.entity.base.system;// default package
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -10,7 +11,7 @@ import javax.persistence.Table;
 */
@Entity
@Table(name = "system_dict")
public class SystemDictDO extends UuidIdentityEntity implements java.io.Serializable {
public class SystemDictDO extends IntegerIdentityEntity {
	public enum Type {
		//基础字典
@ -31,7 +32,7 @@ public class SystemDictDO extends UuidIdentityEntity implements java.io.Serializ
	//类型
	private Type type;
	@Column(name = "saas_id")
	public String getSaasId() {
		return saasId;
	}
@ -40,6 +41,7 @@ public class SystemDictDO extends UuidIdentityEntity implements java.io.Serializ
		this.saasId = saasId;
	}
	@Column(name = "code", nullable = false, length = 50)
	public String getCode() {
		return code;
	}
@ -48,6 +50,7 @@ public class SystemDictDO extends UuidIdentityEntity implements java.io.Serializ
		this.code = code;
	}
	@Column(name = "py_code", nullable = false, length = 50)
	public String getPyCode() {
		return pyCode;
	}
@ -56,6 +59,7 @@ public class SystemDictDO extends UuidIdentityEntity implements java.io.Serializ
		this.pyCode = pyCode;
	}
	@Column(name = "name", nullable =  false, length = 50)
	public String getName() {
		return name;
	}
@ -64,6 +68,7 @@ public class SystemDictDO extends UuidIdentityEntity implements java.io.Serializ
		this.name = name;
	}
	@Column(name = "type", nullable = false)
	public Type getType() {
		return type;
	}

+ 9 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictEntryDO.java

@ -1,7 +1,8 @@
package com.yihu.jw.entity.base.system;// default package
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -10,7 +11,7 @@ import javax.persistence.Table;
 */
@Entity
@Table(name = "system_dict_entry")
public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Serializable {
public class SystemDictEntryDO extends IntegerIdentityEntity {
	//所属字典编码
	private String dictCode;
@ -25,6 +26,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Ser
	//备注
	private String remark;
	@Column(name = "dict_code", nullable = false, length = 50)
	public String getDictCode() {
		return dictCode;
	}
@ -33,6 +35,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Ser
		this.dictCode = dictCode;
	}
	@Column(name = "code", nullable = false, length = 50)
	public String getCode() {
		return code;
	}
@ -41,6 +44,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Ser
		this.code = code;
	}
	@Column(name = "py_code", nullable = false, length = 50)
	public String getPyCode() {
		return pyCode;
	}
@ -49,6 +53,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Ser
		this.pyCode = pyCode;
	}
	@Column(name = "value", nullable = false)
	public String getValue() {
		return value;
	}
@ -57,6 +62,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Ser
		this.value = value;
	}
	@Column(name = "sort")
	public Integer getSort() {
		return sort;
	}
@ -65,6 +71,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity implements java.io.Ser
		this.sort = sort;
	}
	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

+ 10 - 34
common/common-entity/src/main/java/com/yihu/jw/entity/base/theme/ThemeDO.java

@ -1,7 +1,8 @@
package com.yihu.jw.entity.base.theme;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -10,42 +11,17 @@ import javax.persistence.Table;
 */
@Entity
@Table(name = "base_theme")
public class ThemeDO extends UuidIdentityEntityWithOperator {
public class ThemeDO extends IntegerIdentityEntity {
    private String backgroundColor; //主体背景颜色
    private String fontColor; //主体字体颜色
    private String fontFamily; //主体字体系列
    private Integer fontSize; //主体字体大小
    //主题风格
    private String style;
    public String getBackgroundColor() {
        return backgroundColor;
    @Column(name = "style", nullable = false)
    public String getStyle() {
        return style;
    }
    public void setBackgroundColor(String backgroundColor) {
        this.backgroundColor = backgroundColor;
    }
    public String getFontColor() {
        return fontColor;
    }
    public void setFontColor(String fontColor) {
        this.fontColor = fontColor;
    }
    public String getFontFamily() {
        return fontFamily;
    }
    public void setFontFamily(String fontFamily) {
        this.fontFamily = fontFamily;
    }
    public Integer getFontSize() {
        return fontSize;
    }
    public void setFontSize(Integer fontSize) {
        this.fontSize = fontSize;
    public void setStyle(String style) {
        this.style = style;
    }
}

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

@ -6,8 +6,51 @@ package com.yihu.jw.rm.base;
 */
public class BaseRequestMapping {
    @Deprecated
    public static final String api_base_common = "/svr-bases";
    /**
     * 基础请求地址
     */
    private abstract static class Basic {
        public static final String CREATE =  "/create";
        public static final String DELETE = "/delete";
        public static final String UPDATE = "/update";
        public static final String PAGE = "/page";
        public static final String LIST = "/list";
    }
    /**
     * SAAS
     */
    public static class Saas extends Basic {
        public static final String PREFIX  = "/saas";
        public static final String AUDIT  = "/audit";
    }
    /**
     * 模块
     */
    public static class Module extends Basic {
        public static final String PREFIX  = "/module";
    }
    /**
     * 主题
     */
    public static class Theme extends Basic {
        public static final String PREFIX  = "/theme";
        public static final String CHECK_STYLE = "/check_style";
    }
    /**
     * 系统字典
     */
    public static class SystemDict extends Basic {
        public static final String PREFIX  = "/system_dict";
    }
    //功能模块常量
    public static class Function{
        public static final String message_success_create="function create success";
@ -17,14 +60,10 @@ public class BaseRequestMapping {
        public static final String message_success_delete="function delete success";
        public static final String message_success_assign_function=" assign function create success";
        public static final String message_success_find_functions_module="moduleFunctions find success";
        public static final String message_fail_name_exist="function name exist";
        public static final String message_fail_name_is_null="function is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist=" no exist";
        public static final String api_create="/function";
        public static final String api_update="/function";
        public static final String api_delete="/function/{ids}";
@ -36,91 +75,13 @@ public class BaseRequestMapping {
        public static final String api_getChildren="/function/children/{id}";
    }
    //模块常量
    public static class Module{
        public static final String message_success_create="Module create success";
        public static final String message_success_update="Module update success";
        public static final String message_success_find="Module find success";
        public static final String message_success_find_Modules="Module find success";
        public static final String message_success_delete="Module delete success";
        public static final String message_success_assign_module=" assign Module create success";
        public static final String message_fail_name_exist=" name exist";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_saasid_is_null="saasid is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist="id no exist";
        public static final String api_create="/module";
        public static final String api_update="/module";
        public static final String api_delete="/module/{ids}";
        public static final String api_getById="/module/{id}";
        public static final String api_getListNoPage="/module/listNoPage";
        public static final String api_getList="/module/list";
        public static final String api_getChildren="/module/children/{id}";
    }
    public static class ModuleFun{
        public static final String api_getExistFun = "/moduleFun/existFunc/{id}";
        public static final String api_changeFun="/moduleFun/changeFun";
        public static final String moduleId_is_null="moduleId is null";
        public static final String funIds_is_null="funIds is null";
    }
    //saas常量
    public static class Saas{
        public static final String message_success_create="saas create success";
        public static final String message_success_update="saas update success";
        public static final String message_success_find="saas find success";
        public static final String message_success_find_saass="saas find success";
        public static final String message_success_delete="saas delete success";
        public static final String message_fail_name_exist="saas name exist";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist="id no exist";
        public static final String api_create="/saas";
        public static final String api_update="/saas";
        public static final String api_delete="/saas";
        public static final String api_getById="/getById";
        public static final String api_getSaass="/getSaass";
        public static final String api_getSaassNoPage="/getSaassNoPage";
    }
    //SystemDict常量
    public static class SystemDict{
        public static final String message_success_create="SystemDict create success";
        public static final String message_success_update="SystemDict update success";
        public static final String message_success_find="SystemDict find success";
        public static final String message_success_find_saass="SystemDict find success";
        public static final String message_success_delete="SystemDict delete success";
        public static final String message_fail_name_exist="SystemDict name exist";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist="id no exist";
        public static final String api_create="/systemDict";
        public static final String api_update="/systemDict";
        public static final String api_delete="/systemDict";
        public static final String api_getById="/getById";
        public static final String api_getList="/systemDict/list";
        public static final String api_getListNoPage="/systemDict/listNoPage";
    }
    //SystemDictList常量
    public static class SystemDictList{
        public static final String message_success_create="SystemDictList create success";
@ -144,8 +105,11 @@ public class BaseRequestMapping {
        public static final String api_getListNoPage="/systemDictList/listNoPage";
        public static final String api_getChildren="/systemDictList/children/{id}";
    }
/*
    //d行政人员模块
    public static class Employee{

+ 12 - 8
common/common-web/src/main/java/com/yihu/jw/web/endpoint/EnvelopRestEndpoint.java

@ -1,10 +1,7 @@
package com.yihu.jw.web.endpoint;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.web.model.Envelop;
import com.yihu.jw.web.model.ListEnvelop;
import com.yihu.jw.web.model.MixEnvelop;
import com.yihu.jw.web.model.ObjEnvelop;
import com.yihu.jw.web.model.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
@ -65,16 +62,23 @@ public abstract class EnvelopRestEndpoint {
        return listEnvelop;
    }
    protected <T> MixEnvelop success(List<T> contents, int totalCount, int currPage, int pageSize) {
    protected <T> PageEnvelop success(List<T> contents, int totalCount, int currPage, int pageSize) {
        return success(contents, "success", totalCount, currPage, pageSize);
    }
    protected <T> MixEnvelop success(List<T> contents, String desc, int totalCount, int currPage, int pageSize) {
    protected <T> PageEnvelop success(List<T> contents, String desc, int totalCount, int currPage, int pageSize) {
        return success(contents, desc, 200, totalCount, currPage, pageSize);
    }
    protected <T> MixEnvelop success(List<T> contents, String desc, int code, int totalCount, int currPage, int pageSize) {
        return success(contents, null, desc, code, totalCount, currPage, pageSize);
    protected <T> PageEnvelop success(List<T> contents, String desc, int code, int totalCount, int currPage, int pageSize) {
        PageEnvelop<T> pageEnvelop = new PageEnvelop();
        pageEnvelop.setDesc(desc);
        pageEnvelop.setCode(code);
        pageEnvelop.setCurrPage(currPage);
        pageEnvelop.setPageSize(pageSize);
        pageEnvelop.setTotalCount(totalCount);
        pageEnvelop.setContents(contents);
        return pageEnvelop;
    }
    protected <T, J> MixEnvelop success(List<T> contents, J obj) {

+ 1 - 1
common/common-web/src/main/java/com/yihu/jw/web/model/MixEnvelop.java

@ -24,7 +24,7 @@ import java.util.List;
 * @author llh
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "ListResult", description = "通用的实体")
@ApiModel(value = "MixEnvelop", description = "通用的实体")
public class MixEnvelop<T, J> extends Envelop {
    @ApiModelProperty("当前页")

+ 89 - 0
common/common-web/src/main/java/com/yihu/jw/web/model/PageEnvelop.java

@ -0,0 +1,89 @@
package com.yihu.jw.web.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
 * 信封对象,封装REST接口的返回值内容。包括:
 * - 页码
 * - 页大小
 * - 错误消息
 * - 错误代码
 * - 对象模型
 * <p>
 * 信封对象的返回场景:
 * - API使用者确实无法访问返回头,即一些语言库无法处理HTTP的响应消息,这时候需要以这种形式提供返回值。
 * - API需要支持交叉域请求(通过JSONP)。
 *
 * @author llh
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "PageEnvelop", description = "通用的实体")
public class PageEnvelop<T> extends Envelop {
    @ApiModelProperty("当前页")
    private int currPage = 1;
    @ApiModelProperty("每页大小 默认10")
    private int pageSize = 15;
    @ApiModelProperty("总共多少页")
    private int totalPage;
    @ApiModelProperty("总共多少数据")
    private int totalCount;
    @ApiModelProperty("列表内容")
    private List<T> contents = new ArrayList<>(0);
    public int getCurrPage() {
        return currPage;
    }
    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public int getTotalPage() {
        if (totalCount % pageSize == 0) {
            totalPage = totalCount / pageSize;
        } else {
            totalPage = totalCount / pageSize + 1;
        }
        return totalPage;
    }
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
    public int getTotalCount() {
        return totalCount;
    }
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
    public List<T> getContents() {
        return contents;
    }
    public void setContents(List<T> contents) {
        this.contents = contents;
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/SvrBaseApplication.java

@ -11,7 +11,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
 * localhost:10020/refresh  刷新当个微服务的配置 可以在需要刷新的bean上面@RefreshScope
 */
@SpringBootApplication
//@EnableJpaAuditing
@EnableJpaAuditing
public class SvrBaseApplication  extends SpringBootServletInitializer  {
    public static void main(String[] args)  {

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

@ -0,0 +1,12 @@
package com.yihu.jw.base.dao;
import com.yihu.jw.entity.base.module.ModuleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/19.
 */
public interface ModuleDao extends PagingAndSortingRepository<ModuleDO, String>, JpaSpecificationExecutor<ModuleDO> {
}

+ 2 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/dao/SaasDao.java

@ -1,20 +1,14 @@
package com.yihu.jw.base.dao;
import com.yihu.jw.entity.base.saas.SaasDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/19.
 */
public interface SaasDao extends PagingAndSortingRepository<SaasDO, String>, JpaSpecificationExecutor<SaasDO> {
    @Query("from SaasDO f where f.name=?1 and f.status=1")
    SaasDO findByName(String name);
public interface SaasDao extends PagingAndSortingRepository<SaasDO, String> {
    @Query("from SaasDO f where f.name=?1 and f.status=1 and f.id != ?2")
    SaasDO findByNameExcludeId(String name, String id);
    SaasDO findByName(String name);
    @Query("from SaasDO f where f.id=?1 and f.status=1")
    SaasDO findById(String id);
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/SystemDictDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.business.base.dao;
package com.yihu.jw.base.dao;
import com.yihu.jw.entity.base.system.SystemDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@ -7,5 +7,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public interface SystemDictDao extends PagingAndSortingRepository<SystemDictDO, String>, JpaSpecificationExecutor<SystemDictDO> {
public interface SystemDictDao extends PagingAndSortingRepository<SystemDictDO, Integer>, JpaSpecificationExecutor<SystemDictDO> {
}

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

@ -0,0 +1,10 @@
package com.yihu.jw.base.dao;
import com.yihu.jw.entity.base.theme.ThemeDO;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by progr1mmer on 2018/8/16.
 */
public interface ThemeDao extends PagingAndSortingRepository<ThemeDO, Integer> {
}

+ 94 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/ModuleEndpoint.java

@ -0,0 +1,94 @@
package com.yihu.jw.base.endpoint;
import com.yihu.jw.base.service.ModuleService;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.web.model.Envelop;
import com.yihu.jw.web.model.ListEnvelop;
import com.yihu.jw.web.model.ObjEnvelop;
import com.yihu.jw.web.model.PageEnvelop;
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;
/**
 * Created by progr1mmer on 2018/8/16.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.Module.PREFIX)
@Api(value = "模块管理", description = "模块管理服务接口", tags = {"wlyy基础服务 - 模块管理服务接口"})
public class ModuleEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ModuleService moduleService;
    @PostMapping(value = BaseRequestMapping.Module.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<ModuleDO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        ModuleDO module = toEntity(jsonData, ModuleDO.class);
        module = moduleService.save(module);
        return success(module);
    }
    @PostMapping(value = BaseRequestMapping.Module.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        moduleService.delete(ids);
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.Module.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        ModuleDO module = toEntity(jsonData, ModuleDO.class);
        if (null == module.getId()) {
            return failed("ID不能为空");
        }
        module = moduleService.save(module);
        return success(module);
    }
    @GetMapping(value = BaseRequestMapping.Module.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<ModuleDO> 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<ModuleDO> modules = moduleService.search(fields, filters, sorts, page, size);
        int count = (int)moduleService.getCount(filters);
        return success(modules, count, page, size);
    }
    @GetMapping(value = BaseRequestMapping.Module.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<ModuleDO> 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<ModuleDO> modules = moduleService.search(fields, filters, sorts);
        return success(modules);
    }
}

+ 61 - 72
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/SaasEndpoint.java

@ -2,11 +2,12 @@ package com.yihu.jw.base.endpoint;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.base.service.SaasService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.web.model.Envelop;
import com.yihu.jw.web.model.ListEnvelop;
import com.yihu.jw.web.model.ObjEnvelop;
import com.yihu.jw.web.model.PageEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -20,102 +21,90 @@ import java.util.List;
 * Created by chenweida on 2017/5/19.
 */
@RestController
@Api(value = "Saas配置模块", description = "Saas配置模块接口管理", tags = {"wlyy基础服务 - Saas配置模块接口管理"})
@RequestMapping(value = BaseRequestMapping.Saas.PREFIX)
@Api(value = "Saas管理", description = "Saas管理服务接口", tags = {"wlyy基础服务 - Saas管理服务接口"})
public class SaasEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private SaasService saasService;
    @PostMapping(value = BaseRequestMapping.Saas.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建Saas配置", notes = "创建单个Saas配置")
    @PostMapping(value = BaseRequestMapping.Saas.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<SaasDO> create (
            @ApiParam(name = "json_data", value = "Json数据")
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        SaasDO saas = toEntity(jsonData, SaasDO.class);
        saas = saasService.save(saas);
        return success(saas);
    }
//    @PutMapping(value = BaseRequestMapping.Saas.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改Saas配置", notes = "修改Saas配置")
//    public Envelop updateSaas(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            SaasDO saas = toEntity(jsonData, SaasDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_update, saasService.updateSaas(saas));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
    @DeleteMapping(value = BaseRequestMapping.Saas.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除Saas配置", notes = "删除Saas配置")
    public com.yihu.jw.restmodel.common.Envelop deleteSaas(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            saasService.deleteSaas(id);
            return com.yihu.jw.restmodel.common.Envelop.getSuccess(BaseRequestMapping.Saas.message_success_delete);
        } catch (ApiException e) {
            return com.yihu.jw.restmodel.common.Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    @PostMapping(value = BaseRequestMapping.Saas.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        saasService.delete(ids);
        return success("删除成功");
    }
    @GetMapping(value = BaseRequestMapping.Saas.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据code查找Saas配置", notes = "根据code查找Saas配置")
    public com.yihu.jw.restmodel.common.Envelop findByCode(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return com.yihu.jw.restmodel.common.Envelop.getSuccess(BaseRequestMapping.Saas.message_success_find, saasService.findById(id));
        } catch (ApiException e) {
            return com.yihu.jw.restmodel.common.Envelop.getError(e.getMessage(), e.getErrorCode());
    @PostMapping(value = BaseRequestMapping.Saas.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        SaasDO saas = toEntity(jsonData, SaasDO.class);
        if (null == saas.getId()) {
            return failed("ID不能为空");
        }
        saas = saasService.save(saas);
        return success(saas);
    }
    /*@RequestMapping(value = BaseRequestMapping.Saas.api_getSaass, method = RequestMethod.GET)
    @ApiOperation(value = "获取Saas配置列表(分页)")
    public Envelop getSaass(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
    @GetMapping(value = BaseRequestMapping.Saas.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SaasDO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<SaasDO> list = saasService.search(fields, filters, sorts, page, size);
        //获取总数
        long count = saasService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<SaasDO> mSaass = convertToModels(list, new ArrayList<>(list.size()), SaasDO.class, fields);
        return Envelop.getSuccessListWithPage(BaseRequestMapping.Saas.message_success_find_saass, mSaass, page, size, count);
    }*/
            @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<SaasDO> saas = saasService.search(fields, filters, sorts, page, size);
        int count = (int)saasService.getCount(filters);
        return success(saas, count, page, size);
    }
    @GetMapping(value = BaseRequestMapping.Saas.api_getSaassNoPage)
    @ApiOperation(value = "获取Saas配置列表,不分页")
    public ListEnvelop<SaasDO> getAppsNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,id,remark")
    @GetMapping(value = BaseRequestMapping.Saas.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<SaasDO> 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 = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<SaasDO> list = saasService.search(filters, sorts);
        return success(list);
        List<SaasDO> themes = saasService.search(fields, filters, sorts);
        return success(themes);
    }
    @PostMapping(value = BaseRequestMapping.Saas.AUDIT)
    @ApiOperation(value = "审核")
    public Envelop audit (
            @ApiParam(name = "id", value = "SaasId", required = true)
            @RequestParam(value = "id") String id,
            @ApiParam(name = "status", value = "状态", required = true)
            @RequestParam(value = "status") SaasDO.Status status) throws Exception {
        SaasDO saas = saasService.retrieve(id);
        if (null == saas) {
            return failed("无相关SAAS配置");
        }
        saas.setStatus(status);
        saasService.save(saas);
        return success("操作成功");
    }
}

+ 93 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/SystemDictEndpoint.java

@ -0,0 +1,93 @@
package com.yihu.jw.base.endpoint;
import com.yihu.jw.base.service.SystemDictService;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.web.model.Envelop;
import com.yihu.jw.web.model.ListEnvelop;
import com.yihu.jw.web.model.ObjEnvelop;
import com.yihu.jw.web.model.PageEnvelop;
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;
/**
 * Created by progr1mmer on 2018/8/16.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.SystemDict.PREFIX)
@Api(value = "系统字典", description = "系统字典服务接口", tags = {"wlyy基础服务 - 系统字典服务接口"})
public class SystemDictEndpoint extends EnvelopRestEndpoint {
    
    @Autowired
    private SystemDictService systemDictService;
    @PostMapping(value = BaseRequestMapping.SystemDict.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<SystemDictDO> create (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        SystemDictDO systemDict = toEntity(jsonData, SystemDictDO.class);
        systemDict = systemDictService.save(systemDict);
        return success(systemDict);
    }
    @PostMapping(value = BaseRequestMapping.SystemDict.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        systemDictService.delete(ids);
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.SystemDict.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        SystemDictDO systemDict = toEntity(jsonData, SystemDictDO.class);
        if (null == systemDict.getId()) {
            return failed("ID不能为空");
        }
        systemDict = systemDictService.save(systemDict);
        return success(systemDict);
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SystemDictDO> 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<SystemDictDO> systemDict = systemDictService.search(fields, filters, sorts, page, size);
        int count = (int)systemDictService.getCount(filters);
        return success(systemDict, count, page, size);
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<SystemDictDO> 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<SystemDictDO> themes = systemDictService.search(fields, filters, sorts);
        return success(themes);
    }
}

+ 106 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/ThemeEndpoint.java

@ -0,0 +1,106 @@
package com.yihu.jw.base.endpoint;
import com.yihu.jw.base.service.ThemeService;
import com.yihu.jw.entity.base.theme.ThemeDO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.web.model.Envelop;
import com.yihu.jw.web.model.ListEnvelop;
import com.yihu.jw.web.model.ObjEnvelop;
import com.yihu.jw.web.model.PageEnvelop;
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;
/**
 * Created by progr1mmer on 2018/8/16.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.Theme.PREFIX)
@Api(value = "主题应用", description = "主题应用服务接口", tags = {"wlyy基础服务 - 主题应用服务接口"})
public class ThemeEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ThemeService themeService;
    @PostMapping(value = BaseRequestMapping.Theme.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<ThemeDO> create (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        ThemeDO theme = toEntity(jsonData, ThemeDO.class);
        theme = themeService.save(theme);
        return success(theme);
    }
    @PostMapping(value = BaseRequestMapping.Theme.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete (
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids){
        themeService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.Theme.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        ThemeDO theme = toEntity(jsonData, ThemeDO.class);
        if (null == theme.getId()) {
            return failed("ID不能为空");
        }
        theme = themeService.save(theme);
        return success(theme);
    }
    @GetMapping(value = BaseRequestMapping.Theme.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<ThemeDO> 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<ThemeDO> themes = themeService.search(fields, filters, sorts, page, size);
        int count = (int)themeService.getCount(filters);
        return success(themes, count, page, size);
    }
    @GetMapping(value = BaseRequestMapping.Theme.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<ThemeDO> 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<ThemeDO> themes = themeService.search(fields, filters, sorts);
        return success(themes);
    }
    @GetMapping(value = BaseRequestMapping.Theme.CHECK_STYLE)
    @ApiOperation(value = "检查主题风格是否已存在(desc=1代表存在,desc=0代表不存在)")
    public Envelop checkName (
            @ApiParam(name = "style", value = "主题风格", required = true)
            @RequestParam(value = "style", required = false) String style) throws Exception {
        if (themeService.search("style=" + style).size() > 0) {
            return success("1");
        } else {
            return success("0");
        }
    }
}

+ 52 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/ModuleService.java

@ -0,0 +1,52 @@
package com.yihu.jw.base.service;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.saas.SaasModuleDO;
import com.yihu.jw.base.dao.ModuleDao;
import com.yihu.jw.business.base.dao.SaasModuleDao;
import com.yihu.jw.restmodel.base.base.ModuleVO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
    @Autowired
    private ModuleDao moduleDao;
    @Autowired
    private SaasModuleDao saasModuleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public void assignModule(String saasCode, String moduleCodes) {
        //先删除原来已经分配好的模块
        saasModuleDao.deleteBySaasCode(saasCode);
        //分配新的模块
        String [] moduleCodeArr=moduleCodes.split(",");
        List<SaasModuleDO> saasModuleList=new ArrayList<>();
        for(String moduleCode:moduleCodeArr){
            SaasModuleDO saasModule=new SaasModuleDO();
            saasModule.setModuleId(moduleCode);
            saasModule.setSaasId(saasCode);
            saasModuleList.add(saasModule);
        }
        saasModuleDao.save(saasModuleList);
    }
    public List<ModuleVO> getSaasModules(String saasCode) {
        String sql=" select m.code,m.parent_code,m.name from base_module m,base_saas_module sm where m.code=sm.module_id and m.status=1 and sm.saas_id=?";
       return jdbcTemplate.queryForList(sql,ModuleVO.class,saasCode);
    }
}

+ 5 - 50
svr/svr-base/src/main/java/com/yihu/jw/base/service/SaasService.java

@ -2,71 +2,26 @@ package com.yihu.jw.base.service;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.base.dao.SaasDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
    @Autowired
    private SaasDao saasDao;
    @Transactional
    public SaasDO createSaas(SaasDO saas) throws ApiException {
        if (StringUtils.isEmpty(saas.getId())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(saas.getName())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        SaasDO saasTmp = saasDao.findByName(saas.getName());
        if (saasTmp != null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return saasDao.save(saas);
    }
    @Transactional
    public SaasDO updateSaas(SaasDO saas) {
        if (StringUtils.isEmpty(saas.getName())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(saas.getId())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        SaasDO saasTmp = saasDao.findByNameExcludeId(saas.getName(), saas.getId());
        if (saasTmp != null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_exist, ExceptionCode.common_error_params_code);
    public void delete(String ids) {
        for (String id : ids.split(",")) {
            SaasDO saas = saasDao.findById(id);
            saas.setStatus(SaasDO.Status.delete);
        }
        return saasDao.save(saas);
    }
    public SaasDO findById(String id) {
        SaasDO saas = saasDao.findById(id);
        if (saas == null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return saas;
    }
    @Transactional
    public void deleteSaas(String id) {
        SaasDO saas = saasDao.findById(id);
        if (saas == null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        saas.setStatus(SaasDO.Status.delete);
    }
    public SaasDO findByName(String cityName) {
        return saasDao.findByName(cityName);
    }
}

+ 5 - 2
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictService.java

@ -1,11 +1,14 @@
package com.yihu.jw.business.base.service;
package com.yihu.jw.base.service;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.business.base.dao.SystemDictDao;
import com.yihu.jw.base.dao.SystemDictDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 * Created by LiTaohong on 2017/12/01.
 */
@Service
public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDao> {
}

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/ThemeService.java

@ -0,0 +1,18 @@
package com.yihu.jw.base.service;
import com.yihu.jw.base.dao.ThemeDao;
import com.yihu.jw.entity.base.theme.ThemeDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
/**
 * Created by progr1mmer on 2018/8/16.
 */
@Service
@Transactional
public class ThemeService extends BaseJpaService<ThemeDO, ThemeDao> {
}

+ 0 - 162
svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/ModuleController.java

@ -1,162 +0,0 @@
package com.yihu.jw.business.base.controller;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.business.base.service.ModuleService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.base.base.ModuleVO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@RestController
@RequestMapping(BaseRequestMapping.api_base_common)
@Api(value = "模块模块", description = "模块接口管理")
public class ModuleController extends EnvelopRestController {
    @Autowired
    private ModuleService moduleService;
//    @PostMapping(value = BaseRequestMapping.Module.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建模块", notes = "创建单个模块")
//    public Envelop createModule(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            ModuleDO module = toEntity(jsonData, ModuleDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_create, moduleService.createModule(module));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PutMapping(value = BaseRequestMapping.Module.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改模块", notes = "修改模块")
//    public Envelop updateModule(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//        try {
//            ModuleDO module = toEntity(jsonData, ModuleDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_update, moduleService.updateModule(module));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
    @DeleteMapping(value = BaseRequestMapping.Module.api_delete)
    @ApiOperation(value = "删除模块", notes = "删除模块")
    public Envelop deleteModule(
            @ApiParam(name = "codes", value = "codes")
            @PathVariable(value = "codes", required = true) String codes) {
        try {
            moduleService.deleteModule(codes);
            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseRequestMapping.Module.api_getById)
    @ApiOperation(value = "根据code查找模块", notes = "根据code查找模块")
    public Envelop findByCode(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_find, moduleService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseRequestMapping.Module.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取父模块列表(分页)")
    public Envelop getModules(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if(StringUtils.isBlank(sorts)){
            sorts = "-updateTime";
        }
        if(StringUtils.isBlank(filters)){
            filters = "parentCode=0;";
        }else{
            filters="parentCode=0;"+filters;
        }
        //得到list数据
        List<ModuleDO> list = moduleService.search(fields, filters, sorts, page, size);
        if(list!=null){
            for(ModuleDO module:list){//循环遍历,设置是否有子节点
                List<ModuleDO> children = moduleService.getChildren(module.getId());
                //children长度为0时    state  “open”表示是子节点,“closed”表示为父节点;
                // children长度>0时,  state   “open,closed”表示是节点的打开关闭
                if (children.size()>0){
                    module.setState("closed");
                }else{
                    module.setState("open");
                }
            }
        }
        //获取总数
        long count=moduleService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<ModuleVO> ModuleVOs = convertToModels(list, new ArrayList<>(list.size()), ModuleVO.class, fields);
        return Envelop.getSuccessListWithPage(BaseRequestMapping.Module.message_success_find_Modules,ModuleVOs, page, size,count);
    }
    @GetMapping(value = BaseRequestMapping.Module.api_getListNoPage)
    @ApiOperation(value = "获取模块列表,不分页")
    public Envelop getListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<ModuleDO> list = moduleService.search(filters, sorts);
        //封装返回格式
        List<ModuleVO> ModuleVOs = convertToModels(list, new ArrayList<>(list.size()), ModuleVO.class, fields);
        return Envelop.getSuccessList(BaseRequestMapping.Module.message_success_find_Modules,ModuleVOs);
    }
    @GetMapping(value =BaseRequestMapping.Module.api_getChildren )
    @ApiOperation(value="查找子节点")
    public Envelop getChildren(@PathVariable String code){
        List<ModuleDO> children = moduleService.getChildren(code);
        return Envelop.getSuccess("查询成功",children);
    }
}

+ 0 - 17
svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/FunctionDao.java

@ -2,28 +2,11 @@ package com.yihu.jw.business.base.dao;
import com.yihu.jw.entity.base.function.FunctionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
public interface FunctionDao extends PagingAndSortingRepository<FunctionDO, String>, JpaSpecificationExecutor<FunctionDO> {
    @Query("from FunctionDO f where f.name=?1 and f.status=1")
    FunctionDO findByName(String name);
    @Query("from FunctionDO f where f.id=?1 and f.status=1")
    FunctionDO findById(String id);
    @Query("from FunctionDO f where f.name=?1 and f.status=1 and f.id!=?2")
    FunctionDO findByNameExcludeId(String name,String id);
    @Query("from FunctionDO f where f.parentCode=?1 and f.status=1")
    List<FunctionDO> getChildren(String parentCode);
    @Query("from FunctionDO f where f.status=1")
    List<FunctionDO> findAll();
}

+ 0 - 28
svr/svr-base/src/main/java/com/yihu/jw/business/base/dao/ModuleDao.java

@ -1,28 +0,0 @@
package com.yihu.jw.business.base.dao;
import com.yihu.jw.entity.base.module.ModuleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
public interface ModuleDao extends PagingAndSortingRepository<ModuleDO, String>, JpaSpecificationExecutor<ModuleDO> {
    @Query("from ModuleDO f where f.name=?1 and f.status=1")
    ModuleDO findByName(String name);
    @Query("from ModuleDO f where f.id=?1 and f.status=1")
    ModuleDO findById(String id);
    @Query("from ModuleDO f where f.name=?1 and f.status=1 and f.id != ?2")
    ModuleDO findByNameExcludeId(String name, String code);
    @Query("from ModuleDO f where f.parentId=?1 and f.status=1")
    List<ModuleDO> getChildren(String code);
    @Query("from ModuleDO f where f.status=1")
    List<ModuleDO> findAll();
}

+ 1 - 135
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/FunctionService.java

@ -1,152 +1,18 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.entity.base.module.ModuleFunctionDO;
import com.yihu.jw.business.base.dao.FunctionDao;
import com.yihu.jw.business.base.dao.ModuleFunctionDao;
import com.yihu.jw.entity.base.function.FunctionDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.base.FunctionVO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class FunctionService extends BaseJpaService<FunctionDO, FunctionDao> {
    @Autowired
    private FunctionDao functionDao;
    @Autowired
    private ModuleFunctionDao moduleFunctionDao;
    @Autowired
    private ModuleFunService moduleFunService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public FunctionDO createFunction(FunctionDO function) throws ApiException {
        if (StringUtils.isEmpty(function.getId())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getName())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        FunctionDO functionTmp = functionDao.findByName(function.getName());
        if (functionTmp != null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return functionDao.save(function);
    }
    @Transactional
    public FunctionDO updateFunction(FunctionDO function) {
        if (StringUtils.isEmpty(function.getName())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getId())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        FunctionDO functionTmp = functionDao.findByNameExcludeId(function.getName(), function.getId());
        if (functionTmp != null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return functionDao.save(function);
    }
    public FunctionDO findById(String id) {
        FunctionDO function = functionDao.findById(id);
        if (function == null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return function;
    }
    @Transactional
    public void deleteFunction(String id) {
        FunctionDO function = functionDao.findById(id);
        if (function == null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        function.setStatus(-1);
        functionDao.save(function);
    }
    @Transactional
    public void assignFunction(String moduleId, String functionIds) {
        //先删除原来已经分配好的功能
        moduleFunctionDao.deleteByModuleId(moduleId);
        //分配新的功能
        String [] functionCodeArr=functionIds.split(",");
        List<ModuleFunctionDO> saasModuleList=new ArrayList<>();
        for(String functionId:functionCodeArr){
            ModuleFunctionDO saasModule=new ModuleFunctionDO();
            saasModule.setModuleId(moduleId);
            saasModule.setFunctionId(functionId);
            saasModuleList.add(saasModule);
        }
        moduleFunctionDao.save(saasModuleList);
    }
    public List<FunctionVO> getModuleFunctions(String saasId) {
        String sql=" select m.code,m.parent_code,m.name from base_function f,base_module_function mf where f.code=mf.function_id and f.status=1 and mf.module_id=?";
        return jdbcTemplate.queryForList(sql,FunctionVO.class,saasId);
    }
    /**
     * 根据code获得子节点,并判断是否子节点是否还有孙节点 (treegrid点击查询子节点 用到)
     * @param code
     * @return
     */
    public List<FunctionDO> getChildren(String code){
        List<FunctionDO> childrens = functionDao.getChildren(code);
        for(FunctionDO children:childrens){
            List<FunctionDO> children1 = functionDao.getChildren(children.getId());//判断子节点是否有孙节点
            children.setChildren(children1);
        }
        return childrens;
    }
    public List<FunctionDO> findAll(){
        return functionDao.findAll();
    }
    /**
     * key为code ,value为功能名称
     * @return
     */
    public Map<String,String> getName(){
        List<FunctionDO> functions = findAll();
        Map<String, String> map = new HashMap<>();
        if(null!=functions){
            for(FunctionDO function: functions){
                map.put(function.getId(),function.getName());
            }
        }
        return map;
    }
    /**
     * 根据code获取所有子节点(包括孙节点,曾孙节点....)
     * @param id
     * @return
     */
    public FunctionDO getAllChildren(String id){
        FunctionDO function = functionDao.findById(id);
        List<FunctionDO> childrens = functionDao.getChildren(id);
        for(FunctionDO children:childrens){
            getAllChildren(children.getId());
        }
        function.setChildren(childrens);
        return function;
    }
}

+ 0 - 141
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/ModuleService.java

@ -1,141 +0,0 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.saas.SaasModuleDO;
import com.yihu.jw.business.base.dao.ModuleDao;
import com.yihu.jw.business.base.dao.SaasModuleDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.base.ModuleVO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
    @Autowired
    private ModuleDao moduleDao;
    @Autowired
    private SaasModuleDao saasModuleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public ModuleDO createModule(ModuleDO module) throws ApiException {
        if (StringUtils.isEmpty(module.getId())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(module.getName())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(module.getSaasId())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        ModuleDO moduleTmp = moduleDao.findByName(module.getName());
        if (moduleTmp != null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return moduleDao.save(module);
    }
    @Transactional
    public ModuleDO updateModule(ModuleDO module) {
        if (StringUtils.isEmpty(module.getName())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(module.getId())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        ModuleDO moduleTmp = moduleDao.findByNameExcludeId(module.getName(), module.getId());
        if (moduleTmp != null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return moduleDao.save(module);
    }
    public ModuleDO findById(String Id) {
        ModuleDO module = moduleDao.findById(Id);
        if (module == null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return module;
    }
    @Transactional
    public void deleteModule(String Id) {
        ModuleDO module = moduleDao.findById(Id);
        if (module == null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        module.setStatus(ModuleDO.Status.delete);
    }
    @Transactional
    public void assignModule(String saasCode, String moduleCodes) {
        //先删除原来已经分配好的模块
        saasModuleDao.deleteBySaasCode(saasCode);
        //分配新的模块
        String [] moduleCodeArr=moduleCodes.split(",");
        List<SaasModuleDO> saasModuleList=new ArrayList<>();
        for(String moduleCode:moduleCodeArr){
            SaasModuleDO saasModule=new SaasModuleDO();
            saasModule.setModuleId(moduleCode);
            saasModule.setSaasId(saasCode);
            saasModuleList.add(saasModule);
        }
        saasModuleDao.save(saasModuleList);
    }
    public List<ModuleVO> getSaasModules(String saasCode) {
        String sql=" select m.code,m.parent_code,m.name from base_module m,base_saas_module sm where m.code=sm.module_id and m.status=1 and sm.saas_id=?";
       return jdbcTemplate.queryForList(sql,ModuleVO.class,saasCode);
    }
    public List<ModuleDO> getChildren(String code){
        List<ModuleDO> childrens = moduleDao.getChildren(code);
        for(ModuleDO children:childrens){
            List<ModuleDO> children1 = moduleDao.getChildren(children.getId());//判断子节点是否有孙节点
            //没有children    state
            //“open”表示是子节点,“closed”表示为父节点;
            if (children1.size()>0){
                children.setState("closed");
            }else{
                children.setState("open");
            }
        }
        return childrens;
    }
    public List<ModuleDO> findAll(){
        return moduleDao.findAll();
    }
    /**
     * key为code ,value为模块名称
     * @return
     */
    public Map<String,String> getName(){
        List<ModuleDO> modules = findAll();
        Map<String, String> map = new HashMap<>();
        if(null!=modules){
            for(ModuleDO module: modules){
                map.put(module.getId(),module.getName());
            }
        }
        return map;
    }
}