| @@ -0,0 +1,113 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_authorizer_info") | |||||
| @Data | |||||
| public class WxAuthorizerInfo implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| /**微信公众账号基本信息表id,关联微信公众号基本信息表*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信公众账号基本信息表id,关联微信公众号基本信息表",name="officialAccountId") | |||||
| private Long officialAccountId; | |||||
| /**授权方appid*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="授权方appid",name="authorizerAppid") | |||||
| private String authorizerAppid; | |||||
| /**授权方头像*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="授权方头像",name="headImg") | |||||
| private String headImg; | |||||
| /**授权方公众号所设置的微信号,可能为空*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="授权方公众号所设置的微信号,可能为空",name="alias") | |||||
| private String alias; | |||||
| /**二维码图片的URL,开发者最好自行也进行保存*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="二维码图片的URL,开发者最好自行也进行保存",name="qrcodeUrl") | |||||
| private String qrcodeUrl; | |||||
| /**创建时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||||
| private Date createTime; | |||||
| /**更新时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||||
| private Date updateTime; | |||||
| /**授权状态,0为已授权,1为已取消授权*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="授权状态,0为已授权,1为已取消授权",name="authorizationStatus") | |||||
| private Integer authorizationStatus; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,OfficialAccountId_ASC("`official_account_id` ASC"),OfficialAccountId_DESC("`official_account_id` DESC") | |||||
| ,AuthorizerAppid_ASC("`authorizer_appid` ASC"),AuthorizerAppid_DESC("`authorizer_appid` DESC") | |||||
| ,HeadImg_ASC("`head_img` ASC"),HeadImg_DESC("`head_img` DESC") | |||||
| ,Alias_ASC("`alias` ASC"),Alias_DESC("`alias` DESC") | |||||
| ,QrcodeUrl_ASC("`qrcode_url` ASC"),QrcodeUrl_DESC("`qrcode_url` DESC") | |||||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||||
| ,Updateime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC") | |||||
| ,AuthorizationStatus_ASC("`authorization_status` ASC"),AuthorizationStatus_DESC("`authorization_status` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxAuthorizerInfo.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,97 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_component_verify_ticket") | |||||
| @Data | |||||
| public class WxComponentVerifyTicket implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| /**微信第三方componentAppid*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信第三方componentAppid",name="componentAppid") | |||||
| private String componentAppid; | |||||
| /**微信第三方component_verify_ticket*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信第三方component_verify_ticket",name="componentVerifyTicket") | |||||
| private String componentVerifyTicket; | |||||
| /**创建时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||||
| private Date createTime; | |||||
| /**失效时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="失效时间",name="deadline") | |||||
| private Date deadline; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,ComponentAppid_ASC("`component_appid` ASC"),ComponentAppid_DESC("`component_appid` DESC") | |||||
| ,ComponentVerifyTicket_ASC("`component_verify_ticket` ASC"),ComponentVerifyTicket_DESC("`component_verify_ticket` DESC") | |||||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||||
| ,Deadline_ASC("`deadline` ASC"),Deadline_DESC("`deadline` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxComponentVerifyTicket.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,5 +1,7 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import lombok.Data; | |||||
| import javax.persistence.*; | import javax.persistence.*; | ||||
| import java.util.*; | import java.util.*; | ||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| @@ -8,6 +10,7 @@ import javax.persistence.Id; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| @Table(name = "wx_template_msg") | @Table(name = "wx_template_msg") | ||||
| @Data | |||||
| public class WxTemplateMsg implements Serializable { | public class WxTemplateMsg implements Serializable { | ||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @@ -18,26 +21,6 @@ public class WxTemplateMsg implements Serializable { | |||||
| protected List<Long> ids; | protected List<Long> ids; | ||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /**租户ID**/ | /**租户ID**/ | ||||
| @@ -55,37 +38,6 @@ public class WxTemplateMsg implements Serializable { | |||||
| /**更新时间**/ | /**更新时间**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | |||||
| } | |||||
| public String getTemplateId() { | |||||
| return templateId; | |||||
| } | |||||
| public void setTemplateId(String _templateId) { | |||||
| templateId = _templateId; | |||||
| } | |||||
| public Integer getType() { | |||||
| return type; | |||||
| } | |||||
| public void setType(Integer _type) { | |||||
| type = _type; | |||||
| } | |||||
| public Date getCreateDate() { | |||||
| return createDate; | |||||
| } | |||||
| public void setCreateDate(Date _createDate) { | |||||
| createDate = _createDate; | |||||
| } | |||||
| public Date getUpdateDate() { | |||||
| return updateDate; | |||||
| } | |||||
| public void setUpdateDate(Date _updateDate) { | |||||
| updateDate = _updateDate; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| @@ -0,0 +1,109 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_weapp_basic_set") | |||||
| @Data | |||||
| public class WxWeappBasicSet implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| /**小程序类型(1-B端 2-C端)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端)",name="type") | |||||
| private Integer type; | |||||
| /**部署类型(1:dev,2:test,3:prod)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="部署类型(1:dev,2:test,3:prod)",name="deploy") | |||||
| private Integer deploy; | |||||
| /**服务器域名*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="服务器域名",name="domainUrl") | |||||
| private String domainUrl; | |||||
| /**小程序基础版本*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序基础版本",name="version") | |||||
| private String version; | |||||
| /**模板库信息*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板库信息",name="templateInfo") | |||||
| private String templateInfo; | |||||
| /**创建时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| /**更新时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,Deploy_ASC("`deploy` ASC"),Deploy_DESC("`deploy` DESC") | |||||
| ,DomainUrl_ASC("`domain_url` ASC"),DomainUrl_DESC("`domain_url` DESC") | |||||
| ,Version_ASC("`version` ASC"),Version_DESC("`version` DESC") | |||||
| ,TemplateInfo_ASC("`template_info` ASC"),TemplateInfo_DESC("`template_info` DESC") | |||||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxWeappBasicSet.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,112 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_weapp_code_status") | |||||
| @Data | |||||
| public class WxWeappCodeStatus implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| /**小程序ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序ID",name="appId") | |||||
| private String appId; | |||||
| /**小程序类型(1-B端 2-C端)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端)",name="type") | |||||
| private Integer type; | |||||
| /**用户版本*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户版本",name="userVersion") | |||||
| private String userVersion; | |||||
| /**code提交状态*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="code提交状态(0:成功, ...error code)",name="codeStatus") | |||||
| private Integer codeStatus; | |||||
| /**审核状态*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="审核状态((0为审核成功,1为审核失败,2为审核中,3已撤回))",name="auditStatus") | |||||
| private Integer auditStatus; | |||||
| /**发布状态*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="发布状态((0为发布成功,...error code))",name="releaseStatus") | |||||
| private Integer releaseStatus; | |||||
| /**创建时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| /**更新时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,AppId_ASC("`app_id` ASC"),AppId_DESC("`app_id` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,UserVersion_ASC("`user_version` ASC"),UserVersion_DESC("`user_version` DESC") | |||||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxWeappCodeStatus.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| List<Field> fList = new ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,105 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_weapp_ext_set") | |||||
| @Data | |||||
| public class WxWeappExtSet implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| /**小程序ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序ID",name="appId") | |||||
| private String appId; | |||||
| /**小程序类型(1-B端 2-C端)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端)",name="type") | |||||
| private Integer type; | |||||
| /**小程序扩展信息*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序扩展信息",name="ext") | |||||
| private String ext; | |||||
| /**提交审核列表*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="提交审核列表",name="release") | |||||
| private String release; | |||||
| /**创建时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| /**更新时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,AppId_ASC("`app_id` ASC"),AppId_DESC("`app_id` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,Ext_ASC("`ext` ASC"),Ext_DESC("`ext` DESC") | |||||
| ,Release_ASC("`release` ASC"),Release_DESC("`release` DESC") | |||||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxWeappExtSet.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,109 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_weapp_info") | |||||
| @Data | |||||
| public class WxWeappInfo implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| /**小程序ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序ID",name="appId") | |||||
| private String appId; | |||||
| /**小程序类型(1-B端 2-C端)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端)",name="type") | |||||
| private Integer type; | |||||
| /**小程序名称*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序名称",name="name") | |||||
| private String name; | |||||
| /**当前版本*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="当前版本",name="currentVersion") | |||||
| private String currentVersion; | |||||
| /**描述*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="描述",name="currentDesc") | |||||
| private String currentDesc; | |||||
| /**创建时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| /**更新时间*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,AppId_ASC("`app_id` ASC"),AppId_DESC("`app_id` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,ame_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||||
| ,CurrentVersion_ASC("`current_version` ASC"),CurrentVersion_DESC("`current_version` DESC") | |||||
| ,CurrentDesc_ASC("`current_desc` ASC"),CurrentDesc_DESC("`current_desc` DESC") | |||||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxWeappInfo.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,39 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumAuditStatus { | |||||
| // 0为审核成功,1为审核失败,2为审核中,3已撤回 | |||||
| SUCCESS(0, "审核成功"), | |||||
| FAIL(1, "审核失败"), | |||||
| AUDITING(2, "审核中"), | |||||
| UNDO(3, "已撤回"), | |||||
| ; | |||||
| public static EnumAuditStatus getEnum(Integer code) { | |||||
| for (EnumAuditStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumAuditStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/11/16. | |||||
| */ | |||||
| public enum EnumLoginType { | |||||
| // 0-password, 1-nopassword | |||||
| PASSWORD(0, "PASSWORD"), | |||||
| NOPASSWD(1, "NOPASSWORD") | |||||
| ; | |||||
| public static EnumLoginType getEnum(Integer code) { | |||||
| for (EnumLoginType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumLoginType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumWxAuthorizationInfoType { | |||||
| COMPONENT_VERIFY_TICKET(1, "component_verify_ticket"), | |||||
| UNAUTHORIZED(2, "unauthorized"), | |||||
| AUTHORIZED(3, "authorized"), | |||||
| UPDATEAUTHORIZED(4, "updateauthorized") | |||||
| ; | |||||
| public static EnumWxAuthorizationInfoType getEnum(Integer code) { | |||||
| for (EnumWxAuthorizationInfoType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumWxAuthorizationInfoType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumWxAuthorizationStatus { | |||||
| // 0-authorized, 1-unauthorized | |||||
| AUTHORIZED(0, "authorized"), | |||||
| UNAUTHORIZED(1, "unauthorized") | |||||
| ; | |||||
| public static EnumWxAuthorizationStatus getEnum(Integer code) { | |||||
| for (EnumWxAuthorizationStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumWxAuthorizationStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, Long> { | |||||
| List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| public interface WxComponentVerifyTicketMapper extends CommonMapper<WxComponentVerifyTicket, Long> { | |||||
| List<WxComponentVerifyTicket> findList(WxComponentVerifyTicket wxComponentVerifyTicket); | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxWeappBasicSet; | |||||
| public interface WxWeappBasicSetMapper extends CommonMapper<WxWeappBasicSet, Long> { | |||||
| List<WxWeappBasicSet> findList(WxWeappBasicSet wxWeappBasicSet); | |||||
| } | |||||
| @@ -0,0 +1,17 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxWeappCodeStatus; | |||||
| import java.util.List; | |||||
| public interface WxWeappCodeStatusMapper extends CommonMapper<WxWeappCodeStatus, Long> { | |||||
| List<WxWeappCodeStatus> findList(WxWeappCodeStatus wxWeappCodeStatus); | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxWeappExtSet; | |||||
| public interface WxWeappExtSetMapper extends CommonMapper<WxWeappExtSet, Long> { | |||||
| List<WxWeappExtSet> findList(WxWeappExtSet wxWeappReleaseSet); | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxWeappInfo; | |||||
| public interface WxWeappInfoMapper extends CommonMapper<WxWeappInfo, Long> { | |||||
| List<WxWeappInfo> findList(WxWeappInfo wxWeappInfo); | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.iformall.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| public interface WxAuthorizerInfoService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxAuthorizerInfo> listAsPage(WxAuthorizerInfo record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxAuthorizerInfo getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxAuthorizerInfo record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| public interface WxComponentVerifyTicketService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxComponentVerifyTicket> listAsPage(WxComponentVerifyTicket record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxComponentVerifyTicket getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxComponentVerifyTicket record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,54 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappBasicSet; | |||||
| public interface WxWeappBasicSetService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxWeappBasicSet> listAsPage(WxWeappBasicSet record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxWeappBasicSet getById(Long id); | |||||
| /** | |||||
| * 根据type and deploy获取 | |||||
| * @param weappBasicSet | |||||
| * @return | |||||
| */ | |||||
| WxWeappBasicSet getByTypeAndDeploy(WxWeappBasicSet weappBasicSet); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxWeappBasicSet record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,70 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappCodeStatus; | |||||
| public interface WxWeappCodeStatusService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxWeappCodeStatus> listAsPage(WxWeappCodeStatus record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxWeappCodeStatus getById(Long id); | |||||
| /** | |||||
| * 根据appId获得实体 | |||||
| * | |||||
| * @param appId | |||||
| * @return | |||||
| */ | |||||
| WxWeappCodeStatus getByAppId(String appId); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxWeappCodeStatus record); | |||||
| /** | |||||
| * 更新codeCommit Status | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void updateCodeCommitStatus(WxWeappCodeStatus record); | |||||
| /** | |||||
| * 更新audit Status | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void updateAuditStatus(WxWeappCodeStatus record); | |||||
| /** | |||||
| * 更新release Status | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void updateReleaseStatus(WxWeappCodeStatus record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,55 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappExtSet; | |||||
| public interface WxWeappExtSetService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxWeappExtSet> listAsPage(WxWeappExtSet record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxWeappExtSet getById(Long id); | |||||
| /** | |||||
| * 根据Obj获得实体 | |||||
| * | |||||
| * @param record | |||||
| * @return | |||||
| */ | |||||
| WxWeappExtSet getByObj(WxWeappExtSet record); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxWeappExtSet record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,47 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappInfo; | |||||
| public interface WxWeappInfoService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxWeappInfo> listAsPage(WxWeappInfo record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxWeappInfo getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxWeappInfo record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,70 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||||
| import com.iformall.service.WxAuthorizerInfoService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| import java.util.Date; | |||||
| @Service | |||||
| public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxAuthorizerInfoMapper wxAuthorizerInfoMapper; | |||||
| @Override | |||||
| public PageInfo<WxAuthorizerInfo> listAsPage(WxAuthorizerInfo record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxAuthorizerInfoMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxAuthorizerInfo getById(Long id) { | |||||
| return wxAuthorizerInfoMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxAuthorizerInfo record) { | |||||
| WxAuthorizerInfo authorizerInfo = null; | |||||
| try { | |||||
| WxAuthorizerInfo aiQ = new WxAuthorizerInfo(); | |||||
| aiQ.setAuthorizerAppid(record.getAuthorizerAppid()); | |||||
| authorizerInfo = wxAuthorizerInfoMapper.selectOne(aiQ); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| if (authorizerInfo == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateTime(new Date()); | |||||
| record.setUpdateTime(new Date()); | |||||
| wxAuthorizerInfoMapper.insertSelective(record); | |||||
| } else { | |||||
| record.setId(authorizerInfo.getId()); | |||||
| record.setUpdateTime(new Date()); | |||||
| wxAuthorizerInfoMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxAuthorizerInfoMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,64 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | |||||
| import com.iformall.service.WxComponentVerifyTicketService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| @Service | |||||
| public class WxComponentVerifyTicketServiceImpl implements WxComponentVerifyTicketService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxComponentVerifyTicketMapper wxComponentVerifyTicketMapper; | |||||
| @Override | |||||
| public PageInfo<WxComponentVerifyTicket> listAsPage(WxComponentVerifyTicket record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxComponentVerifyTicketMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxComponentVerifyTicket getById(Long id) { | |||||
| return wxComponentVerifyTicketMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxComponentVerifyTicket record) { | |||||
| WxComponentVerifyTicket wxComponentVerifyTicket = null; | |||||
| try { | |||||
| WxComponentVerifyTicket ctQ = new WxComponentVerifyTicket(); | |||||
| ctQ.setComponentAppid(record.getComponentAppid()); | |||||
| wxComponentVerifyTicket = wxComponentVerifyTicketMapper.selectOne(ctQ); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| if (wxComponentVerifyTicket == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxComponentVerifyTicketMapper.insertSelective(record); | |||||
| } else { | |||||
| record.setId(wxComponentVerifyTicket.getId()); | |||||
| wxComponentVerifyTicketMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxComponentVerifyTicketMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,59 @@ | |||||
| package com.iformall.service.impl; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappBasicSet; | |||||
| import com.iformall.mapper.WxWeappBasicSetMapper; | |||||
| import com.iformall.service.WxWeappBasicSetService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| @Service | |||||
| public class WxWeappBasicSetServiceImpl implements WxWeappBasicSetService { | |||||
| @Autowired | |||||
| WxWeappBasicSetMapper wxWeappBasicSetMapper; | |||||
| @Override | |||||
| public PageInfo<WxWeappBasicSet> listAsPage(WxWeappBasicSet record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxWeappBasicSetMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxWeappBasicSet getById(Long id) { | |||||
| return wxWeappBasicSetMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public WxWeappBasicSet getByTypeAndDeploy(WxWeappBasicSet weappBasicSet) { | |||||
| return wxWeappBasicSetMapper.selectOne(weappBasicSet); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxWeappBasicSet record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxWeappBasicSetMapper.insertSelective(record); | |||||
| } else { | |||||
| wxWeappBasicSetMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxWeappBasicSetMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,93 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxWeappCodeStatus; | |||||
| import com.iformall.mapper.WxWeappCodeStatusMapper; | |||||
| import com.iformall.service.WxWeappCodeStatusService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | |||||
| @Service | |||||
| public class WxWeappCodeStatusServiceImpl implements WxWeappCodeStatusService { | |||||
| @Autowired | |||||
| WxWeappCodeStatusMapper wxWeappCodeStatusMapper; | |||||
| @Override | |||||
| public PageInfo<WxWeappCodeStatus> listAsPage(WxWeappCodeStatus record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxWeappCodeStatusMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxWeappCodeStatus getById(Long id) { | |||||
| return wxWeappCodeStatusMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public WxWeappCodeStatus getByAppId(String appId) { | |||||
| WxWeappCodeStatus weappCodeStatusQ = new WxWeappCodeStatus(); | |||||
| weappCodeStatusQ.setAppId(appId); | |||||
| return wxWeappCodeStatusMapper.selectOne(weappCodeStatusQ); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxWeappCodeStatus record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateDate(new Date()); | |||||
| record.setUpdateDate(new Date()); | |||||
| wxWeappCodeStatusMapper.insertSelective(record); | |||||
| } else { | |||||
| record.setUpdateDate(new Date()); | |||||
| wxWeappCodeStatusMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateCodeCommitStatus(WxWeappCodeStatus record) { | |||||
| WxWeappCodeStatus updateRecord = new WxWeappCodeStatus(); | |||||
| updateRecord.setId(record.getId()); | |||||
| updateRecord.setUserVersion(record.getUserVersion()); | |||||
| updateRecord.setCodeStatus(record.getCodeStatus()); | |||||
| updateRecord.setUpdateDate(new Date()); | |||||
| wxWeappCodeStatusMapper.updateByPrimaryKeySelective(updateRecord); | |||||
| } | |||||
| @Override | |||||
| public void updateAuditStatus(WxWeappCodeStatus record) { | |||||
| WxWeappCodeStatus updateRecord = new WxWeappCodeStatus(); | |||||
| updateRecord.setId(record.getId()); | |||||
| updateRecord.setAuditStatus(record.getAuditStatus()); | |||||
| updateRecord.setUpdateDate(new Date()); | |||||
| wxWeappCodeStatusMapper.updateByPrimaryKeySelective(updateRecord); | |||||
| } | |||||
| @Override | |||||
| public void updateReleaseStatus(WxWeappCodeStatus record) { | |||||
| WxWeappCodeStatus updateRecord = new WxWeappCodeStatus(); | |||||
| updateRecord.setId(record.getId()); | |||||
| updateRecord.setReleaseStatus(record.getReleaseStatus()); | |||||
| updateRecord.setUpdateDate(new Date()); | |||||
| wxWeappCodeStatusMapper.updateByPrimaryKeySelective(updateRecord); | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxWeappCodeStatusMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,58 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappExtSet; | |||||
| import com.iformall.mapper.WxWeappExtSetMapper; | |||||
| import com.iformall.service.WxWeappExtSetService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| @Service | |||||
| public class WxWeappExtSetServiceImpl implements WxWeappExtSetService { | |||||
| @Autowired | |||||
| WxWeappExtSetMapper wxWeappExtSetMapper; | |||||
| @Override | |||||
| public PageInfo<WxWeappExtSet> listAsPage(WxWeappExtSet record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxWeappExtSetMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxWeappExtSet getById(Long id) { | |||||
| return wxWeappExtSetMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public WxWeappExtSet getByObj(WxWeappExtSet record) { | |||||
| return wxWeappExtSetMapper.selectOne(record); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxWeappExtSet record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxWeappExtSetMapper.insertSelective(record); | |||||
| } else { | |||||
| wxWeappExtSetMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxWeappExtSetMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,54 @@ | |||||
| package com.iformall.service.impl; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxWeappInfo; | |||||
| import com.iformall.mapper.WxWeappInfoMapper; | |||||
| import com.iformall.service.WxWeappInfoService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| @Service | |||||
| public class WxWeappInfoServiceImpl implements WxWeappInfoService { | |||||
| @Autowired | |||||
| WxWeappInfoMapper wxWeappInfoMapper; | |||||
| @Override | |||||
| public PageInfo<WxWeappInfo> listAsPage(WxWeappInfo record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxWeappInfoMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxWeappInfo getById(Long id) { | |||||
| return wxWeappInfoMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxWeappInfo record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxWeappInfoMapper.insertSelective(record); | |||||
| } else { | |||||
| wxWeappInfoMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxWeappInfoMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -9,23 +9,24 @@ import java.net.UnknownHostException; | |||||
| public class IPUtil { | public class IPUtil { | ||||
| private final static Logger logger = LoggerFactory.getLogger(IPUtil.class); | private final static Logger logger = LoggerFactory.getLogger(IPUtil.class); | ||||
| private final static String UNKNOWN = "unknown"; | |||||
| public static String getIpAddr(HttpServletRequest request) { | public static String getIpAddr(HttpServletRequest request) { | ||||
| String ipAddress = request.getHeader("x-forwarded-for"); | String ipAddress = request.getHeader("x-forwarded-for"); | ||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| if (ipAddress == null || ipAddress.length() == 0 || UNKNOWN.equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("Proxy-Client-IP"); | ipAddress = request.getHeader("Proxy-Client-IP"); | ||||
| } | } | ||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknow".equalsIgnoreCase(ipAddress)) { | |||||
| if (ipAddress == null || ipAddress.length() == 0 || UNKNOWN.equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("WL-Proxy-Client-IP"); | ipAddress = request.getHeader("WL-Proxy-Client-IP"); | ||||
| } | } | ||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| if (ipAddress == null || ipAddress.length() == 0 || UNKNOWN.equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("HTTP_CLIENT_IP"); | ipAddress = request.getHeader("HTTP_CLIENT_IP"); | ||||
| } | } | ||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| if (ipAddress == null || ipAddress.length() == 0 || UNKNOWN.equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("HTTP_X_FORWARDED_FOR"); | ipAddress = request.getHeader("HTTP_X_FORWARDED_FOR"); | ||||
| } | } | ||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| if (ipAddress == null || ipAddress.length() == 0 || UNKNOWN.equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getRemoteAddr(); | ipAddress = request.getRemoteAddr(); | ||||
| if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) { | if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) { | ||||
| //根据网卡获取本机配置的IP地址 | //根据网卡获取本机配置的IP地址 | ||||
| @@ -0,0 +1,60 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxAuthorizerInfoMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxAuthorizerInfo"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid" /> | |||||
| <result column="head_img" jdbcType="VARCHAR" property="headImg" /> | |||||
| <result column="alias" jdbcType="VARCHAR" property="alias" /> | |||||
| <result column="qrcode_url" jdbcType="VARCHAR" property="qrcodeUrl" /> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||||
| <result column="authorization_status" jdbcType="INTEGER" property="authorizationStatus" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != authorizerAppid "> | |||||
| and `authorizer_appid` like concat('%', #{authorizerAppid},'%') | |||||
| </if> | |||||
| <if test=" null != headImg "> | |||||
| and `head_img` like concat('%', #{headImg},'%') | |||||
| </if> | |||||
| <if test=" null != alias "> | |||||
| and `alias` like concat('%', #{alias},'%') | |||||
| </if> | |||||
| <if test=" null != qrcodeUrl "> | |||||
| and `qrcode_url` like concat('%', #{qrcodeUrl},'%') | |||||
| </if> | |||||
| <if test=" null != createTime "> | |||||
| and `create_time` = #{createTime} | |||||
| </if> | |||||
| <if test=" null != authorizationStatus "> | |||||
| and `authorization_status` = #{authorizationStatus} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxAuthorizerInfo" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_authorizer_info | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,52 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxComponentVerifyTicketMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxComponentVerifyTicket"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="component_appid" jdbcType="VARCHAR" property="componentAppid" /> | |||||
| <result column="component_verify_ticket" jdbcType="VARCHAR" property="componentVerifyTicket" /> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||||
| <result column="deadline" jdbcType="TIMESTAMP" property="deadline" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`component_appid`,`component_verify_ticket`,`create_time`,`deadline` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != componentAppid "> | |||||
| and `component_appid` like concat('%', #{componentAppid},'%') | |||||
| </if> | |||||
| <if test=" null != componentVerifyTicket "> | |||||
| and `component_verify_ticket` like concat('%', #{componentVerifyTicket},'%') | |||||
| </if> | |||||
| <if test=" null != createTime "> | |||||
| and `create_time` = #{createTime} | |||||
| </if> | |||||
| <if test=" null != deadline "> | |||||
| and `deadline` = #{deadline} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxComponentVerifyTicket" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_component_verify_ticket | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,55 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxWeappBasicSetMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxWeappBasicSet"> | |||||
| <id column="id" jdbcType="INTEGER" property="id" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="deploy" jdbcType="INTEGER" property="deploy" /> | |||||
| <result column="domain_url" jdbcType="VARCHAR" property="domainUrl" /> | |||||
| <result column="version" jdbcType="VARCHAR" property="version" /> | |||||
| <result column="template_info" jdbcType="VARCHAR" property="templateInfo" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`type`,`domain_url`,`version`,`template_info`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != deploy "> | |||||
| and `deploy` = #{deploy} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxWeappBasicSet" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_weapp_basic_set | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,68 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxWeappInfoMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxWeappCodeStatus"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="app_id" jdbcType="VARCHAR" property="appId" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="user_version" jdbcType="VARCHAR" property="userVersion" /> | |||||
| <result column="code_status" jdbcType="INTEGER" property="codeStatus" /> | |||||
| <result column="audit_status" jdbcType="INTEGER" property="auditStatus" /> | |||||
| <result column="release_status" jdbcType="INTEGER" property="releaseStatus" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`app_id`,`type`,`user_version`,`code_status`,`audit_status`,`release_status`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != appId "> | |||||
| and `app_id` = #{appId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != userVersion "> | |||||
| and `user_version` = #{userVersion} | |||||
| </if> | |||||
| <if test=" null != codeStatus "> | |||||
| and `code_status` = #{codeStatus} | |||||
| </if> | |||||
| <if test=" null != auditStatus "> | |||||
| and `audit_status` = #{auditStatus} | |||||
| </if> | |||||
| <if test=" null != releaseStatus "> | |||||
| and `release_status` = #{releaseStatus} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxWeappCodeStatus" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_weapp_code_status | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,54 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxWeappExtSetMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxWeappExtSet"> | |||||
| <id column="id" jdbcType="INTEGER" property="id" /> | |||||
| <result column="app_id" jdbcType="VARCHAR" property="appId" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="ext" jdbcType="VARCHAR" property="ext" /> | |||||
| <result column="release" jdbcType="VARCHAR" property="release" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`app_id`,`type`,`ext`,`release`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != appId "> | |||||
| and `app_id` = #{appId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxWeappExtSet" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_weapp_ext_set | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,64 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxWeappInfoMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxWeappInfo"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="app_id" jdbcType="VARCHAR" property="appId" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| <result column="current_version" jdbcType="VARCHAR" property="currentVersion" /> | |||||
| <result column="current_desc" jdbcType="VARCHAR" property="currentDesc" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`app_id`,`type`,`current_version`,`current_desc`,`create_date`,`update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != appId "> | |||||
| and `app_id` = #{appId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and `name` = #{name} | |||||
| </if> | |||||
| <if test=" null != currentVersion "> | |||||
| and `current_version` like concat('%', #{currentVersion},'%') | |||||
| </if> | |||||
| <if test=" null != currentDesc "> | |||||
| and `current_desc` like concat('%', #{currentDesc},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxWeappInfo" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_weapp_info | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,61 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <parent> | |||||
| <artifactId>mallink</artifactId> | |||||
| <groupId>com.iformall</groupId> | |||||
| <version>1.0</version> | |||||
| </parent> | |||||
| <artifactId>mallinkWechatOpen</artifactId> | |||||
| <properties> | |||||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | |||||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||||
| </properties> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>com.iformall</groupId> | |||||
| <artifactId>mallinkService</artifactId> | |||||
| <version>1.0</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-open</artifactId> | |||||
| <version>${weixin-java-open.version}</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-mp</artifactId> | |||||
| <version>${weixin-java-mp.version}</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.google.zxing</groupId> | |||||
| <artifactId>core</artifactId> | |||||
| <version>3.3.3</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.axet</groupId> | |||||
| <artifactId>kaptcha</artifactId> | |||||
| <version>0.0.9</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <build> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <groupId>org.springframework.boot</groupId> | |||||
| <artifactId>spring-boot-maven-plugin</artifactId> | |||||
| <configuration> | |||||
| <executable>true</executable> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| </project> | |||||
| @@ -0,0 +1,33 @@ | |||||
| package com.iformall; | |||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.boot.SpringApplication; | |||||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import tk.mybatis.spring.annotation.MapperScan; | |||||
| /** | |||||
| * @author stormeye | |||||
| * @date 2019-01-14 | |||||
| */ | |||||
| @SpringBootApplication | |||||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||||
| @EnableSwagger2 | |||||
| @EnableEncryptableProperties | |||||
| public class WechatOpenApplication { | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| SpringApplication.run(WechatOpenApplication.class, args); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "aws") | |||||
| public class AwsProperty { | |||||
| // AWS ACCESS KEY | |||||
| private String access; | |||||
| private String secret; | |||||
| private String clientRegion; | |||||
| private String bucketName; | |||||
| public String getAccess() { | |||||
| return access; | |||||
| } | |||||
| public void setAccess(String access) { | |||||
| this.access = access; | |||||
| } | |||||
| public String getSecret() { | |||||
| return secret; | |||||
| } | |||||
| public void setSecret(String secret) { | |||||
| this.secret = secret; | |||||
| } | |||||
| public String getClientRegion() { | |||||
| return clientRegion; | |||||
| } | |||||
| public void setClientRegion(String clientRegion) { | |||||
| this.clientRegion = clientRegion; | |||||
| } | |||||
| public String getBucketName() { | |||||
| return bucketName; | |||||
| } | |||||
| public void setBucketName(String bucketName) { | |||||
| this.bucketName = bucketName; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.config; | |||||
| import com.google.code.kaptcha.impl.DefaultKaptcha; | |||||
| import com.google.code.kaptcha.util.Config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import java.util.Properties; | |||||
| /** | |||||
| * 生成验证码配置 | |||||
| * | |||||
| * @author stormeye.wu | |||||
| * @email wugq@mippoint.com | |||||
| * @date 2017-04-20 19:22 | |||||
| */ | |||||
| @Configuration | |||||
| public class KaptchaConfig { | |||||
| @Bean | |||||
| public DefaultKaptcha producer() { | |||||
| Properties properties = new Properties(); | |||||
| properties.put("kaptcha.border", "no"); | |||||
| properties.put("kaptcha.textproducer.font.color", "black"); | |||||
| properties.put("kaptcha.textproducer.char.space", "5"); | |||||
| Config config = new Config(properties); | |||||
| DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); | |||||
| defaultKaptcha.setConfig(config); | |||||
| return defaultKaptcha; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,71 @@ | |||||
| package com.iformall.config; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.cache.CacheManager; | |||||
| import org.springframework.cache.annotation.CachingConfigurerSupport; | |||||
| import org.springframework.cache.annotation.EnableCaching; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.data.redis.cache.RedisCacheConfiguration; | |||||
| import org.springframework.data.redis.cache.RedisCacheManager; | |||||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | |||||
| import java.time.Duration; | |||||
| import java.util.HashMap; | |||||
| import java.util.HashSet; | |||||
| import java.util.Map; | |||||
| import java.util.Set; | |||||
| /** | |||||
| * Created by Stormeye on 2018/10/1. | |||||
| */ | |||||
| @Configuration | |||||
| @EnableCaching | |||||
| public class RedisConfig extends CachingConfigurerSupport { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| //缓存管理器 | |||||
| @Bean | |||||
| public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||||
| /* | |||||
| //user信息缓存配置 | |||||
| RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||||
| Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||||
| redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||||
| //初始化一个RedisCacheWriter | |||||
| RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||||
| // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||||
| // ClassLoader loader = this.getClass().getClassLoader(); | |||||
| // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||||
| // RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||||
| // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||||
| RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||||
| //设置默认超过期时间是30秒 | |||||
| defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||||
| //初始化RedisCacheManager | |||||
| RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||||
| return cacheManager; | |||||
| */ | |||||
| RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); // 生成一个默认配置,通过config对象即可对缓存进行自定义配置 | |||||
| config = config.entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置 | |||||
| .disableCachingNullValues(); // 不缓存空值 | |||||
| // 设置一个初始化的缓存空间set集合 | |||||
| Set<String> cacheNames = new HashSet<>(); | |||||
| cacheNames.add("my-redis-cache1"); | |||||
| cacheNames.add("my-redis-cache2"); | |||||
| // 对每个缓存空间应用不同的配置 | |||||
| Map<String, RedisCacheConfiguration> configMap = new HashMap<>(); | |||||
| configMap.put("my-redis-cache1", config); | |||||
| configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120))); | |||||
| RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory) // 使用自定义的缓存配置初始化一个cacheManager | |||||
| .initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置 | |||||
| .withInitialCacheConfigurations(configMap) | |||||
| .build(); | |||||
| return cacheManager; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,124 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import redis.clients.jedis.JedisPoolConfig; | |||||
| import redis.clients.jedis.Protocol; | |||||
| import javax.net.ssl.HostnameVerifier; | |||||
| import javax.net.ssl.SSLParameters; | |||||
| import javax.net.ssl.SSLSocketFactory; | |||||
| /** | |||||
| * Stormeye | |||||
| */ | |||||
| @ConfigurationProperties(prefix = "wechat.redis") | |||||
| public class RedisProperies extends JedisPoolConfig { | |||||
| private String host = Protocol.DEFAULT_HOST; | |||||
| private int port = Protocol.DEFAULT_PORT; | |||||
| private String password; | |||||
| private int database = 1; | |||||
| private int connectionTimeout = Protocol.DEFAULT_TIMEOUT; | |||||
| private int soTimeout = Protocol.DEFAULT_TIMEOUT; | |||||
| private String clientName; | |||||
| private boolean ssl; | |||||
| private SSLSocketFactory sslSocketFactory; | |||||
| private SSLParameters sslParameters; | |||||
| private HostnameVerifier hostnameVerifier; | |||||
| public boolean isSsl() { | |||||
| return ssl; | |||||
| } | |||||
| public void setSsl(boolean ssl) { | |||||
| this.ssl = ssl; | |||||
| } | |||||
| public SSLSocketFactory getSslSocketFactory() { | |||||
| return sslSocketFactory; | |||||
| } | |||||
| public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { | |||||
| this.sslSocketFactory = sslSocketFactory; | |||||
| } | |||||
| public SSLParameters getSslParameters() { | |||||
| return sslParameters; | |||||
| } | |||||
| public void setSslParameters(SSLParameters sslParameters) { | |||||
| this.sslParameters = sslParameters; | |||||
| } | |||||
| public HostnameVerifier getHostnameVerifier() { | |||||
| return hostnameVerifier; | |||||
| } | |||||
| public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { | |||||
| this.hostnameVerifier = hostnameVerifier; | |||||
| } | |||||
| public String getHost() { | |||||
| return host; | |||||
| } | |||||
| public void setHost(String host) { | |||||
| if (host == null || "".equals(host)) { | |||||
| host = Protocol.DEFAULT_HOST; | |||||
| } | |||||
| this.host = host; | |||||
| } | |||||
| public int getPort() { | |||||
| return port; | |||||
| } | |||||
| public void setPort(int port) { | |||||
| this.port = port; | |||||
| } | |||||
| public String getPassword() { | |||||
| return password; | |||||
| } | |||||
| public void setPassword(String password) { | |||||
| if ("".equals(password)) { | |||||
| password = null; | |||||
| } | |||||
| this.password = password; | |||||
| } | |||||
| public int getDatabase() { | |||||
| return database; | |||||
| } | |||||
| public void setDatabase(int database) { | |||||
| this.database = database; | |||||
| } | |||||
| public String getClientName() { | |||||
| return clientName; | |||||
| } | |||||
| public void setClientName(String clientName) { | |||||
| if ("".equals(clientName)) { | |||||
| clientName = null; | |||||
| } | |||||
| this.clientName = clientName; | |||||
| } | |||||
| public int getConnectionTimeout() { | |||||
| return connectionTimeout; | |||||
| } | |||||
| public void setConnectionTimeout(int connectionTimeout) { | |||||
| this.connectionTimeout = connectionTimeout; | |||||
| } | |||||
| public int getSoTimeout() { | |||||
| return soTimeout; | |||||
| } | |||||
| public void setSoTimeout(int soTimeout) { | |||||
| this.soTimeout = soTimeout; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,58 @@ | |||||
| package com.iformall.config; | |||||
| import java.io.IOException; | |||||
| import java.util.Optional; | |||||
| import javax.servlet.Filter; | |||||
| import javax.servlet.FilterChain; | |||||
| import javax.servlet.FilterConfig; | |||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.ServletResponse; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| /** | |||||
| * 前后端分离RESTful接口过滤器 | |||||
| * | |||||
| * @author xuguoqin | |||||
| * | |||||
| */ | |||||
| public class RestFilter implements Filter { | |||||
| @Override | |||||
| public void init(FilterConfig filterConfig) throws ServletException { | |||||
| } | |||||
| @Override | |||||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||||
| throws IOException, ServletException { | |||||
| HttpServletRequest req = null; | |||||
| if (request instanceof HttpServletRequest) { | |||||
| req = (HttpServletRequest) request; | |||||
| } | |||||
| HttpServletResponse res = null; | |||||
| if (response instanceof HttpServletResponse) { | |||||
| res = (HttpServletResponse) response; | |||||
| } | |||||
| if (req != null && res != null) { | |||||
| //设置允许传递的参数 | |||||
| res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); | |||||
| //设置允许带上cookie | |||||
| res.setHeader("Access-Control-Allow-Credentials", "true"); | |||||
| String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer")); | |||||
| //设置允许的请求来源 | |||||
| res.setHeader("Access-Control-Allow-Origin", origin); | |||||
| //设置允许的请求方法 | |||||
| res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS"); | |||||
| } | |||||
| chain.doFilter(request, response); | |||||
| } | |||||
| @Override | |||||
| public void destroy() { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.client.ClientHttpRequestFactory; | |||||
| import org.springframework.http.client.SimpleClientHttpRequestFactory; | |||||
| import org.springframework.web.client.RestTemplate; | |||||
| @Configuration | |||||
| public class RestTemplateConfig { | |||||
| @Bean | |||||
| public RestTemplate restTemplate(ClientHttpRequestFactory factory) { | |||||
| return new RestTemplate(factory); | |||||
| } | |||||
| @Bean | |||||
| public ClientHttpRequestFactory simpleClientHttpRequestFactory() { | |||||
| SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | |||||
| factory.setReadTimeout(5000);//ms | |||||
| factory.setConnectTimeout(10000);//ms | |||||
| return factory; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,303 @@ | |||||
| package com.iformall.config; | |||||
| import com.iformall.service.MallPermissionService; | |||||
| import com.iformall.shiro.MyRetryLimitCredentialsMatcher; | |||||
| import com.iformall.shiro.MyShiroRealm; | |||||
| import org.apache.shiro.mgt.SecurityManager; | |||||
| import org.apache.shiro.spring.LifecycleBeanPostProcessor; | |||||
| import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; | |||||
| import org.apache.shiro.spring.web.ShiroFilterFactoryBean; | |||||
| import org.apache.shiro.web.mgt.DefaultWebSecurityManager; | |||||
| import org.apache.shiro.web.servlet.SimpleCookie; | |||||
| import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; | |||||
| import org.crazycake.shiro.RedisCacheManager; | |||||
| import org.crazycake.shiro.RedisManager; | |||||
| import org.crazycake.shiro.RedisSessionDAO; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import javax.servlet.Filter; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * Created by yangqj on 2017/4/23. | |||||
| */ | |||||
| @Configuration | |||||
| public class ShiroConfig { | |||||
| @Autowired(required = false) | |||||
| private MallPermissionService resourcesService; | |||||
| @Value("${spring.redis.host}") | |||||
| private String host; | |||||
| @Value("${spring.redis.port}") | |||||
| private int port; | |||||
| @Value("${spring.redis.timeout}") | |||||
| private int timeout; | |||||
| @Value("${spring.redis.expire}") | |||||
| private int expire; | |||||
| @Value("${spring.redis.password}") | |||||
| private String password; | |||||
| @Bean | |||||
| public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() { | |||||
| return new LifecycleBeanPostProcessor(); | |||||
| } | |||||
| /** | |||||
| * ShiroDialect,为了在thymeleaf里使用shiro的标签的bean | |||||
| * @return | |||||
| */ | |||||
| // @Bean | |||||
| // public ShiroDialect shiroDialect() { | |||||
| // return new ShiroDialect(); | |||||
| // } | |||||
| /** | |||||
| * ShiroFilterFactoryBean 处理拦截资源文件问题。 | |||||
| * 注意:单独一个ShiroFilterFactoryBean配置是或报错的,因为在 | |||||
| * 初始化ShiroFilterFactoryBean的时候需要注入:SecurityManager | |||||
| * <p> | |||||
| * Filter Chain定义说明 | |||||
| * 1、一个URL可以配置多个Filter,使用逗号分隔 | |||||
| * 2、当设置多个过滤器时,全部验证通过,才视为通过 | |||||
| * 3、部分过滤器可指定参数,如perms,roles | |||||
| */ | |||||
| @Bean | |||||
| public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) { | |||||
| System.out.println("ShiroConfiguration.shirFilter()"); | |||||
| ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); | |||||
| // 必须设置 SecurityManager | |||||
| shiroFilterFactoryBean.setSecurityManager(securityManager); | |||||
| Map<String, Filter> filters = new LinkedHashMap<String, Filter>(); | |||||
| filters.put("token", new ShiroLoginFilter()); | |||||
| filters.put("corsFilter", new RestFilter()); | |||||
| //filters.put("authc", new MyFormAuthenticationFilter()); | |||||
| shiroFilterFactoryBean.setFilters(filters); | |||||
| // 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面 | |||||
| shiroFilterFactoryBean.setLoginUrl("/#/"); | |||||
| // 登录成功后要跳转的链接 | |||||
| shiroFilterFactoryBean.setSuccessUrl("/usersPage"); | |||||
| //未授权界面; | |||||
| shiroFilterFactoryBean.setUnauthorizedUrl("/403"); | |||||
| //拦截器. | |||||
| Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>(); | |||||
| //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||||
| //filterChainDefinitionMap.put("/ue/**", "anon"); | |||||
| //filterChainDefinitionMap.put("/config.json", "anon"); | |||||
| // 静态文件 | |||||
| filterChainDefinitionMap.put("/css/**", "anon"); | |||||
| filterChainDefinitionMap.put("/js/**", "anon"); | |||||
| filterChainDefinitionMap.put("/img/**", "anon"); | |||||
| filterChainDefinitionMap.put("/font-awesome/**", "anon"); | |||||
| //<!-- 过滤链定义,从上向下顺序执行,一般将 /**放在最为下边 -->:这是一个坑呢,一不小心代码就不好使了; | |||||
| //<!-- authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问--> | |||||
| //自定义加载权限资源关系 | |||||
| // Map<String,Object> map = new HashMap<>(); | |||||
| // List<SysPermission> resourcesList = resourcesService.list(map); | |||||
| // for(SysPermission resources:resourcesList){ | |||||
| // | |||||
| // if (StringUtil.isNotEmpty(resources.getUrl())) { | |||||
| // String permission = "perms[" + resources.getUrl()+ "]"; | |||||
| // filterChainDefinitionMap.put(resources.getUrl(),permission); | |||||
| // } | |||||
| // } | |||||
| // 登录 | |||||
| filterChainDefinitionMap.put("/captcha.jpg", "anon"); | |||||
| filterChainDefinitionMap.put("/doLogin/**", "anon"); | |||||
| filterChainDefinitionMap.put("/version", "anon"); | |||||
| /// swagger-ui.html | |||||
| filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | |||||
| filterChainDefinitionMap.put("/v2/**", "anon"); | |||||
| filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | |||||
| filterChainDefinitionMap.put("/webjars/**", "anon"); | |||||
| // 第三方平台 | |||||
| filterChainDefinitionMap.put("/wxOpen/**", "anon"); | |||||
| // filterChainDefinitionMap.put("/role/**", "corsFilter,token"); | |||||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||||
| // filterChainDefinitionMap.put("/**", "anon"); | |||||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||||
| return shiroFilterFactoryBean; | |||||
| } | |||||
| public static boolean isAjax(ServletRequest request) { | |||||
| String header = ((HttpServletRequest) request).getHeader("X-Requested-With"); | |||||
| if ("XMLHttpRequest".equalsIgnoreCase(header)) { | |||||
| System.out.println("当前请求为Ajax请求"); | |||||
| return Boolean.TRUE; | |||||
| } | |||||
| System.out.println("当前请求非Ajax请求"); | |||||
| return Boolean.FALSE; | |||||
| } | |||||
| @Bean | |||||
| public SecurityManager securityManager(@Qualifier("myRetryLimitCredentialsMatcher") MyRetryLimitCredentialsMatcher matcher) { | |||||
| DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||||
| //设置realm. | |||||
| securityManager.setRealm(myShiroRealm(matcher)); | |||||
| // 自定义缓存实现 使用redis | |||||
| //securityManager.setCacheManager(cacheManager()); | |||||
| // 自定义session管理 使用redis | |||||
| securityManager.setSessionManager(sessionManager()); | |||||
| return securityManager; | |||||
| } | |||||
| @Bean | |||||
| public MyShiroRealm myShiroRealm(MyRetryLimitCredentialsMatcher matcher) { | |||||
| MyShiroRealm myShiroRealm = new MyShiroRealm(); | |||||
| myShiroRealm.setCredentialsMatcher(matcher); | |||||
| return myShiroRealm; | |||||
| } | |||||
| /** | |||||
| * 密码匹配凭证管理器 凭证匹配器 | |||||
| * (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了 | |||||
| * 所以我们需要修改下doGetAuthenticationInfo中的代码; | |||||
| * ) | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @Bean(name = "myRetryLimitCredentialsMatcher") | |||||
| public MyRetryLimitCredentialsMatcher hashedCredentialsMatcher() { | |||||
| MyRetryLimitCredentialsMatcher hashedCredentialsMatcher = new MyRetryLimitCredentialsMatcher(); | |||||
| hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法; | |||||
| hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5("")); | |||||
| return hashedCredentialsMatcher; | |||||
| } | |||||
| /** | |||||
| * 开启shiro aop注解支持. | |||||
| * 使用代理方式;所以需要开启代码支持; | |||||
| * | |||||
| * @param securityManager | |||||
| * @return | |||||
| */ | |||||
| @Bean | |||||
| public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { | |||||
| AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); | |||||
| authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); | |||||
| return authorizationAttributeSourceAdvisor; | |||||
| } | |||||
| /** | |||||
| * 配置shiro redisManager | |||||
| * 使用的是shiro-redis开源插件 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| public RedisManager redisManager() { | |||||
| RedisManager redisManager = new RedisManager(); | |||||
| redisManager.setHost(host); | |||||
| redisManager.setPort(port); | |||||
| //redisManager.setExpire(expire);// 配置缓存过期时间 | |||||
| redisManager.setTimeout(timeout); | |||||
| redisManager.setPassword(password); | |||||
| return redisManager; | |||||
| } | |||||
| /** | |||||
| * cacheManager 缓存 redis实现 | |||||
| * 使用的是shiro-redis开源插件 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| public RedisCacheManager cacheManager() { | |||||
| RedisCacheManager redisCacheManager = new RedisCacheManager(); | |||||
| redisCacheManager.setRedisManager(redisManager()); | |||||
| return redisCacheManager; | |||||
| } | |||||
| /** | |||||
| * RedisSessionDAO shiro sessionDao层的实现 通过redis | |||||
| * 使用的是shiro-redis开源插件 | |||||
| */ | |||||
| @Bean | |||||
| public RedisSessionDAO redisSessionDAO() { | |||||
| RedisSessionDAO redisSessionDAO = new RedisSessionDAO(); | |||||
| redisSessionDAO.setRedisManager(redisManager()); | |||||
| return redisSessionDAO; | |||||
| } | |||||
| /** | |||||
| * shiro session的管理 | |||||
| */ | |||||
| @Bean | |||||
| public DefaultWebSessionManager sessionManager() { | |||||
| DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); | |||||
| //设置session过期时间为1小时(单位:毫秒),默认为30分钟 | |||||
| sessionManager.setGlobalSessionTimeout(60 * 60 * 1000); | |||||
| sessionManager.setSessionValidationSchedulerEnabled(true); | |||||
| sessionManager.setSessionIdUrlRewritingEnabled(false); | |||||
| sessionManager.setSessionDAO(redisSessionDAO()); | |||||
| sessionManager.setSessionIdCookie(simpleCookie()); | |||||
| return sessionManager; | |||||
| } | |||||
| @Bean | |||||
| public SimpleCookie simpleCookie() { | |||||
| SimpleCookie simpleCookie = new SimpleCookie("SSIDS"); | |||||
| simpleCookie.setDomain(""); | |||||
| return simpleCookie; | |||||
| } | |||||
| // @Bean | |||||
| // public SimpleCookie rememberMeCookie(){ | |||||
| // //System.out.println("ShiroConfiguration.rememberMeCookie()"); | |||||
| // //这个参数是cookie的名称,对应前端的checkbox的name = rememberMe | |||||
| // SimpleCookie simpleCookie = new SimpleCookie("rememberMe"); | |||||
| // //<!-- 记住我cookie生效时间30天 ,单位秒;--> | |||||
| // simpleCookie.setMaxAge(60*30); | |||||
| // return simpleCookie; | |||||
| // } | |||||
| // @Bean | |||||
| // public CookieRememberMeManager rememberMeManager(){ | |||||
| // //System.out.println("ShiroConfiguration.rememberMeManager()"); | |||||
| // CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager(); | |||||
| // cookieRememberMeManager.setCookie(rememberMeCookie()); | |||||
| // //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位) | |||||
| // cookieRememberMeManager.setCipherKey(Base64.decodeBytes("2AvVhdsgUs0FSA3SDFAdag==")); | |||||
| // return cookieRememberMeManager; | |||||
| // } | |||||
| // @Bean(name = "securityManager") | |||||
| // public DefaultWebSecurityManager defaultWebSecurityManager(MyShiroRealm realm){ | |||||
| // DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); | |||||
| // //设置realm | |||||
| // securityManager.setRealm(realm); | |||||
| // //用户授权/认证信息Cache, 采用EhCache缓存 | |||||
| // securityManager.setCacheManager(cacheManager()); | |||||
| // //注入记住我管理器 | |||||
| // securityManager.setRememberMeManager(rememberMeManager()); | |||||
| // return securityManager; | |||||
| // } | |||||
| } | |||||
| @@ -0,0 +1,31 @@ | |||||
| package com.iformall.config; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.common.ResultData; | |||||
| import org.apache.shiro.web.filter.authc.FormAuthenticationFilter; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.ServletResponse; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| public class ShiroLoginFilter extends FormAuthenticationFilter { | |||||
| @Override | |||||
| protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { | |||||
| response.setCharacterEncoding("UTF-8"); | |||||
| response.setContentType("application/json"); | |||||
| ResultData resultData = new ResultData(ResultData.UNLOGIN,"用户未登录"); | |||||
| response.getWriter().write(JSON.toJSONString(resultData)); | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * 判断ajax请求 | |||||
| * @param request | |||||
| * @return | |||||
| */ | |||||
| boolean isAjax(HttpServletRequest request){ | |||||
| return (request.getHeader("X-Requested-With") != null && "XMLHttpRequest".equals( request.getHeader("X-Requested-With").toString()) ) ; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,79 @@ | |||||
| package com.iformall.config; | |||||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||||
| import com.fasterxml.jackson.databind.DeserializationConfig; | |||||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||||
| import com.fasterxml.jackson.databind.module.SimpleModule; | |||||
| import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.converter.HttpMessageConverter; | |||||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||||
| import org.springframework.web.servlet.config.annotation.CorsRegistry; | |||||
| import org.springframework.web.servlet.config.annotation.EnableWebMvc; | |||||
| import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |||||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.BigInteger; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.List; | |||||
| @Configuration | |||||
| @EnableWebMvc | |||||
| public class WebConfig implements WebMvcConfigurer { | |||||
| @Override | |||||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||||
| registry.addResourceHandler("swagger-ui.html") | |||||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||||
| registry.addResourceHandler("/webjars/**") | |||||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||||
| //registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/"); | |||||
| } | |||||
| @Override | |||||
| public void addCorsMappings(CorsRegistry registry) { | |||||
| registry.addMapping("/**") | |||||
| .allowedOrigins("*") | |||||
| .allowCredentials(true) | |||||
| .allowedMethods("GET", "POST", "DELETE", "PUT") | |||||
| .maxAge(3600); | |||||
| } | |||||
| @Override | |||||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||||
| MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||||
| //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||||
| ObjectMapper objectMapper = new ObjectMapper(); | |||||
| SimpleModule simpleModule = new SimpleModule(); | |||||
| //不显示为null的字段 | |||||
| objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||||
| DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||||
| // 设置反序列化日期格式、忽略不存在get、set的属性 | |||||
| objectMapper.setConfig( | |||||
| dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||||
| .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||||
| ); | |||||
| //序列化将Long转String类型 | |||||
| simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||||
| simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||||
| SimpleModule bigIntegerModule = new SimpleModule(); | |||||
| //序列化将BigInteger转String类型 | |||||
| bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||||
| SimpleModule bigDecimalModule = new SimpleModule(); | |||||
| //序列化将BigDecimal转String类型 | |||||
| bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||||
| objectMapper.registerModule(simpleModule); | |||||
| objectMapper.registerModule(bigDecimalModule); | |||||
| objectMapper.registerModule(bigIntegerModule); | |||||
| jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||||
| converters.add(jackson2HttpMessageConverter); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,69 @@ | |||||
| package com.iformall.config; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| /** | |||||
| * Stormeye | |||||
| */ | |||||
| @ConfigurationProperties(prefix = "wechat.open") | |||||
| public class WechatOpenProperties { | |||||
| /** | |||||
| * 设置微信三方平台的appid | |||||
| */ | |||||
| private String componentAppId; | |||||
| /** | |||||
| * 设置微信三方平台的app secret | |||||
| */ | |||||
| private String componentSecret; | |||||
| /** | |||||
| * 设置微信三方平台的token | |||||
| */ | |||||
| private String componentToken; | |||||
| /** | |||||
| * 设置微信三方平台的EncodingAESKey | |||||
| */ | |||||
| private String componentAesKey; | |||||
| public String getComponentAppId() { | |||||
| return componentAppId; | |||||
| } | |||||
| public void setComponentAppId(String componentAppId) { | |||||
| this.componentAppId = componentAppId; | |||||
| } | |||||
| public String getComponentSecret() { | |||||
| return componentSecret; | |||||
| } | |||||
| public void setComponentSecret(String componentSecret) { | |||||
| this.componentSecret = componentSecret; | |||||
| } | |||||
| public String getComponentToken() { | |||||
| return componentToken; | |||||
| } | |||||
| public void setComponentToken(String componentToken) { | |||||
| this.componentToken = componentToken; | |||||
| } | |||||
| public String getComponentAesKey() { | |||||
| return componentAesKey; | |||||
| } | |||||
| public void setComponentAesKey(String componentAesKey) { | |||||
| this.componentAesKey = componentAesKey; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return ToStringBuilder.reflectionToString(this, | |||||
| ToStringStyle.MULTI_LINE_STYLE); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.utils.IPUtil; | |||||
| import org.springframework.web.bind.WebDataBinder; | |||||
| import org.springframework.web.bind.annotation.InitBinder; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.context.request.RequestContextHolder; | |||||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.beans.PropertyEditorSupport; | |||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | |||||
| @RestController | |||||
| public class BaseController { | |||||
| @InitBinder | |||||
| public void InitBinder(WebDataBinder dataBinder) { | |||||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||||
| public void setAsText(String value) { | |||||
| try { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||||
| } catch(ParseException e) { | |||||
| try { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||||
| } catch (ParseException e1) { | |||||
| setValue(null); | |||||
| } | |||||
| } | |||||
| } | |||||
| public String getAsText() { | |||||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| public String getIpAddr() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String ipaddress = IPUtil.getIpAddr(request); | |||||
| return ipaddress; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,161 @@ | |||||
| package com.iformall.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.google.code.kaptcha.Constants; | |||||
| import com.google.code.kaptcha.Producer; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.MallRolePermission; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.MallUserRole; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.MallRolePermissionService; | |||||
| import com.iformall.service.MallUserInfoService; | |||||
| import com.iformall.service.MallUserRoleService; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import com.iformall.utils.ShiroUtils; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.io.IOUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.authc.UsernamePasswordToken; | |||||
| import org.apache.shiro.subject.Subject; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import javax.imageio.ImageIO; | |||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletOutputStream; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.awt.image.BufferedImage; | |||||
| import java.io.IOException; | |||||
| @RestController | |||||
| @Api(description = "登录相关接口") | |||||
| public class HomeController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Value("${version}") | |||||
| private String version; | |||||
| @Autowired | |||||
| private Producer producer; | |||||
| @Autowired | |||||
| private MallUserInfoService mallUserInfoService; | |||||
| @Autowired | |||||
| private MallUserRoleService mallUserRoleService; | |||||
| @Autowired | |||||
| private MallRolePermissionService mallRolePermissionService; | |||||
| @GetMapping("/captcha.jpg") | |||||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | |||||
| logger.debug("[" + getIpAddr() + "] HomeController::captcha"); | |||||
| response.setHeader("Cache-Control", "no-store, no-cache"); | |||||
| response.setContentType("image/jpeg"); | |||||
| //生成文字验证码 | |||||
| String text = producer.createText(); | |||||
| //生成图片验证码 | |||||
| BufferedImage image = producer.createImage(text); | |||||
| //保存到shiro session | |||||
| ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||||
| ServletOutputStream out = response.getOutputStream(); | |||||
| ImageIO.write(image, "jpg", out); | |||||
| IOUtils.closeQuietly(out); | |||||
| } | |||||
| @ApiOperation("登录") | |||||
| @PostMapping("/doLogin") | |||||
| public ResultData login(@RequestBody MallUserInfo user) { | |||||
| logger.debug("[" + getIpAddr() + "] HomeController::login"); | |||||
| try { | |||||
| String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||||
| if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||||
| return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||||
| } | |||||
| } catch (MallinkException e) { | |||||
| logger.error("验证码" + e.getMessage()); | |||||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | |||||
| } | |||||
| ResultData data = new ResultData(); | |||||
| if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | |||||
| // throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); | |||||
| return new ResultData(ResultData.ERROR, "用户名或者密码错误"); | |||||
| } | |||||
| try { | |||||
| Subject subject = SecurityUtils.getSubject(); | |||||
| UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | |||||
| subject.login(token); | |||||
| // List<MallRole> roleList = sysRoleService.findRoleByUserId(user.getId()); | |||||
| // if (null != roleList && roleList.size() > 0) { | |||||
| // List<MallPermission> permissionList = sysPermissionService | |||||
| // .findPermissionByRoleIds(roleList.stream().map(MallRole::getId).collect(Collectors.toList())); | |||||
| // user.setRole(roleList); | |||||
| // user.setPermission(permissionList); | |||||
| // } | |||||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
| info.setPassword("保密"); | |||||
| // System.out.println("id:"+ SecurityUtils.getSubject().getSession().getId()); | |||||
| String menus = getPermissionsByRole(info); | |||||
| if(menus != null) { | |||||
| info.setMenus(menus); | |||||
| } | |||||
| data.data = info; | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ResultData.ERROR, "用户名或者密码错误"); | |||||
| } | |||||
| return data; | |||||
| } | |||||
| private String getPermissionsByRole(MallUserInfo info) { | |||||
| MallUserRole ur = new MallUserRole(); | |||||
| ur.setUid(info.getId()); | |||||
| PageInfo<MallUserRole> page = mallUserRoleService.listAsPage(ur, 1, 1); | |||||
| if (page.getSize() > 0) { | |||||
| Long roleId = page.getList().get(0).getRoleId(); | |||||
| MallRolePermission p = new MallRolePermission(); | |||||
| p.setRoleId(roleId); | |||||
| p.setTenantId(info.getTenantId()); | |||||
| PageInfo<MallRolePermission> listAsPage = mallRolePermissionService.listAsPage(p, 1, 100); | |||||
| String menus = ""; | |||||
| for (MallRolePermission rp : listAsPage.getList()) { | |||||
| menus += rp.getPermissionId() + ","; | |||||
| } | |||||
| if (menus.length() > 0) { | |||||
| menus = menus.substring(0, menus.length() - 1); | |||||
| } | |||||
| return menus; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| @ApiOperation("登出") | |||||
| @GetMapping("/logout") | |||||
| public ResultData logout() { | |||||
| logger.debug("[" + getIpAddr() + "] HomeController::logout"); | |||||
| ResultData data = new ResultData(); | |||||
| SecurityUtils.getSubject().logout(); | |||||
| return data; | |||||
| } | |||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| return new ResultData(version); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,96 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | |||||
| import com.iformall.service.WxAuthorizerInfoService; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.IOException; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @Controller | |||||
| @RequestMapping("/wt_auth") | |||||
| @Api(description = "微信第三方开放平台授权相关接口") | |||||
| public class WechatAuthController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| @Autowired | |||||
| private WxAuthorizerInfoService authorizerInfoService; | |||||
| @GetMapping("/goto_auth_url_show") | |||||
| @ResponseBody | |||||
| public String gotoPreAuthUrlShow() { | |||||
| return "<html>" + | |||||
| "<body>" + | |||||
| "<a href='/api/wt_auth/goto_auth_url'>go</a>" + | |||||
| "</body>" + | |||||
| "</html>"; | |||||
| } | |||||
| @GetMapping("/goto_auth_url") | |||||
| public void gotoPreAuthUrl(HttpServletRequest request, HttpServletResponse response) { | |||||
| String host = request.getHeader("host"); | |||||
| String url = "https://" + host + "/api/wt_auth/jump"; | |||||
| try { | |||||
| url = openService.getWxOpenComponentService().getPreAuthUrl(url); | |||||
| response.sendRedirect(url); | |||||
| } catch (WxErrorException | IOException e) { | |||||
| logger.error("gotoPreAuthUrl", e); | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| } | |||||
| @GetMapping("/jump") | |||||
| @ResponseBody | |||||
| public WxOpenQueryAuthResult jump(@RequestParam("auth_code") String authorizationCode) { | |||||
| try { | |||||
| WxOpenQueryAuthResult queryAuthResult = openService.getWxOpenComponentService().getQueryAuth(authorizationCode); | |||||
| logger.info("getQueryAuth", queryAuthResult); | |||||
| WxOpenAuthorizerInfoResult openAuthorizerInfoResult = openService.getWxOpenComponentService().getAuthorizerInfo( | |||||
| queryAuthResult.getAuthorizationInfo().getAuthorizerAppid()); | |||||
| // save auth info | |||||
| authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ | |||||
| { | |||||
| setAuthorizerAppid(openAuthorizerInfoResult.getAuthorizationInfo().getAuthorizerAppid()); | |||||
| setAlias(openAuthorizerInfoResult.getAuthorizerInfo().getAlias()); | |||||
| setHeadImg(openAuthorizerInfoResult.getAuthorizerInfo().getHeadImg()); | |||||
| setQrcodeUrl(openAuthorizerInfoResult.getAuthorizerInfo().getQrcodeUrl()); | |||||
| setAuthorizationStatus(EnumWxAuthorizationStatus.AUTHORIZED.getCode()); | |||||
| } | |||||
| }); | |||||
| return queryAuthResult; | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("gotoPreAuthUrl", e); | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| } | |||||
| @GetMapping("/getMobilePreAuthUrl") | |||||
| @ResponseBody | |||||
| public String getMobilePreAuthUrl(HttpServletRequest request, HttpServletResponse response) { | |||||
| String host = request.getHeader("host"); | |||||
| String url = "https://" + host + "/api/wt_auth/jump"; | |||||
| try { | |||||
| url = openService.getWxOpenComponentService().getMobilePreAuthUrl(url); | |||||
| return url; | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("getMobilePreAuthUrl", e); | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,242 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| import com.iformall.enums.EnumWxAuthorizationInfoType; | |||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | |||||
| import com.iformall.service.WxAuthorizerInfoService; | |||||
| import com.iformall.service.WxComponentVerifyTicketService; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; | |||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | |||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | |||||
| import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.io.ByteArrayOutputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.nio.charset.Charset; | |||||
| import java.util.Date; | |||||
| @Controller | |||||
| @RequestMapping("/wxOpen") | |||||
| @Api(description = "微信第三方开放平台回调相关接口") | |||||
| public class WechatCalllbackController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| protected WxOpenService wxOpenService; | |||||
| @Autowired | |||||
| private WxComponentVerifyTicketService componentVerifyTicketService; | |||||
| @Autowired | |||||
| private WxAuthorizerInfoService authorizerInfoService; | |||||
| @RequestMapping(value = "/notify", method = RequestMethod.POST) | |||||
| @ApiOperation("接收ticket回调") | |||||
| public Object receiveTicket(HttpServletRequest request) throws IOException { | |||||
| logger.info("[" +getIpAddr() + "]接收微信请求 /wxOpen/notify"); | |||||
| InputStream inStream = request.getInputStream(); | |||||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||||
| byte[] buffer = new byte[1024]; | |||||
| int len = 0; | |||||
| while ((len = inStream.read(buffer)) != -1) { | |||||
| outSteam.write(buffer, 0, len); | |||||
| } | |||||
| String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||||
| logger.info(resultxml); | |||||
| outSteam.close(); | |||||
| inStream.close(); | |||||
| String timestamp = request.getParameter("timestamp"); | |||||
| String nonce = request.getParameter("nonce"); | |||||
| String signature = request.getParameter("signature"); | |||||
| String encType = request.getParameter("encrypt_type"); | |||||
| String msgSignature= request.getParameter("msg_signature"); | |||||
| /* | |||||
| // 测试数据 | |||||
| String timestamp = "1545708083"; | |||||
| String nonce = "1052028699"; | |||||
| String signature = "b5fa8296b46c726cbed35f744944f20f682776a6"; | |||||
| String encType = "aes"; | |||||
| String msgSignature= "54bec4c513f447cb312fd091bea48326f87aedde"; | |||||
| String resultxml = "<xml>\n" + | |||||
| " <AppId><![CDATA[wx897e4673286c915d]]></AppId>\n" + | |||||
| " <Encrypt><![CDATA[92gl+PCgxooLh85YZ74VX8gNPV3tq2w8br4tuBl2UIc9uJuJiSNBgohFxgS7tRXSMUtr5t+75MiLKlaMKvv4FH5iF3WdYbxjF6ojnA1+MBzD7mf9fo6KkWUdDq+1V0OtrooP4s8iuAC0Lx3elCtWUZXYGnCeP5Y/2A8ZZBwpvcBz73d7n2Kv8QVvLsw2dmrej1b8KGdmRAEbm/oYoVthlAkmoTTAAx+Gj10XTMem1wp1vT/a0mGxN88oJxNZoHdFvAbmc24A7VD4i5VDOt9FqwerqlGXnBX5pBAmOx8ZUsndM8yuf3I54GE9hEPRvdWBiyLb96Lb8ZnjEBlvc9kvs7PpFOSQhkbGMNQKWGW1os8UImr7O3+IiKLuBv2G1pJBb2/kIeZn5v9NuxYLOsXQmb2XijHYMXwCNHCI3Eji22k9XDiiuK1miHlUuL8Gz8X7lN9JuVcE24jd7Ty4H0pThQ==]]></Encrypt>\n" + | |||||
| "</xml>"; | |||||
| */ | |||||
| logger.info("\n接收微信请求:[signature=[{}], encType=[{}], msgSignature=[{}]," | |||||
| + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", | |||||
| signature, encType, msgSignature, timestamp, nonce, resultxml); | |||||
| if (!StringUtils.equalsIgnoreCase("aes", encType) | |||||
| || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) { | |||||
| throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); | |||||
| } | |||||
| // aes加密的消息 | |||||
| WxOpenXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedXml(resultxml, | |||||
| wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); | |||||
| this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); | |||||
| if(inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.COMPONENT_VERIFY_TICKET.getMessage())) { | |||||
| // 保存component_verify_ticket | |||||
| componentVerifyTicketService.saveOrUpdate(new WxComponentVerifyTicket(){ | |||||
| { | |||||
| setComponentVerifyTicket(inMessage.getComponentVerifyTicket()); | |||||
| setCreateTime(new Date(Long.valueOf(inMessage.getCreateTime() * 1000))); | |||||
| setComponentAppid(inMessage.getAppId()); | |||||
| setDeadline(new Date(Long.valueOf(System.currentTimeMillis() + (60*60*1000)))); | |||||
| } | |||||
| }); | |||||
| } else if (inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.AUTHORIZED.getMessage()) || | |||||
| inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.UPDATEAUTHORIZED.getMessage()) | |||||
| ) { | |||||
| try { | |||||
| WxOpenQueryAuthResult queryAuthResult = wxOpenService.getWxOpenComponentService().getQueryAuth(inMessage.getAuthorizationCode()); | |||||
| logger.info("getQueryAuth", queryAuthResult); | |||||
| WxOpenAuthorizerInfoResult openAuthorizerInfoResult = wxOpenService.getWxOpenComponentService().getAuthorizerInfo( | |||||
| queryAuthResult.getAuthorizationInfo().getAuthorizerAppid()); | |||||
| // save auth info | |||||
| authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ | |||||
| { | |||||
| setAuthorizerAppid(openAuthorizerInfoResult.getAuthorizationInfo().getAuthorizerAppid()); | |||||
| setAlias(openAuthorizerInfoResult.getAuthorizerInfo().getAlias()); | |||||
| setHeadImg(openAuthorizerInfoResult.getAuthorizerInfo().getHeadImg()); | |||||
| setQrcodeUrl(openAuthorizerInfoResult.getAuthorizerInfo().getQrcodeUrl()); | |||||
| setAuthorizationStatus(EnumWxAuthorizationStatus.AUTHORIZED.getCode()); | |||||
| } | |||||
| }); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } else if (inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.UNAUTHORIZED.getMessage())) { | |||||
| authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ | |||||
| { | |||||
| setAuthorizerAppid(inMessage.getAuthorizerAppid()); | |||||
| setAuthorizationStatus(EnumWxAuthorizationStatus.UNAUTHORIZED.getCode()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| try { | |||||
| String out = wxOpenService.getWxOpenComponentService().route(inMessage); | |||||
| this.logger.debug("\n组装回复信息:{}", out); | |||||
| } catch (WxErrorException e) { | |||||
| this.logger.error("notify", e); | |||||
| } | |||||
| return "success"; | |||||
| } | |||||
| @RequestMapping(value = "/{appId}/callback") | |||||
| @ApiOperation("消息回调") | |||||
| public Object callback(@PathVariable("appId") String appId, HttpServletRequest request) throws IOException { | |||||
| logger.info("[" +getIpAddr() + "]接收微信请求 /{appId}/callback"); | |||||
| InputStream inStream = request.getInputStream(); | |||||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||||
| byte[] buffer = new byte[1024]; | |||||
| int len = 0; | |||||
| while ((len = inStream.read(buffer)) != -1) { | |||||
| outSteam.write(buffer, 0, len); | |||||
| } | |||||
| String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||||
| logger.info(resultxml); | |||||
| outSteam.close(); | |||||
| inStream.close(); | |||||
| String timestamp = request.getParameter("timestamp"); | |||||
| String nonce = request.getParameter("nonce"); | |||||
| String signature = request.getParameter("signature"); | |||||
| String encType = request.getParameter("encrypt_type"); | |||||
| String openid = request.getParameter("openid"); | |||||
| String msgSignature= request.getParameter("msg_signature"); | |||||
| logger.info( | |||||
| "\n接收微信请求:[appId=[{}], openid=[{}], signature=[{}], encType=[{}], msgSignature=[{}]," | |||||
| + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", | |||||
| appId, openid, signature, encType, msgSignature, timestamp, nonce, resultxml); | |||||
| if (!StringUtils.equalsIgnoreCase("aes", encType) | |||||
| || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) { | |||||
| throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); | |||||
| } | |||||
| String out = ""; | |||||
| // aes加密的消息 | |||||
| WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(resultxml, | |||||
| wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); | |||||
| logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); | |||||
| // 全网发布测试用例 | |||||
| if (StringUtils.equalsAnyIgnoreCase(appId, "wx570bc396a51b8ff8", "wxd101a85aa106f53e")) { | |||||
| try { | |||||
| if (StringUtils.equals(inMessage.getMsgType(), "text")) { | |||||
| if (StringUtils.equals(inMessage.getContent(), "TESTCOMPONENT_MSG_TYPE_TEXT")) { | |||||
| out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml( | |||||
| WxMpXmlOutMessage.TEXT().content("TESTCOMPONENT_MSG_TYPE_TEXT_callback") | |||||
| .fromUser(inMessage.getToUser()) | |||||
| .toUser(inMessage.getFromUser()) | |||||
| .build(), | |||||
| wxOpenService.getWxOpenConfigStorage() | |||||
| ); | |||||
| } else if (StringUtils.startsWith(inMessage.getContent(), "QUERY_AUTH_CODE:")) { | |||||
| String msg = inMessage.getContent().replace("QUERY_AUTH_CODE:", "") + "_from_api"; | |||||
| WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(msg).toUser(inMessage.getFromUser()).build(); | |||||
| wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); | |||||
| } | |||||
| } else if (StringUtils.equals(inMessage.getMsgType(), "event")) { | |||||
| WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(inMessage.getEvent() + "from_callback").toUser(inMessage.getFromUser()).build(); | |||||
| wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("callback", e); | |||||
| } | |||||
| } else { | |||||
| /**判断消息类型,调用对应的方法*/ | |||||
| switch (inMessage.getMsgType()){ | |||||
| case "event": | |||||
| case "text": | |||||
| WxMpXmlOutMessage outMessage = wxOpenService.getWxOpenMessageRouter().route(inMessage, appId); | |||||
| if (outMessage != null) { | |||||
| out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml(outMessage, wxOpenService.getWxOpenConfigStorage()); | |||||
| } | |||||
| /* | |||||
| else { | |||||
| WxMpXmlOutMessage outMsg = new WxMpXmlOutTextMessage(); | |||||
| outMsg.setCreateTime(System.currentTimeMillis()); | |||||
| outMsg.setToUserName(inMessage.getFromUser()); | |||||
| outMsg.setFromUserName(inMessage.getToUser()); | |||||
| outMsg.setMsgType("text"); | |||||
| ((WxMpXmlOutTextMessage) outMsg).setContent(inMessage.getContent()); | |||||
| out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml(outMsg, wxOpenService.getWxOpenConfigStorage()); | |||||
| } | |||||
| */ | |||||
| else { | |||||
| out = "success"; | |||||
| } | |||||
| break; | |||||
| default: | |||||
| return "success"; | |||||
| } | |||||
| } | |||||
| logger.info(out); | |||||
| return out; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,236 @@ | |||||
| package com.iformall.controller; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.google.gson.Gson; | |||||
| import com.google.gson.GsonBuilder; | |||||
| import com.google.gson.reflect.TypeToken; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | |||||
| import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | |||||
| import me.chanjar.weixin.open.bean.result.*; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import javax.servlet.ServletOutputStream; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.File; | |||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/weappCode") | |||||
| @Api(description = "微信第三方开发平台-小程序-代码管理") | |||||
| public class WechatWeappCodeController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| @ApiOperation(value = "为授权的小程序帐号上传小程序代码", notes = "extInfo参考https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html") | |||||
| @PostMapping("/codeCommit") | |||||
| public ResultData codeCommit(Long templateId, String userVersion, String userDesc, String extInfoStr) { | |||||
| try { | |||||
| Gson gson= new GsonBuilder().create(); | |||||
| WxMaOpenCommitExtInfo extInfo = gson.fromJson(extInfoStr, new TypeToken<WxMaOpenCommitExtInfo>() { }.getType()); | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(extInfo.getExtAppid()); | |||||
| logger.info(extInfo.toString()); | |||||
| WxOpenResult openRet = openMaService.codeCommit(templateId, userVersion, userDesc, extInfo); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("获取体验小程序的体验二维码") | |||||
| @GetMapping("/getQrcode") | |||||
| public void getQrcode(String appId, String pagePath, Map<String, String> params, HttpServletResponse response, HttpServletRequest req) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| File file = openMaService.getTestQrcode(pagePath, params); | |||||
| ServletOutputStream out = response.getOutputStream(); | |||||
| response.reset(); | |||||
| response.setContentType("bin"); | |||||
| String agent = req.getHeader("user-agent"); | |||||
| String filename = "qrcode"; | |||||
| if (agent.contains("Firefox")) { | |||||
| response.setHeader("Content-disposition", | |||||
| "attachment; filename=" | |||||
| + new String(filename.getBytes("GB2312"),"ISO-8859-1")); | |||||
| } else { | |||||
| response.setHeader("Content-disposition", | |||||
| "attachment; filename=" | |||||
| + java.net.URLEncoder.encode(filename,"UTF-8")); | |||||
| } | |||||
| // 循环取出流中的数据 | |||||
| byte[] b = new byte[1024]; | |||||
| int len; | |||||
| InputStream inStream = new FileInputStream(file); | |||||
| while ((len = inStream.read(b)) > 0) | |||||
| response.getOutputStream().write(b, 0, len); | |||||
| inStream.close(); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } catch (IOException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("获取授权小程序帐号已设置的类目") | |||||
| @GetMapping("/getCategory") | |||||
| public ResultData getCategory(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaCategoryListResult openRet = openMaService.getCategoryList(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("获取小程序的第三方提交代码的页面配置") | |||||
| @GetMapping("/getPage") | |||||
| public ResultData getPage(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaPageListResult openRet = openMaService.getPageList(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("将第三方提交的代码包提交审核") | |||||
| @PostMapping("/submitAudit") | |||||
| public ResultData submitAudit(String appId, String subMesgStr) { | |||||
| try { | |||||
| WxOpenMaSubmitAuditMessage subMessage = JSON.parseObject(subMesgStr, WxOpenMaSubmitAuditMessage.class); | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaSubmitAuditResult openRet = openMaService.submitAudit(subMessage); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("查询某个指定版本的审核状态") | |||||
| @PostMapping("/getAuditstatus") | |||||
| public ResultData getAuditstatus(String appId, String auditidStr) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaQueryAuditResult openRet = openMaService.getAuditStatus(Long.valueOf(auditidStr)); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("查询最新一次提交的审核状态") | |||||
| @GetMapping("/getLatestAuditstatus") | |||||
| public ResultData get_latest_auditstatus(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaQueryAuditResult openRet = openMaService.getLatestAuditStatus(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("发布已通过审核的小程序") | |||||
| @PostMapping("/releaesAudited") | |||||
| public ResultData releaesAudited(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.releaesAudited(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("小程序版本回退") | |||||
| @GetMapping("/revertCodeRelease") | |||||
| public ResultData revertCodeRelease(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.revertCodeReleaes(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("查询当前设置的最低基础库版本及各版本用户占比") | |||||
| @GetMapping("/getSupportVersion") | |||||
| public ResultData getSupportVersion(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| String openRet = openMaService.getSupportVersion(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("设置最低基础库版本") | |||||
| @GetMapping("/setSupportVersion") | |||||
| public ResultData setSupportVersion(String appId, String version) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| String openRet = openMaService.setSupportVersion(version); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation(value = "小程序审核撤回", notes = "单个帐号每天审核撤回次数最多不超过1次,一个月不超过10次。") | |||||
| @GetMapping("/undoCodeAudit") | |||||
| public ResultData undoCodeAudit(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| openMaService.undoCodeAudit(); | |||||
| return new ResultData(); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,72 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/weappDraftTemplate") | |||||
| @Api(description = "微信第三方开发平台-小程序-代码模版库管理") | |||||
| public class WechatWeappDraftTemplateController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| @GetMapping("/tempDraftList") | |||||
| public ResultData getTempDraftList() { | |||||
| try { | |||||
| List<WxOpenMaCodeTemplate> list = openService.getWxOpenComponentService().getTemplateDraftList(); | |||||
| return new ResultData(list); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @GetMapping("/tempList") | |||||
| public ResultData getTempList() { | |||||
| try { | |||||
| List<WxOpenMaCodeTemplate> list = openService.getWxOpenComponentService().getTemplateList(); | |||||
| return new ResultData(list); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @PostMapping("/addToTemplate") | |||||
| public ResultData addToTemplate(Long draftId) { | |||||
| try { | |||||
| openService.getWxOpenComponentService().addToTemplate(draftId); | |||||
| return new ResultData(); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @PostMapping("/deleteTemplate") | |||||
| public ResultData deleteTemplate(Long templateId) { | |||||
| try { | |||||
| openService.getWxOpenComponentService().deleteTemplate(templateId); | |||||
| return new ResultData(); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,115 @@ | |||||
| package com.iformall.controller; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult; | |||||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryGetResult; | |||||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult; | |||||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/weappMsgTemplate") | |||||
| @Api(description = "微信第三方开发平台-小程序-消息模板设置") | |||||
| public class WechatWeappMsgTemplateController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| @ApiOperation("获取小程序模板库标题列表") | |||||
| @GetMapping("getTmpLibList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData getTmpLibList(String appId, Integer pageNum, Integer pageSize) { | |||||
| try { | |||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxMaTemplateLibraryListResult ret = maService.getTemplateService().findTemplateLibraryList(pageNum, pageSize); | |||||
| return new ResultData(ret); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("获取模板库某个模板标题下关键词库") | |||||
| @GetMapping("getTemplateLibraryKeywordList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "id", value = "页数", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData findTemplateLibraryKeywordList(String appId, String id) { | |||||
| try { | |||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxMaTemplateLibraryGetResult ret = maService.getTemplateService().findTemplateLibraryKeywordList(id); | |||||
| return new ResultData(ret); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("组合模板并添加至帐号下的个人模板库") | |||||
| @PostMapping("addTemplate") | |||||
| public ResultData addTemplate( | |||||
| @RequestParam(value = "appId") String appId, | |||||
| @RequestParam(value = "id") String id, | |||||
| @RequestParam(value = "keywordIdList")List<Integer> keywordIdList) { | |||||
| try { | |||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxMaTemplateAddResult ret = maService.getTemplateService().addTemplate(id, keywordIdList); | |||||
| return new ResultData(ret); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("获取帐号下已存在的模板列表") | |||||
| @GetMapping("getTemplateList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData findTemplateList(String appId, Integer pageNum, Integer pageSize) { | |||||
| try { | |||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxMaTemplateListResult ret = maService.getTemplateService().findTemplateList(pageNum, pageSize); | |||||
| return new ResultData(ret); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("删除帐号下的某个模板") | |||||
| @PostMapping("delTemplate") | |||||
| public ResultData delTemplate(@RequestParam(value = "appId") String appId, @RequestParam(value = "templateId") String templateId) { | |||||
| try { | |||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| maService.getTemplateService().delTemplate(templateId); | |||||
| return new ResultData(); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,140 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||||
| import me.chanjar.weixin.open.bean.result.*; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/weappSet") | |||||
| @Api(description = "微信第三方开发平台-小程序设置") | |||||
| public class WechatWeappSetController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| @ApiOperation("获取小程序的信息") | |||||
| @GetMapping("/getInfo") | |||||
| public ResultData getAccountBasicInfo(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| String openRet = openMaService.getAccountBasicInfo(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation("获取小程序服务器域名") | |||||
| @GetMapping("/getDomain") | |||||
| public ResultData modifyDomain(String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.getDomain(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation(value = "设置小程序服务器域名", notes = "{\n" + | |||||
| " \"action\":\"add\",\n" + | |||||
| " \"requestdomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||||
| " \"wsrequestdomain\":[\"wss://www.qq.com\",\"wss://www.qq.com\"],\n" + | |||||
| " \"uploaddomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||||
| " \"downloaddomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||||
| " }") | |||||
| @PostMapping("/modifyDomain") | |||||
| public ResultData modifyDomain(@RequestParam(value = "appId") String appId, @RequestParam(value = "action") String action, | |||||
| @RequestParam(value = "requestDomain") List<String> requestDomain, @RequestParam(value = "wsrequestdomain") List<String> wsrequestdomain, | |||||
| @RequestParam(value = "uploaddomain") List<String> uploaddomain, @RequestParam(value = "downloaddomain") List<String> downloaddomain) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaDomainResult openRet = openMaService.modifyDomain(action, | |||||
| requestDomain, wsrequestdomain, | |||||
| uploaddomain, downloaddomain); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation(value = "设置小程序业务域名", notes = "{\n" + | |||||
| " \"action\":\"add\",\n" + | |||||
| " \"webviewdomain\":[\"https://www.qq.com\",\"https://m.qq.com\"]\n" + | |||||
| " }") | |||||
| @PostMapping("/setWebViewDomain") | |||||
| public ResultData setWebViewDomain(@RequestParam(value = "appId") String appId, @RequestParam(value = "action") String action, | |||||
| @RequestParam(value = "urlList") List<String> urlList) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| String openRet = openMaService.setWebViewDomain(action, urlList); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation(value = "绑定微信用户为小程序体验者", notes = "") | |||||
| @PostMapping("/bindTester") | |||||
| public ResultData bindTester(@RequestParam(value = "appId") String appId, @RequestParam(value = "wechatId") String wechatId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.bindTester(wechatId); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation(value = "解除绑定小程序的体验者", notes = "") | |||||
| @PostMapping("/unbindTester") | |||||
| public ResultData unbindTester(@RequestParam(value = "appId") String appId, @RequestParam(value = "wechatId") String wechatId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.unbindTester(wechatId); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| @ApiOperation(value = "获取体验者列表", notes = "") | |||||
| @PostMapping("/getTesterList") | |||||
| public ResultData getTesterList(@RequestParam(value = "appId") String appId) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.getTesterList(); | |||||
| logger.info(openRet.toString()); | |||||
| return new ResultData(openRet); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.ERROR); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,58 @@ | |||||
| package com.iformall.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxWeappBasicSet; | |||||
| import com.iformall.service.WxWeappBasicSetService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @Controller | |||||
| @RequestMapping("/weappBasicSet") | |||||
| @Api(description = "小程序基础设置接口") | |||||
| public class WxWeappBasicSetController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxWeappBasicSetService weappBasicSetService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute WxWeappBasicSet weappBasicSet, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappBasicSetController::list"); | |||||
| if (null == weappBasicSet) weappBasicSet = new WxWeappBasicSet(); | |||||
| final PageInfo<WxWeappBasicSet> page = weappBasicSetService.listAsPage(weappBasicSet, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| public ResultData add(WxWeappBasicSet weappBasicSet) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappBasicSetController::add"); | |||||
| if (null == weappBasicSet) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| weappBasicSetService.saveOrUpdate(weappBasicSet); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| public ResultData update(WxWeappBasicSet weappBasicSet) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappBasicSetController::update"); | |||||
| if (null == weappBasicSet) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| weappBasicSetService.saveOrUpdate(weappBasicSet); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,61 @@ | |||||
| package com.iformall.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxWeappExtSet; | |||||
| import com.iformall.service.WxWeappExtSetService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @Controller | |||||
| @RequestMapping("/weappExtSet") | |||||
| @Api(description = "小程序扩展设置接口") | |||||
| public class WxWeappExtSetController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxWeappExtSetService weappExtSetService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute WxWeappExtSet weappExtSet, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappExtSetController::list"); | |||||
| if (null == weappExtSet) weappExtSet = new WxWeappExtSet(); | |||||
| final PageInfo<WxWeappExtSet> page = weappExtSetService.listAsPage(weappExtSet, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| public ResultData add(WxWeappExtSet weappExtSet) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappExtSetController::add"); | |||||
| if (null == weappExtSet) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| weappExtSetService.saveOrUpdate(weappExtSet); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| public ResultData update(WxWeappExtSet weappExtSet) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappBasicSetController::update"); | |||||
| if (null == weappExtSet) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| weappExtSetService.saveOrUpdate(weappExtSet); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,358 @@ | |||||
| package com.iformall.controller; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.google.gson.Gson; | |||||
| import com.google.gson.GsonBuilder; | |||||
| import com.google.gson.reflect.TypeToken; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxWeappBasicSet; | |||||
| import com.iformall.domain.po.WxWeappCodeStatus; | |||||
| import com.iformall.domain.po.WxWeappExtSet; | |||||
| import com.iformall.domain.po.WxWeappInfo; | |||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.enums.EnumAuditStatus; | |||||
| import com.iformall.service.WxWeappBasicSetService; | |||||
| import com.iformall.service.WxWeappCodeStatusService; | |||||
| import com.iformall.service.WxWeappExtSetService; | |||||
| import com.iformall.service.WxWeappInfoService; | |||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | |||||
| import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenMaDomainResult; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenMaSubmitAuditResult; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenResult; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * Stormeye Wu | |||||
| */ | |||||
| @Controller | |||||
| @RequestMapping("/weapp") | |||||
| @Api(description = "小程序") | |||||
| public class WxWeappInfoController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WxWeappInfoService weappInfoService; | |||||
| @Autowired | |||||
| private WxWeappBasicSetService weappBasicSetService; | |||||
| @Autowired | |||||
| private WxWeappExtSetService weappExtSetService; | |||||
| @Autowired | |||||
| private WxWeappCodeStatusService weappCodeStatusService; | |||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData list(@ModelAttribute WxWeappInfo weappInfo, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] WxWeappController::list"); | |||||
| if (null == weappInfo) weappInfo = new WxWeappInfo(); | |||||
| final PageInfo<WxWeappInfo> page = weappInfoService.listAsPage(weappInfo, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation(value = "APPs基础设置(服务器域名、业务域名、基础版本、微信模板)", notes = "{\"apps\":\"appid,appid\",\"type\":\"String\",\"deploy\":\"String\"}") | |||||
| @PostMapping("batchBasicSet") | |||||
| public ResultData batchSet(Map<String, String> params) { | |||||
| String appsStr = params.get("apps"); | |||||
| String typeStr = params.get("type"); | |||||
| String deployStr = params.get("deploy"); | |||||
| Integer type = 0, deploy = 0; | |||||
| try { | |||||
| type = Integer.parseInt(typeStr); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| try { | |||||
| deploy = Integer.parseInt(deployStr); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| WxWeappBasicSet weappBasicSetQ = new WxWeappBasicSet(); | |||||
| weappBasicSetQ.setType(type); | |||||
| weappBasicSetQ.setDeploy(deploy); | |||||
| WxWeappBasicSet weappBasicSet = weappBasicSetService.getByTypeAndDeploy(weappBasicSetQ); | |||||
| if(weappBasicSet == null) { | |||||
| logger.error("未找到相关的基础设置参数"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| } | |||||
| JSONObject domainObj = JSON.parseObject(weappBasicSet.getDomainUrl()); | |||||
| if(domainObj == null) { | |||||
| logger.error("未找到相关的基础设置参数"); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||||
| } | |||||
| JSONObject templeObj = JSON.parseObject(weappBasicSet.getTemplateInfo()); | |||||
| // 逐一设置app配置 | |||||
| String [] apps = appsStr.split(","); | |||||
| for(String appId: apps) { | |||||
| ResultData openRet = setBasicForAppId(appId, weappBasicSet, domainObj, templeObj); | |||||
| if (openRet != null) return openRet; | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private ResultData setBasicForAppId(String appId, WxWeappBasicSet weappBasicSet, JSONObject domainObj, JSONObject templeObj) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| // 设置基础版本 | |||||
| openMaService.setSupportVersion(weappBasicSet.getVersion()); | |||||
| // 服务器域名 | |||||
| String action = "set"; | |||||
| JSONObject urlObj = domainObj.getJSONObject("url"); | |||||
| List<String> requestDomain = getUrlList(urlObj.getJSONArray("requestdomain")); | |||||
| List<String> wsrequestDomain = getUrlList(urlObj.getJSONArray("wsrequestdomain")); | |||||
| List<String> uploadDomain = getUrlList(urlObj.getJSONArray("requestdomain")); | |||||
| List<String> downloadDomain = getUrlList(urlObj.getJSONArray("requestdomain")); | |||||
| WxOpenMaDomainResult openRet = openMaService.modifyDomain(action, | |||||
| requestDomain, wsrequestDomain, | |||||
| uploadDomain, downloadDomain); | |||||
| logger.info(openRet.toString()); | |||||
| // 业务域名 | |||||
| JSONObject webObj = domainObj.getJSONObject("web"); | |||||
| List<String> urlList = getUrlList(webObj.getJSONArray("webviewdomain")); | |||||
| String openRet1 = openMaService.setWebViewDomain(action, urlList); | |||||
| logger.info(openRet1); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| // 设置微信模板 | |||||
| if(weappBasicSet.getType().equals(EnumAppType.C.getCode())) { | |||||
| try { | |||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| // 核销成功消息 | |||||
| JSONObject verify_success = templeObj.getJSONObject("verify_success"); | |||||
| JSONArray keyidlist = verify_success.getJSONArray("keyword_id_list"); | |||||
| List<Integer> keyArr = getIdList(keyidlist); | |||||
| WxMaTemplateAddResult ret = maService.getTemplateService().addTemplate(verify_success.getString("id"), keyArr); | |||||
| // TODO update wx_template_msg | |||||
| // 核销失败消息 | |||||
| JSONObject verify_fail = templeObj.getJSONObject("verify_fail"); | |||||
| keyidlist = verify_fail.getJSONArray("keyword_id_list"); | |||||
| List<Integer> keyArr1 = getIdList(keyidlist); | |||||
| ret = maService.getTemplateService().addTemplate(verify_fail.getString("id"), keyArr1); | |||||
| // TODO update wx_template_msg | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(Result.ERROR, e.getMessage()); | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private List<Integer> getIdList(JSONArray keyidlist) { | |||||
| List<Integer> keyArr = new ArrayList<Integer>(); | |||||
| for (int i = 0; i < keyidlist.size(); i++) { | |||||
| keyArr.add(keyidlist.getIntValue(i)); | |||||
| } | |||||
| return keyArr; | |||||
| } | |||||
| private List<String> getUrlList(JSONArray urlList) { | |||||
| List<String> keyArr = new ArrayList<String>(); | |||||
| for (int i = 0; i < urlList.size(); i++) { | |||||
| keyArr.add(urlList.getString(i)); | |||||
| } | |||||
| return keyArr; | |||||
| } | |||||
| @ApiOperation(value = "批量,授权的小程序上传code并提交审核", notes = "{\"apps\":\"appid,appid\",\"templateId\":\"String\",\"userVersion\":\"String\",\"userDesc\":\"String\"}") | |||||
| @PostMapping("batchCodeCommitAndAudit") | |||||
| public ResultData batchExtSet(Map<String, String> params) { | |||||
| String appsStr = params.get("apps"); | |||||
| String templateIdStr = params.get("templateId"); | |||||
| String userVersion = params.get("userVersion"); | |||||
| String userDesc = params.get("userDesc"); | |||||
| Long templateId = null; | |||||
| try { | |||||
| templateId = Long.parseLong(templateIdStr); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| // 逐一设置app配置 | |||||
| String [] apps = appsStr.split(","); | |||||
| for(String appId: apps) { | |||||
| codeOperation(appId, userVersion, userDesc, templateId); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private void codeOperation(String appId, String userVersion, String userDesc, Long templateId) { | |||||
| // get ext json | |||||
| WxWeappExtSet extSetQ = new WxWeappExtSet(); | |||||
| extSetQ.setAppId(appId); | |||||
| WxWeappExtSet extSet = weappExtSetService.getByObj(extSetQ); | |||||
| WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); | |||||
| if(extSet != null) { | |||||
| boolean codeCommitStatus = false; | |||||
| // code commit | |||||
| try { | |||||
| Gson gson= new GsonBuilder().create(); | |||||
| WxMaOpenCommitExtInfo extInfo = gson.fromJson(extSet.getExt(), new TypeToken<WxMaOpenCommitExtInfo>() { }.getType()); | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(extInfo.getExtAppid()); | |||||
| logger.info(extInfo.toString()); | |||||
| WxOpenResult openRet = openMaService.codeCommit(templateId, userVersion, userDesc, extInfo); | |||||
| logger.info(openRet.toString()); | |||||
| if(openRet.isSuccess()) { | |||||
| codeCommitStatus = true; | |||||
| } | |||||
| if(codeStatus == null) { | |||||
| codeStatus = new WxWeappCodeStatus(); | |||||
| codeStatus.setAppId(appId); | |||||
| codeStatus.setUserVersion(userVersion); | |||||
| codeStatus.setCodeStatus(Integer.valueOf(openRet.getErrcode())); | |||||
| weappCodeStatusService.saveOrUpdate(codeStatus); | |||||
| } else { | |||||
| codeStatus.setUserVersion(userVersion); | |||||
| codeStatus.setCodeStatus(Integer.valueOf(openRet.getErrcode())); | |||||
| weappCodeStatusService.updateCodeCommitStatus(codeStatus); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| // 提交审核 | |||||
| if(codeCommitStatus) { | |||||
| try { | |||||
| WxOpenMaSubmitAuditMessage subMessage = JSON.parseObject(extSet.getRelease(), WxOpenMaSubmitAuditMessage.class); | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenMaSubmitAuditResult openRet = openMaService.submitAudit(subMessage); | |||||
| logger.info(openRet.toString()); | |||||
| if(openRet.isSuccess()) { | |||||
| codeStatus.setAuditStatus(EnumAuditStatus.AUDITING.getCode()); | |||||
| weappCodeStatusService.updateAuditStatus(codeStatus); | |||||
| } else { | |||||
| codeStatus.setAuditStatus(Integer.valueOf(openRet.getErrcode())); | |||||
| weappCodeStatusService.updateAuditStatus(codeStatus); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ApiOperation(value = "批量审核撤回", notes = "{\"apps\":\"appid,appid\"}") | |||||
| @PostMapping("batchAuditCancel") | |||||
| public ResultData batchAuditCancel(Map<String, String> params) { | |||||
| String appsStr = params.get("apps"); | |||||
| // 逐一设置app配置 | |||||
| String [] apps = appsStr.split(","); | |||||
| for(String appId: apps) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openResult = openMaService.undoCodeAudit(); | |||||
| logger.info(openResult.toString()); | |||||
| if(openResult.isSuccess()) { | |||||
| WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); | |||||
| if(codeStatus != null) { | |||||
| codeStatus.setAuditStatus(EnumAuditStatus.UNDO.getCode()); | |||||
| weappCodeStatusService.updateAuditStatus(codeStatus); | |||||
| } | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation(value = "批量发布", notes = "{\"apps\":\"appid,appid\"}") | |||||
| @PostMapping("batchRelease") | |||||
| public ResultData batchRelease(Map<String, String> params) { | |||||
| String appsStr = params.get("apps"); | |||||
| // 逐一设置app配置 | |||||
| String [] apps = appsStr.split(","); | |||||
| for(String appId: apps) { | |||||
| try { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| WxOpenResult openRet = openMaService.releaesAudited(); | |||||
| logger.info(openRet.toString()); | |||||
| WxWeappCodeStatus codeStatus = weappCodeStatusService.getByAppId(appId); | |||||
| if(codeStatus != null) { | |||||
| codeStatus.setReleaseStatus(Integer.valueOf(openRet.getErrcode())); | |||||
| weappCodeStatusService.updateReleaseStatus(codeStatus); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| /* | |||||
| * 0. 回调搭建好 | |||||
| * 1. wx_appinfo配置好 | |||||
| * | |||||
| * 10. 授权 | |||||
| * 11. 设置服务器域名及业务域名 - B/C 配置表 | |||||
| * C 服务器域名 c.malls.iformall.com | |||||
| * 业务域名 c.malls.iformall.com,game.malls.iformall.com | |||||
| * B 服务器域名 b.malls.iformall.com | |||||
| * 业务域名 mobile.malls.iformall.com,admin.malls.iformall.com | |||||
| * C 服务器域名 ciformall.youlane.cn | |||||
| * 业务域名 ciformall.youlane.cn,game.youlane.cn | |||||
| * B 服务器域名 biformall.youlane.cn | |||||
| * 业务域名 mobile.youlane.cn,mall.youlane.cn | |||||
| * C 服务器域名 ctest.malls.iformall.com | |||||
| * 业务域名 ctest.malls.iformall.com,gametest.malls.iformall.com | |||||
| * B 服务器域名 btest.malls.iformall.com | |||||
| * 业务域名 mobiletest.malls.iformall.com,admintest.malls.iformall.com | |||||
| * 12. 设置微信基础版本 - 配置 | |||||
| * 2.0.9 | |||||
| * 13. 设置微信模板 - 配置 | |||||
| * 核销成功模板 AT0423 14,15,16,7,10,3,9 | |||||
| * 核销失败模板 AT1824 1,3,4,5 | |||||
| * 14. 草稿提交 | |||||
| * 15. 模板 | |||||
| * 16. 上传小程序代码 - 配置 ext.json | |||||
| * 17. 体验二维码 | |||||
| * 18. 提交审核 - json --- 获取审核ID | |||||
| * 19. 获取审核结果 - 基于审核ID查询 -- event 回调 | |||||
| * 20. 审核撤回 | |||||
| * 21. 发布已通过审核的小程序 | |||||
| * 22. oauth2refreshAccessToken | |||||
| */ | |||||
| } | |||||
| @@ -0,0 +1,223 @@ | |||||
| package com.iformall.service.wechat; | |||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import redis.clients.jedis.Jedis; | |||||
| import redis.clients.jedis.JedisPool; | |||||
| import redis.clients.util.Pool; | |||||
| public class WxOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||||
| private final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:"; | |||||
| private final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:"; | |||||
| private final static String AUTHORIZER_REFRESH_TOKEN_KEY = "wechat_authorizer_refresh_token:"; | |||||
| private final static String AUTHORIZER_ACCESS_TOKEN_KEY = "wechat_authorizer_access_token:"; | |||||
| private final static String JSAPI_TICKET_KEY = "wechat_jsapi_ticket:"; | |||||
| private final static String CARD_API_TICKET_KEY = "wechat_card_api_ticket:"; | |||||
| protected final Pool<Jedis> jedisPool; | |||||
| /** | |||||
| * redis 存储的 key 的前缀,可为空 | |||||
| */ | |||||
| private String keyPrefix; | |||||
| private String componentVerifyTicketKey; | |||||
| private String componentAccessTokenKey; | |||||
| private String authorizerRefreshTokenKey; | |||||
| private String authorizerAccessTokenKey; | |||||
| private String jsapiTicketKey; | |||||
| private String cardApiTicket; | |||||
| @Autowired | |||||
| WxComponentVerifyTicketMapper wxComponentVerifyTicketMapper; | |||||
| public WxOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool) { | |||||
| this.jedisPool = jedisPool; | |||||
| } | |||||
| public WxOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool, String keyPrefix) { | |||||
| this.jedisPool = jedisPool; | |||||
| this.keyPrefix = keyPrefix; | |||||
| } | |||||
| public WxOpenInRedisDBConfigStorage(JedisPool jedisPool) { | |||||
| this.jedisPool = jedisPool; | |||||
| } | |||||
| @Override | |||||
| public void setComponentAppId(String componentAppId) { | |||||
| super.setComponentAppId(componentAppId); | |||||
| String prefix = StringUtils.isBlank(keyPrefix) ? "" : | |||||
| (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); | |||||
| componentVerifyTicketKey = prefix + COMPONENT_VERIFY_TICKET_KEY.concat(componentAppId); | |||||
| componentAccessTokenKey = prefix + COMPONENT_ACCESS_TOKEN_KEY.concat(componentAppId); | |||||
| authorizerRefreshTokenKey = prefix + AUTHORIZER_REFRESH_TOKEN_KEY.concat(componentAppId); | |||||
| authorizerAccessTokenKey = prefix + AUTHORIZER_ACCESS_TOKEN_KEY.concat(componentAppId); | |||||
| this.jsapiTicketKey = JSAPI_TICKET_KEY.concat(componentAppId); | |||||
| this.cardApiTicket = CARD_API_TICKET_KEY.concat(componentAppId); | |||||
| } | |||||
| @Override | |||||
| public String getComponentVerifyTicket() { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.componentVerifyTicketKey); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void setComponentVerifyTicket(String componentVerifyTicket) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.set(this.componentVerifyTicketKey, componentVerifyTicket); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| @Override | |||||
| public String getComponentAccessToken() { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.componentAccessTokenKey); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isComponentAccessTokenExpired() { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.componentAccessTokenKey) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireComponentAccessToken(){ | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.componentAccessTokenKey, 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.componentAccessTokenKey, expiresInSeconds - 200, componentAccessToken); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| private String getKey(String prefix, String appId) { | |||||
| return prefix.endsWith(":") ? prefix.concat(appId) : prefix.concat(":").concat(appId); | |||||
| } | |||||
| @Override | |||||
| public String getAuthorizerRefreshToken(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.authorizerRefreshTokenKey, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.set(this.getKey(this.authorizerRefreshTokenKey, appId), authorizerRefreshToken); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| @Override | |||||
| public String getAuthorizerAccessToken(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.authorizerAccessTokenKey, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isAuthorizerAccessTokenExpired(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.getKey(this.authorizerAccessTokenKey, appId)) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireAuthorizerAccessToken(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.authorizerAccessTokenKey, appId), 0); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| @Override | |||||
| public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.getKey(this.authorizerAccessTokenKey, appId), expiresInSeconds - 200, authorizerAccessToken); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| /* | |||||
| @Override | |||||
| public void changeAuthorizationStatus(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.authorizerAccessTokenKey, appId), 0); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| */ | |||||
| @Override | |||||
| public String getJsapiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.jsapiTicketKey, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isJsapiTicketExpired(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.getKey(this.jsapiTicketKey, appId)) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireJsapiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.jsapiTicketKey, appId), 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.getKey(this.jsapiTicketKey, appId), expiresInSeconds - 200, jsapiTicket); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| @Override | |||||
| public String getCardApiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.get(this.getKey(this.cardApiTicket, appId)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean isCardApiTicketExpired(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| return jedis.ttl(this.getKey(this.cardApiTicket, appId)) < 2; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void expireCardApiTicket(String appId) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.expire(this.getKey(this.cardApiTicket, appId), 0); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds) { | |||||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||||
| jedis.setex(this.getKey(this.cardApiTicket, appId), expiresInSeconds - 200, cardApiTicket); | |||||
| } | |||||
| // TODO update to DB | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,64 @@ | |||||
| package com.iformall.service.wechat; | |||||
| import com.iformall.config.RedisProperies; | |||||
| import com.iformall.config.WechatOpenProperties; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenMessageRouter; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenServiceImpl; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||||
| import org.springframework.stereotype.Service; | |||||
| import redis.clients.jedis.JedisPool; | |||||
| import javax.annotation.PostConstruct; | |||||
| /** | |||||
| * Stormeye WU | |||||
| */ | |||||
| @Service | |||||
| @EnableConfigurationProperties({WechatOpenProperties.class, RedisProperies.class}) | |||||
| public class WxOpenService extends WxOpenServiceImpl { | |||||
| private Logger logger = LoggerFactory.getLogger(getClass()); | |||||
| @Autowired | |||||
| private WechatOpenProperties wechatProperties; | |||||
| @Autowired | |||||
| private RedisProperies redisProperies; | |||||
| private static JedisPool pool; | |||||
| private WxOpenMessageRouter wxOpenMessageRouter; | |||||
| @PostConstruct | |||||
| public void init() { | |||||
| WxOpenInRedisDBConfigStorage configStorage = new WxOpenInRedisDBConfigStorage(getJedisPool()); | |||||
| configStorage.setComponentAppId(wechatProperties.getComponentAppId()); | |||||
| configStorage.setComponentAppSecret(wechatProperties.getComponentSecret()); | |||||
| configStorage.setComponentToken(wechatProperties.getComponentToken()); | |||||
| configStorage.setComponentAesKey(wechatProperties.getComponentAesKey()); | |||||
| setWxOpenConfigStorage(configStorage); | |||||
| wxOpenMessageRouter = new WxOpenMessageRouter(this); | |||||
| wxOpenMessageRouter.rule().handler((wxMpXmlMessage, map, wxMpService, wxSessionManager) -> { | |||||
| logger.info("\n接收到 {} 公众号请求消息,内容:{}", wxMpService.getWxMpConfigStorage().getAppId(), wxMpXmlMessage); | |||||
| return null; | |||||
| }).next(); | |||||
| } | |||||
| public WxOpenMessageRouter getWxOpenMessageRouter() { | |||||
| return wxOpenMessageRouter; | |||||
| } | |||||
| private JedisPool getJedisPool() { | |||||
| if (pool == null) { | |||||
| synchronized (WxOpenService.class) { | |||||
| if (pool == null) { | |||||
| pool = new JedisPool(redisProperies, redisProperies.getHost(), | |||||
| redisProperies.getPort(), redisProperies.getConnectionTimeout(), | |||||
| redisProperies.getSoTimeout(), redisProperies.getPassword(), | |||||
| redisProperies.getDatabase(), redisProperies.getClientName(), | |||||
| redisProperies.isSsl(), redisProperies.getSslSocketFactory(), | |||||
| redisProperies.getSslParameters(), redisProperies.getHostnameVerifier()); | |||||
| } | |||||
| } | |||||
| } | |||||
| return pool; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.shiro; | |||||
| import com.iformall.enums.EnumLoginType; | |||||
| import org.apache.shiro.authc.AuthenticationInfo; | |||||
| import org.apache.shiro.authc.AuthenticationToken; | |||||
| import org.apache.shiro.authc.credential.HashedCredentialsMatcher; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| @Configuration | |||||
| public class MyRetryLimitCredentialsMatcher extends HashedCredentialsMatcher { | |||||
| @Override | |||||
| public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) { | |||||
| if(authcToken instanceof UseriFormallToken) { | |||||
| UseriFormallToken tk = (UseriFormallToken) authcToken; | |||||
| if(tk.getType().equals(EnumLoginType.NOPASSWD)){ | |||||
| return true; | |||||
| } | |||||
| boolean matches = super.doCredentialsMatch(authcToken, info); | |||||
| return matches; | |||||
| } | |||||
| boolean matches =super.doCredentialsMatch(authcToken, info); | |||||
| return matches; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,89 @@ | |||||
| package com.iformall.shiro; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.enums.EnumMallUserStatus; | |||||
| import com.iformall.service.MallPermissionService; | |||||
| import com.iformall.service.MallUserInfoService; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.authc.*; | |||||
| import org.apache.shiro.authz.AuthorizationInfo; | |||||
| import org.apache.shiro.authz.SimpleAuthorizationInfo; | |||||
| import org.apache.shiro.realm.AuthorizingRealm; | |||||
| import org.apache.shiro.session.Session; | |||||
| import org.apache.shiro.subject.PrincipalCollection; | |||||
| import org.apache.shiro.util.ByteSource; | |||||
| import javax.annotation.Resource; | |||||
| /** | |||||
| * Created by yangqj on 2017/4/21. | |||||
| */ | |||||
| public class MyShiroRealm extends AuthorizingRealm { | |||||
| @Resource | |||||
| private MallUserInfoService userService; | |||||
| @Resource | |||||
| private MallPermissionService resourcesService; | |||||
| //授权 | |||||
| @Override | |||||
| protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { | |||||
| MallUserInfo user= (MallUserInfo) SecurityUtils.getSubject().getPrincipal();//User{id=1, username='admin', password='3ef7164d1f6167cb9f2658c07d3c2f0a', enable=1} | |||||
| // Map<String,Object> map = new HashMap<String,Object>(); | |||||
| // map.put("userid",user.getId()); | |||||
| // List<SysPermission> resourcesList = resourcesService.list(map); | |||||
| // 权限信息对象info,用来存放查出的用户的所有的角色(role)及权限(permission) | |||||
| SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); | |||||
| // for(SysPermission resources: resourcesList){ | |||||
| // info.addStringPermission(resources.getUrl()); | |||||
| // } | |||||
| return info; | |||||
| } | |||||
| //认证 | |||||
| @Override | |||||
| protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { | |||||
| //获取用户的输入的账号. | |||||
| String username = (String)token.getPrincipal(); | |||||
| MallUserInfo user = userService.getByUsername(username); | |||||
| if(user == null) { | |||||
| throw new UnknownAccountException("用户名不存在"); | |||||
| } | |||||
| // if (0==user.getEnable()) { | |||||
| // throw new LockedAccountException(); // 帐号锁定 | |||||
| // } | |||||
| if(user.getStatus()==null || | |||||
| !EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) {//用户被禁用 | |||||
| throw new UnknownAccountException("用户被禁用"); | |||||
| } | |||||
| if(!user.getTenantId().equals("1")) { | |||||
| // 只支持租户为1的用户 | |||||
| throw new UnknownAccountException("用户名不支持"); | |||||
| } | |||||
| SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( | |||||
| user, //用户 | |||||
| user.getPassword(), //密码 | |||||
| ByteSource.Util.bytes(username), | |||||
| getName() //realm name | |||||
| ); | |||||
| // 当验证都通过后,把用户信息放在session里 | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.userInfo, user); | |||||
| session.setAttribute(UserSession.userId, user.getId()); | |||||
| session.setAttribute(UserSession.tenantId, user.getTenantId()); | |||||
| return authenticationInfo; | |||||
| } | |||||
| /** | |||||
| * 指定principalCollection 清除 | |||||
| */ | |||||
| /* public void clearCachedAuthorizationInfo(PrincipalCollection principalCollection) { | |||||
| SimplePrincipalCollection principals = new SimplePrincipalCollection( | |||||
| principalCollection, getName()); | |||||
| super.clearCachedAuthorizationInfo(principals); | |||||
| } | |||||
| */ | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.shiro; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import org.apache.shiro.crypto.hash.SimpleHash; | |||||
| import org.apache.shiro.util.ByteSource; | |||||
| public class PasswordHelper { | |||||
| //private RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator(); | |||||
| private String algorithmName = "md5"; | |||||
| private int hashIterations = 2; | |||||
| public void encryptPassword(MallUserInfo user) { | |||||
| //String salt=randomNumberGenerator.nextBytes().toHex(); | |||||
| String newPassword = new SimpleHash(algorithmName, user.getPassword(), ByteSource.Util.bytes(user.getUsername()), hashIterations).toHex(); | |||||
| //String newPassword = new SimpleHash(algorithmName, user.getPassword()).toHex(); | |||||
| user.setPassword(newPassword); | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| MallUserInfo user = new MallUserInfo(); | |||||
| user.setUsername("fmadmin"); | |||||
| user.setPassword("admin123"); | |||||
| PasswordHelper passwordHelper = new PasswordHelper(); | |||||
| passwordHelper.encryptPassword(user); | |||||
| System.out.println(user); | |||||
| System.out.println(user.getPassword()); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,126 @@ | |||||
| package com.iformall.shiro; | |||||
| import com.iformall.service.MallPermissionService; | |||||
| import org.apache.shiro.spring.web.ShiroFilterFactoryBean; | |||||
| import org.apache.shiro.web.filter.mgt.DefaultFilterChainManager; | |||||
| import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver; | |||||
| import org.apache.shiro.web.servlet.AbstractShiroFilter; | |||||
| import org.crazycake.shiro.RedisSessionDAO; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import java.util.LinkedHashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * Created by yangqj on 2017/4/30. | |||||
| */ | |||||
| //@Service | |||||
| public class ShiroService { | |||||
| @Autowired | |||||
| private ShiroFilterFactoryBean shiroFilterFactoryBean; | |||||
| @Autowired | |||||
| private MallPermissionService resourcesService; | |||||
| @Autowired | |||||
| private RedisSessionDAO redisSessionDAO; | |||||
| /** | |||||
| * 初始化权限 | |||||
| */ | |||||
| public Map<String, String> loadFilterChainDefinitions() { | |||||
| // 权限控制map.从数据库获取 | |||||
| Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>(); | |||||
| filterChainDefinitionMap.put("/logout", "logout"); | |||||
| filterChainDefinitionMap.put("/css/**","anon"); | |||||
| filterChainDefinitionMap.put("/js/**","anon"); | |||||
| filterChainDefinitionMap.put("/img/**","anon"); | |||||
| filterChainDefinitionMap.put("/user/**","anon"); | |||||
| filterChainDefinitionMap.put("/font-awesome/**","anon"); | |||||
| // Map<String,Object> map = new HashMap<>(); | |||||
| // List<SysPermission> resourcesList = resourcesService.list(map); | |||||
| // for(SysPermission resources:resourcesList){ | |||||
| // | |||||
| // if (StringUtil.isNotEmpty(resources.getUrl())) { | |||||
| // String permission = "perms[" + resources.getUrl()+ "]"; | |||||
| // filterChainDefinitionMap.put(resources.getUrl(),permission); | |||||
| // } | |||||
| // } | |||||
| filterChainDefinitionMap.put("/**", "authc"); | |||||
| return filterChainDefinitionMap; | |||||
| } | |||||
| /** | |||||
| * 重新加载权限 | |||||
| */ | |||||
| public void updatePermission() { | |||||
| synchronized (shiroFilterFactoryBean) { | |||||
| AbstractShiroFilter shiroFilter = null; | |||||
| try { | |||||
| shiroFilter = (AbstractShiroFilter) shiroFilterFactoryBean | |||||
| .getObject(); | |||||
| } catch (Exception e) { | |||||
| throw new RuntimeException( | |||||
| "get ShiroFilter from shiroFilterFactoryBean error!"); | |||||
| } | |||||
| PathMatchingFilterChainResolver filterChainResolver = (PathMatchingFilterChainResolver) shiroFilter | |||||
| .getFilterChainResolver(); | |||||
| DefaultFilterChainManager manager = (DefaultFilterChainManager) filterChainResolver | |||||
| .getFilterChainManager(); | |||||
| // 清空老的权限控制 | |||||
| manager.getFilterChains().clear(); | |||||
| shiroFilterFactoryBean.getFilterChainDefinitionMap().clear(); | |||||
| shiroFilterFactoryBean | |||||
| .setFilterChainDefinitionMap(loadFilterChainDefinitions()); | |||||
| // 重新构建生成 | |||||
| Map<String, String> chains = shiroFilterFactoryBean | |||||
| .getFilterChainDefinitionMap(); | |||||
| for (Map.Entry<String, String> entry : chains.entrySet()) { | |||||
| String url = entry.getKey(); | |||||
| String chainDefinition = entry.getValue().trim() | |||||
| .replace(" ", ""); | |||||
| manager.createChain(url, chainDefinition); | |||||
| } | |||||
| System.out.println("更新权限成功!!"); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 根据userId 清除当前session存在的用户的权限缓存 | |||||
| * @param userIds 已经修改了权限的userId | |||||
| */ | |||||
| /* public void clearUserAuthByUserId(List<Integer> userIds){ | |||||
| if(null == userIds || userIds.size() == 0) return ; | |||||
| //获取所有session | |||||
| Collection<Session> sessions = redisSessionDAO.getActiveSessions(); | |||||
| //定义返回 | |||||
| List<SimplePrincipalCollection> list = new ArrayList<SimplePrincipalCollection>(); | |||||
| for (Session session:sessions){ | |||||
| //获取session登录信息。 | |||||
| Object obj = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY); | |||||
| if(null != obj && obj instanceof SimplePrincipalCollection){ | |||||
| //强转 | |||||
| SimplePrincipalCollection spc = (SimplePrincipalCollection)obj; | |||||
| //判断用户,匹配用户ID。 | |||||
| obj = spc.getPrimaryPrincipal(); | |||||
| if(null != obj && obj instanceof User){ | |||||
| User user = (User) obj; | |||||
| System.out.println("user:"+user); | |||||
| //比较用户ID,符合即加入集合 | |||||
| if(null != user && userIds.contains(user.getId())){ | |||||
| list.add(spc); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| RealmSecurityManager securityManager = | |||||
| (RealmSecurityManager) SecurityUtils.getSecurityManager(); | |||||
| MyShiroRealm realm = (MyShiroRealm)securityManager.getRealms().iterator().next(); | |||||
| for (SimplePrincipalCollection simplePrincipalCollection : list) { | |||||
| realm.clearCachedAuthorizationInfo(simplePrincipalCollection); | |||||
| } | |||||
| }*/ | |||||
| } | |||||
| @@ -0,0 +1,11 @@ | |||||
| package com.iformall.shiro; | |||||
| public class UserSession { | |||||
| public static String userInfo="userSession"; | |||||
| public static String userId ="userSessionId"; | |||||
| public static String tenantId ="TENANT_ID"; | |||||
| } | |||||
| @@ -0,0 +1,39 @@ | |||||
| package com.iformall.shiro; | |||||
| import com.iformall.enums.EnumLoginType; | |||||
| import org.apache.shiro.authc.UsernamePasswordToken; | |||||
| public class UseriFormallToken extends UsernamePasswordToken { | |||||
| private static final long serialVersionUID = -2564928913725078138L; | |||||
| private EnumLoginType type; | |||||
| public UseriFormallToken() { | |||||
| super(); | |||||
| } | |||||
| public UseriFormallToken(String username, String password, EnumLoginType type, boolean rememberMe, String host) { | |||||
| super(username, password, rememberMe, host); | |||||
| this.type = type; | |||||
| } | |||||
| /** 免密登录 */ | |||||
| public UseriFormallToken(String username) { | |||||
| super(username, "", false, null); | |||||
| this.type = EnumLoginType.NOPASSWD; | |||||
| } | |||||
| /** 账号密码登录 */ | |||||
| public UseriFormallToken(String username, String pwd) { | |||||
| super(username, pwd, false, null); | |||||
| this.type = EnumLoginType.PASSWORD; | |||||
| } | |||||
| public EnumLoginType getType() { | |||||
| return type; | |||||
| } | |||||
| public void setType(EnumLoginType type) { | |||||
| this.type = type; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,61 @@ | |||||
| package com.iformall.utils; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.session.Session; | |||||
| import org.apache.shiro.subject.Subject; | |||||
| /** | |||||
| * Shiro工具类 | |||||
| * | |||||
| * @author stormeye.wu | |||||
| * @email wugq@mippoint.com | |||||
| * @date 2016年11月12日 上午9:49:19 | |||||
| */ | |||||
| public class ShiroUtils { | |||||
| public static Session getSession() { | |||||
| return SecurityUtils.getSubject().getSession(); | |||||
| } | |||||
| public static Subject getSubject() { | |||||
| return SecurityUtils.getSubject(); | |||||
| } | |||||
| public static MallUserInfo getUserInfo() { | |||||
| return (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||||
| } | |||||
| public static Long getUserId() { | |||||
| return getUserInfo().getId(); | |||||
| } | |||||
| public static void setSessionAttribute(Object key, Object value) { | |||||
| getSession().setAttribute(key, value); | |||||
| } | |||||
| public static Object getSessionAttribute(Object key) { | |||||
| return getSession().getAttribute(key); | |||||
| } | |||||
| public static boolean isLogin() { | |||||
| return SecurityUtils.getSubject().getPrincipal() != null; | |||||
| } | |||||
| public static void logout() { | |||||
| SecurityUtils.getSubject().logout(); | |||||
| } | |||||
| public static String getKaptcha(String key) { | |||||
| Object kaptcha = getSessionAttribute(key); | |||||
| if (kaptcha == null) { | |||||
| throw new MallinkException(ErrorCode.KAPCHA_NOT_VALID); | |||||
| } | |||||
| getSession().removeAttribute(key); | |||||
| return kaptcha.toString(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://202.165.179.86:3306/mallinkDev?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false | |||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | |||||
| password: ENC(WGu0+1DPIHrqorDhrbq1+7wr7xNG53mN) | |||||
| type: com.alibaba.druid.pool.DruidDataSource | |||||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||||
| filters: stat | |||||
| maxActive: 20 | |||||
| initialSize: 1 | |||||
| maxWait: 60000 | |||||
| minIdle: 1 | |||||
| timeBetweenEvictionRunsMillis: 60000 | |||||
| minEvictableIdleTimeMillis: 300000 | |||||
| validationQuery: select 'x' | |||||
| testWhileIdle: true | |||||
| testOnBorrow: false | |||||
| testOnReturn: false | |||||
| poolPreparedStatements: true | |||||
| maxOpenPreparedStatements: 20 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| #jackson: | |||||
| #date-format: yyyy-MM-dd HH:mm:ss | |||||
| # REDIS | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 50 | |||||
| max-idle: 50 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(R0bER9E9OB9/YQcpNXMyYDwofNVb8/pFl4nrApS8mi0=) | |||||
| password: ENC(50YqJd0iK/2r2YnmEd5RKaki3ktU73UDapBJrVYfqmc=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | |||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | |||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | |||||
| encryptor: | |||||
| password: oRqdnDbK5pj3eMmB | |||||
| fm: | |||||
| exception: false | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall.mapper: debug | |||||
| path: ./logs/w | |||||
| @@ -0,0 +1,84 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false | |||||
| username: ENC(NUzgQOdJnCbVLKT6BaX0aw==) | |||||
| password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=) | |||||
| type: com.alibaba.druid.pool.DruidDataSource | |||||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||||
| filters: stat | |||||
| maxActive: 20 | |||||
| initialSize: 1 | |||||
| maxWait: 60000 | |||||
| minIdle: 1 | |||||
| timeBetweenEvictionRunsMillis: 60000 | |||||
| minEvictableIdleTimeMillis: 300000 | |||||
| validationQuery: select 'x' | |||||
| testWhileIdle: true | |||||
| testOnBorrow: false | |||||
| testOnReturn: false | |||||
| poolPreparedStatements: true | |||||
| maxOpenPreparedStatements: 20 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| # REDIS | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 8 | |||||
| max-idle: 8 | |||||
| max-wait: -1 | |||||
| min-idle: 0 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=) | |||||
| password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | |||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | |||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | |||||
| exception: true | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall: debug | |||||
| path: ./logs/w | |||||
| @@ -0,0 +1,84 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false | |||||
| username: ENC(Uc0AjgkytxHHCwZrmDASWg==) | |||||
| password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=) | |||||
| type: com.alibaba.druid.pool.DruidDataSource | |||||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||||
| filters: stat | |||||
| maxActive: 20 | |||||
| initialSize: 1 | |||||
| maxWait: 60000 | |||||
| minIdle: 1 | |||||
| timeBetweenEvictionRunsMillis: 60000 | |||||
| minEvictableIdleTimeMillis: 300000 | |||||
| validationQuery: select 'x' | |||||
| testWhileIdle: true | |||||
| testOnBorrow: false | |||||
| testOnReturn: false | |||||
| poolPreparedStatements: true | |||||
| maxOpenPreparedStatements: 20 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| # REDIS | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 8 | |||||
| max-idle: 8 | |||||
| max-wait: -1 | |||||
| min-idle: 0 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=) | |||||
| password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | |||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | |||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 2 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | |||||
| exception: true | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall: debug | |||||
| path: ./logs/w | |||||
| @@ -0,0 +1,58 @@ | |||||
| server: | |||||
| port: 6060 | |||||
| servlet: | |||||
| context-path: / | |||||
| spring: | |||||
| application: | |||||
| name: mallink | |||||
| profiles: | |||||
| active: dev | |||||
| jackson: | |||||
| date-format: yyyy-MM-dd HH:mm:ss | |||||
| time-zone: GMT+8 | |||||
| default-property-inclusion: non_null | |||||
| servlet: | |||||
| multipart: | |||||
| max-file-size: 2MB | |||||
| max-request-size: 2MB | |||||
| cache: | |||||
| type: REDIS | |||||
| cache-names: redis_cache #缓存的名字(可以不指定) | |||||
| redis: | |||||
| time-to-live: 60000ms #很重要,缓存的有效时间,以便缓存的过期(单位为毫秒) | |||||
| # @{link} https://github.com/abel533 | |||||
| #Mybatis | |||||
| mybatis: | |||||
| type-aliases-package: com.iformall.domain.po | |||||
| mapper-locations: classpath:mapper/*Mapper.xml | |||||
| configuration: | |||||
| map-underscore-to-camel-case: true | |||||
| cache-enabled: true | |||||
| lazy-loading-enabled: true | |||||
| use-generated-keys: true | |||||
| default-fetch-size: 100 | |||||
| default-statement-timeout: 10 | |||||
| #PageHelper | |||||
| pagehelper: | |||||
| helperDialect: mysql | |||||
| reasonable: false | |||||
| supportMethodsArguments: true | |||||
| params: count=countSql | |||||
| offset-as-page-num: true | |||||
| page-size-zero: true | |||||
| row-bounds-with-count: true | |||||
| mapper: | |||||
| mappers: | |||||
| - com.iformall.common.CommonMapper | |||||
| pay: | |||||
| real: true | |||||
| version: @project.version@ | |||||
| @@ -0,0 +1,100 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <configuration scan="true" scanPeriod="10 seconds"> | |||||
| <!-- 外部指定路径 --> | |||||
| <springProperty scop="context" name="logPath" source="logging.path" /> | |||||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |||||
| <encoder> | |||||
| <Pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] --%mdc{client}%msg%n</Pattern> | |||||
| </encoder> | |||||
| </appender> | |||||
| <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/trace.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/trace.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| </appender> | |||||
| <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/info.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/info.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>INFO</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/debug.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/debug.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>DEBUG</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/warn.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/warn.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>WARN</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/error.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/error.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>ERROR</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <root level="TRACE"> | |||||
| <appender-ref ref="TRACE_FILE" /> | |||||
| <appender-ref ref="INFO_FILE" /> | |||||
| <!-- <appender-ref ref="DEBUG_FILE" /> --> | |||||
| <!-- <appender-ref ref="WARN_FILE" /> --> | |||||
| <appender-ref ref="ERROR_FILE" /> | |||||
| </root> | |||||
| <root level="INFO"> | |||||
| <appender-ref ref="STDOUT" /> | |||||
| </root> | |||||
| </configuration> | |||||
| @@ -17,6 +17,7 @@ | |||||
| <module>mallinkCApi</module> | <module>mallinkCApi</module> | ||||
| <module>mallinkBApi</module> | <module>mallinkBApi</module> | ||||
| <module>mallinkSchedule</module> | <module>mallinkSchedule</module> | ||||
| <module>mallinkWeChatOpen</module> | |||||
| </modules> | </modules> | ||||
| <parent> | <parent> | ||||