| @@ -0,0 +1,91 @@ | |||||
| package com.simple.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgValidationcode; | |||||
| import com.simple.service.WxMsgValidationcodeService; | |||||
| 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("wxMsgValidationcode") | |||||
| public class WxMsgValidationcodeController extends BaseController | |||||
| { | |||||
| @Autowired | |||||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
| private Logger logger = Logger.getLogger(WxMsgValidationcodeController.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 WxMsgValidationcode wxMsgValidationcode,Integer pageNum, Integer pageSize) { | |||||
| if (null == wxMsgValidationcode) wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| final PageInfo<WxMsgValidationcode> page = wxMsgValidationcodeService.listAsPage(wxMsgValidationcode, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxMsgValidationcode wxMsgValidationcode) { | |||||
| //Assert.notNull(wxMsgValidationcode.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxMsgValidationcodeService.saveOrUpdate(wxMsgValidationcode); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxMsgValidationcode wxMsgValidationcode) { | |||||
| wxMsgValidationcodeService.saveOrUpdate(wxMsgValidationcode); | |||||
| return new ResultData(); | |||||
| } | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData delete(Long id) { | |||||
| wxMsgValidationcodeService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData findById(Long id) { | |||||
| return new ResultData(Result.SUCCESS,"查询成功",wxMsgValidationcodeService.getById(id)); | |||||
| } | |||||
| @GetMapping("sendvalidationcode") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="tenantId",value="租户ID",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) { | |||||
| WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setTenantId(tenantId); | |||||
| wxMsgValidationcode.setPhone(phone); | |||||
| wxMsgValidationcode.setType(type); | |||||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||||
| } | |||||
| @GetMapping("hasvalidationcode") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="tenantId",value="租户ID",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="code",value="验证码",dataType="String", paramType = "query",required=true)}) | |||||
| public ResultData hasvalidationcode(String tenantId,String phone,Integer type,String code) { | |||||
| WxMsgValidationcode wxMsgValidationcode =new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setTenantId(tenantId); | |||||
| wxMsgValidationcode.setPhone(phone); | |||||
| wxMsgValidationcode.setType(type); | |||||
| wxMsgValidationcode.setCode(code); | |||||
| return wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); | |||||
| } | |||||
| } | |||||
| @@ -1,10 +1,5 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.util.Assert; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| @@ -14,6 +9,9 @@ import com.simple.service.WxShopService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxShop") | @RequestMapping("wxShop") | ||||
| @@ -40,6 +38,7 @@ public class WxShopController extends BaseController | |||||
| public ResultData add(@RequestBody WxShop wxShop) { | public ResultData add(@RequestBody WxShop wxShop) { | ||||
| //Assert.notNull(wxShop.getName(), "角色名不能为空"); | //Assert.notNull(wxShop.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxShop.setTenantId(getTenantId()); | |||||
| wxShopService.saveOrUpdate(wxShop); | wxShopService.saveOrUpdate(wxShop); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -1,31 +1,30 @@ | |||||
| 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.math.BigDecimal; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_mall") | @Table(name = "wx_mall") | ||||
| public class WxMall implements Serializable { | public class WxMall implements Serializable { | ||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @Id | @Id | ||||
| protected Long id; | |||||
| protected Long mallId; | |||||
| @Transient | @Transient | ||||
| protected List<String> ids; | protected List<String> ids; | ||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| public Long getId() { | |||||
| return id; | |||||
| public Long getMallId() { | |||||
| return mallId; | |||||
| } | } | ||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| public void setMallId(Long mallId) { | |||||
| this.mallId = mallId; | |||||
| } | } | ||||
| public String getSortColumns() { | public String getSortColumns() { | ||||
| @@ -154,7 +153,7 @@ public class WxMall implements Serializable { | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| Id_ASC("`mallId` ASC"),Id_DESC("`mallId` DESC") | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | ||||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | ||||
| ,Group_ASC("`group` ASC"),Group_DESC("`group` DESC") | ,Group_ASC("`group` ASC"),Group_DESC("`group` DESC") | ||||
| @@ -0,0 +1,179 @@ | |||||
| 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") | |||||
| public class WxMsgValidationcode 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="phone") | |||||
| private String phone; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="expiretime") | |||||
| private Date expiretime; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="createtime") | |||||
| private Date createtime; | |||||
| /*场景 1 登录 2买券 3停车**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="场景 1 登录 2买券 3停车",name="type") | |||||
| private Integer type; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") | |||||
| private String tenantId; | |||||
| /*内容**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="内容",name="msg") | |||||
| private String msg; | |||||
| /*签名**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="签名",name="signature") | |||||
| private String signature; | |||||
| /***/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="code") | |||||
| private String code; | |||||
| public String getPhone() { | |||||
| return phone; | |||||
| } | |||||
| public void setPhone(String _phone) { | |||||
| phone = _phone; | |||||
| } | |||||
| public Date getExpiretime() { | |||||
| return expiretime; | |||||
| } | |||||
| public void setExpiretime(Date _expiretime) { | |||||
| expiretime = _expiretime; | |||||
| } | |||||
| public Date getCreatetime() { | |||||
| return createtime; | |||||
| } | |||||
| public void setCreatetime(Date _createtime) { | |||||
| createtime = _createtime; | |||||
| } | |||||
| public Integer getType() { | |||||
| return type; | |||||
| } | |||||
| public void setType(Integer _type) { | |||||
| type = _type; | |||||
| } | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | |||||
| } | |||||
| public String getMsg() { | |||||
| return msg; | |||||
| } | |||||
| public void setMsg(String _msg) { | |||||
| msg = _msg; | |||||
| } | |||||
| public String getSignature() { | |||||
| return signature; | |||||
| } | |||||
| public void setSignature(String _signature) { | |||||
| signature = _signature; | |||||
| } | |||||
| public String getCode() { | |||||
| return code; | |||||
| } | |||||
| public void setCode(String _code) { | |||||
| code = _code; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,Phone_ASC("`phone` ASC"),Phone_DESC("`phone` DESC") | |||||
| ,Expiretime_ASC("`expiretime` ASC"),Expiretime_DESC("`expiretime` DESC") | |||||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,Msg_ASC("`msg` ASC"),Msg_DESC("`msg` DESC") | |||||
| ,Signature_ASC("`signature` ASC"),Signature_DESC("`signature` DESC") | |||||
| ,Code_ASC("`code` ASC"),Code_DESC("`code` 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 com.simple.common.CommonMapper; | |||||
| import com.simple.domain.po.WxMsgValidationcode; | |||||
| import java.util.List; | |||||
| public interface WxMsgValidationcodeMapper extends CommonMapper<WxMsgValidationcode, String> { | |||||
| List<WxMsgValidationcode> findList(WxMsgValidationcode wxMsgValidationcode); | |||||
| } | |||||
| @@ -0,0 +1,51 @@ | |||||
| package com.simple.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMsgValidationcode; | |||||
| public interface WxMsgValidationcodeService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxMsgValidationcode getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxMsgValidationcode record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| ResultData sendvalidationcode(WxMsgValidationcode record); | |||||
| ResultData hasvalidationcode(WxMsgValidationcode record); | |||||
| } | |||||
| @@ -0,0 +1,169 @@ | |||||
| 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.WxMall; | |||||
| import com.simple.domain.po.WxMsg; | |||||
| import com.simple.domain.po.WxMsgConfig; | |||||
| import com.simple.domain.po.WxMsgValidationcode; | |||||
| import com.simple.mapper.WxMallMapper; | |||||
| import com.simple.mapper.WxMsgConfigMapper; | |||||
| import com.simple.mapper.WxMsgValidationcodeMapper; | |||||
| import com.simple.service.WxMsgValidationcodeService; | |||||
| import com.simple.utils.*; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.*; | |||||
| import java.util.stream.Collectors; | |||||
| @Service | |||||
| public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeService { | |||||
| @Autowired | |||||
| WxMsgValidationcodeMapper wxMsgValidationcodeMapper; | |||||
| @Autowired | |||||
| WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Autowired | |||||
| WxMallMapper wxMallMapper; | |||||
| @Override | |||||
| public PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgValidationcodeMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public WxMsgValidationcode getById(Long id) { | |||||
| return wxMsgValidationcodeMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxMsgValidationcode record) { | |||||
| if (record.getId() == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxMsgValidationcodeMapper.insertSelective(record); | |||||
| } else { | |||||
| wxMsgValidationcodeMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxMsgValidationcodeMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public ResultData sendvalidationcode(WxMsgValidationcode wxMsgValidationcode) { | |||||
| //1、查看是否存在未过期的短信,有返回成功 没有继续 | |||||
| List<WxMsgValidationcode> wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | |||||
| Date currentdate = new Date(); | |||||
| wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode -> | |||||
| validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); | |||||
| if(wxmsgvalidationcodelist.size()>0) return new ResultData(200,"发送成功"); | |||||
| //2、根据tenantid查询出商场名称作为签名 | |||||
| WxMall wxMall = new WxMall(); | |||||
| wxMall.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| List<WxMall> wxmallist = wxMallMapper.findList(wxMall); | |||||
| wxMsgValidationcode.setSignature(wxmallist.get(0).getName()); | |||||
| //3、从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| //验证码 | |||||
| int code = (int) ((Math.random() * 9 + 1) * 100000); | |||||
| String phone = wxMsgValidationcode.getPhone(); | |||||
| String signature = wxMsgValidationcode.getSignature(); | |||||
| //内容 | |||||
| String msg=new StringBuilder().append(code).append("(动态验证码),请在15分钟内填写").toString(); | |||||
| wxMsgValidationcode.setCode(String.valueOf(code)); | |||||
| wxMsgValidationcode.setMsg(msg); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| TreeMap<String, String> message = new TreeMap<>(); | |||||
| message.put("bid", bid); | |||||
| message.put("phone", phone); | |||||
| message.put("signature", signature); | |||||
| message.put("msg", msg); | |||||
| message.put("notify_url", notifyUrl); | |||||
| 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(), publickey); | |||||
| params.put("data", data); | |||||
| params.put("sc", sc); | |||||
| } catch (Exception e) { | |||||
| throw new RuntimeException("发送失败"); | |||||
| } | |||||
| String requestUrl = "https://webapp.wiwide.com/apisms/send"; | |||||
| String result = HttpUtil.doPost(requestUrl, params); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| if (ret.equals("1")) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| long currentTime = System.currentTimeMillis() ; | |||||
| Date createtime=new Date(currentTime); | |||||
| currentTime +=15*60*1000; | |||||
| Date expiredate=new Date(currentTime); | |||||
| wxMsgValidationcode.setExpiretime(expiredate); | |||||
| wxMsgValidationcode.setCreatetime(createtime); | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| return new ResultData(200,"发送成功"); | |||||
| } | |||||
| return new ResultData(500,"发送失败"); | |||||
| } | |||||
| @Override | |||||
| public ResultData hasvalidationcode(WxMsgValidationcode record) { | |||||
| List<WxMsgValidationcode> wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(record); | |||||
| Date currentdate = new Date(); | |||||
| wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode -> | |||||
| validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); | |||||
| if(wxmsgvalidationcodelist.size()>0) return new ResultData(200,"验证码存在",true); | |||||
| return new ResultData(500,"验证码不存在或过期",false); | |||||
| } | |||||
| } | |||||
| @@ -29,12 +29,19 @@ public class WxShopServiceImpl implements WxShopService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxShop record) { | public void saveOrUpdate(WxShop record) { | ||||
| List<WxShop> list = wxShopMapper.findList(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(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setStatus(0); | |||||
| record.setUpdateDate(new Date()); | |||||
| record.setCreateDate(new Date()); | |||||
| wxShopMapper.insertSelective(record); | wxShopMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| record.setUpdateDate(new Date()); | |||||
| wxShopMapper.updateByPrimaryKeySelective(record); | wxShopMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| } | } | ||||
| @@ -2,7 +2,7 @@ | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.simple.mapper.WxMallMapper"> | <mapper namespace="com.simple.mapper.WxMallMapper"> | ||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxMall"> | <resultMap id="BaseResultMap" type="com.simple.domain.po.WxMall"> | ||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <id column="mall_id" jdbcType="BIGINT" property="mallId" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | ||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | <result column="name" jdbcType="VARCHAR" property="name" /> | ||||
| <result column="group" jdbcType="VARCHAR" property="group" /> | <result column="group" jdbcType="VARCHAR" property="group" /> | ||||
| @@ -18,14 +18,14 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number` | |||||
| `mall_id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`,`total_area`,`operating_area`,`park_area`,`park_place_number` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | where 1 = 1 | ||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| <if test=" null != mallId "> | |||||
| and `mall_id` = #{mallId} | |||||
| </if> | </if> | ||||
| @@ -89,7 +89,7 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | |||||
| and mall_id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| @@ -0,0 +1,50 @@ | |||||
| <?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.WxMsgValidationcodeMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxMsgValidationcode"> | |||||
| <id column="id" jdbcType="INTEGER" property="id" /> | |||||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | |||||
| <result column="expiretime" jdbcType="TIMESTAMP" property="expiretime" /> | |||||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="msg" jdbcType="VARCHAR" property="msg" /> | |||||
| <result column="signature" jdbcType="VARCHAR" property="signature" /> | |||||
| <result column="code" jdbcType="VARCHAR" property="code" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`phone`,`expiretime`,`createtime`,`type`,`tenant_id`,`msg`,`signature`,`code` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != phone "> and `phone` = #{phone} </if> | |||||
| <if test=" null != expiretime "> and `expiretime` = #{expiretime} </if> | |||||
| <if test=" null != createtime "> and `createtime` = #{createtime} </if> | |||||
| <if test=" null != type "> and `type` = #{type} </if> | |||||
| <if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if> | |||||
| <if test=" null != msg "> and `msg` = #{msg} </if> | |||||
| <if test=" null != signature "> and `signature` = #{signature} </if> | |||||
| <if test=" null != code "> and `code` = #{code} </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.WxMsgValidationcode" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_msg_validationcode | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||