邮箱添加

main
张海宁 2024-03-28 17:52:56 +08:00
parent 97e9f680b3
commit 7d1eb060d3
7 changed files with 43 additions and 8 deletions

View File

@ -39,8 +39,10 @@ public class AuthServiceImpl implements AuthService {
@Override
public Result<RespJwt> login(RequestUser requestUser) {
log.info("获取的前台登录数值是:{}",requestUser.toString());
String phone = requestUser.getPhone();
String captcha = requestUser.getCaptcha();
if (null == phone || null == captcha) {
return Result.error("联系管理员");
}

View File

@ -6,6 +6,7 @@ import com.xsnb.system.domain.Mail;
import com.xsnb.system.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
@ -22,7 +23,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/test")
@RequestMapping("/mail")
public class DomeController {
@ -42,7 +43,7 @@ public class DomeController {
}
//添加邮件,通过邮箱实体类来创建邮箱,也就是邮箱发送
@PostMapping("/addMail")
public Result<Mail> addMail(Mail mail){
public Result<Mail> addMail(@RequestBody Mail mail){
return mailService.addMail(mail);
}

View File

@ -5,10 +5,9 @@ import com.xsnb.common.domain.User;
import com.xsnb.common.result.Result;
import com.xsnb.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@ -27,6 +26,12 @@ public class UserController {
return userService.byphone(phone);
}
@PostMapping("/list")
public Result<List<User>> list( User user){
return userService.list(user);
}
}

View File

@ -36,13 +36,13 @@ public class MessageConsumerService {
String jsons = TelSmsUtils.sendSms(phone, new HashMap<String, String>() {{
put("code",code);
}});
redisTemplate.opsForValue().set(phone,code);
SendSmsResponseBody sendSmsResponseBody = JSONObject.parseObject(jsons, SendSmsResponseBody.class);
if(!"OK".equals(sendSmsResponseBody.getCode())){
TelSmsUtils.sendSms(phone,new HashMap<String, String>(){{
put("code",code);
}});
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
redisTemplate.opsForValue().set(phone,JSONObject.toJSONString(code));
log.info("短信消费队列消费成功 用户:{},耗时:{}",phone,System.currentTimeMillis()-s);
}
}else {

View File

@ -3,8 +3,11 @@ package com.xsnb.system.service;
import com.xsnb.common.domain.User;
import com.xsnb.common.result.Result;
import java.util.List;
public interface UserService {
Result<User> byphone(String phone);
Result<List<User>> list(User user);
}

View File

@ -6,9 +6,11 @@ import com.xsnb.common.result.Result;
import com.xsnb.system.domain.Mail;
import com.xsnb.system.mapper.MailMapper;
import com.xsnb.system.service.MailService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
@ -21,6 +23,7 @@ import java.util.List;
*
*/
@Service
@Log4j2
public class MailServiceImpl implements MailService {
@Autowired
MailMapper mapper;
@ -36,6 +39,7 @@ public class MailServiceImpl implements MailService {
QueryWrapper<Mail> qw = new QueryWrapper<>();
qw.eq("user_id", user.getId());
List<Mail> mailList = mapper.selectList(qw);
log.info("查询邮件的结果:{}",mailList);
return Result.success(mailList);
}
@ -55,7 +59,16 @@ public class MailServiceImpl implements MailService {
*/
@Override
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("发送失败");
}
}

View File

@ -9,6 +9,8 @@ import com.xsnb.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired
@ -22,6 +24,15 @@ public class UserServiceImpl implements UserService {
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);
}
}