Commit 615a35c3 authored by zhangzc's avatar zhangzc

修复司机账号controller

parent 99ffcd77
......@@ -49,6 +49,7 @@ public class CheckCustomToken {
"/app/ownerBackend/password/reset".equals(url) ||
"/app/driverBackend/account/login/loginBySms".equals(url) ||
"/app/driverBackend/account/login/loginByPwd".equals(url) ||
"/app/driverBackend/account/carrier/list".equals(url) ||
"/app/driverBackend/password/reset".equals(url)) {
//此类接口不校验token
......
package com.esv.freight.app.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: Freight
* @name: com.esv.freight.app.feign.DriverInterface
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/29 15:00
* @version:1.0
*/
@FeignClient(value = "freight-customer-service")
public interface CarrierInterface {
/**
* 查询所有承运商列表
* @param
* @return
*/
@PostMapping(value = "/customer/carrier/account/all")
// JSONObject all();
JSONObject all(JSONObject bodyJson);
}
......@@ -17,28 +17,28 @@ import org.springframework.web.bind.annotation.PostMapping;
public interface DriverInterface {
/**
* 校验司机账号密码
* 查询司机详情-通过帐号
* @param bodyJson
* @return
*/
@PostMapping(value = "/customer/carrier/driver/password/check")
JSONObject checkAccountPwd(JSONObject bodyJson);
@PostMapping(value = "/customer/carrier/driver/getDetailByAccount")
JSONObject getDetailByAccount(JSONObject bodyJson);
/**
* 注册司机账号
* @param bodyJson
* @return
*/
@PostMapping(value = "/customer/goodsowner/account/register")
JSONObject accountRegister(JSONObject bodyJson);
@PostMapping(value = "/customer/carrier/driver/register")
JSONObject register(JSONObject bodyJson);
/**
* 获取司机账号详情
* 帐号密码校验
* @param bodyJson
* @return
*/
@PostMapping(value = "/customer/goodsowner/account/detail")
JSONObject getAccountDetail(JSONObject bodyJson);
@PostMapping(value = "/customer/carrier/driver/account/check")
JSONObject accountCheck(JSONObject bodyJson);
/**
* 更改司机账号信息
......
package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.feign.CarrierInterface;
import com.esv.freight.app.feign.DriverInterface;
import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.form.DriverAuthForm;
import com.esv.freight.app.module.account.form.LoginForm;
import com.esv.freight.app.module.account.form.OwnerAuthForm;
import com.esv.freight.app.module.account.form.RefreshTokenForm;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginBySms;
import com.esv.freight.app.module.account.vo.AccountExistVO;
import com.esv.freight.app.module.account.vo.CarrierInfoBriefVO;
import com.esv.freight.app.module.account.vo.DriverAccountDetailVO;
import com.esv.freight.app.module.account.vo.LoginVO;
import lombok.extern.slf4j.Slf4j;
......@@ -22,6 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 账号Controller
* @project: Freight
......@@ -40,17 +47,19 @@ public class DriverAccountController {
private DriverInterface driverInterface;
private NoticeInterface noticeInterface;
private AppLoginService appLoginService;
private CarrierInterface carrierInterface;
@Autowired
public DriverAccountController(DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
public DriverAccountController(CarrierInterface carrierInterface, DriverInterface driverInterface, NoticeInterface noticeInterface, AppLoginService appLoginService) {
this.noticeInterface = noticeInterface;
this.appLoginService = appLoginService;
this.appLoginService = appLoginService;
this.driverInterface = driverInterface;
this.carrierInterface = carrierInterface;
}
/**
* description 短信验证码登录
* param [LoginBySmsForm]
* param [LoginForm]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/14 14:00
......@@ -74,7 +83,8 @@ public class DriverAccountController {
// 调用注册帐号接口
reqJson.clear();
reqJson.put("account", loginForm.getPhone());
JSONObject resultRegister = driverInterface.accountRegister(reqJson);
reqJson.put("carrierId", loginForm.getCarrierId());
JSONObject resultRegister = driverInterface.register(reqJson);
// 1001表示 帐号已存在
if(resultRegister.getInteger("code") != 200 && resultRegister.getInteger("code") != 1001) {
......@@ -86,8 +96,8 @@ public class DriverAccountController {
}
/**
* description 帐号密码登录RequestHeader
* param [LoginByPwdForm]
* description 帐号密码登录
* param [LoginForm]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/14 14:00
......@@ -99,7 +109,7 @@ public class DriverAccountController {
JSONObject reqJson = new JSONObject();
reqJson.put("account", loginForm.getPhone());
reqJson.put("password", loginForm.getPwd());
JSONObject result = driverInterface.checkAccountPwd(reqJson);
JSONObject result = driverInterface.accountCheck(reqJson);
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
......@@ -109,6 +119,39 @@ public class DriverAccountController {
return EResponse.ok(loginByPwdVO);
}
/**
* description 检验手机号是否已存在,司机短信验证码登录时调用,如果已存在直接注册,如果不存在需要APP先选择一个承运商
* param [LoginForm]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/06 10:00
**/
@PostMapping("/login/check/phone")
public EResponse accountIsExist(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) {
// 调用查询司机详情-通过帐号接口
JSONObject reqJson = new JSONObject();
reqJson.put("account", loginForm.getPhone());
JSONObject result = driverInterface.getDetailByAccount(reqJson);
// 1001-表示账号不存在
if(result.getInteger("code") == 1001) {
AccountExistVO vo = new AccountExistVO();
vo.setAccountStatus(2);
return EResponse.ok(vo);
}
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
}
AccountExistVO vo = new AccountExistVO();
vo.setAccountStatus(1);
vo.setCarrierId(result.getJSONObject("data").getLong("carrierId"));
vo.setCarrierName(result.getJSONObject("data").getString("carrierName"));
return EResponse.ok(vo);
}
/**
* description 帐号登出
* param
......@@ -154,11 +197,11 @@ public class DriverAccountController {
String phone = ReqUtils.getTokenInfo().getAccount();
// 调用帐号密码校验接口
// 调用获取账号详情接口
JSONObject reqJsonDetail = new JSONObject();
reqJsonDetail.put("account", phone);
log.info(reqJsonDetail.toJSONString());
JSONObject result = driverInterface.getAccountDetail(reqJsonDetail);
JSONObject result = driverInterface.getDetailByAccount(reqJsonDetail);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
......@@ -168,10 +211,11 @@ public class DriverAccountController {
DriverAccountDetailVO detailVO = new DriverAccountDetailVO();
detailVO.setId(String.valueOf(result.getJSONObject("data").getLong("id")));
detailVO.setCarrierId(result.getJSONObject("data").getLong("carrierId"));
detailVO.setCarrierName(result.getJSONObject("data").getString("carrierName"));
detailVO.setAccount(result.getJSONObject("data").getString("account"));
detailVO.setSourceType(result.getJSONObject("data").getString("sourceType"));
detailVO.setAccountStatus(result.getJSONObject("data").getInteger("accountStatus"));
detailVO.setSourceType(result.getJSONObject("data").getInteger("sourceType"));
detailVO.setAuditStatus(result.getJSONObject("data").getInteger("auditStatus"));
detailVO.setAuthenticateStatus(result.getJSONObject("data").getInteger("authenticateStatus"));
detailVO.setName(result.getJSONObject("data").getString("name"));
detailVO.setIdCard(result.getJSONObject("data").getString("idCard"));
detailVO.setIdCardExpireDate(result.getJSONObject("data").getString("idCardExpireDate"));
......@@ -229,4 +273,52 @@ public class DriverAccountController {
return EResponse.ok();
}
/**
* description 获取承运商列表
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/13 10:00
**/
@PostMapping("/carrier/list")
public EResponse getCarrierList() {
// 调用获取承运商列表接口
JSONObject reqJson = new JSONObject();
JSONObject result = carrierInterface.all(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
}
List<CarrierInfoBriefVO> carrierInfoBriefVOList = new ArrayList<>();
JSONArray items = result.getJSONArray("data");
if(items.size() > 0) {
for(int i=0; i<items.size(); ++i) {
CarrierInfoBriefVO vo = new CarrierInfoBriefVO();
JSONObject object = items.getJSONObject(i);
vo.setId(object.getLong("id"));
vo.setAccount(object.getString("account"));
vo.setAccountStatus(object.getInteger("accountStatus"));
vo.setCarrierNumber(object.getString("carrierNumber"));
vo.setCarrierName(object.getString("carrierName"));
carrierInfoBriefVOList.add(vo);
}
}
return EResponse.ok(carrierInfoBriefVOList);
}
/**
* description 司机账号停用
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/06 11:00
**/
@PostMapping("/account/stop")
public EResponse stopUsingAccount(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) {
appLoginService.stopUsing(loginForm.getPhone());
return EResponse.ok();
}
}
......@@ -7,6 +7,7 @@ import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.form.*;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginBySms;
import com.esv.freight.app.module.account.vo.OwnerAccountDetailVO;
......@@ -149,7 +150,7 @@ public class OwnerAccountController {
String phone = ReqUtils.getTokenInfo().getAccount();
// 调用帐号密码校验接口
// 调用获取账号详情接口
JSONObject reqJsonDetail = new JSONObject();
reqJsonDetail.put("account", phone);
log.info(reqJsonDetail.toJSONString());
......@@ -236,4 +237,17 @@ public class OwnerAccountController {
return EResponse.ok();
}
/**
* description 货主账号停用
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/05/06 11:00
**/
@PostMapping("/account/stop")
public EResponse stopUsingAccount(@RequestBody(required=false) @Validated(ValidatorAccountExist.class) LoginForm loginForm) {
appLoginService.stopUsing(loginForm.getPhone());
return EResponse.ok();
}
}
\ No newline at end of file
......@@ -4,12 +4,15 @@ import com.esv.freight.app.common.validator.groups.ValidatorDelete;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import com.esv.freight.app.module.account.validator.groups.ValidatorAccountExist;
import com.esv.freight.app.module.account.validator.groups.ValidatorDriverLoginBySms;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginBySms;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
......@@ -26,21 +29,27 @@ public class LoginForm {
/**
* 手机号
*/
@Length(min = 11, max = 11, message = "参数phone长度不合法", groups = {ValidatorInsert.class, ValidatorLoginByPwd.class, ValidatorLoginBySms.class})
@NotBlank(message = "参数phone不能为空", groups = {ValidatorInsert.class, ValidatorLoginByPwd.class, ValidatorLoginBySms.class})
@Length(min = 11, max = 11, message = "参数phone长度不合法", groups = {ValidatorLoginByPwd.class, ValidatorLoginBySms.class, ValidatorAccountExist.class, ValidatorDriverLoginBySms.class})
@NotNull(message = "参数phone不能为空", groups = {ValidatorLoginByPwd.class, ValidatorLoginBySms.class, ValidatorAccountExist.class, ValidatorDriverLoginBySms.class})
private String phone;
/**
* 短信验证码
*/
@Length(min = 6, max = 6, message = "参数smsCode长度不合法", groups = {ValidatorInsert.class, ValidatorLoginBySms.class})
@NotBlank(message = "参数smsCode不能为空", groups = {ValidatorInsert.class, ValidatorLoginBySms.class})
@Length(min = 6, max = 6, message = "参数smsCode长度不合法", groups = {ValidatorLoginBySms.class, ValidatorDriverLoginBySms.class})
@NotNull(message = "参数smsCode不能为空", groups = {ValidatorLoginBySms.class})
private String smsCode;
/**
* 密码
*/
@Length(min = 32, max = 32, message = "参数pwd长度不合法", groups = {ValidatorInsert.class, ValidatorLoginByPwd.class})
@NotBlank(message = "参数pwd不能为空", groups = {ValidatorInsert.class, ValidatorLoginByPwd.class})
@Length(min = 32, max = 32, message = "参数pwd长度不合法", groups = {ValidatorLoginByPwd.class})
@NotNull(message = "参数pwd不能为空", groups = {ValidatorLoginByPwd.class})
private String pwd;
/**
* 承运商帐号ID
*/
@NotNull(message = "参数carrierId不能为空", groups = {ValidatorDriverLoginBySms.class})
private String carrierId;
}
......@@ -14,13 +14,57 @@ import com.esv.freight.app.module.account.vo.LoginVO;
*/
public interface AppLoginService extends IService<AppLoginEntity> {
/**
* description 账号登录
* param [phone]
* return LoginVO
* author 张志臣
* createTime 2020/04/13 16:48
**/
LoginVO login(String phone);
/**
* description 账号登出
* param [accessToken]
* return java.lang.Long
* author 张志臣
* createTime 2020/04/13 16:48
**/
void logout(String accessToken);
/**
* description 账号停用
* param [phone]
* return java.lang.Long
* author 张志臣
* createTime 2020/05/06 16:48
**/
void stopUsing(String phone);
/**
* description 刷新token
* param [accessToken, refreshTokenForm]
* return java.lang.Long
* author 张志臣
* createTime 2020/04/13 16:48
**/
LoginVO refreshToken(String accessToken, RefreshTokenForm refreshTokenForm);
/**
* description 判断accessToken是否有效
* param [accessToken]
* return java.lang.Long
* author 张志臣
* createTime 2020/04/13 16:48
**/
boolean isInvalidAccessToken(String accessToken);
/**
* description 判断refreshToken是否有效
* param [refreshToken]
* return java.lang.Long
* author 张志臣
* createTime 2020/04/13 16:48
**/
boolean isInvalidRefreshToken(String refreshToken);
}
\ No newline at end of file
......@@ -82,6 +82,20 @@ public class AppLoginImpl extends ServiceImpl<AppLoginDao, AppLoginEntity> imple
this.baseMapper.updateById(entity);
}
@Override
public void stopUsing(String phone) {
AppLoginEntity entity = this.getAccountByPhone(phone);
if(null == entity) {
return;
}
entity.setAccessToken("");
entity.setRefreshToken("");
entity.setLoginStatus("2");
entity.setLogoutTime(new Date());
this.baseMapper.updateById(entity);
}
@Override
public LoginVO refreshToken(String accessToken, RefreshTokenForm refreshTokenForm) {
AppLoginEntity entity = this.getAccountByAccessToken(accessToken);
......
package com.esv.freight.app.module.account.validator.groups;
public interface ValidatorAccountExist {
}
package com.esv.freight.app.module.account.validator.groups;
public interface ValidatorDriverLoginBySms {
}
package com.esv.freight.app.module.account.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description: 账号是否存在VO
* @project: freight-app-service
* @name: com.esv.freight.app.module.account.vo.AccountExistVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/05/06 10:00
* @version:1.0
*/
@Data
public class AccountExistVO {
/**
* 帐号状态:1-账号已存在、2-账号不存在
*/
private Integer accountStatus;
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 承运商名称
*/
private String carrierName;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.app.module.account.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description: 承运商简要信息VO
* @project: freight-app-service
* @name: com.esv.freight.app.module.account.vo.CarrierInfoBriefVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/24 16:58
* @version:1.0
*/
@Data
public class CarrierInfoBriefVO {
/**
*
*/
private Long id;
/**
* 登录帐号,承运商联系人电话
*/
private String account;
/**
* 帐号状态:1-正常、2-停用
*/
private Integer accountStatus;
/**
* 客户编码
*/
private String carrierNumber;
/**
* 承运商名称
*/
private String carrierName;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.app.module.account.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description: 司机账号详情VO
* @project: Freight
* @name: com.esv.freight.module.ownerBackend.account.login.vo.DriverAccountDetailVO
* @project: freight-app-service
* @name: com.esv.freight.app.module.account.vo.DriverAccountDetailVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/13 17:00
......@@ -20,18 +22,21 @@ public class DriverAccountDetailVO {
// 承运商帐号ID
private Long carrierId;
// 承运商名称
private String carrierName;
// 登录帐号,司机手机号
private String account;
// 帐号状态:1-正常、2-停用
private Integer accountStatus;
// 创建来源:1-平台创建、2-自行注册
private String sourceType;
private Integer sourceType;
// 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败
private Integer auditStatus;
// 认证状态:1-未认证、2-已认证
private Integer authenticateStatus;
// 姓名
private String name;
......@@ -106,4 +111,9 @@ public class DriverAccountDetailVO {
// 道路运输从业资格证-正面图片URL
private String certificateUrl;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -6,8 +6,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description: 账号密码登录VO
* @project: Freight
* @name: com.esv.freight.module.ownerBackend.account.login.vo.LoginByPwdVO
* @project: freight-app-service
* @name: com.esv.freight.module.ownerBackend.account.login.vo.LoginVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/10 16:00
......
package com.esv.freight.app.module.account.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description: 货主账号详情VO
* @project: Freight
* @project: freight-app-service
* @name: com.esv.freight.module.ownerBackend.account.login.vo.OwnerAccountDetailVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
......@@ -79,4 +81,9 @@ public class OwnerAccountDetailVO {
// 企业法人手机号
private String legalPhone;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -67,6 +67,7 @@ public class OwnerWaybillController {
reqJson.put("goodsOwnerId", waybillQueryForm.getUserId());
reqJson.put("pageNum", waybillQueryForm.getPageNum());
reqJson.put("pageSize", waybillQueryForm.getPageSize());
reqJson.put("waybillStateList", waybillQueryForm.getWaybillStateList());
if(!StringUtils.isEmpty(waybillQueryForm.getOrderNo())) {
reqJson.put("orderNo", waybillQueryForm.getOrderNo());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment