This commit is contained in:
parent
17d4ec5428
commit
1513b6975e
7
pom.xml
7
pom.xml
|
|
@ -15,7 +15,14 @@
|
||||||
<spring-boot.version>2.3.4.RELEASE</spring-boot.version>
|
<spring-boot.version>2.3.4.RELEASE</spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.mail</groupId>
|
||||||
|
<artifactId>mail</artifactId>
|
||||||
|
<version>1.5.0-b01</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ public class DataShowController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataShowService dataShowService;
|
private DataShowService dataShowService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数据信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Public
|
@Public
|
||||||
@RequestMapping(value = "/getdatashowinfo",method = RequestMethod.POST)
|
@RequestMapping(value = "/getdatashowinfo",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> getSelfOrderList(HttpServletRequest request) {
|
private Result<Map<String, Object>> getSelfOrderList(HttpServletRequest request) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package live.tomey.api.express.controller;
|
package live.tomey.api.express.controller;
|
||||||
|
|
||||||
|
import live.tomey.api.express.aop.PassToken;
|
||||||
import live.tomey.api.express.aop.Root;
|
import live.tomey.api.express.aop.Root;
|
||||||
import live.tomey.api.express.dto.Result;
|
import live.tomey.api.express.dto.Result;
|
||||||
import live.tomey.api.express.entity.Flats;
|
import live.tomey.api.express.entity.Flats;
|
||||||
|
|
@ -31,6 +32,11 @@ public class FlatsController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FlatsService flatsService;
|
private FlatsService flatsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加公寓信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Root
|
@Root
|
||||||
@RequestMapping(value = "/addflats",method = RequestMethod.POST)
|
@RequestMapping(value = "/addflats",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> addFlats(HttpServletRequest request) {
|
private Result<Map<String, Object>> addFlats(HttpServletRequest request) {
|
||||||
|
|
@ -50,6 +56,11 @@ public class FlatsController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公寓信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Root
|
@Root
|
||||||
@RequestMapping(value = "/removeflats",method = RequestMethod.POST)
|
@RequestMapping(value = "/removeflats",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> removeFlats(HttpServletRequest request) {
|
private Result<Map<String, Object>> removeFlats(HttpServletRequest request) {
|
||||||
|
|
@ -69,6 +80,12 @@ public class FlatsController {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改公寓信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Root
|
@Root
|
||||||
@RequestMapping(value = "/editflats",method = RequestMethod.POST)
|
@RequestMapping(value = "/editflats",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> editFlats(HttpServletRequest request) {
|
private Result<Map<String, Object>> editFlats(HttpServletRequest request) {
|
||||||
|
|
@ -93,6 +110,12 @@ public class FlatsController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公寓信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PassToken
|
||||||
@RequestMapping(value = "/getallflats",method = RequestMethod.POST)
|
@RequestMapping(value = "/getallflats",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> getAllFlats(HttpServletRequest request) {
|
private Result<Map<String, Object>> getAllFlats(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import live.tomey.api.express.dto.Result;
|
||||||
import live.tomey.api.express.entity.Account;
|
import live.tomey.api.express.entity.Account;
|
||||||
import live.tomey.api.express.enums.LoginEnum;
|
import live.tomey.api.express.enums.LoginEnum;
|
||||||
import live.tomey.api.express.service.AccountService;
|
import live.tomey.api.express.service.AccountService;
|
||||||
|
import live.tomey.api.express.unit.DESUtil;
|
||||||
import live.tomey.api.express.unit.HttpServletRequestUtil;
|
import live.tomey.api.express.unit.HttpServletRequestUtil;
|
||||||
import live.tomey.api.express.unit.TokenUtil;
|
import live.tomey.api.express.unit.TokenUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -38,6 +39,11 @@ public class LoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AccountService accountService;
|
private AccountService accountService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忘记密码
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PassToken
|
@PassToken
|
||||||
@RequestMapping(value = "/forgot",method = RequestMethod.POST)
|
@RequestMapping(value = "/forgot",method = RequestMethod.POST)
|
||||||
private Result<Map<String,Object>> forgot(HttpServletRequest request){
|
private Result<Map<String,Object>> forgot(HttpServletRequest request){
|
||||||
|
|
@ -138,6 +144,7 @@ public class LoginController {
|
||||||
if (ncryptedAnswers==null){
|
if (ncryptedAnswers==null){
|
||||||
return new Result(false, 0,"密保答案不能为空");
|
return new Result(false, 0,"密保答案不能为空");
|
||||||
}
|
}
|
||||||
|
password = DESUtil.getEncryptString(password);
|
||||||
Account account = new Account(phone,username,password,email,sex,birthday,ncryptedProble,ncryptedAnswers);
|
Account account = new Account(phone,username,password,email,sex,birthday,ncryptedProble,ncryptedAnswers);
|
||||||
boolean type = accountService.addAccount(account);
|
boolean type = accountService.addAccount(account);
|
||||||
if (type){
|
if (type){
|
||||||
|
|
@ -151,6 +158,11 @@ public class LoginController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改个人信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@UserLoginToken
|
@UserLoginToken
|
||||||
@RequestMapping(value = "/editinfo",method = RequestMethod.POST)
|
@RequestMapping(value = "/editinfo",method = RequestMethod.POST)
|
||||||
private Result<Map<String,Object>> editInfo(HttpServletRequest request){
|
private Result<Map<String,Object>> editInfo(HttpServletRequest request){
|
||||||
|
|
@ -176,6 +188,12 @@ public class LoginController {
|
||||||
return new Result(false, LoginEnum.OFFLINE.getState(), LoginEnum.OFFLINE.getStateInfo());
|
return new Result(false, LoginEnum.OFFLINE.getState(), LoginEnum.OFFLINE.getStateInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员修改用户权限
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Root
|
@Root
|
||||||
@RequestMapping(value = "/editidentityid",method = RequestMethod.POST)
|
@RequestMapping(value = "/editidentityid",method = RequestMethod.POST)
|
||||||
private Result<Map<String,Object>> editIdentityId(HttpServletRequest request){
|
private Result<Map<String,Object>> editIdentityId(HttpServletRequest request){
|
||||||
|
|
@ -199,6 +217,12 @@ public class LoginController {
|
||||||
return new Result(false, LoginEnum.OFFLINE.getState(), LoginEnum.OFFLINE.getStateInfo());
|
return new Result(false, LoginEnum.OFFLINE.getState(), LoginEnum.OFFLINE.getStateInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@UserLoginToken
|
@UserLoginToken
|
||||||
@RequestMapping(value = "/editpassword",method = RequestMethod.POST)
|
@RequestMapping(value = "/editpassword",method = RequestMethod.POST)
|
||||||
private Result<Map<String,Object>> editPassword(HttpServletRequest request){
|
private Result<Map<String,Object>> editPassword(HttpServletRequest request){
|
||||||
|
|
@ -216,9 +240,11 @@ public class LoginController {
|
||||||
if (!password.equals(passwordAgain)){
|
if (!password.equals(passwordAgain)){
|
||||||
return new Result(false, 0,"两次密码不匹配");
|
return new Result(false, 0,"两次密码不匹配");
|
||||||
}
|
}
|
||||||
if (!oldpassword.equals(account.getPassword())){
|
String bpassword = DESUtil.getDecryptString(account.getPassword());
|
||||||
|
if (!oldpassword.equals(bpassword)){
|
||||||
return new Result(false, 0,"原始密码不正确");
|
return new Result(false, 0,"原始密码不正确");
|
||||||
}
|
}
|
||||||
|
password = DESUtil.getEncryptString(password);
|
||||||
boolean type = accountService.editAccountPassword(account.getId(),password);
|
boolean type = accountService.editAccountPassword(account.getId(),password);
|
||||||
if (type){
|
if (type){
|
||||||
return new Result(true,1,"密码修改成功");
|
return new Result(true,1,"密码修改成功");
|
||||||
|
|
@ -252,7 +278,7 @@ public class LoginController {
|
||||||
}
|
}
|
||||||
AccountExecution accountExecution = accountService.getAccountByPhone(phone);
|
AccountExecution accountExecution = accountService.getAccountByPhone(phone);
|
||||||
if (accountExecution.getState()==1){
|
if (accountExecution.getState()==1){
|
||||||
if (accountExecution.getAccount().getPassword().equals(password)){
|
if (accountExecution.getAccount().getPassword().equals(DESUtil.getEncryptString(password))){
|
||||||
Account account = accountExecution.getAccount();
|
Account account = accountExecution.getAccount();
|
||||||
modelMap.put("token", TokenUtil.getToken(accountExecution.getAccount()));
|
modelMap.put("token", TokenUtil.getToken(accountExecution.getAccount()));
|
||||||
modelMap.put("uaername",account.getUsername());
|
modelMap.put("uaername",account.getUsername());
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,11 @@ public class OrderController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户取消订单
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@UserLoginToken
|
@UserLoginToken
|
||||||
@RequestMapping(value = "/cancel", method = RequestMethod.POST)
|
@RequestMapping(value = "/cancel", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> cancel(HttpServletRequest request) {
|
private Result<Map<String, Object>> cancel(HttpServletRequest request) {
|
||||||
|
|
@ -54,6 +59,12 @@ public class OrderController {
|
||||||
return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo());
|
return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户确认快递送达
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@UserLoginToken
|
@UserLoginToken
|
||||||
@RequestMapping(value = "/charge", method = RequestMethod.POST)
|
@RequestMapping(value = "/charge", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> charge(HttpServletRequest request) {
|
private Result<Map<String, Object>> charge(HttpServletRequest request) {
|
||||||
|
|
@ -73,7 +84,11 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员送达快递
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Admin
|
@Admin
|
||||||
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
|
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> delivery(HttpServletRequest request) {
|
private Result<Map<String, Object>> delivery(HttpServletRequest request) {
|
||||||
|
|
@ -96,6 +111,11 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员获取自己的任务列表
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Admin
|
@Admin
|
||||||
@RequestMapping(value = "/couriergetselflist", method = RequestMethod.POST)
|
@RequestMapping(value = "/couriergetselflist", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> courierGetDelfList(HttpServletRequest request) {
|
private Result<Map<String, Object>> courierGetDelfList(HttpServletRequest request) {
|
||||||
|
|
@ -134,7 +154,11 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员获取任务
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Admin
|
@Admin
|
||||||
@RequestMapping(value = "/gettack", method = RequestMethod.POST)
|
@RequestMapping(value = "/gettack", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> getTack(HttpServletRequest request) {
|
private Result<Map<String, Object>> getTack(HttpServletRequest request) {
|
||||||
|
|
@ -158,7 +182,7 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快递员公共接口
|
* 任务大厅,快递员领取任务列表接口
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -195,6 +219,11 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员获取所有的的订单列表
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Root
|
@Root
|
||||||
@RequestMapping(value = "/admingetorderlist", method = RequestMethod.POST)
|
@RequestMapping(value = "/admingetorderlist", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> adminGetOrderList(HttpServletRequest request) {
|
private Result<Map<String, Object>> adminGetOrderList(HttpServletRequest request) {
|
||||||
|
|
@ -229,6 +258,11 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户获取自己的的订单列表
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@UserLoginToken
|
@UserLoginToken
|
||||||
@RequestMapping(value = "/getselforderlist", method = RequestMethod.POST)
|
@RequestMapping(value = "/getselforderlist", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> getSelfOrderList(HttpServletRequest request) {
|
private Result<Map<String, Object>> getSelfOrderList(HttpServletRequest request) {
|
||||||
|
|
@ -263,7 +297,11 @@ public class OrderController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加订单
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@UserLoginToken
|
@UserLoginToken
|
||||||
@RequestMapping(value = "/addorder", method = RequestMethod.POST)
|
@RequestMapping(value = "/addorder", method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> addOrder(HttpServletRequest request) {
|
private Result<Map<String, Object>> addOrder(HttpServletRequest request) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package live.tomey.api.express.controller;
|
package live.tomey.api.express.controller;
|
||||||
|
|
||||||
|
import live.tomey.api.express.aop.PassToken;
|
||||||
import live.tomey.api.express.aop.Root;
|
import live.tomey.api.express.aop.Root;
|
||||||
import live.tomey.api.express.dto.Result;
|
import live.tomey.api.express.dto.Result;
|
||||||
import live.tomey.api.express.entity.Price;
|
import live.tomey.api.express.entity.Price;
|
||||||
|
|
@ -31,7 +32,11 @@ public class PriceController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PriceSercie priceSercie;
|
private PriceSercie priceSercie;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递类型和价格
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Root
|
@Root
|
||||||
@RequestMapping(value = "/editprice",method = RequestMethod.POST)
|
@RequestMapping(value = "/editprice",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> editPrice(HttpServletRequest request) {
|
private Result<Map<String, Object>> editPrice(HttpServletRequest request) {
|
||||||
|
|
@ -58,8 +63,12 @@ public class PriceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取快递类型
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PassToken
|
||||||
@RequestMapping(value = "/getpricelist",method = RequestMethod.POST)
|
@RequestMapping(value = "/getpricelist",method = RequestMethod.POST)
|
||||||
private Result<Map<String, Object>> getPriceList(HttpServletRequest request) {
|
private Result<Map<String, Object>> getPriceList(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package live.tomey.api.express.controller;
|
package live.tomey.api.express.controller;
|
||||||
|
|
||||||
import live.tomey.api.express.dao.CategoryDao;
|
import live.tomey.api.express.aop.PassToken;
|
||||||
import live.tomey.api.express.dao.DataShowDao;
|
import live.tomey.api.express.dao.*;
|
||||||
import live.tomey.api.express.dao.OrderDao;
|
import live.tomey.api.express.entity.MailConfig;
|
||||||
import live.tomey.api.express.dao.PriceDao;
|
|
||||||
import live.tomey.api.express.service.OrderService;
|
import live.tomey.api.express.service.OrderService;
|
||||||
|
import live.tomey.api.express.unit.MailUnit;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
@ -32,18 +32,25 @@ public class TestController {
|
||||||
private PriceDao priceDao;
|
private PriceDao priceDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataShowDao dataShowDao;
|
private DataShowDao dataShowDao;
|
||||||
|
@Autowired
|
||||||
|
private MailConfigDao mailConfigDao;
|
||||||
|
@Autowired
|
||||||
|
private AccountDao accountDao;
|
||||||
|
|
||||||
|
|
||||||
|
@PassToken
|
||||||
@RequestMapping(value = "/test",method = RequestMethod.POST)
|
@RequestMapping(value = "/test",method = RequestMethod.POST)
|
||||||
private Map<String,Object> test(){
|
private Map<String,Object> test(){
|
||||||
Map<String,Object> modeMap = new HashMap<String, Object>();
|
Map<String,Object> modeMap = new HashMap<String, Object>();
|
||||||
modeMap.put("qureyCountStateAdmin",dataShowDao.qureyCountStateAdmin(0));
|
// modeMap.put("qureyCountStateAdmin",dataShowDao.qureyCountStateAdmin(0));
|
||||||
modeMap.put("qureyPriceStateAdmin",dataShowDao.qureyPriceStateAdmin(0));
|
// modeMap.put("qureyPriceStateAdmin",dataShowDao.qureyPriceStateAdmin(0));
|
||||||
modeMap.put("qureyCountStateCourier",dataShowDao.qureyCountStateCourier(2,0));
|
// modeMap.put("qureyCountStateCourier",dataShowDao.qureyCountStateCourier(2,0));
|
||||||
modeMap.put("qureyPriceStateCourier",dataShowDao.qureyPriceStateCourier(2,0));
|
// modeMap.put("qureyPriceStateCourier",dataShowDao.qureyPriceStateCourier(2,0));
|
||||||
modeMap.put("qureyCountStateSelf",dataShowDao.qureyCountStateSelf(3,0));
|
// modeMap.put("qureyCountStateSelf",dataShowDao.qureyCountStateSelf(3,0));
|
||||||
modeMap.put("qureyPriceStateSelf",dataShowDao.qureyPriceStateSelf(3,0));
|
// modeMap.put("qureyPriceStateSelf",dataShowDao.qureyPriceStateSelf(3,0));
|
||||||
|
modeMap.put("data",mailConfigDao.getMailConfig());
|
||||||
|
modeMap.put("dataa",accountDao.queryAccountForOrderId(44));
|
||||||
|
|
||||||
return modeMap;
|
return modeMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,40 @@ public interface AccountDao {
|
||||||
*/
|
*/
|
||||||
Account queryAccountForPhone(@Param("phone") String phone);
|
Account queryAccountForPhone(@Param("phone") String phone);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过订单id获取到用户信息
|
||||||
|
* @param orderID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Account queryAccountForOrderId(@Param("orderId") Integer orderID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户
|
||||||
|
* @param account
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer insertAccount(@Param("account") Account account);
|
Integer insertAccount(@Param("account") Account account);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户权限
|
||||||
|
* @param id
|
||||||
|
* @param identityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer updateAccountIdentity(@Param("id") Integer id, @Param("identityId") Integer identityId);
|
Integer updateAccountIdentity(@Param("id") Integer id, @Param("identityId") Integer identityId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
* @param id
|
||||||
|
* @param password
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer updateAccountPassword(@Param("id") Integer id, @Param("password") String password);
|
Integer updateAccountPassword(@Param("id") Integer id, @Param("password") String password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户信息
|
||||||
|
* @param account
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer updateAccountInfo(@Param("account") Account account);
|
Integer updateAccountInfo(@Param("account") Account account);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,30 @@ import java.util.List;
|
||||||
* @date 2020/12/3 19:53
|
* @date 2020/12/3 19:53
|
||||||
*/
|
*/
|
||||||
public interface FlatsDao {
|
public interface FlatsDao {
|
||||||
|
/**
|
||||||
|
* 获取公寓列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
List<Flats> queryAllFlat();
|
List<Flats> queryAllFlat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加公寓
|
||||||
|
* @param flats
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer isnertFlats(@Param("flats") Flats flats);
|
Integer isnertFlats(@Param("flats") Flats flats);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公寓
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer deleteFlats(@Param("id") Integer id);
|
Integer deleteFlats(@Param("id") Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改公寓
|
||||||
|
* @param flats
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer updataFlats(@Param("flats") Flats flats);
|
Integer updataFlats(@Param("flats") Flats flats);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package live.tomey.api.express.dao;
|
||||||
|
|
||||||
|
import live.tomey.api.express.entity.MailConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clay
|
||||||
|
* @version 1.0
|
||||||
|
* @mail 20932067@zju.edu.cn
|
||||||
|
* @date 2020/12/13 17:04
|
||||||
|
*/
|
||||||
|
public interface MailConfigDao {
|
||||||
|
/**
|
||||||
|
* 获取邮件配置
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MailConfig getMailConfig();
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@ public interface OrderDao {
|
||||||
*/
|
*/
|
||||||
Integer insertOrder(@Param("orderInsert") OrderInsert orderInsert);
|
Integer insertOrder(@Param("orderInsert") OrderInsert orderInsert);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部订单列表
|
* 获取全部订单列表
|
||||||
* @param orderSelect
|
* @param orderSelect
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,23 @@ import java.util.List;
|
||||||
* @date 2020/12/3 19:07
|
* @date 2020/12/3 19:07
|
||||||
*/
|
*/
|
||||||
public interface PriceDao {
|
public interface PriceDao {
|
||||||
|
/**
|
||||||
|
* 获取快递类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
List<Price> queryAllPrice();
|
List<Price> queryAllPrice();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id获取快递类型对应价格
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Price queryPriceById(@Param("id") Integer id);
|
Price queryPriceById(@Param("id") Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改价格
|
||||||
|
* @param price
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Integer upadtePrice(@Param("price") Price price);
|
Integer upadtePrice(@Param("price") Price price);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@ public class OrderInsert extends Order {
|
||||||
private Double price;
|
private Double price;
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
public OrderInsert() {
|
||||||
|
}
|
||||||
|
|
||||||
public OrderInsert(Integer accountId, String number, String company, String name, String phone,Integer flatsId, String hostel, Integer type, String decs) {
|
public OrderInsert(Integer accountId, String number, String company, String name, String phone, Integer flatsId, String hostel, Integer type, String decs) {
|
||||||
super(number, company, name, phone, hostel, decs);
|
super(number, company, name, phone, hostel, decs);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
package live.tomey.api.express.entity;
|
||||||
|
|
||||||
|
public class MailConfig {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String sender;
|
||||||
|
private String personal;
|
||||||
|
private String emailSmtpHost;
|
||||||
|
private String emailSmtpPort;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String encryption;
|
||||||
|
private long state;
|
||||||
|
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSender(String sender) {
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPersonal() {
|
||||||
|
return personal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonal(String personal) {
|
||||||
|
this.personal = personal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getEmailSmtpHost() {
|
||||||
|
return emailSmtpHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailSmtpHost(String emailSmtpHost) {
|
||||||
|
this.emailSmtpHost = emailSmtpHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getEmailSmtpPort() {
|
||||||
|
return emailSmtpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmailSmtpPort(String emailSmtpPort) {
|
||||||
|
this.emailSmtpPort = emailSmtpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getEncryption() {
|
||||||
|
return encryption;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncryption(String encryption) {
|
||||||
|
this.encryption = encryption;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(long state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,11 @@ public class AccountServiceImpl implements AccountService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AccountDao accountDao;
|
private AccountDao accountDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过phone获取到用户信息
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AccountExecution getAccountByPhone(String phone) {
|
public AccountExecution getAccountByPhone(String phone) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -42,6 +47,11 @@ public class AccountServiceImpl implements AccountService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户
|
||||||
|
* @param account
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean addAccount(Account account) {
|
public boolean addAccount(Account account) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -57,6 +67,12 @@ public class AccountServiceImpl implements AccountService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户角色
|
||||||
|
* @param id
|
||||||
|
* @param identityId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean editAccountIdentity(Integer id, Integer identityId) {
|
public boolean editAccountIdentity(Integer id, Integer identityId) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -72,6 +88,12 @@ public class AccountServiceImpl implements AccountService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户密码
|
||||||
|
* @param id
|
||||||
|
* @param password
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean editAccountPassword(Integer id, String password) {
|
public boolean editAccountPassword(Integer id, String password) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -87,6 +109,11 @@ public class AccountServiceImpl implements AccountService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户信息
|
||||||
|
* @param account
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean editAccountInfo(Account account) {
|
public boolean editAccountInfo(Account account) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@ public class DataShowServiceImpl implements DataShowService {
|
||||||
private Logger logger = LoggerFactory.getLogger(DataShowServiceImpl.class);
|
private Logger logger = LoggerFactory.getLogger(DataShowServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataShowDao dataShowDao;
|
private DataShowDao dataShowDao;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员获取订单数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Map<String, Object> dataShowAdminInfo() {
|
public Map<String, Object> dataShowAdminInfo() {
|
||||||
|
|
@ -38,7 +44,13 @@ public class DataShowServiceImpl implements DataShowService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员获取订单数据
|
||||||
|
* @param courierId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public Map<String, Object> dataShowCourierInfo(Integer courierId) {
|
public Map<String, Object> dataShowCourierInfo(Integer courierId) {
|
||||||
Map<String, Object> modeMap = new HashMap<String, Object>();
|
Map<String, Object> modeMap = new HashMap<String, Object>();
|
||||||
try {
|
try {
|
||||||
|
|
@ -52,7 +64,13 @@ public class DataShowServiceImpl implements DataShowService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户获取订单数据
|
||||||
|
* @param selfId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public Map<String, Object> dataShowSelfInfo(Integer selfId) {
|
public Map<String, Object> dataShowSelfInfo(Integer selfId) {
|
||||||
Map<String, Object> modeMap = new HashMap<String, Object>();
|
Map<String, Object> modeMap = new HashMap<String, Object>();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ public class FlatsServiceImpl implements FlatsService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FlatsDao flatsDao;
|
private FlatsDao flatsDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加公寓
|
||||||
|
* @param flats
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer addFlats(Flats flats) {
|
public Integer addFlats(Flats flats) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -33,6 +38,11 @@ public class FlatsServiceImpl implements FlatsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除公寓
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer removeFlats(Integer id) {
|
public Integer removeFlats(Integer id) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -43,6 +53,11 @@ public class FlatsServiceImpl implements FlatsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改公寓
|
||||||
|
* @param flats
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer editFlats(Flats flats) {
|
public Integer editFlats(Flats flats) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -53,6 +68,10 @@ public class FlatsServiceImpl implements FlatsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有公寓
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Flats> getAllFlats() {
|
public List<Flats> getAllFlats() {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
package live.tomey.api.express.service.impl;
|
package live.tomey.api.express.service.impl;
|
||||||
|
|
||||||
|
import live.tomey.api.express.dao.AccountDao;
|
||||||
|
import live.tomey.api.express.dao.MailConfigDao;
|
||||||
import live.tomey.api.express.dao.OrderDao;
|
import live.tomey.api.express.dao.OrderDao;
|
||||||
import live.tomey.api.express.dao.PriceDao;
|
import live.tomey.api.express.dao.PriceDao;
|
||||||
import live.tomey.api.express.dto.*;
|
import live.tomey.api.express.dto.*;
|
||||||
|
import live.tomey.api.express.entity.Account;
|
||||||
|
import live.tomey.api.express.entity.MailConfig;
|
||||||
import live.tomey.api.express.entity.Price;
|
import live.tomey.api.express.entity.Price;
|
||||||
import live.tomey.api.express.enums.OrderEnum;
|
import live.tomey.api.express.enums.OrderEnum;
|
||||||
import live.tomey.api.express.exceptions.OrderOperationException;
|
import live.tomey.api.express.exceptions.OrderOperationException;
|
||||||
import live.tomey.api.express.service.OrderService;
|
import live.tomey.api.express.service.OrderService;
|
||||||
|
import live.tomey.api.express.unit.MailUnit;
|
||||||
import live.tomey.api.express.unit.PageCalculator;
|
import live.tomey.api.express.unit.PageCalculator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -14,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,7 +36,17 @@ public class OrderServiceImpl implements OrderService {
|
||||||
private OrderDao orderDao;
|
private OrderDao orderDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PriceDao priceDao;
|
private PriceDao priceDao;
|
||||||
|
@Autowired
|
||||||
|
private AccountDao accountDao;
|
||||||
|
@Autowired
|
||||||
|
private MailConfigDao mailConfigDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加订单
|
||||||
|
*
|
||||||
|
* @param orderInsert
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean addOrder(OrderInsert orderInsert) {
|
public boolean addOrder(OrderInsert orderInsert) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -38,17 +54,22 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderInsert.setPrice(price.getPrice());
|
orderInsert.setPrice(price.getPrice());
|
||||||
orderInsert.setTypeDesc(price.getDesc());
|
orderInsert.setTypeDesc(price.getDesc());
|
||||||
Integer init = orderDao.insertOrder(orderInsert);
|
Integer init = orderDao.insertOrder(orderInsert);
|
||||||
if (init == 1){
|
if (init == 1) {
|
||||||
return true;
|
return true;
|
||||||
}else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员获取所有的的订单列表
|
||||||
|
* @param orderSelect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderExcution<List<OrderAdmin>> adminGetAllList(OrderSelect orderSelect) {
|
public OrderExcution<List<OrderAdmin>> adminGetAllList(OrderSelect orderSelect) {
|
||||||
|
|
@ -56,18 +77,23 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
||||||
List<OrderAdmin> orderAdmins = orderDao.queryOrderAllList(orderSelect);
|
List<OrderAdmin> orderAdmins = orderDao.queryOrderAllList(orderSelect);
|
||||||
Integer count = orderDao.queryOrderAllListCount(orderSelect);
|
Integer count = orderDao.queryOrderAllListCount(orderSelect);
|
||||||
if (orderAdmins.size()>0){
|
if (orderAdmins.size() > 0) {
|
||||||
return new OrderExcution<List<OrderAdmin>>(orderAdmins,count,OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderAdmin>>(orderAdmins, count, OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderAdmin>>(OrderEnum.NULL);
|
return new OrderExcution<List<OrderAdmin>>(OrderEnum.NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderAdmin>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderAdmin>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户获取自己的的订单列表
|
||||||
|
* @param orderSelect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderExcution<List<OrderSelf>> getSelfList(OrderSelect orderSelect) {
|
public OrderExcution<List<OrderSelf>> getSelfList(OrderSelect orderSelect) {
|
||||||
|
|
@ -75,18 +101,23 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
||||||
List<OrderSelf> orderSelfList = orderDao.queryOrderSelfList(orderSelect);
|
List<OrderSelf> orderSelfList = orderDao.queryOrderSelfList(orderSelect);
|
||||||
Integer count = orderDao.queryOrderSelfListCount(orderSelect);
|
Integer count = orderDao.queryOrderSelfListCount(orderSelect);
|
||||||
if (orderSelfList.size()>0){
|
if (orderSelfList.size() > 0) {
|
||||||
return new OrderExcution<List<OrderSelf>>(orderSelfList,count,OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderSelf>>(orderSelfList, count, OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderSelf>>(OrderEnum.NULL);
|
return new OrderExcution<List<OrderSelf>>(OrderEnum.NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderSelf>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderSelf>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务大厅,快递员领取任务列表
|
||||||
|
* @param orderSelect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderExcution<List<OrderCourier>> courierGetAllList(OrderSelect orderSelect) {
|
public OrderExcution<List<OrderCourier>> courierGetAllList(OrderSelect orderSelect) {
|
||||||
|
|
@ -94,111 +125,155 @@ public class OrderServiceImpl implements OrderService {
|
||||||
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
||||||
List<OrderCourier> orderCouriers = orderDao.queryOrderPublicCourierList(orderSelect);
|
List<OrderCourier> orderCouriers = orderDao.queryOrderPublicCourierList(orderSelect);
|
||||||
Integer count = orderDao.queryOrderPublicCourierListCount(orderSelect);
|
Integer count = orderDao.queryOrderPublicCourierListCount(orderSelect);
|
||||||
if (orderCouriers.size()>0){
|
if (orderCouriers.size() > 0) {
|
||||||
return new OrderExcution<List<OrderCourier>>(orderCouriers,count,OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderCourier>>(orderCouriers, count, OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.NULL);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.NULL);
|
||||||
}
|
}
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员获取任务
|
||||||
|
*
|
||||||
|
* @param orderModifyState
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OrderExcution changeState(OrderModifyState orderModifyState) {
|
public OrderExcution changeState(OrderModifyState orderModifyState) {
|
||||||
try {
|
try {
|
||||||
Integer state = orderDao.queryStart(orderModifyState.getId());
|
Integer state = orderDao.queryStart(orderModifyState.getId());
|
||||||
if (state != 1){
|
if (state != 1) {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
||||||
}else {
|
} else {
|
||||||
Integer type = orderDao.editCourierPicks(orderModifyState);
|
Integer type = orderDao.editCourierPicks(orderModifyState);
|
||||||
if (type == 1){
|
if (type == 1) {
|
||||||
|
// todo 发送快递员领取任务邮件
|
||||||
|
Account account = accountDao.queryAccountForOrderId(orderModifyState.getId());
|
||||||
|
sendMail(account,state);
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员获取自己的任务列表
|
||||||
|
* @param orderSelect
|
||||||
|
* @param courierId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public OrderExcution courierGetSelfList(OrderSelect orderSelect, Integer courierId) {
|
public OrderExcution courierGetSelfList(OrderSelect orderSelect, Integer courierId) {
|
||||||
try{
|
try {
|
||||||
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
orderSelect.setPage(PageCalculator.calculateRowIndex(orderSelect.getPage(), orderSelect.getSize()));
|
||||||
List<OrderCourier> courierList = orderDao.queryOrderSelfierCourierList(orderSelect,courierId);
|
List<OrderCourier> courierList = orderDao.queryOrderSelfierCourierList(orderSelect, courierId);
|
||||||
Integer count = orderDao.queryOrderSelfierCourierListCout(orderSelect,courierId);
|
Integer count = orderDao.queryOrderSelfierCourierListCout(orderSelect, courierId);
|
||||||
if (courierList.size()>0){
|
if (courierList.size() > 0) {
|
||||||
return new OrderExcution<List<OrderCourier>>(courierList,count,OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderCourier>>(courierList, count, OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.NULL);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.NULL);
|
||||||
}
|
}
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递员送达快递
|
||||||
|
* @param orderModifyState
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OrderExcution changDelivery(OrderModifyState orderModifyState) {
|
public OrderExcution changDelivery(OrderModifyState orderModifyState) {
|
||||||
try {
|
try {
|
||||||
Integer state = orderDao.queryCourierStart(orderModifyState);
|
Integer state = orderDao.queryCourierStart(orderModifyState);
|
||||||
if (state != 2){
|
if (state != 2) {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
||||||
}else {
|
} else {
|
||||||
Integer type = orderDao.editCourierPicks(orderModifyState);
|
Integer type = orderDao.editCourierPicks(orderModifyState);
|
||||||
if (type == 1){
|
if (type == 1) {
|
||||||
|
Account account = accountDao.queryAccountForOrderId(orderModifyState.getId());
|
||||||
|
sendMail(account,state);
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户确认快递送达
|
||||||
|
* @param orderModifyState
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OrderExcution changCharge(OrderModifyState orderModifyState) {
|
public OrderExcution changCharge(OrderModifyState orderModifyState) {
|
||||||
try {
|
try {
|
||||||
Integer state = orderDao.queryChargeStart(orderModifyState);
|
Integer state = orderDao.queryChargeStart(orderModifyState);
|
||||||
if (state != 3){
|
if (state != 3) {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.GETON);
|
||||||
}else {
|
} else {
|
||||||
Integer type = orderDao.editCourierPicks(orderModifyState);
|
Integer type = orderDao.editCourierPicks(orderModifyState);
|
||||||
if (type == 1){
|
if (type == 1) {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.SUCCESS);
|
||||||
}else {
|
} else {
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.EREE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (OrderOperationException e){
|
} catch (OrderOperationException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
return new OrderExcution<List<OrderCourier>>(OrderEnum.OFFLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户取消订单
|
||||||
|
* @param orderid
|
||||||
|
* @param acountid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer cancelOrder(Integer orderid, Integer acountid) {
|
public Integer cancelOrder(Integer orderid, Integer acountid) {
|
||||||
try {
|
try {
|
||||||
Integer state = orderDao.queryStart(orderid);
|
Integer state = orderDao.queryStart(orderid);
|
||||||
if (state==1){
|
if (state == 1) {
|
||||||
Integer type = orderDao.deleteOrder(orderid,acountid);
|
Integer type = orderDao.deleteOrder(orderid, acountid);
|
||||||
if (type==1){
|
if (type == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}catch (RuntimeException e){
|
} catch (RuntimeException e) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendMail(Account account,Integer state){
|
||||||
|
// todo 后期加入邮件发送表
|
||||||
|
MailConfig mailConfig = mailConfigDao.getMailConfig();
|
||||||
|
boolean type = MailUnit.sendTheMail(account,mailConfig,state);
|
||||||
|
if (type){
|
||||||
|
logger.info(account.getEmail()+"与"+new Date() + "发送邮件成功");
|
||||||
|
}else {
|
||||||
|
logger.info(account.getEmail()+"与"+new Date() + "发送邮件失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@ public class PriceSercieImpl implements PriceSercie {
|
||||||
@Autowired
|
@Autowired
|
||||||
private PriceDao priceDao;
|
private PriceDao priceDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有快递类型列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Price> getAllPrice() {
|
public List<Price> getAllPrice() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -34,6 +37,11 @@ public class PriceSercieImpl implements PriceSercie {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改快递类型价格
|
||||||
|
* @param price
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Integer editPrice(Price price) {
|
public Integer editPrice(Price price) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,9 @@ public class DESUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(getEncryptString("jdbc:mysql://34.96.189.60:3306/mall?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"));
|
System.out.println(getEncryptString("123456789"));
|
||||||
System.out.println(getDecryptString("xW6OiZLo8/ly0RW0vIm4nLovV+Cp9HuqfGXYUO1QtqN9nov1i1mGCu8wfdlb0IvGQHy33l1ok5iSMx9lhN6SddVTN8vsBv7h4gCCwYDigan+8xhhH6uqF/HKdged+cE/06RLny3n8Yrcdip9/pz8lH3HZ+yT8kTf9VR6z1T2+x7Kdbs8O5h4aUZN0O7ExVaX"));
|
// System.out.println(getEncryptString("jdbc:mysql://34.96.189.60:3306/mall?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"));
|
||||||
|
// System.out.println(getDecryptString("xW6OiZLo8/ly0RW0vIm4nLovV+Cp9HuqfGXYUO1QtqN9nov1i1mGCu8wfdlb0IvGQHy33l1ok5iSMx9lhN6SddVTN8vsBv7h4gCCwYDigan+8xhhH6uqF/HKdged+cE/06RLny3n8Yrcdip9/pz8lH3HZ+yT8kTf9VR6z1T2+x7Kdbs8O5h4aUZN0O7ExVaX"));
|
||||||
// DecodedJWT jwt = null;
|
// DecodedJWT jwt = null;
|
||||||
// System.out.println(getEncryptString("mall"));
|
// System.out.println(getEncryptString("mall"));
|
||||||
// System.out.println(getEncryptString("dr4ap4dbnyCMZTcr"));
|
// System.out.println(getEncryptString("dr4ap4dbnyCMZTcr"));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package live.tomey.api.express.unit;
|
||||||
|
|
||||||
|
import live.tomey.api.express.entity.Account;
|
||||||
|
import live.tomey.api.express.entity.MailConfig;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.mail.Session;
|
||||||
|
import javax.mail.Transport;
|
||||||
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clay
|
||||||
|
* @version 1.0
|
||||||
|
* @mail 20932067@zju.edu.cn
|
||||||
|
* @date 2020/12/13 17:18
|
||||||
|
*/
|
||||||
|
public class MailUnit {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(MailUnit.class);
|
||||||
|
|
||||||
|
public static boolean sendTheMail(Account account, MailConfig mailConfig, Integer state) {
|
||||||
|
Transport transport = null;
|
||||||
|
try {
|
||||||
|
// 1. 创建参数配置, 用于连接邮件服务器的参数配置
|
||||||
|
Properties props = new Properties(); // 参数配置
|
||||||
|
props.setProperty("mail.transport.protocol", "smtp"); // 使用的协议(JavaMail规范要求)
|
||||||
|
props.setProperty("mail.smtp.host", mailConfig.getEmailSmtpHost()); // 发件人的邮箱的 SMTP 服务器地址
|
||||||
|
props.setProperty("mail.smtp.auth", "true"); // 需要请求认证
|
||||||
|
props.setProperty("mail.smtp.port", mailConfig.getEmailSmtpPort());
|
||||||
|
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||||
|
props.setProperty("mail.smtp.socketFactory.fallback", "false");
|
||||||
|
props.setProperty("mail.smtp.socketFactory.port", mailConfig.getEmailSmtpPort());
|
||||||
|
// 2. 根据配置创建会话对象, 用于和邮件服务器交互
|
||||||
|
Session session = Session.getInstance(props);
|
||||||
|
MimeMessage message = new MimeMessage(session);
|
||||||
|
message.setFrom(new InternetAddress(mailConfig.getSender(), mailConfig.getUsername(), "UTF-8"));
|
||||||
|
message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(account.getEmail(), account.getEmail(), "UTF-8"));
|
||||||
|
message.setSubject("校园小飞侠系统提示", "UTF-8");
|
||||||
|
message.setContent("<!DOCTYPE html>\n" +
|
||||||
|
"<html>\n" +
|
||||||
|
"<head>\n" +
|
||||||
|
"<meta charset=\"UTF-8\">\n" +
|
||||||
|
"<title></title>\n" +
|
||||||
|
"<style type=\"text/css\">\n" +
|
||||||
|
"\t.box {width: 900px;height: 500px;margin-top: 100px;margin-left: 300px;border: 1px solid white;box-shadow:grey 20px 20px 30px 5px;}\n" +
|
||||||
|
"\t.top {margin: 0px auto;background-color: lightskyblue;width: 900px;height: 80px;}\n" +
|
||||||
|
"\t.text1{color: white;margin-left: 30px;line-height: 80px;}\n" +
|
||||||
|
"\t.text2{margin-top: 50px;margin-left: 20px;font-size: 20px;}\n" +
|
||||||
|
"\t.text3{margin-left: 60px;}\n" +
|
||||||
|
"\t.text4{margin-left: 60px;}\n" +
|
||||||
|
"\t.text5{margin-left: 20px;font-size: 20px;}\n" +
|
||||||
|
"\t.text6{margin-top: 140px;margin-left: 640px;}\n" +
|
||||||
|
"</style>\n" +
|
||||||
|
"</head>\n" +
|
||||||
|
"<body>\n" +
|
||||||
|
"<div class=\"box\">\n" +
|
||||||
|
"<div class=\"top\">\n" +
|
||||||
|
"<p class=\"text1\">快递动态</p>\n" +
|
||||||
|
"</div>\n" +
|
||||||
|
"<div class=\"bottom\">\n" +
|
||||||
|
"<p class=\"text2\"> 尊敬的"+account.getUsername()+": </p>\n" +
|
||||||
|
"<p class=\"text3\" >您的快递于</p>\n" +
|
||||||
|
"<p class=\"text4\"> 感谢你的访问,祝您使用愉快!</p>\n" +
|
||||||
|
"<p class=\"text5\">此致</p>\n" +
|
||||||
|
"<p class=\"text6\">此邮件为系统自动发送,请勿回复。</p>\n" +
|
||||||
|
"</div>\n" +
|
||||||
|
"</div>\n" +
|
||||||
|
"</body>\n" +
|
||||||
|
"</html>", "text/html;charset=UTF-8");
|
||||||
|
message.setSentDate(new Date());
|
||||||
|
session.setDebug(true);
|
||||||
|
transport = session.getTransport();
|
||||||
|
transport.connect(mailConfig.getUsername(), mailConfig.getPassword());
|
||||||
|
transport.sendMessage(message, message.getAllRecipients());
|
||||||
|
transport.close();
|
||||||
|
return true;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return false;
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
transport.close();
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,9 @@ import java.util.Map;
|
||||||
|
|
||||||
public class TokenUtil {
|
public class TokenUtil {
|
||||||
|
|
||||||
|
// 生产环境30分钟token过期
|
||||||
// private static final long EXPIER_TIME = 1800000;
|
// private static final long EXPIER_TIME = 1800000;
|
||||||
|
//测试环境
|
||||||
private static final long EXPIER_TIME = 1800000000;
|
private static final long EXPIER_TIME = 1800000000;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
<select id="queryAccountForPhone" parameterType="String" resultType="live.tomey.api.express.entity.Account">
|
<select id="queryAccountForPhone" parameterType="String" resultType="live.tomey.api.express.entity.Account">
|
||||||
SELECT * FROM m_account WHERE phone = #{phone}
|
SELECT * FROM m_account WHERE phone = #{phone}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="queryAccountForOrderId" parameterType="Integer" resultType="live.tomey.api.express.entity.Account">
|
||||||
|
SELECT * FROM m_account WHERE id IN(SELECT account_id FROM m_order WHERE id =#{orderId})
|
||||||
|
</select>
|
||||||
<insert id="insertAccount" parameterType="live.tomey.api.express.entity.Account" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
<insert id="insertAccount" parameterType="live.tomey.api.express.entity.Account" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
m_account(
|
m_account(
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?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="live.tomey.api.express.dao.MailConfigDao">
|
||||||
|
<select id="getMailConfig" resultType="live.tomey.api.express.entity.MailConfig">
|
||||||
|
SELECT * FROM w_mailconfig WHERE id = 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
package live.tomey.api.express.mail;
|
||||||
|
|
||||||
|
import javax.mail.Session;
|
||||||
|
import javax.mail.Transport;
|
||||||
|
import javax.mail.internet.InternetAddress;
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author clay
|
||||||
|
* @version 1.0
|
||||||
|
* @mail 20932067@zju.edu.cn
|
||||||
|
* @date 2020/12/13 16:31
|
||||||
|
*/
|
||||||
|
public class TestMail {
|
||||||
|
//邮箱账号
|
||||||
|
public static String emailAccount = "3180400053@zju.edu.cn";
|
||||||
|
//客户端密码
|
||||||
|
public static String emailPassword = "Tgra5qUMx25vFSmW";
|
||||||
|
//服务器地址
|
||||||
|
public static String emailSMTPHost = "smtp.zju.edu.cn";
|
||||||
|
//服务器端口
|
||||||
|
public static String emailSMTPPort = "994";
|
||||||
|
//测试地址
|
||||||
|
public static String receiveMailAccount = "1980267249@qq.com";
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.setProperty("mail.transport.protocol", "smtp");
|
||||||
|
props.setProperty("mail.smtp.host", emailSMTPHost);
|
||||||
|
props.setProperty("mail.smtp.auth", "true");
|
||||||
|
props.setProperty("mail.smtp.port", emailSMTPPort);
|
||||||
|
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||||
|
props.setProperty("mail.smtp.socketFactory.fallback", "false");
|
||||||
|
props.setProperty("mail.smtp.socketFactory.port", emailSMTPPort);
|
||||||
|
|
||||||
|
// 2. 根据配置创建会话对象, 用于和邮件服务器交互
|
||||||
|
Session session = Session.getInstance(props);
|
||||||
|
// 设置为debug模式, 可以查看详细的发送 log
|
||||||
|
// 3. 创建一封邮件
|
||||||
|
MimeMessage message = createMimeMessage(session, emailAccount, receiveMailAccount);
|
||||||
|
session.setDebug(true);
|
||||||
|
// 4. 根据 Session 获取邮件传输对象
|
||||||
|
Transport transport = session.getTransport();
|
||||||
|
|
||||||
|
transport.connect(emailAccount, emailPassword);
|
||||||
|
|
||||||
|
// 6. 发送邮件, 发到所有的收件地址, message.getAllRecipients() 获取到的是在创建邮件对象时添加的所有收件人, 抄送人, 密送人
|
||||||
|
transport.sendMessage(message, message.getAllRecipients());
|
||||||
|
|
||||||
|
// 7. 关闭连接
|
||||||
|
transport.close();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一封只包含文本的简单邮件
|
||||||
|
*
|
||||||
|
* @param session 和服务器交互的会话
|
||||||
|
* @param sendMail 发件人邮箱
|
||||||
|
* @param receiveMail 收件人邮箱
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static MimeMessage createMimeMessage(Session session, String sendMail, String receiveMail) throws Exception {
|
||||||
|
// 1. 创建一封邮件
|
||||||
|
MimeMessage message = new MimeMessage(session);
|
||||||
|
|
||||||
|
// 2. From: 发件人
|
||||||
|
message.setFrom(new InternetAddress(sendMail, "昵称", "UTF-8"));
|
||||||
|
|
||||||
|
// 3. To: 收件人(可以增加多个收件人、抄送、密送)
|
||||||
|
message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(receiveMail, "huiyaoyi@qq.com", "UTF-8"));
|
||||||
|
|
||||||
|
// 4. Subject: 邮件主题
|
||||||
|
message.setSubject("主题", "UTF-8");
|
||||||
|
|
||||||
|
// 5. Content: 邮件正文(可以使用html标签)
|
||||||
|
message.setContent("<!DOCTYPE html>\n" +
|
||||||
|
"<html>\n" +
|
||||||
|
"\n" +
|
||||||
|
"\t<head>\n" +
|
||||||
|
"\t\t<meta charset=\"UTF-8\">\n" +
|
||||||
|
"\t\t<title></title>\n" +
|
||||||
|
"\t\t<style type=\"text/css\">\n" +
|
||||||
|
"\t\t\t\n" +
|
||||||
|
"\t\t</style>\n" +
|
||||||
|
"\t</head>\n" +
|
||||||
|
"\n" +
|
||||||
|
"\t<body>\n" +
|
||||||
|
"\t\t<div class=\"box\" style=\"width: 800px;height: 500px;margin-top: 100px;margin-left: 300px;box-shadow: ;\">\n" +
|
||||||
|
"\t\t\t<div class=\"top\" style=\"background-color: lightskyblue; width: 800px;height:50px ;\">\n" +
|
||||||
|
"\t\t\t\t<p style=\"font-size: 30px; color: white; margin-left: 20px;margin-top: 10px;\">库存预警</p>\n" +
|
||||||
|
"\t\t\t</div>\n" +
|
||||||
|
"\t\t\t<div class=\"bottom\">\n" +
|
||||||
|
"\t\t\t\t尊敬的用户:<br /> 商品 库存仅剩余0件,请及时补货<br /> 感谢你的访问,祝您使用愉快!\n" +
|
||||||
|
"\t\t\t\t<br /> 此致\n" +
|
||||||
|
"\t\t\t\t<br />\n" +
|
||||||
|
"\t\t\t</div>\n" +
|
||||||
|
"\t\t</div>\n" +
|
||||||
|
"\t</body>\n" +
|
||||||
|
"\n" +
|
||||||
|
"</html>", "text/html;charset=UTF-8");
|
||||||
|
// 6. 设置发件时间
|
||||||
|
message.setSentDate(new Date());
|
||||||
|
|
||||||
|
// 7. 保存设置
|
||||||
|
message.saveChanges();
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue