Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
4792d83119
@ -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<Object> 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<ResultMessage<Object>> timeoutResponseEntity =
|
||||
new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK);
|
||||
int timeoutSecond = 20;
|
||||
DeferredResult<ResponseEntity<Object>> 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<Object> 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<Object> 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"),
|
||||
|
@ -487,7 +487,16 @@ public enum CachePrefix {
|
||||
/**
|
||||
* 敏感词
|
||||
*/
|
||||
SENSITIVE;
|
||||
SENSITIVE,
|
||||
|
||||
/**
|
||||
* 扫码登录
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
QR_CODE_LOGIN_SESSION
|
||||
|
||||
;
|
||||
|
||||
|
||||
public static String removePrefix(String str) {
|
||||
|
@ -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<String> 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);
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class PreventDuplicateSubmissionsInterceptor {
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("防重复提交拦截器异常", e);
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public interface StudioService extends IService<Studio> {
|
||||
* @param storeId 店铺ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
Boolean push(Integer roomId,Integer goodsId, String storeId);
|
||||
Boolean push(Integer roomId,Integer liveGoodsId, String storeId, String goodsId);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
|
@ -431,6 +431,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.set(Goods::getQuantity, quantity);
|
||||
lambdaUpdateWrapper.eq(Goods::getId, goodsId);
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
|
@ -161,12 +161,12 @@ public class StudioServiceImpl extends ServiceImpl<StudioMapper, Studio> 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<StudioCommodity>().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<StudioMapper, Studio> 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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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<Member> {
|
||||
* @return 用户VO
|
||||
*/
|
||||
MemberVO getMember(String id);
|
||||
|
||||
QRCodeLoginSessionVo createPcSession();
|
||||
|
||||
Object appScanner(String token);
|
||||
|
||||
boolean appSConfirm(String token, Integer code);
|
||||
|
||||
QRLoginResultVo loginWithSession(String token);
|
||||
}
|
@ -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<MemberMapper, Member> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Token autoRegister() {
|
||||
ConnectAuthUser connectAuthUser = this.checkConnectUser();
|
||||
return this.autoRegister(connectAuthUser);
|
||||
@ -403,11 +411,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> 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<MemberMapper, Member> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测会员
|
||||
*
|
||||
|
@ -37,17 +37,18 @@ public class MemberTokenGenerate extends AbstractTokenGenerate<Member> {
|
||||
@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;
|
||||
}
|
||||
//记录最后登录时间,客户端类型
|
||||
|
@ -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 = "请求用户")
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class GoodsManagerController {
|
||||
|
||||
@ApiOperation(value = "分页获取")
|
||||
@GetMapping(value = "/list")
|
||||
public IPage<Goods> getByPage(GoodsSearchParams goodsSearchParams) {
|
||||
return goodsService.queryByParams(goodsSearchParams);
|
||||
public ResultMessage<IPage<Goods>> 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<Goods> getAuthPage(GoodsSearchParams goodsSearchParams) {
|
||||
|
||||
public ResultMessage<IPage<Goods>> 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<Object> unpGoods(@PathVariable List<String> 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);
|
||||
|
@ -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<Specification> getAll() {
|
||||
List<Specification> list = specificationService.list();
|
||||
return list;
|
||||
public ResultMessage<List<Specification>> getAll() {
|
||||
return ResultUtil.data(specificationService.list());
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "搜索规格")
|
||||
public Page<Specification> page(String specName, PageVO page) {
|
||||
public ResultMessage<Page<Specification>> page(String specName, PageVO page) {
|
||||
LambdaQueryWrapper<Specification> 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<Object> 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<Object> delAllByIds(@PathVariable List<String> ids) {
|
||||
specificationService.deleteSpecification(ids);
|
||||
return ResultUtil.success();
|
||||
return ResultUtil.data(specificationService.deleteSpecification(ids));
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class FullDiscountManagerController {
|
||||
@ApiOperation(value = "获取满优惠列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<FullDiscount>> getCouponList(FullDiscountSearchParams searchParams, PageVO page) {
|
||||
page.setNotConvert(true);
|
||||
return ResultUtil.data(fullDiscountService.pageFindAll(searchParams, page));
|
||||
}
|
||||
|
||||
|
@ -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<Studio> push(@PathVariable Integer roomId, @PathVariable Integer liveGoodsId) {
|
||||
public ResultMessage<Studio> 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);
|
||||
|
@ -41,7 +41,6 @@ public class CouponStoreController {
|
||||
@GetMapping
|
||||
@ApiOperation(value = "获取优惠券列表")
|
||||
public ResultMessage<IPage<CouponVO>> getCouponList(CouponSearchParams queryParam, PageVO page) {
|
||||
page.setNotConvert(true);
|
||||
String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
|
||||
queryParam.setStoreId(storeId);
|
||||
IPage<CouponVO> coupons = couponService.pageVOFindAll(queryParam, page);
|
||||
|
Loading…
x
Reference in New Issue
Block a user