diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index 02dfc48a..5a9e86b5 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -7,6 +7,8 @@ import cn.lili.common.security.enums.UserEnums; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dto.MemberEditDTO; +import cn.lili.modules.member.entity.enums.QRCodeLoginSessionStatusEnum; +import cn.lili.modules.member.entity.vo.QRLoginResultVo; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.sms.SmsUtil; import cn.lili.modules.verification.entity.enums.VerificationEnums; @@ -15,10 +17,18 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.async.DeferredResult; import javax.validation.constraints.NotNull; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + /** * 买家端,会员接口 @@ -26,6 +36,7 @@ import javax.validation.constraints.NotNull; * @author Chopper * @since 2020/11/16 10:07 下午 */ +@Slf4j @RestController @Api(tags = "买家端,会员接口") @RequestMapping("/buyer/passport/member") @@ -39,6 +50,73 @@ public class MemberBuyerController { private VerificationService verificationService; + @ApiOperation(value = "web-获取登录二维码") + @PostMapping(value = "/pc_session", produces = "application/json;charset=UTF-8") + public ResultMessage createPcSession() { + return ResultUtil.data(memberService.createPcSession()); + } + + + /** + * 长轮询:参考nacos + * + * @param token + * @param beforeSessionStatus 上次记录的session状态 + * @return + */ + @ApiOperation(value = "web-二维码登录") + @PostMapping(value = "/session_login/{token}", produces = "application/json;charset=UTF-8") + public Object loginWithSession(@PathVariable("token") String token, Integer beforeSessionStatus) { + log.info("receive login with session key {}", token); + ResponseEntity> timeoutResponseEntity = + new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK); + int timeoutSecond = 20; + DeferredResult> deferredResult = new DeferredResult<>(timeoutSecond * 1000L, timeoutResponseEntity); + CompletableFuture.runAsync(() -> { + try { + int i = 0; + while (i < timeoutSecond) { + QRLoginResultVo queryResult = memberService.loginWithSession(token); + int status = queryResult.getStatus(); + if (status == beforeSessionStatus + && (QRCodeLoginSessionStatusEnum.WAIT_SCANNING.getCode() == status + || QRCodeLoginSessionStatusEnum.SCANNING.getCode() == status)) { + //睡眠一秒种,继续等待结果 + TimeUnit.SECONDS.sleep(1); + } else { + deferredResult.setResult(new ResponseEntity<>(ResultUtil.data(queryResult), HttpStatus.OK)); + break; + } + i++; + } + } catch (Exception e) { + log.error("获取登录状态异常,", e); + deferredResult.setResult(new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK)); + Thread.currentThread().interrupt(); + } + }, Executors.newCachedThreadPool()); + return deferredResult; + } + + @ApiOperation(value = "app扫码") + @PostMapping(value = "/app_scanner", produces = "application/json;charset=UTF-8") + public ResultMessage appScanner(String token) { + return ResultUtil.data(memberService.appScanner(token)); + } + + + @ApiOperation(value = "app扫码-登录确认:同意/拒绝") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "sessionToken", required = true, paramType = "query"), + @ApiImplicitParam(name = "code", value = "操作:0拒绝登录,1同意登录", required = true, paramType = "query") + }) + @PostMapping(value = "/app_confirm", produces = "application/json;charset=UTF-8") + public ResultMessage appSConfirm(String token, Integer code) { + boolean flag = memberService.appSConfirm(token, code); + return flag ? ResultUtil.success() : ResultUtil.error(ResultCode.ERROR); + } + + @ApiOperation(value = "登录接口") @ApiImplicitParams({ @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"), diff --git a/framework/src/main/java/cn/lili/cache/CachePrefix.java b/framework/src/main/java/cn/lili/cache/CachePrefix.java index 52592ba6..460fe7bf 100644 --- a/framework/src/main/java/cn/lili/cache/CachePrefix.java +++ b/framework/src/main/java/cn/lili/cache/CachePrefix.java @@ -487,7 +487,16 @@ public enum CachePrefix { /** * 敏感词 */ - SENSITIVE; + SENSITIVE, + + /** + * 扫码登录 + * @param str + * @return + */ + QR_CODE_LOGIN_SESSION + + ; public static String removePrefix(String str) { diff --git a/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java b/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java index 402f165d..1be580ce 100644 --- a/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java +++ b/framework/src/main/java/cn/lili/cache/limit/interceptor/LimitInterceptor.java @@ -45,21 +45,20 @@ public class LimitInterceptor { @Before("@annotation(limitPointAnnotation)") public void interceptor(LimitPoint limitPointAnnotation) { LimitTypeEnums limitTypeEnums = limitPointAnnotation.limitType(); - String name = limitPointAnnotation.name(); + String key; int limitPeriod = limitPointAnnotation.period(); int limitCount = limitPointAnnotation.limit(); - switch (limitTypeEnums) { - case CUSTOMER: - key = limitPointAnnotation.key(); - break; - default: - key = limitPointAnnotation.key() + IpUtils - .getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); + if (limitTypeEnums == LimitTypeEnums.CUSTOMER) { + key = limitPointAnnotation.key(); + } else { + key = limitPointAnnotation.key() + IpUtils + .getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); } ImmutableList keys = ImmutableList.of(StringUtils.join(limitPointAnnotation.prefix(), key)); try { Number count = redisTemplate.execute(limitScript, keys, limitCount, limitPeriod); + assert count != null; log.info("限制请求{}, 当前请求{},缓存key{}", limitCount, count.intValue(), key); //如果缓存里没有值,或者他的值小于限制频率 if (count.intValue() >= limitCount) { @@ -72,6 +71,7 @@ public class LimitInterceptor { } catch (ServiceException e) { throw e; } catch (Exception e) { + log.error("限流异常", e); throw new ServiceException(ResultCode.ERROR); } } diff --git a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java index 8f6decfe..9a860444 100644 --- a/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java +++ b/framework/src/main/java/cn/lili/common/aop/interceptor/PreventDuplicateSubmissionsInterceptor.java @@ -47,6 +47,7 @@ public class PreventDuplicateSubmissionsInterceptor { } catch (ServiceException e) { throw e; } catch (Exception e) { + log.error("防重复提交拦截器异常", e); throw new ServiceException(ResultCode.ERROR); } } diff --git a/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java b/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java index 906c3696..2d783800 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/StudioService.java @@ -53,7 +53,7 @@ public interface StudioService extends IService { * @param storeId 店铺ID * @return 操作结果 */ - Boolean push(Integer roomId,Integer goodsId, String storeId); + Boolean push(Integer roomId,Integer liveGoodsId, String storeId, String goodsId); /** * 删除商品 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 6839148a..8908006b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -431,6 +431,7 @@ public class GoodsServiceImpl extends ServiceImpl implements LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); lambdaUpdateWrapper.set(Goods::getQuantity, quantity); lambdaUpdateWrapper.eq(Goods::getId, goodsId); + cache.remove(CachePrefix.GOODS.getPrefix() + goodsId); this.update(lambdaUpdateWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java index 3e4aff1c..540a1f11 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StudioServiceImpl.java @@ -161,12 +161,12 @@ public class StudioServiceImpl extends ServiceImpl impleme @Override @Transactional(rollbackFor = Exception.class) - public Boolean push(Integer roomId, Integer goodsId, String storeId) { + public Boolean push(Integer roomId, Integer liveGoodsId, String storeId, String goodsId) { //判断直播间是否已添加商品 if (studioCommodityService.getOne( new LambdaQueryWrapper().eq(StudioCommodity::getRoomId, roomId) - .eq(StudioCommodity::getGoodsId, goodsId)) != null) { + .eq(StudioCommodity::getGoodsId, liveGoodsId)) != null) { throw new ServiceException(ResultCode.STODIO_GOODS_EXIST_ERROR); } @@ -176,8 +176,8 @@ public class StudioServiceImpl extends ServiceImpl impleme } //调用微信接口添加直播间商品并进行记录 - if (Boolean.TRUE.equals(wechatLivePlayerUtil.pushGoods(roomId, goodsId))) { - studioCommodityService.save(new StudioCommodity(roomId, goodsId)); + if (Boolean.TRUE.equals(wechatLivePlayerUtil.pushGoods(roomId, liveGoodsId))) { + studioCommodityService.save(new StudioCommodity(roomId, liveGoodsId)); //添加直播间商品数量 Studio studio = this.getByRoomId(roomId); studio.setRoomGoodsNum(studio.getRoomGoodsNum() != null ? studio.getRoomGoodsNum() + 1 : 1); diff --git a/framework/src/main/java/cn/lili/modules/member/entity/enums/QRCodeLoginSessionStatusEnum.java b/framework/src/main/java/cn/lili/modules/member/entity/enums/QRCodeLoginSessionStatusEnum.java new file mode 100644 index 00000000..7a176f72 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/member/entity/enums/QRCodeLoginSessionStatusEnum.java @@ -0,0 +1,46 @@ +package cn.lili.modules.member.entity.enums; + + +import lombok.Getter; + +@Getter +public enum QRCodeLoginSessionStatusEnum { + + /** + * 二维码创建完毕,等待app端扫码 + */ + WAIT_SCANNING(0,"等待扫码"), + + /** + * app端已经扫码,等待确认同意登录 + */ + SCANNING(1,"已经扫码"), + + /** + * 用户在app端点击了同意登录 + */ + VERIFIED(2,"确认登录"), + + /** + * 用户在app端点击了取消登录 + */ + CANCELED(3,"取消登录"), + + /** + * 二维码不存在/或者已经过期 + */ + NO_EXIST(4,"二维码已过期") + + ; + + + private Integer code; + + private String desc; + + + QRCodeLoginSessionStatusEnum(Integer code,String desc){ + this.code = code; + this.desc = desc; + } +} diff --git a/framework/src/main/java/cn/lili/modules/member/entity/vo/QRCodeLoginSessionVo.java b/framework/src/main/java/cn/lili/modules/member/entity/vo/QRCodeLoginSessionVo.java new file mode 100644 index 00000000..3fb89555 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/member/entity/vo/QRCodeLoginSessionVo.java @@ -0,0 +1,21 @@ +package cn.lili.modules.member.entity.vo; + +import cn.lili.modules.member.entity.enums.QRCodeLoginSessionStatusEnum; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class QRCodeLoginSessionVo implements Serializable { + + + private static final long serialVersionUID = 8793639296995408322L; + + private String token; + + private Integer status; + + private long duration; + + private long userId; +} diff --git a/framework/src/main/java/cn/lili/modules/member/entity/vo/QRLoginResultVo.java b/framework/src/main/java/cn/lili/modules/member/entity/vo/QRLoginResultVo.java new file mode 100644 index 00000000..aaa25a4a --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/member/entity/vo/QRLoginResultVo.java @@ -0,0 +1,12 @@ +package cn.lili.modules.member.entity.vo; + +import cn.lili.common.security.token.Token; +import lombok.Data; + +@Data +public class QRLoginResultVo { + + private Token token; + + private int status; +} diff --git a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java index 6824b7cd..25b82f3b 100644 --- a/framework/src/main/java/cn/lili/modules/member/service/MemberService.java +++ b/framework/src/main/java/cn/lili/modules/member/service/MemberService.java @@ -11,6 +11,8 @@ import cn.lili.modules.member.entity.dto.MemberAddDTO; import cn.lili.modules.member.entity.dto.MemberEditDTO; import cn.lili.modules.member.entity.vo.MemberSearchVO; import cn.lili.modules.member.entity.vo.MemberVO; +import cn.lili.modules.member.entity.vo.QRLoginResultVo; +import cn.lili.modules.member.entity.vo.QRCodeLoginSessionVo; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -272,4 +274,12 @@ public interface MemberService extends IService { * @return 用户VO */ MemberVO getMember(String id); + + QRCodeLoginSessionVo createPcSession(); + + Object appScanner(String token); + + boolean appSConfirm(String token, Integer code); + + QRLoginResultVo loginWithSession(String token); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 0194434b..76c8c9b9 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -17,7 +17,10 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.token.Token; import cn.lili.common.sensitive.SensitiveWordsFilter; -import cn.lili.common.utils.*; +import cn.lili.common.utils.BeanUtil; +import cn.lili.common.utils.CookieUtil; +import cn.lili.common.utils.SnowFlake; +import cn.lili.common.utils.UuidUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.connect.config.ConnectAuthEnum; import cn.lili.modules.connect.entity.Connect; @@ -27,8 +30,11 @@ import cn.lili.modules.member.aop.annotation.PointLogPoint; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dto.*; import cn.lili.modules.member.entity.enums.PointTypeEnum; +import cn.lili.modules.member.entity.enums.QRCodeLoginSessionStatusEnum; import cn.lili.modules.member.entity.vo.MemberSearchVO; import cn.lili.modules.member.entity.vo.MemberVO; +import cn.lili.modules.member.entity.vo.QRCodeLoginSessionVo; +import cn.lili.modules.member.entity.vo.QRLoginResultVo; import cn.lili.modules.member.mapper.MemberMapper; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.member.token.MemberTokenGenerate; @@ -54,6 +60,7 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.concurrent.TimeUnit; /** * 会员接口业务层实现 @@ -209,6 +216,7 @@ public class MemberServiceImpl extends ServiceImpl impleme } @Override + @Transactional public Token autoRegister() { ConnectAuthUser connectAuthUser = this.checkConnectUser(); return this.autoRegister(connectAuthUser); @@ -403,11 +411,11 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override public Member updateMember(ManagerMemberEditDTO managerMemberEditDTO) { //过滤会员昵称敏感词 - if (StringUtils.isNotBlank(managerMemberEditDTO.getNickName())) { + if (CharSequenceUtil.isNotBlank(managerMemberEditDTO.getNickName())) { managerMemberEditDTO.setNickName(SensitiveWordsFilter.filter(managerMemberEditDTO.getNickName())); } //如果密码不为空则加密密码 - if (StringUtils.isNotBlank(managerMemberEditDTO.getPassword())) { + if (CharSequenceUtil.isNotBlank(managerMemberEditDTO.getPassword())) { managerMemberEditDTO.setPassword(new BCryptPasswordEncoder().encode(managerMemberEditDTO.getPassword())); } //查询会员信息 @@ -670,6 +678,81 @@ public class MemberServiceImpl extends ServiceImpl impleme return new MemberVO(this.getById(id)); } + @Override + public QRCodeLoginSessionVo createPcSession() { + QRCodeLoginSessionVo session = new QRCodeLoginSessionVo(); + session.setStatus(QRCodeLoginSessionStatusEnum.WAIT_SCANNING.getCode()); + //过期时间,20s + Long duration = 20 * 1000L; + session.setDuration(duration); + String token = CachePrefix.QR_CODE_LOGIN_SESSION.name() + SnowFlake.getIdStr(); + session.setToken(token); + cache.put(token, session, duration, TimeUnit.MILLISECONDS); + return session; + } + + @Override + public Object appScanner(String token) { + AuthUser tokenUser = UserContext.getCurrentUser(); + if (tokenUser == null) { + throw new ServiceException(ResultCode.USER_NOT_LOGIN); + } + QRCodeLoginSessionVo session = (QRCodeLoginSessionVo) cache.get(token); + if (session == null) { + return QRCodeLoginSessionStatusEnum.NO_EXIST.getCode(); + } + session.setStatus(QRCodeLoginSessionStatusEnum.SCANNING.getCode()); + cache.put(token, session, session.getDuration(), TimeUnit.MILLISECONDS); + return QRCodeLoginSessionStatusEnum.SCANNING.getCode(); + } + + @Override + public boolean appSConfirm(String token, Integer code) { + AuthUser tokenUser = UserContext.getCurrentUser(); + if (tokenUser == null) { + throw new ServiceException(ResultCode.USER_NOT_LOGIN); + } + QRCodeLoginSessionVo session = (QRCodeLoginSessionVo) cache.get(token); + if (session == null) { + return false; + } + if (code == 1) { + //同意 + session.setStatus(QRCodeLoginSessionStatusEnum.VERIFIED.getCode()); + session.setUserId(Long.parseLong(tokenUser.getId())); + } else { + //拒绝 + session.setStatus(QRCodeLoginSessionStatusEnum.CANCELED.getCode()); + } + cache.put(token, session, session.getDuration(), TimeUnit.MILLISECONDS); + return true; + } + + @Override + public QRLoginResultVo loginWithSession(String sessionToken) { + QRLoginResultVo result = new QRLoginResultVo(); + result.setStatus(QRCodeLoginSessionStatusEnum.NO_EXIST.getCode()); + QRCodeLoginSessionVo session = (QRCodeLoginSessionVo) cache.get(sessionToken); + if (session == null) { + return result; + } + result.setStatus(session.getStatus()); + if (QRCodeLoginSessionStatusEnum.VERIFIED.getCode().equals(session.getStatus())) { + //生成token + Member member = this.getById(session.getUserId()); + if (member == null) { + throw new ServiceException(ResultCode.USER_NOT_EXIST); + } else { + //生成token + Token token = memberTokenGenerate.createToken(member, false); + result.setToken(token); + cache.vagueDel(sessionToken); + } + + } + return result; + } + /** * 检测会员 * diff --git a/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java b/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java index b83ac909..7b70b5fb 100644 --- a/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java +++ b/framework/src/main/java/cn/lili/modules/member/token/MemberTokenGenerate.java @@ -37,17 +37,18 @@ public class MemberTokenGenerate extends AbstractTokenGenerate { @Override public Token createToken(Member member, Boolean longTerm) { - //获取客户端类型 - String clientType = ThreadContextHolder.getHttpRequest().getHeader("clientType"); + ClientTypeEnum clientTypeEnum; try { + //获取客户端类型 + String clientType = ThreadContextHolder.getHttpRequest().getHeader("clientType"); //如果客户端为空,则缺省值为PC,pc第三方登录时不会传递此参数 if (clientType == null) { clientTypeEnum = ClientTypeEnum.PC; } else { clientTypeEnum = ClientTypeEnum.valueOf(clientType); } - } catch (IllegalArgumentException e) { + } catch (Exception e) { clientTypeEnum = ClientTypeEnum.UNKNOWN; } //记录最后登录时间,客户端类型 diff --git a/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java b/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java index b3a9ec9c..6c5a813e 100644 --- a/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java +++ b/framework/src/main/java/cn/lili/modules/permission/entity/vo/SystemLogVO.java @@ -9,7 +9,6 @@ import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.Accessors; import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.DateFormat; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; @@ -42,7 +41,7 @@ public class SystemLogVO implements Serializable { @ApiModelProperty(value = "日志记录时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @Field(type = FieldType.Date, format = DateFormat.basic_date_time, fielddata = true) + @Field(type = FieldType.Date, fielddata = true) private Date createTime = new Date(); @ApiModelProperty(value = "请求用户") diff --git a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java index dd4b5894..edf3c9f5 100644 --- a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java @@ -96,6 +96,7 @@ public class VerificationServiceImpl implements VerificationService { } catch (ServiceException e) { throw e; } catch (Exception e) { + log.error("生成验证码失败", e); throw new ServiceException(ResultCode.ERROR); } } diff --git a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java index f58b9e6e..71af808d 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/GoodsManagerController.java @@ -48,8 +48,8 @@ public class GoodsManagerController { @ApiOperation(value = "分页获取") @GetMapping(value = "/list") - public IPage getByPage(GoodsSearchParams goodsSearchParams) { - return goodsService.queryByParams(goodsSearchParams); + public ResultMessage> getByPage(GoodsSearchParams goodsSearchParams) { + return ResultUtil.data(goodsService.queryByParams(goodsSearchParams)); } @ApiOperation(value = "分页获取商品列表") @@ -60,10 +60,9 @@ public class GoodsManagerController { @ApiOperation(value = "分页获取待审核商品") @GetMapping(value = "/auth/list") - public IPage getAuthPage(GoodsSearchParams goodsSearchParams) { - + public ResultMessage> getAuthPage(GoodsSearchParams goodsSearchParams) { goodsSearchParams.setAuthFlag(GoodsAuthEnum.TOBEAUDITED.name()); - return goodsService.queryByParams(goodsSearchParams); + return ResultUtil.data(goodsService.queryByParams(goodsSearchParams)); } @PreventDuplicateSubmissions @@ -104,7 +103,7 @@ public class GoodsManagerController { @ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, allowMultiple = true) }) public ResultMessage unpGoods(@PathVariable List goodsId) { - if (goodsService.updateGoodsMarketAble(goodsId, GoodsStatusEnum.UPPER, "")) { + if (Boolean.TRUE.equals(goodsService.updateGoodsMarketAble(goodsId, GoodsStatusEnum.UPPER, ""))) { return ResultUtil.success(); } throw new ServiceException(ResultCode.GOODS_UPPER_ERROR); diff --git a/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java index cb673546..ac97fd6b 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/SpecificationManagerController.java @@ -1,13 +1,13 @@ package cn.lili.controller.goods; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultUtil; -import cn.lili.mybatis.util.PageUtil; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Specification; import cn.lili.modules.goods.service.SpecificationService; +import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; @@ -37,17 +37,16 @@ public class SpecificationManagerController { @GetMapping("/all") @ApiOperation(value = "获取所有可用规格") - public List getAll() { - List list = specificationService.list(); - return list; + public ResultMessage> getAll() { + return ResultUtil.data(specificationService.list()); } @GetMapping @ApiOperation(value = "搜索规格") - public Page page(String specName, PageVO page) { + public ResultMessage> page(String specName, PageVO page) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.like(StringUtils.isNotEmpty(specName), Specification::getSpecName, specName); - return specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper); + lambdaQueryWrapper.like(CharSequenceUtil.isNotEmpty(specName), Specification::getSpecName, specName); + return ResultUtil.data(specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper)); } @PostMapping @@ -61,15 +60,13 @@ public class SpecificationManagerController { @ApiOperation(value = "更改规格") public ResultMessage update(@Valid Specification specification, @PathVariable String id) { specification.setId(id); - specificationService.saveOrUpdate(specification); - return ResultUtil.success(); + return ResultUtil.data(specificationService.saveOrUpdate(specification)); } @DeleteMapping("/{ids}") @ApiImplicitParam(name = "ids", value = "规格ID", required = true, dataType = "String", allowMultiple = true, paramType = "path") @ApiOperation(value = "批量删除") public ResultMessage delAllByIds(@PathVariable List ids) { - specificationService.deleteSpecification(ids); - return ResultUtil.success(); + return ResultUtil.data(specificationService.deleteSpecification(ids)); } } diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java index 0647cf36..fc640c46 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/FullDiscountManagerController.java @@ -35,7 +35,6 @@ public class FullDiscountManagerController { @ApiOperation(value = "获取满优惠列表") @GetMapping public ResultMessage> getCouponList(FullDiscountSearchParams searchParams, PageVO page) { - page.setNotConvert(true); return ResultUtil.data(fullDiscountService.pageFindAll(searchParams, page)); } diff --git a/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java b/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java index efe697e3..44d90022 100644 --- a/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/other/broadcast/StudioStoreController.java @@ -74,9 +74,9 @@ public class StudioStoreController { @ApiImplicitParam(name = "liveGoodsId", value = "直播商品ID", required = true, dataType = "Integer", paramType = "path") }) @PutMapping(value = "/push/{roomId}/{liveGoodsId}") - public ResultMessage push(@PathVariable Integer roomId, @PathVariable Integer liveGoodsId) { + public ResultMessage push(@PathVariable Integer roomId, @PathVariable Integer liveGoodsId, @RequestParam String goodsId) { String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId(); - if (Boolean.TRUE.equals(studioService.push(roomId, liveGoodsId, storeId))) { + if (Boolean.TRUE.equals(studioService.push(roomId, liveGoodsId, storeId, goodsId))) { return ResultUtil.success(ResultCode.SUCCESS); } throw new ServiceException(ResultCode.ERROR); diff --git a/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java b/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java index 90844293..7af2c8e2 100644 --- a/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/promotion/CouponStoreController.java @@ -41,7 +41,6 @@ public class CouponStoreController { @GetMapping @ApiOperation(value = "获取优惠券列表") public ResultMessage> getCouponList(CouponSearchParams queryParam, PageVO page) { - page.setNotConvert(true); String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId(); queryParam.setStoreId(storeId); IPage coupons = couponService.pageVOFindAll(queryParam, page);