| @@ -38,15 +38,15 @@ public class WxMerchantBUserController extends BaseController | |||||
| //Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空"); | //Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxMerchantBUser.setTenantId(getTenantId()); | wxMerchantBUser.setTenantId(getTenantId()); | ||||
| wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||||
| return new ResultData(); | |||||
| Long id = wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||||
| return new ResultData(Result.SUCCESS,"添加成功",id); | |||||
| } | } | ||||
| @ApiOperation("根据id更新接口") | @ApiOperation("根据id更新接口") | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxMerchantBUser wxMerchantBUser) { | public ResultData update(@RequestBody WxMerchantBUser wxMerchantBUser) { | ||||
| wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||||
| return new ResultData(); | |||||
| Long id = wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||||
| return new ResultData(Result.SUCCESS,"更新成功",id); | |||||
| } | } | ||||
| @ApiOperation("根据id删除接口") | @ApiOperation("根据id删除接口") | ||||
| @@ -74,5 +74,19 @@ public class WxMsgCallbackController extends BaseController | |||||
| wxMsgCallbackService.saveOrUpdate(bid,item,sign); | wxMsgCallbackService.saveOrUpdate(bid,item,sign); | ||||
| } | } | ||||
| @RequestMapping(value = "/receivemodel/{bid}") | |||||
| public void receivemodel(@PathVariable String bid, @RequestParam Map<String,String> param) { | |||||
| //解析param数据插入数据库中 | |||||
| wxMsgCallbackService.receivemodel(bid,param); | |||||
| } | |||||
| @RequestMapping(value = "/receiveverifymodel/{bid}") | |||||
| public void receiveverifymodel(@PathVariable String bid, @RequestParam Map<String,String> param) { | |||||
| //解析param数据插入数据库中 | |||||
| wxMsgCallbackService.receiveverifymodel(bid,param); | |||||
| } | |||||
| } | } | ||||
| @@ -44,6 +44,7 @@ public class WxMsgController extends BaseController | |||||
| public ResultData add(@RequestBody WxMsg wxMsg) { | public ResultData add(@RequestBody WxMsg wxMsg) { | ||||
| //Assert.notNull(wxMsg.getName(), "角色名不能为空"); | //Assert.notNull(wxMsg.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxMsg.setTenantId(getTenantId()); | |||||
| wxMsgService.saveOrUpdate(wxMsg); | wxMsgService.saveOrUpdate(wxMsg); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -37,6 +37,7 @@ public class WxMsgModelController extends BaseController | |||||
| public ResultData add(@RequestBody WxMsgModel wxMsgModel) { | public ResultData add(@RequestBody WxMsgModel wxMsgModel) { | ||||
| //Assert.notNull(wxMsgModel.getName(), "角色名不能为空"); | //Assert.notNull(wxMsgModel.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxMsgModel.setTenantId(getTenantId()); | |||||
| return wxMsgModelService.saveOrUpdate(wxMsgModel); | return wxMsgModelService.saveOrUpdate(wxMsgModel); | ||||
| } | } | ||||
| @@ -65,7 +66,7 @@ public class WxMsgModelController extends BaseController | |||||
| @ApiOperation("获取所有数据") | @ApiOperation("获取所有数据") | ||||
| @GetMapping("getmodellist") | @GetMapping("getmodellist") | ||||
| public ResultData getmodellist() { | public ResultData getmodellist() { | ||||
| return wxMsgModelService.getmodellist(); | |||||
| return wxMsgModelService.getmodellist(getTenantId()); | |||||
| } | } | ||||
| @@ -61,29 +61,33 @@ public class WxMsgValidationcodeController extends BaseController | |||||
| @GetMapping("sendvalidationcode") | @GetMapping("sendvalidationcode") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name="tenantId",value="租户ID",dataType="String", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="tenantId",value="租户ID",dataType="String", paramType = "query"), | |||||
| @ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true), | @ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true), | ||||
| @ApiImplicitParam(name="type",value="场景",dataType="Integer", paramType = "query",required=true)}) | |||||
| public ResultData sendvalidationcode(String tenantId,String phone,Integer type) { | |||||
| @ApiImplicitParam(name="type",value="场景",dataType="Integer", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="appid",value="appid",dataType="String", paramType = "query",required=true)}) | |||||
| public ResultData sendvalidationcode(String tenantId,String phone,Integer type,String appid) { | |||||
| WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode(); | WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode(); | ||||
| wxMsgValidationcode.setTenantId(tenantId); | wxMsgValidationcode.setTenantId(tenantId); | ||||
| wxMsgValidationcode.setPhone(phone); | wxMsgValidationcode.setPhone(phone); | ||||
| wxMsgValidationcode.setType(type); | wxMsgValidationcode.setType(type); | ||||
| wxMsgValidationcode.setAppid(appid); | |||||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | ||||
| } | } | ||||
| @GetMapping("hasvalidationcode") | @GetMapping("hasvalidationcode") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name="tenantId",value="租户ID",dataType="String", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="tenantId",value="租户ID",dataType="String", paramType = "query"), | |||||
| @ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true), | @ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true), | ||||
| @ApiImplicitParam(name="type",value="场景",dataType="Integer", paramType = "query",required=true), | @ApiImplicitParam(name="type",value="场景",dataType="Integer", paramType = "query",required=true), | ||||
| @ApiImplicitParam(name="code",value="验证码",dataType="String", paramType = "query",required=true)}) | |||||
| public ResultData hasvalidationcode(String tenantId,String phone,Integer type,String code) { | |||||
| @ApiImplicitParam(name="code",value="验证码",dataType="String", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="appid",value="appid",dataType="String", paramType = "query",required=true)}) | |||||
| public ResultData hasvalidationcode(String tenantId,String phone,Integer type,String code,String appid) { | |||||
| WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode(); | WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode(); | ||||
| wxMsgValidationcode.setTenantId(tenantId); | wxMsgValidationcode.setTenantId(tenantId); | ||||
| wxMsgValidationcode.setPhone(phone); | wxMsgValidationcode.setPhone(phone); | ||||
| wxMsgValidationcode.setType(type); | wxMsgValidationcode.setType(type); | ||||
| wxMsgValidationcode.setCode(code); | wxMsgValidationcode.setCode(code); | ||||
| wxMsgValidationcode.setAppid(appid); | |||||
| return wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); | return wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); | ||||
| } | } | ||||
| @@ -0,0 +1,62 @@ | |||||
| package com.simple.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||||
| import com.simple.service.WxMsgValidationcodeModelService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | |||||
| @RequestMapping("wxMsgValidationcodeModel") | |||||
| public class WxMsgValidationcodeModelController extends BaseController | |||||
| { | |||||
| @Autowired | |||||
| private WxMsgValidationcodeModelService wxMsgValidationcodeModelService; | |||||
| private Logger logger = Logger.getLogger(WxMsgValidationcodeModelController.class); | |||||
| @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 WxMsgValidationcodeModel wxMsgValidationcodeModel,Integer pageNum, Integer pageSize) { | |||||
| if (null == wxMsgValidationcodeModel) wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| final PageInfo<WxMsgValidationcodeModel> page = wxMsgValidationcodeModelService.listAsPage(wxMsgValidationcodeModel, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) { | |||||
| //Assert.notNull(wxMsgValidationcodeModel.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| return wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel); | |||||
| } | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxMsgValidationcodeModel wxMsgValidationcodeModel) { | |||||
| wxMsgValidationcodeModelService.saveOrUpdate(wxMsgValidationcodeModel); | |||||
| return new ResultData(); | |||||
| } | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||||
| public ResultData delete(String id) { | |||||
| wxMsgValidationcodeModelService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||||
| public ResultData findById(String id) { | |||||
| return new ResultData(Result.SUCCESS,"查询成功",wxMsgValidationcodeModelService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -1,12 +1,10 @@ | |||||
| package com.simple.domain.po; | package com.simple.domain.po; | ||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.List; | |||||
| @Table(name = "wx_msg_config") | @Table(name = "wx_msg_config") | ||||
| public class WxMsgConfig implements Serializable { | public class WxMsgConfig implements Serializable { | ||||
| @@ -77,6 +75,18 @@ public class WxMsgConfig implements Serializable { | |||||
| /*回调地址**/ | /*回调地址**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="回调地址",name="notifyurl") | @io.swagger.annotations.ApiModelProperty(value="回调地址",name="notifyurl") | ||||
| private String notifyurl; | private String notifyurl; | ||||
| /*模板回调地址**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板回调地址",name="modelnotifyurl") | |||||
| private String modelnotifyurl; | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板回调地址",name="verifynotifyurl") | |||||
| private String verifynotifyurl; | |||||
| @io.swagger.annotations.ApiModelProperty(value="appid",name="appid") | |||||
| private String appid; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -151,6 +161,29 @@ public class WxMsgConfig implements Serializable { | |||||
| } | } | ||||
| public String getModelnotifyurl() { | |||||
| return modelnotifyurl; | |||||
| } | |||||
| public void setModelnotifyurl(String modelnotifyurl) { | |||||
| this.modelnotifyurl = modelnotifyurl; | |||||
| } | |||||
| public String getVerifynotifyurl() { | |||||
| return verifynotifyurl; | |||||
| } | |||||
| public void setVerifynotifyurl(String verifynotifyurl) { | |||||
| this.verifynotifyurl = verifynotifyurl; | |||||
| } | |||||
| public String getAppid() { | |||||
| return appid; | |||||
| } | |||||
| public void setAppid(String appid) { | |||||
| this.appid = appid; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -1,12 +1,11 @@ | |||||
| package com.simple.domain.po; | package com.simple.domain.po; | ||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_msg_model") | @Table(name = "wx_msg_model") | ||||
| public class WxMsgModel implements Serializable { | public class WxMsgModel implements Serializable { | ||||
| @@ -59,6 +58,11 @@ public class WxMsgModel implements Serializable { | |||||
| /*审核状态 0未通过 1 通过 2审核中**/ | /*审核状态 0未通过 1 通过 2审核中**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="审核状态 0未通过 1 通过 2审核中",name="status") | @io.swagger.annotations.ApiModelProperty(value="审核状态 0未通过 1 通过 2审核中",name="status") | ||||
| private Integer status; | private Integer status; | ||||
| @io.swagger.annotations.ApiModelProperty(value="modelid",name="modelId") | |||||
| private Integer modelId; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -96,7 +100,13 @@ public class WxMsgModel implements Serializable { | |||||
| status = _status; | status = _status; | ||||
| } | } | ||||
| public Integer getModelId() { | |||||
| return modelId; | |||||
| } | |||||
| public void setModelId(Integer modelId) { | |||||
| this.modelId = modelId; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -107,7 +117,9 @@ public class WxMsgModel implements Serializable { | |||||
| ,Content_ASC("`content` ASC"),Content_DESC("`content` DESC") | ,Content_ASC("`content` ASC"),Content_DESC("`content` DESC") | ||||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | ||||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | ||||
| ; | |||||
| ,ModelId_ASC("`modelId` ASC"),ModelId_DESC("`modelId` DESC") | |||||
| ; | |||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| this.value = value; | this.value = value; | ||||
| @@ -63,6 +63,10 @@ public class WxMsgValidationcode implements Serializable { | |||||
| /***/ | /***/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="code") | @io.swagger.annotations.ApiModelProperty(value="",name="code") | ||||
| private String code; | private String code; | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="appid") | |||||
| private String appid; | |||||
| public String getPhone() { | public String getPhone() { | ||||
| return phone; | return phone; | ||||
| } | } | ||||
| @@ -112,7 +116,13 @@ public class WxMsgValidationcode implements Serializable { | |||||
| code = _code; | code = _code; | ||||
| } | } | ||||
| public String getAppid() { | |||||
| return appid; | |||||
| } | |||||
| public void setAppid(String appid) { | |||||
| this.appid = appid; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -0,0 +1,189 @@ | |||||
| package com.simple.domain.po; | |||||
| 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_msg_validationcode_model") | |||||
| public class WxMsgValidationcodeModel implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<String> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<String> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<String> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /*名称**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="name") | |||||
| private String name; | |||||
| /*签名**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="签名",name="signature") | |||||
| private String signature; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="content") | |||||
| private String content; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="createtime") | |||||
| private Date createtime; | |||||
| /*审核状态 0未通过 1 通过 2审核中**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="审核状态 0未通过 1 通过 2审核中",name="status") | |||||
| private Integer status; | |||||
| /*有效分钟数**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="有效分钟数",name="minutes") | |||||
| private Integer minutes; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="modelId") | |||||
| private Integer modelId; | |||||
| /*场景**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="场景",name="type") | |||||
| private Integer type; | |||||
| @io.swagger.annotations.ApiModelProperty(value="tenantid",name="tenantId") | |||||
| private String tenantId; | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public void setName(String _name) { | |||||
| name = _name; | |||||
| } | |||||
| public String getSignature() { | |||||
| return signature; | |||||
| } | |||||
| public void setSignature(String _signature) { | |||||
| signature = _signature; | |||||
| } | |||||
| public String getContent() { | |||||
| return content; | |||||
| } | |||||
| public void setContent(String _content) { | |||||
| content = _content; | |||||
| } | |||||
| public Date getCreatetime() { | |||||
| return createtime; | |||||
| } | |||||
| public void setCreatetime(Date _createtime) { | |||||
| createtime = _createtime; | |||||
| } | |||||
| public Integer getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(Integer _status) { | |||||
| status = _status; | |||||
| } | |||||
| public Integer getMinutes() { | |||||
| return minutes; | |||||
| } | |||||
| public void setMinutes(Integer _minutes) { | |||||
| minutes = _minutes; | |||||
| } | |||||
| public Integer getModelId() { | |||||
| return modelId; | |||||
| } | |||||
| public void setModelId(Integer _modelId) { | |||||
| modelId = _modelId; | |||||
| } | |||||
| public Integer getType() { | |||||
| return type; | |||||
| } | |||||
| public void setType(Integer _type) { | |||||
| type = _type; | |||||
| } | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String tenantId) { | |||||
| this.tenantId = tenantId; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||||
| ,Signature_ASC("`signature` ASC"),Signature_DESC("`signature` DESC") | |||||
| ,Content_ASC("`content` ASC"),Content_DESC("`content` DESC") | |||||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||||
| ,Minutes_ASC("`minutes` ASC"),Minutes_DESC("`minutes` DESC") | |||||
| ,ModelId_ASC("`modelId` ASC"),ModelId_DESC("`modelId` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` 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(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()); | |||||
| } | |||||
| } | |||||
| 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,17 @@ | |||||
| package com.simple.mapper; | |||||
| import java.util.*; | |||||
| import com.simple.common.CommonMapper; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||||
| public interface WxMsgValidationcodeModelMapper extends CommonMapper<WxMsgValidationcodeModel, String> { | |||||
| List<WxMsgValidationcodeModel> findList(WxMsgValidationcodeModel wxMsgValidationcodeModel); | |||||
| } | |||||
| @@ -1,6 +1,5 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxMerchantBUser; | import com.simple.domain.po.WxMerchantBUser; | ||||
| @@ -37,7 +36,7 @@ public interface WxMerchantBUserService { | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void saveOrUpdate(WxMerchantBUser record); | |||||
| Long saveOrUpdate(WxMerchantBUser record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -40,4 +40,9 @@ public interface WxMsgCallbackService { | |||||
| void saveOrUpdate(String bid, String item, String sign); | void saveOrUpdate(String bid, String item, String sign); | ||||
| void receivemodel(String bid, Map<String,String> param); | |||||
| void receiveverifymodel(String bid, Map<String,String> param); | |||||
| } | } | ||||
| @@ -41,7 +41,7 @@ public interface WxMsgModelService { | |||||
| ResultData getmodellist(); | |||||
| ResultData getmodellist(String tenantId); | |||||
| @@ -0,0 +1,49 @@ | |||||
| package com.simple.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||||
| public interface WxMsgValidationcodeModelService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxMsgValidationcodeModel> listAsPage(WxMsgValidationcodeModel record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxMsgValidationcodeModel getById(String id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| ResultData saveOrUpdate(WxMsgValidationcodeModel record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(String id); | |||||
| } | |||||
| @@ -33,7 +33,7 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxMerchantBUser record) { | |||||
| public Long saveOrUpdate(WxMerchantBUser record) { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -44,10 +44,12 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| record.setCreateDate(date); | record.setCreateDate(date); | ||||
| record.setUpdateDate(date); | record.setUpdateDate(date); | ||||
| wxMerchantBUserMapper.insertSelective(record); | wxMerchantBUserMapper.insertSelective(record); | ||||
| return id; | |||||
| } else { | } else { | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| record.setUpdateDate(date); | record.setUpdateDate(date); | ||||
| wxMerchantBUserMapper.updateByPrimaryKeySelective(record); | wxMerchantBUserMapper.updateByPrimaryKeySelective(record); | ||||
| return record.getId(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,15 +6,19 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import com.simple.domain.po.WxMsgCallback; | import com.simple.domain.po.WxMsgCallback; | ||||
| import com.simple.domain.po.WxMsgConfig; | import com.simple.domain.po.WxMsgConfig; | ||||
| import com.simple.domain.po.WxMsgModel; | |||||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||||
| import com.simple.mapper.WxMsgCallbackMapper; | import com.simple.mapper.WxMsgCallbackMapper; | ||||
| import com.simple.mapper.WxMsgConfigMapper; | import com.simple.mapper.WxMsgConfigMapper; | ||||
| import com.simple.mapper.WxMsgModelMapper; | |||||
| import com.simple.mapper.WxMsgValidationcodeModelMapper; | |||||
| import com.simple.service.WxMsgCallbackService; | import com.simple.service.WxMsgCallbackService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.UUID; | |||||
| import java.util.Map; | |||||
| @Service | @Service | ||||
| public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | ||||
| @@ -25,6 +29,13 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgConfigMapper wxMsgConfigMapper; | WxMsgConfigMapper wxMsgConfigMapper; | ||||
| @Autowired | |||||
| WxMsgModelMapper wxMsgModelMapper; | |||||
| @Autowired | |||||
| WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgCallbackMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgCallbackMapper.findList(record)); | ||||
| @@ -56,7 +67,6 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | WxMsgConfig wxMsgConfig = new WxMsgConfig(); | ||||
| wxMsgConfig.setBid(bid); | wxMsgConfig.setBid(bid); | ||||
| String tenantid=null; | |||||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | ||||
| if(list.size()==1) { | if(list.size()==1) { | ||||
| List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); | List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); | ||||
| @@ -65,7 +75,7 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig); | wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig); | ||||
| for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { | for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { | ||||
| wxMsgCallback.setTenantId(tenantid); | |||||
| wxMsgCallback.setTenantId(wxMsgConfig.getTenantId()); | |||||
| wxMsgCallback.setSign(sign); | wxMsgCallback.setSign(sign); | ||||
| wxMsgCallback.setCreatetime(new Date()); | wxMsgCallback.setCreatetime(new Date()); | ||||
| wxMsgCallbackMapper.insertSelective(wxMsgCallback); | wxMsgCallbackMapper.insertSelective(wxMsgCallback); | ||||
| @@ -73,5 +83,37 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public void receivemodel(String bid, Map<String, String> param) { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setBid(bid); | |||||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(list.size()==1) { | |||||
| WxMsgModel wxMsgModel = new WxMsgModel(); | |||||
| wxMsgModel.setModelId(Integer.valueOf(param.get("id"))); | |||||
| wxMsgModel = wxMsgModelMapper.findList(wxMsgModel).get(0); | |||||
| wxMsgModel.setStatus(param.get("status").equals("1")?Integer.valueOf(param.get("status")):0); | |||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void receiveverifymodel(String bid, Map<String, String> param) { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setBid(bid); | |||||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(list.size()==1) { | |||||
| WxMsgValidationcodeModel wxMsgModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgModel.setModelId(Integer.valueOf(param.get("id"))); | |||||
| wxMsgModel = wxMsgValidationcodeModelMapper.findList(wxMsgModel).get(0); | |||||
| wxMsgModel.setStatus(param.get("status").equals("1")?Integer.valueOf(param.get("status")):0); | |||||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -42,11 +42,9 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| @Override | @Override | ||||
| public ResultData saveOrUpdate(WxMsgModel wxMsgModel) { | public ResultData saveOrUpdate(WxMsgModel wxMsgModel) { | ||||
| String tenantid="1"; | |||||
| //从短信配置中查询密钥 bid 等信息 | //从短信配置中查询密钥 bid 等信息 | ||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | WxMsgConfig wxMsgConfig = new WxMsgConfig(); | ||||
| wxMsgConfig.setTenantId(tenantid); | |||||
| wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | ||||
| if(wxMsgConfigs.size()==0)return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | if(wxMsgConfigs.size()==0)return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | ||||
| wxMsgConfig = wxMsgConfigs.get(0); | wxMsgConfig = wxMsgConfigs.get(0); | ||||
| @@ -72,6 +70,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| message.put("bid", bid); | message.put("bid", bid); | ||||
| message.put("signature", signature); | message.put("signature", signature); | ||||
| message.put("content", content); | message.put("content", content); | ||||
| message.put("notify_url",wxMsgConfig.getModelnotifyurl()); | |||||
| StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | Set<Map.Entry<String, String>> entries = message.entrySet(); | ||||
| @@ -105,8 +104,11 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| if (wxMsgModel.getId() == null) { | if (wxMsgModel.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgModel.setId(idWorker.nextId()); | wxMsgModel.setId(idWorker.nextId()); | ||||
| wxMsgModel.setTenantId(tenantid); | |||||
| wxMsgModel.setTenantId(wxMsgModel.getTenantId()); | |||||
| String data = jsonObjectResult.get("data").toString(); | |||||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||||
| wxMsgModel.setCreatetime(new Date()); | wxMsgModel.setCreatetime(new Date()); | ||||
| wxMsgModel.setStatus(2);//审核中 | |||||
| wxMsgModelMapper.insertSelective(wxMsgModel); | wxMsgModelMapper.insertSelective(wxMsgModel); | ||||
| } else { | } else { | ||||
| wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); | ||||
| @@ -124,9 +126,10 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData getmodellist() { | |||||
| public ResultData getmodellist(String tenantId) { | |||||
| WxMsgModel wxMsgModel = new WxMsgModel(); | WxMsgModel wxMsgModel = new WxMsgModel(); | ||||
| wxMsgModel.setTenantId("1"); | |||||
| wxMsgModel.setTenantId(tenantId); | |||||
| wxMsgModel.setStatus(1); | |||||
| List<WxMsgModel> list = wxMsgModelMapper.findList(wxMsgModel); | List<WxMsgModel> list = wxMsgModelMapper.findList(wxMsgModel); | ||||
| return new ResultData(list); | return new ResultData(list); | ||||
| } | } | ||||
| @@ -63,7 +63,6 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| if (wxMsg.getStatus() == 2) { | if (wxMsg.getStatus() == 2) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsg.setId(idWorker.nextId()); | wxMsg.setId(idWorker.nextId()); | ||||
| wxMsg.setTenantId("1"); | |||||
| wxMsg.setCreatetime(new Date()); | wxMsg.setCreatetime(new Date()); | ||||
| wxMsgMapper.insertSelective(wxMsg); | wxMsgMapper.insertSelective(wxMsg); | ||||
| return new ResultData(Result.SUCCESS, "已保存到草稿箱"); | return new ResultData(Result.SUCCESS, "已保存到草稿箱"); | ||||
| @@ -78,7 +77,6 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| wxMsg.setStatus(0); | wxMsg.setStatus(0); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsg.setId(idWorker.nextId()); | wxMsg.setId(idWorker.nextId()); | ||||
| wxMsg.setTenantId("1"); | |||||
| wxMsg.setCreatetime(new Date()); | wxMsg.setCreatetime(new Date()); | ||||
| wxMsgMapper.insertSelective(wxMsg); | wxMsgMapper.insertSelective(wxMsg); | ||||
| return new ResultData(Result.SUCCESS, "短信会在预设时间发送"); | return new ResultData(Result.SUCCESS, "短信会在预设时间发送"); | ||||
| @@ -128,7 +126,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| public ResultData sendmsg(WxMsg wxMsg) { | public ResultData sendmsg(WxMsg wxMsg) { | ||||
| //从短信配置中查询密钥 bid 等信息 | //从短信配置中查询密钥 bid 等信息 | ||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | WxMsgConfig wxMsgConfig = new WxMsgConfig(); | ||||
| wxMsgConfig.setTenantId("1"); | |||||
| wxMsgConfig.setTenantId(wxMsg.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | ||||
| if (wxMsgConfigs.size() == 0) return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | if (wxMsgConfigs.size() == 0) return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | ||||
| wxMsgConfig = wxMsgConfigs.get(0); | wxMsgConfig = wxMsgConfigs.get(0); | ||||
| @@ -187,7 +185,6 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| if (wxMsg.getId() == null) { | if (wxMsg.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsg.setId(idWorker.nextId()); | wxMsg.setId(idWorker.nextId()); | ||||
| wxMsg.setTenantId("1"); | |||||
| wxMsg.setCreatetime(new Date()); | wxMsg.setCreatetime(new Date()); | ||||
| wxMsgMapper.insertSelective(wxMsg); | wxMsgMapper.insertSelective(wxMsg); | ||||
| } else { | } else { | ||||
| @@ -0,0 +1,139 @@ | |||||
| package com.simple.service.impl; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.IdWorker; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgConfig; | |||||
| import com.simple.domain.po.WxMsgModel; | |||||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||||
| import com.simple.mapper.WxMsgConfigMapper; | |||||
| import com.simple.mapper.WxMsgValidationcodeModelMapper; | |||||
| import com.simple.service.WxMsgValidationcodeModelService; | |||||
| import com.simple.utils.AesUtil; | |||||
| import com.simple.utils.HMACSHA256; | |||||
| import com.simple.utils.HttpUtil; | |||||
| import com.simple.utils.RsaUtil; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.*; | |||||
| @Service | |||||
| public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeModelService { | |||||
| @Autowired | |||||
| WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | |||||
| @Autowired | |||||
| WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Override | |||||
| public PageInfo<WxMsgValidationcodeModel> listAsPage(WxMsgValidationcodeModel record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgValidationcodeModelMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxMsgValidationcodeModel getById(String id) { | |||||
| return wxMsgValidationcodeModelMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public ResultData saveOrUpdate(WxMsgValidationcodeModel wxMsgModel) { | |||||
| //从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(wxMsgConfigs.size()==0)return new ResultData(Result.SUCCESS, "您还未接入短信运营商,请联系平台管理员"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String signature = wxMsgModel.getSignature(); | |||||
| String content = wxMsgModel.getContent(); | |||||
| //查看用户最新数据是否存在 | |||||
| List<WxMsgValidationcodeModel> wxMsgModels = wxMsgValidationcodeModelMapper.findList(wxMsgModel); | |||||
| if (wxMsgModel.getId() == null && wxMsgModels.size() == 1) { | |||||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||||
| } | |||||
| if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { | |||||
| WxMsgValidationcodeModel wxmsgmodel = wxMsgModels.get(0); | |||||
| if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { | |||||
| return new ResultData(Result.SUCCESS, "您添加的短信模板已存在"); | |||||
| } | |||||
| } | |||||
| //请求api数据排序 | |||||
| TreeMap<String, String> message = new TreeMap<>(); | |||||
| message.put("bid", bid); | |||||
| message.put("signature", signature); | |||||
| message.put("content", content); | |||||
| message.put("notify_url",wxMsgConfig.getModelnotifyurl()); | |||||
| message.put("verifysms","1"); | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | |||||
| for (Map.Entry<String, String> entry : entries) { | |||||
| sb.append(entry.getKey()).append("=").append(entry.getValue()); | |||||
| } | |||||
| sb.append("&secret=").append(secret); | |||||
| String sign = HMACSHA256.sha256_HMAC(sb.toString(), secret); | |||||
| message.put("sign", sign.toUpperCase()); | |||||
| String str32 = "198b02e8fd704e96198b02e8fd704e96"; | |||||
| String iv = "198b02e8fd704e96"; | |||||
| Map<String, String> params = new HashMap<>(); | |||||
| params.put("iv", iv); | |||||
| params.put("bid", bid); | |||||
| try { | |||||
| String data = AesUtil.AESEncode(str32, JSONObject.toJSONString(message), iv); | |||||
| String sc = RsaUtil.RSAEncode(str32.getBytes(), wxMsgConfig.getPublickey()); | |||||
| params.put("data", data); | |||||
| params.put("sc", sc); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; | |||||
| String result = HttpUtil.doPost(requestUrl, params); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| if (ret.equals("1") || ret.equals("-6")) { | |||||
| if (wxMsgModel.getId() == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMsgModel.setId(idWorker.nextId()); | |||||
| wxMsgModel.setTenantId(wxMsgModel.getTenantId()); | |||||
| String data = jsonObjectResult.get("data").toString(); | |||||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||||
| wxMsgModel.setCreatetime(new Date()); | |||||
| wxMsgModel.setStatus(2);//审核中 | |||||
| wxMsgValidationcodeModelMapper.insertSelective(wxMsgModel); | |||||
| } else { | |||||
| wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "创建模板成功"); | |||||
| }else if (ret == "-4") { | |||||
| return new ResultData(Result.SUCCESS, "短信签名或内容错误"); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "创建模板失败"); | |||||
| } | |||||
| @Override | |||||
| public void deleteById(String id) { | |||||
| wxMsgValidationcodeModelMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -7,14 +7,18 @@ import com.simple.common.IdWorker; | |||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.WxMall; | import com.simple.domain.po.WxMall; | ||||
| import com.simple.domain.po.WxMsg; | |||||
| import com.simple.domain.po.WxMsgConfig; | import com.simple.domain.po.WxMsgConfig; | ||||
| import com.simple.domain.po.WxMsgValidationcode; | import com.simple.domain.po.WxMsgValidationcode; | ||||
| import com.simple.domain.po.WxMsgValidationcodeModel; | |||||
| import com.simple.mapper.WxMallMapper; | import com.simple.mapper.WxMallMapper; | ||||
| import com.simple.mapper.WxMsgConfigMapper; | import com.simple.mapper.WxMsgConfigMapper; | ||||
| import com.simple.mapper.WxMsgValidationcodeMapper; | import com.simple.mapper.WxMsgValidationcodeMapper; | ||||
| import com.simple.mapper.WxMsgValidationcodeModelMapper; | |||||
| import com.simple.service.WxMsgValidationcodeService; | import com.simple.service.WxMsgValidationcodeService; | ||||
| import com.simple.utils.*; | |||||
| import com.simple.utils.AesUtil; | |||||
| import com.simple.utils.HMACSHA256; | |||||
| import com.simple.utils.HttpUtil; | |||||
| import com.simple.utils.RsaUtil; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -33,6 +37,8 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| @Autowired | @Autowired | ||||
| WxMallMapper wxMallMapper; | WxMallMapper wxMallMapper; | ||||
| @Autowired | |||||
| WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -74,17 +80,25 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| //2、根据tenantid查询出商场名称作为签名 | //2、根据tenantid查询出商场名称作为签名 | ||||
| WxMall wxMall = new WxMall(); | |||||
| /*WxMall wxMall = new WxMall(); | |||||
| wxMall.setTenantId(wxMsgValidationcode.getTenantId()); | wxMall.setTenantId(wxMsgValidationcode.getTenantId()); | ||||
| List<WxMall> wxmallist = wxMallMapper.findList(wxMall); | |||||
| wxMsgValidationcode.setSignature(wxmallist.get(0).getName()); | |||||
| List<WxMall> wxmallist = wxMallMapper.findList(wxMall);*/ | |||||
| //3、从短信配置中查询密钥 bid 等信息 | //3、从短信配置中查询密钥 bid 等信息 | ||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | WxMsgConfig wxMsgConfig = new WxMsgConfig(); | ||||
| wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| wxMsgConfig.setAppid(wxMsgValidationcode.getAppid()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | ||||
| if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | ||||
| wxMsgConfig = wxMsgConfigs.get(0); | wxMsgConfig = wxMsgConfigs.get(0); | ||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||||
| wxMsgValidationcodeModel.setType(1); | |||||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| String secret = wxMsgConfig.getSecret(); | String secret = wxMsgConfig.getSecret(); | ||||
| String bid = wxMsgConfig.getBid(); | String bid = wxMsgConfig.getBid(); | ||||
| String publickey = wxMsgConfig.getPublickey(); | String publickey = wxMsgConfig.getPublickey(); | ||||
| @@ -93,7 +107,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| String phone = wxMsgValidationcode.getPhone(); | String phone = wxMsgValidationcode.getPhone(); | ||||
| String signature = wxMsgValidationcode.getSignature(); | String signature = wxMsgValidationcode.getSignature(); | ||||
| //内容 | //内容 | ||||
| String msg=new StringBuilder().append(code).append("(动态验证码),请在15分钟内填写").toString(); | |||||
| String msg = wxMsgValidationcodeModel.getContent().replace("{s6}", String.valueOf(code)); | |||||
| wxMsgValidationcode.setCode(String.valueOf(code)); | wxMsgValidationcode.setCode(String.valueOf(code)); | ||||
| wxMsgValidationcode.setMsg(msg); | wxMsgValidationcode.setMsg(msg); | ||||
| @@ -104,6 +118,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| message.put("signature", signature); | message.put("signature", signature); | ||||
| message.put("msg", msg); | message.put("msg", msg); | ||||
| message.put("notify_url", notifyUrl); | message.put("notify_url", notifyUrl); | ||||
| message.put("verifysms","1"); | |||||
| StringBuilder sb = new StringBuilder(); | StringBuilder sb = new StringBuilder(); | ||||
| Set<Map.Entry<String, String>> entries = message.entrySet(); | Set<Map.Entry<String, String>> entries = message.entrySet(); | ||||
| @@ -140,7 +155,8 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | wxMsgValidationcode.setId(idWorker.nextId()); | ||||
| long currentTime = System.currentTimeMillis() ; | long currentTime = System.currentTimeMillis() ; | ||||
| Date createtime=new Date(currentTime); | Date createtime=new Date(currentTime); | ||||
| currentTime +=15*60*1000; | |||||
| Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| currentTime +=minutes*60*1000; | |||||
| Date expiredate=new Date(currentTime); | Date expiredate=new Date(currentTime); | ||||
| wxMsgValidationcode.setExpiretime(expiredate); | wxMsgValidationcode.setExpiretime(expiredate); | ||||
| wxMsgValidationcode.setCreatetime(createtime); | wxMsgValidationcode.setCreatetime(createtime); | ||||
| @@ -15,10 +15,15 @@ | |||||
| <result column="reminder" jdbcType="BIGINT" property="reminder" /> | <result column="reminder" jdbcType="BIGINT" property="reminder" /> | ||||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | <result column="phone" jdbcType="VARCHAR" property="phone" /> | ||||
| <result column="notifyurl" jdbcType="VARCHAR" property="notifyurl" /> | <result column="notifyurl" jdbcType="VARCHAR" property="notifyurl" /> | ||||
| <result column="modelnotifyurl" jdbcType="VARCHAR" property="modelnotifyurl" /> | |||||
| <result column="verifynotifyurl" jdbcType="VARCHAR" property="verifynotifyurl" /> | |||||
| <result column="appid" jdbcType="VARCHAR" property="appid" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`secret`,`publickey`,`bid`,`recharge`,`remains`,`total`,`account`,`reminderstatus`,`reminder`,`phone`,`notifyurl` | |||||
| `id`,`tenant_id`,`secret`,`publickey`,`bid`,`recharge`,`remains`,`total`,`account`,`reminderstatus`,`reminder`,`phone`,`notifyurl`,`modelnotifyurl`,`verifynotifyurl`,`appid` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -9,10 +9,12 @@ | |||||
| <result column="content" jdbcType="VARCHAR" property="content" /> | <result column="content" jdbcType="VARCHAR" property="content" /> | ||||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> | <result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> | ||||
| <result column="status" jdbcType="INTEGER" property="status" /> | <result column="status" jdbcType="INTEGER" property="status" /> | ||||
| <result column="model_id" jdbcType="INTEGER" property="modelId" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`name`,`signature`,`content`,`createtime`,`status` | |||||
| `id`,`tenant_id`,`name`,`signature`,`content`,`createtime`,`status`,`model_id` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -51,7 +53,11 @@ | |||||
| <if test=" null != status "> | <if test=" null != status "> | ||||
| and `status` = #{status} | and `status` = #{status} | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != modelId"> | |||||
| and `model_id` = #{modelId} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -65,7 +71,8 @@ | |||||
| select <include refid="allColumns" /> from wx_msg_model | select <include refid="allColumns" /> from wx_msg_model | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| @@ -11,10 +11,12 @@ | |||||
| <result column="msg" jdbcType="VARCHAR" property="msg" /> | <result column="msg" jdbcType="VARCHAR" property="msg" /> | ||||
| <result column="signature" jdbcType="VARCHAR" property="signature" /> | <result column="signature" jdbcType="VARCHAR" property="signature" /> | ||||
| <result column="code" jdbcType="VARCHAR" property="code" /> | <result column="code" jdbcType="VARCHAR" property="code" /> | ||||
| <result column="appid" jdbcType="VARCHAR" property="appid" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`phone`,`expiretime`,`createtime`,`type`,`tenant_id`,`msg`,`signature`,`code` | |||||
| `id`,`phone`,`expiretime`,`createtime`,`type`,`tenant_id`,`msg`,`signature`,`code`,`appid` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -0,0 +1,53 @@ | |||||
| <?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.simple.mapper.WxMsgValidationcodeModelMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxMsgValidationcodeModel"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| <result column="signature" jdbcType="VARCHAR" property="signature" /> | |||||
| <result column="content" jdbcType="VARCHAR" property="content" /> | |||||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| <result column="minutes" jdbcType="INTEGER" property="minutes" /> | |||||
| <result column="model_id" jdbcType="INTEGER" property="modelId" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`name`,`signature`,`content`,`createtime`,`status`,`minutes`,`model_id`,`type`,`tenant_id` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != name "> and `name` = #{name} </if> | |||||
| <if test=" null != signature "> and `signature` = #{signature} </if> | |||||
| <if test=" null != content "> and `content` = #{content} </if> | |||||
| <if test=" null != createtime "> and `createtime` = #{createtime} </if> | |||||
| <if test=" null != status "> and `status` = #{status} </if> | |||||
| <if test=" null != minutes "> and `minutes` = #{minutes} </if> | |||||
| <if test=" null != modelId "> and `model_id` = #{modelId} </if> | |||||
| <if test=" null != type "> and `type` = #{type} </if> | |||||
| <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </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.simple.domain.po.WxMsgValidationcodeModel" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_msg_validationcode_model | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||