邮箱添加
parent
97e9f680b3
commit
7d1eb060d3
|
@ -39,8 +39,10 @@ public class AuthServiceImpl implements AuthService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<RespJwt> login(RequestUser requestUser) {
|
public Result<RespJwt> login(RequestUser requestUser) {
|
||||||
|
log.info("获取的前台登录数值是:{}",requestUser.toString());
|
||||||
String phone = requestUser.getPhone();
|
String phone = requestUser.getPhone();
|
||||||
String captcha = requestUser.getCaptcha();
|
String captcha = requestUser.getCaptcha();
|
||||||
|
|
||||||
if (null == phone || null == captcha) {
|
if (null == phone || null == captcha) {
|
||||||
return Result.error("联系管理员");
|
return Result.error("联系管理员");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.xsnb.system.domain.Mail;
|
||||||
import com.xsnb.system.service.MailService;
|
import com.xsnb.system.service.MailService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test")
|
@RequestMapping("/mail")
|
||||||
public class DomeController {
|
public class DomeController {
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ public class DomeController {
|
||||||
}
|
}
|
||||||
//添加邮件,通过邮箱实体类来创建邮箱,也就是邮箱发送
|
//添加邮件,通过邮箱实体类来创建邮箱,也就是邮箱发送
|
||||||
@PostMapping("/addMail")
|
@PostMapping("/addMail")
|
||||||
public Result<Mail> addMail(Mail mail){
|
public Result<Mail> addMail(@RequestBody Mail mail){
|
||||||
return mailService.addMail(mail);
|
return mailService.addMail(mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@ import com.xsnb.common.domain.User;
|
||||||
import com.xsnb.common.result.Result;
|
import com.xsnb.common.result.Result;
|
||||||
import com.xsnb.system.service.UserService;
|
import com.xsnb.system.service.UserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -27,6 +26,12 @@ public class UserController {
|
||||||
return userService.byphone(phone);
|
return userService.byphone(phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/list")
|
||||||
|
public Result<List<User>> list( User user){
|
||||||
|
return userService.list(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class MessageConsumerService {
|
||||||
String jsons = TelSmsUtils.sendSms(phone, new HashMap<String, String>() {{
|
String jsons = TelSmsUtils.sendSms(phone, new HashMap<String, String>() {{
|
||||||
put("code",code);
|
put("code",code);
|
||||||
}});
|
}});
|
||||||
|
redisTemplate.opsForValue().set(phone,code);
|
||||||
SendSmsResponseBody sendSmsResponseBody = JSONObject.parseObject(jsons, SendSmsResponseBody.class);
|
SendSmsResponseBody sendSmsResponseBody = JSONObject.parseObject(jsons, SendSmsResponseBody.class);
|
||||||
if(!"OK".equals(sendSmsResponseBody.getCode())){
|
if(!"OK".equals(sendSmsResponseBody.getCode())){
|
||||||
TelSmsUtils.sendSms(phone,new HashMap<String, String>(){{
|
TelSmsUtils.sendSms(phone,new HashMap<String, String>(){{
|
||||||
put("code",code);
|
put("code",code);
|
||||||
}});
|
}});
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
redisTemplate.opsForValue().set(phone,JSONObject.toJSONString(code));
|
|
||||||
log.info("短信消费队列消费成功 用户:{},耗时:{}",phone,System.currentTimeMillis()-s);
|
log.info("短信消费队列消费成功 用户:{},耗时:{}",phone,System.currentTimeMillis()-s);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
|
|
@ -3,8 +3,11 @@ package com.xsnb.system.service;
|
||||||
import com.xsnb.common.domain.User;
|
import com.xsnb.common.domain.User;
|
||||||
import com.xsnb.common.result.Result;
|
import com.xsnb.common.result.Result;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
Result<User> byphone(String phone);
|
Result<User> byphone(String phone);
|
||||||
|
|
||||||
|
|
||||||
|
Result<List<User>> list(User user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@ import com.xsnb.common.result.Result;
|
||||||
import com.xsnb.system.domain.Mail;
|
import com.xsnb.system.domain.Mail;
|
||||||
import com.xsnb.system.mapper.MailMapper;
|
import com.xsnb.system.mapper.MailMapper;
|
||||||
import com.xsnb.system.service.MailService;
|
import com.xsnb.system.service.MailService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
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.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +23,7 @@ import java.util.List;
|
||||||
* 作者姓名 修改时间 版本号 描述
|
* 作者姓名 修改时间 版本号 描述
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Log4j2
|
||||||
public class MailServiceImpl implements MailService {
|
public class MailServiceImpl implements MailService {
|
||||||
@Autowired
|
@Autowired
|
||||||
MailMapper mapper;
|
MailMapper mapper;
|
||||||
|
@ -36,6 +39,7 @@ public class MailServiceImpl implements MailService {
|
||||||
QueryWrapper<Mail> qw = new QueryWrapper<>();
|
QueryWrapper<Mail> qw = new QueryWrapper<>();
|
||||||
qw.eq("user_id", user.getId());
|
qw.eq("user_id", user.getId());
|
||||||
List<Mail> mailList = mapper.selectList(qw);
|
List<Mail> mailList = mapper.selectList(qw);
|
||||||
|
log.info("查询邮件的结果:{}",mailList);
|
||||||
return Result.success(mailList);
|
return Result.success(mailList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +59,16 @@ public class MailServiceImpl implements MailService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result<Mail> addMail(Mail mail) {
|
public Result<Mail> addMail(Mail mail) {
|
||||||
return null;
|
log.info("添加邮件的数据:{}",mail);
|
||||||
|
//获取当前时间转换为Date类型
|
||||||
|
mail.setSendTime(new Date());
|
||||||
|
mail.setEmailStatus("未读");
|
||||||
|
//存入数据库
|
||||||
|
int insert = mapper.insert(mail);
|
||||||
|
log.info("添加邮件的结果:{}",insert);
|
||||||
|
|
||||||
|
|
||||||
|
return insert==1?Result.success(mail,"发送成功"):Result.error("发送失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import com.xsnb.system.service.UserService;
|
||||||
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.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -22,6 +24,15 @@ public class UserServiceImpl implements UserService {
|
||||||
return Result.success(user);
|
return Result.success(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<List<User>> list(User user) {
|
||||||
|
List<User> list = userMapper.selectList(null);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue