use of cn.dubidubi.model.dto.WxInfoDTO in project dubidubi by lzzzz4.
the class MailController method addMail.
/**
* @Description: 增加邮箱
* @data :@return
* @date :2018年3月10日上午11:56:58
*/
@RequestMapping("/addMail")
@ResponseBody
public MailBindResult addMail(MailInfo mailInfo, HttpServletRequest request) {
MailBindResult mailBindResult = new MailBindResult();
// 储存邮箱
WxInfoDTO wxInfoDTO = (WxInfoDTO) request.getSession().getAttribute("user");
mailInfo.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
mailInfo.setNickName(wxInfoDTO.getNickname());
mailInfo.setOpenId(wxInfoDTO.getOpenid());
mailInfo.setPicUrl(wxInfoDTO.getHeadimgurl());
mailService.saveOneMail(mailInfo);
mailBindResult.setResult("200");
return mailBindResult;
}
use of cn.dubidubi.model.dto.WxInfoDTO in project dubidubi by lzzzz4.
the class GetPicByKeyController method key.
/**
* @throws IOException
* @throws ExecutionException
* @throws InterruptedException
* @Description: 界面输入关键词,执行爬虫,异步将内容发送至用户的邮箱
* @data :@param getPicDTO
* @data :@param file
* @data :@param request
* @data :@return
* @date :2018年3月20日下午12:55:12
*/
@RequestMapping("/key")
@ResponseBody
public AjaxResultDTO key(GetPicDTO getPicDTO, @RequestParam(required = false) MultipartFile file, HttpServletRequest request) throws InterruptedException, ExecutionException, IOException {
AjaxResultDTO resultDTO = new AjaxResultDTO();
WxInfoDTO wxInfoDTO = (WxInfoDTO) request.getSession().getAttribute("user");
if (mailInfoMapper.listMailByOpenid(wxInfoDTO.getOpenid()) == null || mailInfoMapper.listMailByOpenid(wxInfoDTO.getOpenid()).size() == 0) {
resultDTO.setCode(500);
}
// 当为九妹源时
if ("2".equals(getPicDTO.getSource())) {
// System.out.println("九妹源");
resultDTO.setUid(wxInfoDTO.getOpenid());
Future<PicUrlToBase64DTO> list = pyBeautifuGirlSerivce.startPy(getPicDTO.getKey(), wxInfoDTO.getOpenid(), getPicDTO.getTime());
pyBeautifuGirlSerivce.waitForComplete(list);
resultDTO.setUrl("/9mei_suc.html");
resultDTO.setCode(9);
} else {
// System.out.println("百度源");
if (getPicDTO.getAmount() == null) {
getPicDTO.setAmount(4);
}
int pn = RandomUtils.nextInt(0, 10) * getPicDTO.getAmount();
// 链接 标题为一组
List<String> strings = pyBeautifuGirlSerivce.startPy(0, 0, getPicDTO.getKey(), pn, getPicDTO.getAmount());
PicUrlToBase64DTO picUrlToBase64DTO = new PicUrlToBase64DTO();
picUrlToBase64DTO.setOpenId(wxInfoDTO.getOpenid());
picUrlToBase64DTO.setList(strings);
picUrlToBase64DTO.setMail(mailInfoMapper.listMailByOpenid(wxInfoDTO.getOpenid()));
// 将对象序列化为base64字符串
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(arrayOutputStream);
objectOutputStream.writeObject(picUrlToBase64DTO);
// 将序列化的对象存入job中执行
String str = Base64.encodeBase64URLSafeString(arrayOutputStream.toByteArray());
Quartz.addJob(pyBeautifuGirlSerivce.randomString(wxInfoDTO.getOpenid(), "job"), pyBeautifuGirlSerivce.randomString(wxInfoDTO.getOpenid(), "jobgroup"), pyBeautifuGirlSerivce.randomString(wxInfoDTO.getOpenid(), "trigger"), pyBeautifuGirlSerivce.randomString(wxInfoDTO.getOpenid(), "triggergroup"), BaiduMailJob.class, pyBeautifuGirlSerivce.dateToCron(getPicDTO.getTime()), "str", str);
resultDTO.setCode(200);
resultDTO.setUrl("/9mei_suc.html");
IOUtils.closeQuietly(arrayOutputStream);
IOUtils.closeQuietly(objectOutputStream);
}
// System.out.println(resultDTO);
return resultDTO;
}
use of cn.dubidubi.model.dto.WxInfoDTO in project dubidubi by lzzzz4.
the class GetPicByKeyController method assess.
/**
* @Description: 拉取微信的授权
* @data :@param code
* @data :@param state
* @data :@param request
* @data :@return
* @date :2018年3月20日下午1:03:34
*/
@RequestMapping("/access")
public String assess(String code, String state, HttpServletRequest request) {
String json = wxBaseService.codeToAccessToken(code);
// 将数据传入session
JSONObject tempInfo = JSON.parseObject(json);
WxInfoDTO wxInfoDTO = new WxInfoDTO();
wxInfoDTO.setNickname(tempInfo.getString("nickname"));
wxInfoDTO.setCity(tempInfo.getString("city"));
wxInfoDTO.setHeadimgurl(tempInfo.getString("headimgurl"));
wxInfoDTO.setOpenid(tempInfo.getString("openid"));
request.getSession().setAttribute("user", wxInfoDTO);
LoggerFactory.getLogger(this.getClass()).info("关键词查询图片,获取用户授权");
// System.out.println(wxInfoDTO);
return "redirect:/pic.html";
}
use of cn.dubidubi.model.dto.WxInfoDTO in project dubidubi by lzzzz4.
the class MailController method getAuth.
/**
* @Description: 拉取授权并跳转至index.html
* @data :
* @date :2018年3月10日下午12:05:08
*/
@RequestMapping("/getAuth")
public String getAuth(String code, String state, HttpServletRequest request) {
// 用code换取access_token
String userInfo = wxBaseService.codeToAccessToken(code);
JSONObject tempInfo = JSON.parseObject(userInfo);
WxInfoDTO wxInfoDTO = new WxInfoDTO();
wxInfoDTO.setNickname(tempInfo.getString("nickname"));
wxInfoDTO.setCity(tempInfo.getString("city"));
wxInfoDTO.setHeadimgurl(tempInfo.getString("headimgurl"));
wxInfoDTO.setOpenid(tempInfo.getString("openid"));
request.getSession().setAttribute("user", wxInfoDTO);
LoggerFactory.getLogger(this.getClass()).info("增加邮箱,获取用户授权");
System.out.println(wxInfoDTO);
return "redirect:/index.html";
}
Aggregations