验证码
个人中心-菜单页 首页接口 预约到店(店铺列表) 通用商品列表 登录 退出登录 商品详情(缺少评价部分)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
@@ -8,25 +10,26 @@ import com.chaozhanggui.system.cashierservice.util.StringUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.ValidateCodeUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 通用接口
|
||||
* @author lyf
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/phoneValidateCode")
|
||||
@RequestMapping
|
||||
@RequiredArgsConstructor
|
||||
public class PhoneValidateCodeController {
|
||||
public class CommonController {
|
||||
|
||||
private final ValidateCodeUtil validateCodeUtil;
|
||||
@Resource
|
||||
private RedisUtils redisUtils;
|
||||
@Resource
|
||||
private TbPlatformDictMapper platformDictMapper;
|
||||
/**
|
||||
* 一分钟
|
||||
*/
|
||||
@@ -37,7 +40,7 @@ public class PhoneValidateCodeController {
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@GetMapping("/phoneValidateCode")
|
||||
public Result verifyPhoneIsExist(@RequestParam String phone) {
|
||||
if (StringUtils.isBlank(phone)) {
|
||||
return Result.fail("手机号不可为空!");
|
||||
@@ -52,4 +55,13 @@ public class PhoneValidateCodeController {
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单
|
||||
*/
|
||||
@GetMapping("/tbPlatformDict")
|
||||
public Result getPlatformDict(@RequestParam String type, @RequestHeader String environment) {
|
||||
List<TbPlatformDict> carouselList = platformDictMapper.queryAllByType(type, environment);
|
||||
return Result.success(CodeEnum.SUCCESS,carouselList);
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,13 @@ public class HomeController {
|
||||
@Resource
|
||||
private HomePageService homePageService;
|
||||
|
||||
@PostMapping
|
||||
public Result homePage(@RequestBody HomeDto homeDto,@RequestHeader("environment") String environmen)throws Exception{
|
||||
return homePageService.homePage(homeDto, environmen);
|
||||
}
|
||||
@PostMapping("/homePageUp")
|
||||
public Result homePageUp(@RequestHeader("environment") String environment){
|
||||
return homePageService.homePageUp(environment);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Result homePage(@RequestBody HomeDto homeDto,@RequestHeader("environment") String environmen)throws Exception{
|
||||
return homePageService.proList(homeDto, environmen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeBaseDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
import com.chaozhanggui.system.cashierservice.service.HomeDistrictService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* 首页其它接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/distirict")
|
||||
@RequiredArgsConstructor
|
||||
public class HomeDistrictController {
|
||||
|
||||
@Resource
|
||||
private HomeDistrictService districtService;
|
||||
|
||||
/**
|
||||
* 预约到店(店铺列表)
|
||||
*/
|
||||
@RequestMapping("/subShopList")
|
||||
public Result subShopList(HomeBaseDto param,@RequestHeader("environment") String environment){
|
||||
return districtService.queryShopListByPage(param,environment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 品类
|
||||
*
|
||||
* 今日上新
|
||||
* 热榜推荐
|
||||
* 咖啡饮品
|
||||
*/
|
||||
@RequestMapping("/productCate")
|
||||
public Result productCate(HomeDto param, @RequestHeader("environment") String environment) throws ExecutionException, InterruptedException {
|
||||
return districtService.proList(param,environment);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,12 @@ public class LoginContoller {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序登录
|
||||
* @param request
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/wx/custom/login")
|
||||
public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map<String, String> map
|
||||
// ,
|
||||
@@ -102,15 +107,15 @@ public class LoginContoller {
|
||||
|
||||
String code = map.get("code").toString();
|
||||
|
||||
String qrCode = map.get("qrCode");
|
||||
// String qrCode = map.get("qrCode");
|
||||
|
||||
String rawData = map.get("rawData");
|
||||
|
||||
String signature = map.get("signature");
|
||||
|
||||
String encryptedData = map.get("encryptedData");
|
||||
|
||||
String ivStr = map.get("iv");
|
||||
// String encryptedData = map.get("encryptedData");
|
||||
//
|
||||
// String ivStr = map.get("iv");
|
||||
|
||||
String phone = map.get("phone");
|
||||
|
||||
@@ -134,7 +139,8 @@ public class LoginContoller {
|
||||
String avatarUrl = rawDataJson.getString("avatarUrl");
|
||||
|
||||
try {
|
||||
return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, qrCode, IpUtil.getIpAddr(request));
|
||||
// return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, qrCode, IpUtil.getIpAddr(request));
|
||||
return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, IpUtil.getIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -144,6 +150,11 @@ public class LoginContoller {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序获取手机号
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("getPhoneNumber")
|
||||
public Result getPhoneNumber(@RequestBody Map<String, String> map) {
|
||||
|
||||
@@ -202,27 +213,33 @@ public class LoginContoller {
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取会员码
|
||||
// *
|
||||
// * @param openId
|
||||
// * @param token
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping("createCardNo")
|
||||
// public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id,
|
||||
//
|
||||
// @RequestParam("shopId") String shopId
|
||||
// ) {
|
||||
// return loginService.createCardNo(id, openId,shopId);
|
||||
// }
|
||||
|
||||
@GetMapping("/userInfo")
|
||||
public Result userInfo(@RequestParam("userId") Integer userId) {
|
||||
return loginService.userInfo(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员码
|
||||
*
|
||||
* @param openId
|
||||
* 更新用户信息
|
||||
* @param token
|
||||
* @param id
|
||||
* @param userInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("createCardNo")
|
||||
public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id,
|
||||
|
||||
@RequestParam("shopId") String shopId
|
||||
) {
|
||||
return loginService.createCardNo(id, openId,shopId);
|
||||
}
|
||||
|
||||
@GetMapping("/wx/userInfo")
|
||||
public Result userInfo(@RequestParam("userId") Integer userId, @RequestParam("shopId") String shopId) {
|
||||
return loginService.userInfo(userId, shopId);
|
||||
}
|
||||
|
||||
@PostMapping("/upUserInfo")
|
||||
public Result userInfo(@RequestHeader String token, @RequestBody TbUserInfo userInfo) {
|
||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
@@ -262,6 +279,7 @@ public class LoginContoller {
|
||||
*/
|
||||
@PostMapping("/app/login")
|
||||
public Result applogin(@RequestBody AuthUserDto authUserDto) {
|
||||
boolean tf = false;
|
||||
if (ObjectUtil.isNull(authUserDto.getCode())) {
|
||||
if (StringUtils.isBlank(authUserDto.getPassword())) {
|
||||
return Result.fail("请输入密码,或使用验证码登录");
|
||||
@@ -270,7 +288,7 @@ public class LoginContoller {
|
||||
String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8");
|
||||
return loginService.appLogin(authUserDto.getUsername(), mdPasswordString);
|
||||
} else {
|
||||
boolean tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername());
|
||||
tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername());
|
||||
if (tf) {
|
||||
return loginService.appLogin(authUserDto.getUsername(), null);
|
||||
} else {
|
||||
@@ -279,14 +297,21 @@ public class LoginContoller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//退出登录的接口
|
||||
/**
|
||||
* APP退出登录
|
||||
* @header token
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/loginOut")
|
||||
public Result loginOut(HttpServletRequest request) {
|
||||
String token = request.getHeader("token");
|
||||
public Result loginOut(@RequestHeader String token,@RequestHeader String environment,HttpServletRequest request) {
|
||||
//获取当前登录人的账号
|
||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
redisUtil.deleteByKey(RedisCst.ONLINE_APP_USER.concat(userId));
|
||||
if(environment.equals("wx")){
|
||||
String openId = request.getHeader("openId");
|
||||
redisUtil.deleteByKey(RedisCst.ONLINE_USER.concat(openId));
|
||||
}else if(environment.equals("app")){
|
||||
redisUtil.deleteByKey(RedisCst.ONLINE_APP_USER.concat(userId));
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ public class ProductController {
|
||||
}
|
||||
|
||||
@GetMapping("/productInfo")
|
||||
public Result productInfo(@RequestParam Integer productId) throws Exception {
|
||||
return productService.productInfo(productId);
|
||||
public Result productInfo(@RequestParam Integer productId,@RequestHeader String environment) throws Exception {
|
||||
return productService.productInfo(productId,environment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user