提交 8ef624a3 authored 作者: hzh's avatar hzh

部分代码生成

上级 e41ef5c9
...@@ -3,20 +3,16 @@ package org.dromara.mall.controller.weishi.app; ...@@ -3,20 +3,16 @@ package org.dromara.mall.controller.weishi.app;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.weishi.model.req.ApplyRequest; import org.dromara.common.weishi.model.req.ApplyRequest;
import org.dromara.common.weishi.model.req.ProposalRequest; import org.dromara.common.weishi.model.req.ProposalRequest;
import org.dromara.common.weishi.model.res.*; import org.dromara.common.weishi.model.res.*;
import org.dromara.common.weishi.service.WeishiService; import org.dromara.common.weishi.service.WeishiService;
import org.dromara.mall.service.weishi.IInsureService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.Duration;
import java.util.List; import java.util.List;
import static org.dromara.mall.enums.weishi.WeishiConstants.WEISHI_TOKEN;
/** /**
* @author hzh * @author hzh
* @date 2025-05-12 * @date 2025-05-12
...@@ -29,6 +25,7 @@ import static org.dromara.mall.enums.weishi.WeishiConstants.WEISHI_TOKEN; ...@@ -29,6 +25,7 @@ import static org.dromara.mall.enums.weishi.WeishiConstants.WEISHI_TOKEN;
public class WeishiController { public class WeishiController {
private final WeishiService weishiService; private final WeishiService weishiService;
private final IInsureService insureService;
/** /**
* 产品列表 * 产品列表
...@@ -128,13 +125,7 @@ public class WeishiController { ...@@ -128,13 +125,7 @@ public class WeishiController {
* @return token * @return token
*/ */
private String getToken() { private String getToken() {
String token = RedisUtils.getCacheObject(WEISHI_TOKEN); return insureService.getToken();
if (StringUtils.isEmpty(token)) {
AuthResponse res = weishiService.authorize();
RedisUtils.setCacheObject(WEISHI_TOKEN, res.getAccess_token(), Duration.ofSeconds(res.getExpires_in().longValue()));
token = res.getAccess_token();
}
return token;
} }
} }
package org.dromara.mall.service.weishi; package org.dromara.mall.service.weishi;
import org.dromara.mall.domain.weishi.Insure;
import org.dromara.mall.controller.weishi.admin.vo.InsureVo;
import org.dromara.mall.controller.weishi.admin.bo.InsureBo;
import org.dromara.common.mybatis.service.IBaseService; import org.dromara.common.mybatis.service.IBaseService;
import org.dromara.mall.controller.weishi.admin.bo.InsureBo;
import org.dromara.mall.controller.weishi.admin.vo.InsureVo;
import org.dromara.mall.domain.weishi.Insure;
/** /**
* 保险订单Service接口 * 保险订单Service接口
...@@ -11,7 +11,13 @@ import org.dromara.common.mybatis.service.IBaseService; ...@@ -11,7 +11,13 @@ import org.dromara.common.mybatis.service.IBaseService;
* @author hzh * @author hzh
* @date 2025-05-13 * @date 2025-05-13
*/ */
public interface IInsureService extends IBaseService<InsureVo, InsureBo, Insure>{ public interface IInsureService extends IBaseService<InsureVo, InsureBo, Insure> {
/**
* 获取token
*
* @return token
*/
String getToken();
} }
...@@ -4,6 +4,9 @@ import org.dromara.common.core.utils.StringUtils; ...@@ -4,6 +4,9 @@ import org.dromara.common.core.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.weishi.model.res.AuthResponse;
import org.dromara.common.weishi.service.WeishiService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.mall.controller.weishi.admin.bo.InsureBo; import org.dromara.mall.controller.weishi.admin.bo.InsureBo;
import org.dromara.mall.controller.weishi.admin.vo.InsureVo; import org.dromara.mall.controller.weishi.admin.vo.InsureVo;
...@@ -13,8 +16,11 @@ import org.dromara.mall.service.weishi.IInsureService; ...@@ -13,8 +16,11 @@ import org.dromara.mall.service.weishi.IInsureService;
import org.dromara.common.mybatis.service.AbstractBaseService; import org.dromara.common.mybatis.service.AbstractBaseService;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.time.Duration;
import java.util.Map; import java.util.Map;
import static org.dromara.mall.enums.weishi.WeishiConstants.WEISHI_TOKEN;
/** /**
* 保险订单Service业务层处理 * 保险订单Service业务层处理
* *
...@@ -61,4 +67,15 @@ public class InsureServiceImpl extends AbstractBaseService<InsureVo, InsureBo, I ...@@ -61,4 +67,15 @@ public class InsureServiceImpl extends AbstractBaseService<InsureVo, InsureBo, I
return lqw; return lqw;
} }
private final WeishiService weishiService;
@Override
public String getToken() {
String token = RedisUtils.getCacheObject(WEISHI_TOKEN);
if (StringUtils.isEmpty(token)) {
AuthResponse res = weishiService.authorize();
RedisUtils.setCacheObject(WEISHI_TOKEN, res.getAccess_token(), Duration.ofSeconds(res.getExpires_in().longValue()));
token = res.getAccess_token();
}
return token;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论