proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/canal/Mall4cloudCanalGlue.java | Mall4cloudCanalGlue | process | class Mall4cloudCanalGlue implements CanalGlue {
private final CanalBinlogEventProcessorFactory canalBinlogEventProcessorFactory;
@Override
public void process(String content) {<FILL_FUNCTION_BODY>}
private Mall4cloudCanalGlue(CanalBinlogEventProcessorFactory canalBinlogEventProcessorFactory) {
... |
CanalBinLogEvent event = (CanalBinLogEvent) SourceAdapterFacade.X.adapt(CanalBinLogEvent.class, content);
ModelTable modelTable = ModelTable.of(event.getDatabase(), event.getTable());
List<BaseCanalBinlogEventProcessor<?>> baseCanalBinlogEventProcessors = this.canalBinlogEventProcessorFactory.g... | 172 | 160 | 332 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/config/CanalGlueAutoConfiguration.java | CanalGlueAutoConfiguration | afterSingletonsInstantiated | class CanalGlueAutoConfiguration implements SmartInitializingSingleton, BeanFactoryAware {
private ConfigurableListableBeanFactory configurableListableBeanFactory;
@Bean
@ConditionalOnMissingBean
public CanalBinlogEventProcessorFactory canalBinlogEventProcessorFactory() {
return Mall4cloudCana... |
ParseResultInterceptorManager parseResultInterceptorManager
= configurableListableBeanFactory.getBean(ParseResultInterceptorManager.class);
ModelTableMetadataManager modelTableMetadataManager
= configurableListableBeanFactory.getBean(ModelTableMetadataManager.class);
... | 458 | 313 | 771 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/controller/app/ProductSearchController.java | ProductSearchController | page | class ProductSearchController {
@Autowired
private ProductSearchManager productSearchManager;
@Autowired
private ShopDetailFeignClient shopDetailFeignClient;
@GetMapping("/page")
@Operation(summary = "商品信息列表-包含spu、品牌、分类、属性和店铺信息" , description = "spu列表-包含spu、品牌、分类、属性和店铺信息")
public ServerRe... |
productSearchDTO.setSpuStatus(StatusEnum.ENABLE.value());
EsPageVO<ProductSearchVO> searchPage = productSearchManager.page(pageDTO, productSearchDTO);
loadShopData(searchPage.getList());
return ServerResponseEntity.success(searchPage);
| 581 | 74 | 655 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/controller/multishop/ProductSearchController.java | ProductSearchController | page | class ProductSearchController {
@Autowired
private ProductSearchManager productSearchManager;
@GetMapping("/page")
@Operation(summary = "商品信息列表" , description = "商品信息列表")
public ServerResponseEntity<EsPageVO<SpuAdminVO>> page(@Valid EsPageDTO pageDTO, ProductSearchDTO productSearchDTO) {<FILL_FUNC... |
Long shopId = AuthUserContext.get().getTenantId();
productSearchDTO.setSearchType(SearchTypeEnum.MULTISHOP.value());
productSearchDTO.setShopId(shopId);
EsPageVO<SpuAdminVO> searchPage = productSearchManager.adminPage(pageDTO, productSearchDTO);
return ServerResponseEntity.succ... | 106 | 98 | 204 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/feign/SearchOrderFeignController.java | SearchOrderFeignController | getOrderPage | class SearchOrderFeignController implements SearchOrderFeignClient {
@Autowired
private OrderSearchManager orderSearchManager;
@Override
public ServerResponseEntity<EsPageVO<EsOrderVO>> getOrderPage(OrderSearchDTO orderSearch) {<FILL_FUNCTION_BODY>}
} |
EsPageDTO pageDTO = new EsPageDTO();
pageDTO.setPageNum(orderSearch.getPageNum());
pageDTO.setPageSize(orderSearch.getPageSize());
return ServerResponseEntity.success(orderSearchManager.pageSearchResult(pageDTO, orderSearch));
| 78 | 77 | 155 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/feign/SearchSpuFeignController.java | SearchSpuFeignController | getSpusBySpuIds | class SearchSpuFeignController implements SearchSpuFeignClient {
@Autowired
private ProductSearchManager productSearchManager;
@Override
public ServerResponseEntity<EsPageVO<ProductSearchVO>> search(EsPageDTO pageDTO, ProductSearchDTO productSearchDTO) {
return ServerResponseEntity.success(pro... |
if (CollUtil.isEmpty(spuIds)) {
return ServerResponseEntity.success(new ArrayList<>());
}
ProductSearchDTO productSearchDTO = new ProductSearchDTO();
productSearchDTO.setSpuIds(spuIds);
List<SpuSearchVO> list = productSearchManager.list(productSearchDTO);
ret... | 446 | 99 | 545 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/BrandCanalListener.java | BrandCanalListener | processUpdateInternal | class BrandCanalListener extends BaseCanalBinlogEventProcessor<BrandBO> {
private static final Logger log = LoggerFactory.getLogger(BrandCanalListener.class);
@Autowired
private ProductUpdateManager productUpdateManager;
@Autowired
private ProductFeignClient productFeignClient;
/**
* 新增品... |
BrandBO beforeData = result.getBeforeData();
if (Objects.isNull(beforeData.getName()) && StrUtil.isBlank(beforeData.getImgUrl())) {
return;
}
BrandBO afterData = result.getAfterData();
EsProductBO esProductBO = new EsProductBO();
if (StrUtil.isNotBlank(before... | 184 | 219 | 403 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/CanalListener.java | CanalListener | onMessage | class CanalListener implements RocketMQListener<String> {
private static final Logger log = LoggerFactory.getLogger(CanalListener.class);
@Autowired
private CanalGlue canalGlue;
@Override
public void onMessage(String message) {<FILL_FUNCTION_BODY>}
} |
Map map = JSON.parseObject(message, Map.class);
String table = map.get("table").toString();
String database = map.get("database").toString();
log.info("canal-database: {}, table: {}, mq message:{}", database, table, message);
canalGlue.process(message);
| 83 | 82 | 165 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/CategoryCanalListener.java | CategoryCanalListener | getSpuIdsByCategoryId | class CategoryCanalListener extends BaseCanalBinlogEventProcessor<CategoryBO> {
private static final Logger log = LoggerFactory.getLogger(CategoryCanalListener.class);
@Autowired
private CategoryFeignClient categoryFeignClient;
@Autowired
private ProductUpdateManager productUpdateManager;
@Aut... |
List<Long> spuIds = new ArrayList<>();
ServerResponseEntity<List<Long>> spuIdResponse = null;
List<Long> categoryIds = new ArrayList<>();
Boolean isSearch = (category.getShopId().equals(Constant.PLATFORM_SHOP_ID) && !category.getLevel().equals(CategoryLevel.THIRD.value())) &&
... | 766 | 312 | 1,078 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/OrderCanalListener.java | OrderCanalListener | processUpdateInternal | class OrderCanalListener extends BaseCanalBinlogEventProcessor<OrderBO> {
private static final Logger log = LoggerFactory.getLogger(OrderCanalListener.class);
@Autowired
private OrderFeignClient orderFeignClient;
@Autowired
private RestHighLevelClient restHighLevelClient;
/**
* 插入订单,此时插... |
Long orderId = result.getPrimaryKey();
ServerResponseEntity<EsOrderBO> esOrderResponse = orderFeignClient.getEsOrder(orderId);
UpdateRequest request = new UpdateRequest(EsIndexEnum.ORDER.value(), String.valueOf(orderId));
request.doc(Json.toJsonString(esOrderResponse.getData()), XConten... | 432 | 180 | 612 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/ShopDetailCanalListener.java | ShopDetailCanalListener | processUpdateInternal | class ShopDetailCanalListener extends BaseCanalBinlogEventProcessor<ShopDetailBO> {
private static final Logger log = LoggerFactory.getLogger(ShopDetailCanalListener.class);
@Autowired
private ProductUpdateManager productUpdateManager;
@Autowired
private ProductFeignClient productFeignClient;
... |
ShopDetailBO beforeData = result.getBeforeData();
if (Objects.isNull(beforeData.getShopName()) && StrUtil.isBlank(beforeData.getShopLogo()) && !Objects.equals(beforeData.getShopStatus(), StatusEnum.ENABLE.value())) {
return;
}
ShopDetailBO afterData = result.getAfterData();
... | 188 | 302 | 490 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/SpuCanalListener.java | SpuCanalListener | exceptionHandler | class SpuCanalListener extends BaseCanalBinlogEventProcessor<SpuBO> {
private static final Logger log = LoggerFactory.getLogger(SpuCanalListener.class);
@Autowired
private ProductFeignClient productFeignClient;
@Autowired
private RestHighLevelClient restHighLevelClient;
/**
* 插入商品,此时插入e... |
return (CanalBinLogEvent event, Throwable throwable) -> {
throw new Mall4cloudException("创建索引异常",throwable);
};
| 610 | 44 | 654 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/listener/SpuExtensionCanalListener.java | SpuExtensionCanalListener | processUpdateInternal | class SpuExtensionCanalListener extends BaseCanalBinlogEventProcessor<SpuExtensionBO> {
private static final Logger log = LoggerFactory.getLogger(SpuExtensionCanalListener.class);
@Autowired
private CacheManagerUtil cacheManagerUtil;
@Autowired
private RestHighLevelClient restHighLevelClient;
... |
// 更新之后的数据
SpuExtensionBO afterData = result.getAfterData();
// 清除缓存
cacheManagerUtil.evictCache(CacheNames.SPU_EXTENSION_KEY, afterData.getSpuId().toString());
UpdateRequest request = new UpdateRequest(EsIndexEnum.PRODUCT.value(), String.valueOf(afterData.getSpuId()));
... | 208 | 298 | 506 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/manager/ProductUpdateManager.java | ProductUpdateManager | esUpdateSpuBySpuIds | class ProductUpdateManager {
@Autowired
private RestHighLevelClient restHighLevelClient;
/**
* 批量更新es中的商品信息
* @param spuIds spuId列表
* @param esProductBO 更新的数据
*/
public void esUpdateSpuBySpuIds(List<Long> spuIds, EsProductBO esProductBO) {<FILL_FUNCTION_BODY>}
} |
String source = Json.toJsonString(esProductBO);
try {
BulkRequest request = new BulkRequest();
// 准备更新的数据
for (Long spuId : spuIds) {
request.add(new UpdateRequest(EsIndexEnum.PRODUCT.value(), String.valueOf(spuId)).doc(source, XContentType.JSON));
... | 111 | 183 | 294 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-search/src/main/java/com/mall4j/cloud/search/vo/SpuAdminVO.java | SpuAdminVO | toString | class SpuAdminVO {
@Schema(description = "商品id" )
private Long spuId;
@Schema(description = "商品名称" )
private String spuName;
@Schema(description = "商品介绍主图" )
private String mainImgUrl;
@Schema(description = "店铺id" )
private Long shopId;
@Schema(description = "店铺名称" )
private ... |
return "SpuAdminVO{" +
"spuId=" + spuId +
", spuName='" + spuName + '\'' +
", mainImgUrl='" + mainImgUrl + '\'' +
", shopId=" + shopId +
", shopName='" + shopName + '\'' +
", priceFee=" + priceFee +
... | 824 | 162 | 986 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/controller/app/UserAddrController.java | UserAddrController | delete | class UserAddrController {
@Autowired
private UserAddrService userAddrService;
private static final Integer MAX_USER_ADDR = 10;
@GetMapping("/list")
@Operation(summary = "获取用户地址列表" , description = "获取用户地址列表")
public ServerResponseEntity<List<UserAddrVO>> list() {
Long userId = AuthU... |
Long userId = AuthUserContext.get().getUserId();
UserAddrVO dbUserAddr = userAddrService.getUserAddrByUserId(addrId, userId);
if (dbUserAddr == null) {
throw new Mall4cloudException("该地址已被删除");
} else if (dbUserAddr.getIsDefault().equals(UserAddr.DEFAULT_ADDR)) {
... | 947 | 144 | 1,091 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/controller/app/UserController.java | UserController | updateUser | class UserController {
@Autowired
private UserService userService;
@GetMapping("/simple_info")
@Operation(summary = "用户头像昵称" , description = "用户头像昵称")
public ServerResponseEntity<UserSimpleInfoVO> getByAddrId() {
Long userId = AuthUserContext.get().getUserId();
UserApiVO userApiVO... |
Long userId = AuthUserContext.get().getUserId();
UserApiVO byUserId = userService.getByUserId(userId);
User user = new User();
user.setUserId(userId);
user.setNickName(Objects.isNull(userApiVO.getNickName())? byUserId.getNickName() : userApiVO.getNickName());
user.setPic... | 413 | 158 | 571 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/controller/app/UserRegisterController.java | UserRegisterController | register | class UserRegisterController {
@Autowired
private UserService userService;
@Autowired
private AccountFeignClient accountFeignClient;
@Operation(summary = "注册")
@PostMapping
public ServerResponseEntity<TokenInfoVO> register(@Valid @RequestBody UserRegisterDTO param) {<FILL_FUNCTION_BODY>}
... |
if (StrUtil.isBlank(param.getNickName())) {
param.setNickName(param.getUserName());
}
// 1. 保存账户信息
Long uid = userService.save(param);
// 2. 登录
UserInfoInTokenBO userInfoInTokenBO = new UserInfoInTokenBO();
userInfoInTokenBO.setUid(uid);
user... | 95 | 185 | 280 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/dto/UserAddrDTO.java | UserAddrDTO | toString | class UserAddrDTO {
private static final long serialVersionUID = 1L;
@Schema(description = "ID" )
private Long addrId;
@Schema(description = "手机" )
private String mobile;
@Schema(description = "是否默认地址 1是" )
private Integer isDefault;
@Schema(description = "收货人" )
@Length(min = 2, ma... |
return "UserAddrDTO{" +
"addrId=" + addrId +
",mobile=" + mobile +
",isDefault=" + isDefault +
",consignee=" + consignee +
",provinceId=" + provinceId +
",province=" + province +
",cityId=" + cityId +
",city=" + city +
",areaId=" + areaId +
",area=" + area +
",postCode=" +... | 917 | 177 | 1,094 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/dto/UserDTO.java | UserDTO | toString | class UserDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "ID" )
private Long userId;
@Schema(description = "用户昵称" )
private String nickName;
@Schema(description = "头像图片路径" )
private String pic;
@Schema(description = "状态 1 正常 0 无效" )
private Integer st... |
return "UserDTO{" +
"userId=" + userId +
",nickName=" + nickName +
",pic=" + pic +
",status=" + status +
'}';
| 295 | 61 | 356 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/dto/UserRegisterDTO.java | UserRegisterDTO | toString | class UserRegisterDTO {
@NotBlank
@Schema(description = "密码" )
private String password;
@Schema(description = "头像" )
private String img;
@Schema(description = "昵称" )
private String nickName;
@NotBlank
@Schema(description = "用户名" )
private String userName;
@Schema(description = "当账户未绑定时,临时的uid" )
privat... |
return "UserRegisterDTO{" +
"password='" + password + '\'' +
", img='" + img + '\'' +
", nickName='" + nickName + '\'' +
", userName='" + userName + '\'' +
", tempUid='" + tempUid + '\'' +
", userId=" + userId +
'}';
| 410 | 102 | 512 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/model/Area.java | Area | toString | class Area extends BaseModel implements Serializable{
private static final long serialVersionUID = 1L;
/**
*
*/
private Long areaId;
/**
* 地址
*/
private String areaName;
/**
* 上级地址
*/
private Long parentId;
/**
* 等级(从1开始)
*/
private Integer... |
return "Area{" +
"areaId=" + areaId +
",areaName=" + areaName +
",parentId=" + parentId +
",level=" + level +
",createTime=" + createTime +
",updateTime=" + updateTime +
'}';
| 293 | 84 | 377 | <methods>public non-sealed void <init>() ,public java.util.Date getCreateTime() ,public java.util.Date getUpdateTime() ,public void setCreateTime(java.util.Date) ,public void setUpdateTime(java.util.Date) ,public java.lang.String toString() <variables>protected java.util.Date createTime,protected java.util.Date updateT... |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/model/User.java | User | toString | class User extends BaseModel implements Serializable{
private static final long serialVersionUID = 1L;
public static final String DISTRIBUTED_ID_KEY = "mall4cloud-user";
/**
* ID
*/
private Long userId;
/**
* 用户昵称
*/
private String nickName;
/**
* 头像图片路径
*/
... |
return "User{" +
"userId=" + userId +
",createTime=" + createTime +
",updateTime=" + updateTime +
",nickName=" + nickName +
",pic=" + pic +
",status=" + status +
'}';
| 323 | 83 | 406 | <methods>public non-sealed void <init>() ,public java.util.Date getCreateTime() ,public java.util.Date getUpdateTime() ,public void setCreateTime(java.util.Date) ,public void setUpdateTime(java.util.Date) ,public java.lang.String toString() <variables>protected java.util.Date createTime,protected java.util.Date updateT... |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/model/UserAddr.java | UserAddr | toString | class UserAddr extends BaseModel implements Serializable{
private static final long serialVersionUID = 1L;
public static final Integer DEFAULT_ADDR = 1;
public static final Integer NOT_DEFAULT_ADDR = 0;
/**
* ID
*/
private Long addrId;
/**
* 用户ID
*/
private Long userId;
... |
return "UserAddr{" +
"addrId=" + addrId +
",createTime=" + createTime +
",updateTime=" + updateTime +
",userId=" + userId +
",mobile=" + mobile +
",isDefault=" + isDefault +
",consignee=" + consignee +
",provinceId=" + provinceId +
",province=" + province +
",cityId=" + cityId... | 976 | 211 | 1,187 | <methods>public non-sealed void <init>() ,public java.util.Date getCreateTime() ,public java.util.Date getUpdateTime() ,public void setCreateTime(java.util.Date) ,public void setUpdateTime(java.util.Date) ,public java.lang.String toString() <variables>protected java.util.Date createTime,protected java.util.Date updateT... |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/service/impl/AreaServiceImpl.java | AreaServiceImpl | getAreaListInfo | class AreaServiceImpl implements AreaService {
@Autowired
private AreaMapper areaMapper;
@Override
public List<AreaVO> list() {
return areaMapper.list();
}
@Override
@Cacheable(cacheNames = CacheNames.AREA_INFO_KEY, key = "'areaList'", sync = true)
public List<AreaVO> getAreaL... |
List<AreaVO> areaList = areaMapper.getAreaListInfo();
for (AreaVO province:areaList){
List<Long> cityAll = new ArrayList<>();
for (AreaVO city:province.getAreas()){
cityAll.add(city.getAreaId());
List<Long> areaAll = new ArrayList<>();
... | 569 | 152 | 721 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/service/impl/UserAddrServiceImpl.java | UserAddrServiceImpl | getUserAddrByUserId | class UserAddrServiceImpl implements UserAddrService {
@Autowired
private UserAddrMapper userAddrMapper;
@Override
public List<UserAddrVO> list(Long userId) {
return userAddrMapper.list(userId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(UserAdd... |
// 获取用户默认地址
if (addrId == 0) {
return userAddrMapper.getUserDefaultAddrByUserId(userId);
}
return userAddrMapper.getByAddrId(addrId,userId);
| 415 | 61 | 476 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/service/impl/UserServiceImpl.java | UserServiceImpl | save | class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Autowired
private AccountFeignClient accountFeignClient;
@Autowired
private SegmentFeignClient segmentFeignClient;
@Override
public PageVO<UserApiVO> page(PageDTO pageDTO) {
return PageUt... |
this.checkRegisterInfo(param);
ServerResponseEntity<Long> segmentIdResponse = segmentFeignClient.getSegmentId(User.DISTRIBUTED_ID_KEY);
if (!segmentIdResponse.isSuccess()) {
throw new Mall4cloudException(ResponseEnum.EXCEPTION);
}
Long userId = segmentIdResponse.get... | 485 | 398 | 883 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/vo/UserSimpleInfoVO.java | UserSimpleInfoVO | toString | class UserSimpleInfoVO {
@Schema(description = "用户昵称" ,requiredMode = Schema.RequiredMode.REQUIRED)
private String nickName;
@Schema(description = "用户头像" ,requiredMode = Schema.RequiredMode.REQUIRED)
private String pic;
public String getNickName() {
return nickName;
}
public void... |
return "UserCenterInfoVO{" +
"nickName='" + nickName + '\'' +
", pic='" + pic + '\'' +
'}';
| 193 | 45 | 238 | <no_super_class> |
gz-yami_mall4cloud | mall4cloud/mall4cloud-user/src/main/java/com/mall4j/cloud/user/vo/UserVO.java | UserVO | toString | class UserVO extends BaseVO{
private static final long serialVersionUID = 1L;
@Schema(description = "ID" )
private Long userId;
@Schema(description = "用户昵称" )
private String nickName;
@Schema(description = "头像图片路径" )
private String pic;
@Schema(description = "状态 1 正常 0 无效" )
priv... |
return "UserApiVO{" +
"userId=" + userId +
",createTime=" + createTime +
",updateTime=" + updateTime +
",nickName=" + nickName +
",pic=" + pic +
",status=" + status +
'}';
| 387 | 85 | 472 | <methods>public non-sealed void <init>() ,public java.util.Date getCreateTime() ,public java.util.Date getUpdateTime() ,public void setCreateTime(java.util.Date) ,public void setUpdateTime(java.util.Date) ,public java.lang.String toString() <variables>protected java.util.Date createTime,protected java.util.Date updateT... |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/config/SwaggerConfiguration.java | SwaggerConfiguration | springShopOpenApi | class SwaggerConfiguration {
@Bean
public GroupedOpenApi baseRestApi() {
return GroupedOpenApi.builder()
.group("接口文档")
.packagesToScan("com.yami").build();
}
@Bean
public OpenAPI springShopOpenApi() {<FILL_FUNCTION_BODY>}
} |
return new OpenAPI()
.info(new Info().title("Mall4j接口文档")
.description("Mall4j接口文档,openapi3.0 接口,用于前端对接")
.version("v0.0.1")
.license(new License().name("使用请遵守AGPL3.0授权协议").url("https://www.mall4j.com")));
| 86 | 107 | 193 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/AdminLoginController.java | AdminLoginController | login | class AdminLoginController {
@Autowired
private TokenStore tokenStore;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysMenuService sysMenuService;
@Autowired
private PasswordCheckManager passwordCheckManager;
@Autowired
private CaptchaService captchaS... |
// 登陆后台登录需要再校验一遍验证码
CaptchaVO captchaVO = new CaptchaVO();
captchaVO.setCaptchaVerification(captchaAuthenticationDTO.getCaptchaVerification());
ResponseModel response = captchaService.verification(captchaVO);
if (!response.isSuccess()) {
return ServerResponseEntity.s... | 426 | 514 | 940 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/AreaController.java | AreaController | save | class AreaController {
@Autowired
private AreaService areaService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:area:page')")
public ServerResponseEntity<IPage<Area>> page(Area area,PageParam<Area> page) {
IPage<Area> sysUserPage = areaService.p... |
if (area.getParentId() != null) {
Area parentArea = areaService.getById(area.getParentId());
area.setLevel(parentArea.getLevel() + 1);
areaService.removeAreaCacheByParentId(area.getParentId());
}
areaService.save(area);
return ServerResponseEntity.suc... | 1,061 | 91 | 1,152 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/AttributeController.java | AttributeController | update | class AttributeController {
@Autowired
private ProdPropService prodPropService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:attribute:page')")
public ServerResponseEntity<IPage<ProdProp>> page(ProdProp prodProp,PageParam<ProdProp> page){
prodProp.setRule(ProdPro... |
ProdProp dbProdProp = prodPropService.getById(prodProp.getPropId());
if (!Objects.equals(dbProdProp.getShopId(), SecurityUtils.getSysUser().getShopId())) {
throw new YamiShopBindException("没有权限获取该商品规格信息");
}
prodProp.setRule(ProdPropRule.ATTRIBUTE.value());
prodProp.setShopId(SecurityUtils.getSysUser().ge... | 574 | 150 | 724 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/BrandController.java | BrandController | page | class BrandController {
@Autowired
private BrandService brandService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:brand:page')")
public ServerResponseEntity<IPage<Brand>> page(Brand brand,PageParam<Brand> page) {<FILL_FUNCTION_BODY>}
/**
* 获取... |
IPage<Brand> brands = brandService.page(page,
new LambdaQueryWrapper<Brand>()
.like(StrUtil.isNotBlank(brand.getBrandName()), Brand::getBrandName, brand.getBrandName()).orderByAsc(Brand::getFirstChar));
return ServerResponseEntity.success(brands);
| 571 | 90 | 661 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/CategoryController.java | CategoryController | delete | class CategoryController {
@Autowired
private CategoryService categoryService;
/**
* 获取菜单页面的表
* @return
*/
@GetMapping("/table")
@PreAuthorize("@pms.hasPermission('prod:category:page')")
public ServerResponseEntity<List<Category>> table(){
List<Category> categoryMenuList = categoryService.tableCategory(... |
if (categoryService.count(new LambdaQueryWrapper<Category>().eq(Category::getParentId,categoryId)) >0) {
return ServerResponseEntity.showFailMsg("请删除子分类,再删除该分类");
}
categoryService.deleteCategory(categoryId);
return ServerResponseEntity.success();
| 1,118 | 83 | 1,201 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/FileController.java | FileController | uploadElementFile | class FileController {
@Autowired
private AttachFileService attachFileService;
@Autowired
private Qiniu qiniu;
@Autowired
private ImgUploadUtil imgUploadUtil;
@PostMapping("/upload/element")
public ServerResponseEntity<String> uploadElementFile(@RequestParam("file") MultipartFile file) throws IOException{<F... |
if(file.isEmpty()){
return ServerResponseEntity.success();
}
String fileName = attachFileService.uploadFile(file);
return ServerResponseEntity.success(fileName);
| 263 | 51 | 314 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/HotSearchController.java | HotSearchController | page | class HotSearchController {
@Autowired
private HotSearchService hotSearchService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:hotSearch:page')")
public ServerResponseEntity<IPage<HotSearch>> page(HotSearch hotSearch,PageParam<HotSearch> page){<FILL_FUNCTION_BODY>}
... |
IPage<HotSearch> hotSearchs = hotSearchService.page(page,new LambdaQueryWrapper<HotSearch>()
.eq(HotSearch::getShopId, SecurityUtils.getSysUser().getShopId())
.like(StrUtil.isNotBlank(hotSearch.getContent()), HotSearch::getContent,hotSearch.getContent())
.like(StrUtil.isNotBlank(hotSearch.getTitle()), HotS... | 564 | 179 | 743 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/IndexImgController.java | IndexImgController | page | class IndexImgController {
@Autowired
private IndexImgService indexImgService;
@Autowired
private ProductService productService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:indexImg:page')")
public ServerResponseEntity<IPage<IndexImg>> page(I... |
IPage<IndexImg> indexImgPage = indexImgService.page(page,
new LambdaQueryWrapper<IndexImg>()
.eq(indexImg.getStatus() != null, IndexImg::getStatus, indexImg.getStatus())
.orderByAsc(IndexImg::getSeq));
return ServerResponseEntity.success(i... | 922 | 99 | 1,021 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/MessageController.java | MessageController | page | class MessageController {
@Autowired
private MessageService messageService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:message:page')")
public ServerResponseEntity<IPage<Message>> page(Message message,PageParam<Message> page) {<FILL_FUNCTION_BODY>}
... |
IPage<Message> messages = messageService.page(page, new LambdaQueryWrapper<Message>()
.like(StrUtil.isNotBlank(message.getUserName()), Message::getUserName, message.getUserName())
.eq(message.getStatus() != null, Message::getStatus, message.getStatus()));
return ServerRe... | 686 | 94 | 780 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/NoticeController.java | NoticeController | updateById | class NoticeController {
private final NoticeService noticeService;
/**
* 分页查询
*
* @param page 分页对象
* @param notice 公告管理
* @return 分页数据
*/
@GetMapping("/page")
public ServerResponseEntity<IPage<Notice>> getNoticePage(PageParam<Notice> page, Notice notice) {
IPag... |
Notice oldNotice = noticeService.getById(notice.getId());
if (oldNotice.getStatus() == 0 && notice.getStatus() == 1) {
notice.setPublishTime(new Date());
}
notice.setUpdateTime(new Date());
noticeService.removeNoticeList();
noticeService.removeNoticeById(noti... | 751 | 110 | 861 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/PickAddrController.java | PickAddrController | update | class PickAddrController {
@Autowired
private PickAddrService pickAddrService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('shop:pickAddr:page')")
public ServerResponseEntity<IPage<PickAddr>> page(PickAddr pickAddr,PageParam<PickAddr> page){
IPage<PickAddr> pickAddrs = pi... |
PickAddr dbPickAddr = pickAddrService.getById(pickAddr.getAddrId());
if (!Objects.equals(dbPickAddr.getShopId(),SecurityUtils.getSysUser().getShopId())) {
throw new YamiShopBindException(ResponseEnum.UNAUTHORIZED);
}
pickAddrService.updateById(pickAddr);
return ServerResponseEntity.success();
| 559 | 107 | 666 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/ProdTagController.java | ProdTagController | removeById | class ProdTagController {
@Autowired
private ProdTagService prodTagService;
/**
* 分页查询
*
* @param page 分页对象
* @param prodTag 商品分组标签
* @return 分页数据
*/
@GetMapping("/page")
public ServerResponseEntity<IPage<ProdTag>> getProdTagPage(PageParam<ProdTag> page, ProdTag pr... |
ProdTag prodTag = prodTagService.getById(id);
if (prodTag.getIsDefault() != 0) {
throw new YamiShopBindException("默认标签不能删除");
}
prodTagService.removeProdTag();
return ServerResponseEntity.success(prodTagService.removeById(id));
| 968 | 86 | 1,054 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/ProductController.java | ProductController | checkParam | class ProductController {
@Autowired
private ProductService productService;
@Autowired
private SkuService skuService;
@Autowired
private ProdTagReferenceService prodTagReferenceService;
@Autowired
private BasketService basketService;
/**
* 分页获取商品信息
*/
@GetMapping(... |
if (CollectionUtil.isEmpty(productParam.getTagList())) {
throw new YamiShopBindException("请选择产品分组");
}
Product.DeliveryModeVO deliveryMode = productParam.getDeliveryModeVo();
boolean hasDeliverMode = deliveryMode != null
&& (deliveryMode.getHasShopDelivery()... | 1,753 | 232 | 1,985 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/ShopDetailController.java | ShopDetailController | listShopName | class ShopDetailController {
@Autowired
private ShopDetailService shopDetailService;
/**
* 修改分销开关
*/
@PutMapping("/isDistribution")
public ServerResponseEntity<Void> updateIsDistribution(@RequestParam Integer isDistribution){
ShopDetail shopDetail=new ShopDetail();
shopDetail.setShopId(SecurityUti... |
List<ShopDetail> list = shopDetailService.list().stream().map((dbShopDetail) ->{
ShopDetail shopDetail = new ShopDetail();
shopDetail.setShopId(dbShopDetail.getShopId());
shopDetail.setShopName(dbShopDetail.getShopName());
return shopDetail;
}).collect(Collectors.toList());
return ServerResponseEntit... | 1,127 | 107 | 1,234 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/SpecController.java | SpecController | page | class SpecController {
@Autowired
private ProdPropService prodPropService;
@Autowired
private ProdPropValueService prodPropValueService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('prod:spec:page')")
public ServerResponseEntity<IPage<ProdProp>> page(... |
prodProp.setRule(ProdPropRule.SPEC.value());
prodProp.setShopId(SecurityUtils.getSysUser().getShopId());
IPage<ProdProp> list = prodPropService.pagePropAndValue(prodProp, page);
return ServerResponseEntity.success(list);
| 953 | 79 | 1,032 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/TransportController.java | TransportController | save | class TransportController {
@Autowired
private TransportService transportService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('shop:transport:page')")
public ServerResponseEntity<IPage<Transport>> page(Transport transport,PageParam<Transport> page) {
... |
Long shopId = SecurityUtils.getSysUser().getShopId();
transport.setShopId(shopId);
Date createTime = new Date();
transport.setCreateTime(createTime);
transportService.insertTransportAndTransfee(transport);
return ServerResponseEntity.success();
| 680 | 75 | 755 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/controller/UserController.java | UserController | page | class UserController {
@Autowired
private UserService userService;
/**
* 分页获取
*/
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:user:page')")
public ServerResponseEntity<IPage<User>> page(User user,PageParam<User> page) {<FILL_FUNCTION_BODY>}
/**
* 获取信息
... |
IPage<User> userPage = userService.page(page, new LambdaQueryWrapper<User>()
.like(StrUtil.isNotBlank(user.getNickName()), User::getNickName, user.getNickName())
.eq(user.getStatus() != null, User::getStatus, user.getStatus()));
for (User userResult : userPage.getRecords... | 434 | 149 | 583 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-admin/src/main/java/com/yami/shop/admin/task/OrderTask.java | OrderTask | confirmOrder | class OrderTask {
private static final Logger logger = LoggerFactory.getLogger(OrderTask.class);
@Autowired
private OrderService orderService;
@Autowired
private ProductService productService;
@Autowired
private SkuService skuService;
@XxlJob("cancelOrder")
public void cancelOrde... |
Date now = new Date();
logger.info("系统自动确认收货订单。。。");
// 获取15天之前未支付的订单
List<Order> orders = orderService.listOrderAndOrderItems(OrderStatus.CONSIGNMENT.value(),DateUtil.offsetDay(now, -15));
if (CollectionUtil.isEmpty(orders)) {
return;
}
orderService.... | 348 | 208 | 556 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/config/SwaggerConfiguration.java | SwaggerConfiguration | springShopOpenApi | class SwaggerConfiguration {
@Bean
public GroupedOpenApi createRestApi() {
return GroupedOpenApi.builder()
.group("接口文档")
.packagesToScan("com.yami.shop.api").build();
}
@Bean
public OpenAPI springShopOpenApi() {<FILL_FUNCTION_BODY>}
} |
return new OpenAPI()
.info(new Info().title("Mall4j接口文档")
.description("Mall4j接口文档,openapi3.0 接口,用于前端对接")
.version("v0.0.1")
.license(new License().name("使用请遵守AGPL3.0授权协议").url("https://www.mall4j.com")));
| 90 | 107 | 197 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/AddrController.java | AddrController | dvyList | class AddrController {
@Autowired
private UserAddrService userAddrService;
/**
* 选择订单配送地址
*/
@GetMapping("/list")
@Operation(summary = "用户地址列表" , description = "获取用户的所有地址信息")
public ServerResponseEntity<List<UserAddrDto>> dvyList() {<FILL_FUNCTION_BODY>}
@PostMapping("/addAddr")... |
String userId = SecurityUtils.getUser().getUserId();
List<UserAddr> userAddrs = userAddrService.list(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId).orderByDesc(UserAddr::getCommonAddr).orderByDesc(UserAddr::getUpdateTime));
return ServerResponseEntity.success(BeanUtil.copyTo... | 1,360 | 107 | 1,467 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/CategoryController.java | CategoryController | categoryInfo | class CategoryController {
@Autowired
private CategoryService categoryService;
/**
* 分类信息列表接口
*/
@GetMapping("/categoryInfo")
@Operation(summary = "分类信息列表" , description = "获取所有的产品分类信息,顶级分类的parentId为0,默认为顶级分类")
@Parameter(name = "parentId", description = "分类ID", required = false)
... |
List<Category> categories = categoryService.listByParentId(parentId);
List<CategoryDto> categoryDtos = BeanUtil.copyToList(categories, CategoryDto.class);
return ServerResponseEntity.success(categoryDtos);
| 158 | 66 | 224 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/DeliveryController.java | DeliveryController | checkDelivery | class DeliveryController {
@Autowired
private DeliveryService deliveryService;
@Autowired
private OrderService orderService;
/**
* 查看物流接口
*/
@GetMapping("/check")
@Operation(summary = "查看物流" , description = "根据订单号查看物流")
@Parameter(name = "orderNumber", description = "订单号" , required = tr... |
Order order = orderService.getOrderByOrderNumber(orderNumber);
Delivery delivery = deliveryService.getById(order.getDvyId());
String url = delivery.getQueryUrl().replace("{dvyFlowId}", order.getDvyFlowId());
String deliveryJson = HttpUtil.get(url);
DeliveryDto deliveryDto = Json.parseObject(... | 135 | 188 | 323 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/IndexImgController.java | IndexImgController | indexImgs | class IndexImgController {
@Autowired
private IndexImgService indexImgService;
/**
* 首页轮播图接口
*/
@GetMapping("/indexImgs")
@Operation(summary = "首页轮播图" , description = "获取首页轮播图列表信息")
public ServerResponseEntity<List<IndexImgDto>> indexImgs() {<FILL_FUNCTION_BODY>}
} |
List<IndexImg> indexImgList = indexImgService.listIndexImg();
List<IndexImgDto> indexImgDtos = BeanUtil.copyToList(indexImgList, IndexImgDto.class);
return ServerResponseEntity.success(indexImgDtos);
| 116 | 80 | 196 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/NoticeController.java | NoticeController | getTopNoticeList | class NoticeController {
private NoticeService noticeService;
/**
* 置顶公告列表接口
*/
@GetMapping("/topNoticeList")
@Operation(summary = "置顶公告列表信息" , description = "获取所有置顶公告列表信息")
public ServerResponseEntity<List<NoticeDto>> getTopNoticeList() {<FILL_FUNCTION_BODY>}
/**
* 获取公告详... |
List<Notice> noticeList = noticeService.listNotice();
List<NoticeDto> noticeDtoList = BeanUtil.copyToList(noticeList, NoticeDto.class);
return ServerResponseEntity.success(noticeDtoList);
| 340 | 64 | 404 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/OrderController.java | OrderController | submitOrders | class OrderController {
@Autowired
private OrderService orderService;
@Autowired
private SkuService skuService;
@Autowired
private ProductService productService;
@Autowired
private UserAddrService userAddrService;
@Autowired
private BasketService basketService;
@Autowired
... |
String userId = SecurityUtils.getUser().getUserId();
ShopCartOrderMergerDto mergerOrder = orderService.getConfirmOrderCache(userId);
if (mergerOrder == null) {
throw new YamiShopBindException("订单已过期,请重新下单");
}
List<OrderShopParam> orderShopParams = submitOrderParam.... | 1,197 | 615 | 1,812 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java | PayController | normalPay | class PayController {
private final PayService payService;
/**
* 支付接口
*/
@PostMapping("/pay")
@Operation(summary = "根据订单号进行支付" , description = "根据订单号进行支付")
public ServerResponseEntity<Void> pay(@RequestBody PayParam payParam) {
YamiUser user = SecurityUtils.getUser();
Str... |
YamiUser user = SecurityUtils.getUser();
String userId = user.getUserId();
PayInfoDto pay = payService.pay(userId, payParam);
// 根据内部订单号更新order settlement
payService.paySuccess(pay.getPayNo(), "");
return ServerResponseEntity.success(true);
| 243 | 89 | 332 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/ProdCommController.java | ProdCommController | saveProdCommPage | class ProdCommController {
private final ProdCommService prodCommService;
@GetMapping("/prodCommData")
@Operation(summary = "返回商品评论数据(好评率 好评数量 中评数 差评数)" , description = "根据商品id获取")
public ServerResponseEntity<ProdCommDataDto> getProdCommData(Long prodId) {
return ServerResponseEntity.success(... |
ProdComm prodComm = new ProdComm();
prodComm.setProdId(prodCommParam.getProdId());
prodComm.setOrderItemId(prodCommParam.getOrderItemId());
prodComm.setUserId(SecurityUtils.getUser().getUserId());
prodComm.setScore(prodCommParam.getScore());
prodComm.setContent(prodCommP... | 546 | 200 | 746 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/ProdController.java | ProdController | prodInfo | class ProdController {
@Autowired
private ProductService prodService;
@Autowired
private SkuService skuService;
@Autowired
private TransportService transportService;
@GetMapping("/pageProd")
@Operation(summary = "通过分类id商品列表信息" , description = "根据分类ID获取该分类下所有的商品列表信息")
@Parameter... |
Product product = prodService.getProductByProdId(prodId);
if (product == null) {
return ServerResponseEntity.success();
}
List<Sku> skuList = skuService.listByProdId(prodId);
// 启用的sku列表
List<Sku> useSkuList = skuList.stream().filter(sku -> sku.getStatus() ... | 806 | 321 | 1,127 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/ProdTagController.java | ProdTagController | getProdTagList | class ProdTagController {
private ProdTagService prodTagService;
/**
* 商品分组标签列表接口
*/
@GetMapping("/prodTagList")
@Operation(summary = "商品分组标签列表" , description = "获取所有的商品分组列表")
public ServerResponseEntity<List<ProdTagDto>> getProdTagList() {<FILL_FUNCTION_BODY>}
} |
List<ProdTag> prodTagList = prodTagService.listProdTag();
List<ProdTagDto> prodTagDtoList = BeanUtil.copyToList(prodTagList, ProdTagDto.class);
return ServerResponseEntity.success(prodTagDtoList);
| 117 | 75 | 192 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/SearchController.java | SearchController | getListResponseEntity | class SearchController {
private final HotSearchService hotSearchService;
private final ProductService productService;
@GetMapping("/hotSearchByShopId")
@Operation(summary = "查看店铺热搜" , description = "根据店铺id,热搜数量获取热搜")
@Parameters({
@Parameter(name = "shopId", description = "店铺id" , re... |
if(sort == null || sort == 0){
Collections.shuffle(list);
}
if(!CollectionUtil.isNotEmpty(list) || list.size()< number){
return ServerResponseEntity.success(list);
}
return ServerResponseEntity.success(list.subList(0, number));
| 672 | 81 | 753 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/SkuController.java | SkuController | getSkuListByProdId | class SkuController {
private final SkuService skuService;
@GetMapping("/getSkuList")
@Operation(summary = "通过prodId获取商品全部规格列表" , description = "通过prodId获取商品全部规格列表")
@Parameter(name = "prodId", description = "商品id" )
public ServerResponseEntity<List<SkuDto>> getSkuListByProdId(Long prodId) {... |
List<Sku> skus = skuService.list(new LambdaQueryWrapper<Sku>()
.eq(Sku::getStatus, 1)
.eq(Sku::getIsDelete, 0)
.eq(Sku::getProdId, prodId)
);
List<SkuDto> skuDtoList = BeanUtil.copyToList(skus, SkuDto.class);
return ServerResponseEntity.su... | 127 | 125 | 252 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/SmsController.java | SmsController | audit | class SmsController {
@Autowired
private SmsLogService smsLogService;
/**
* 发送验证码接口
*/
@PostMapping("/send")
@Operation(summary = "发送验证码" , description = "用户的发送验证码")
public ServerResponseEntity<Void> audit(@RequestBody SendSmsParam sendSmsParam) {<FILL_FUNCTION_BODY>}
} |
String userId = SecurityUtils.getUser().getUserId();
smsLogService.sendSms(SmsType.VALID, userId, sendSmsParam.getMobile(),Maps.newHashMap());
return ServerResponseEntity.success();
| 111 | 65 | 176 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserCollectionController.java | UserCollectionController | addOrCancel | class UserCollectionController {
private final UserCollectionService userCollectionService;
private final ProductService productService;
@GetMapping("/page")
@Operation(summary = "分页返回收藏数据" , description = "根据用户id获取")
public ServerResponseEntity<IPage<UserCollectionDto>> getUserCollectionDtoPageB... |
if (Objects.isNull(productService.getProductByProdId(prodId))) {
throw new YamiShopBindException("该商品不存在");
}
String userId = SecurityUtils.getUser().getUserId();
if (userCollectionService.count(new LambdaQueryWrapper<UserCollection>()
.eq(UserCollection::get... | 656 | 240 | 896 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserController.java | UserController | userInfo | class UserController {
private final UserService userService;
/**
* 查看用户接口
*/
@GetMapping("/userInfo")
@Operation(summary = "查看用户信息" , description = "根据用户ID(userId)获取用户信息")
public ServerResponseEntity<UserDto> userInfo() {<FILL_FUNCTION_BODY>}
@PutMapping("/setUserInfo")
@Operation(summary = "设置用户信息" , ... |
String userId = SecurityUtils.getUser().getUserId();
User user = userService.getById(userId);
UserDto userDto = BeanUtil.copyProperties(user, UserDto.class);
return ServerResponseEntity.success(userDto);
| 242 | 72 | 314 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserRegisterController.java | UserRegisterController | updatePwd | class UserRegisterController {
private final UserService userService;
private final PasswordEncoder passwordEncoder;
private final TokenStore tokenStore;
private final PasswordManager passwordManager;
@PostMapping("/register")
@Operation(summary = "注册" , description = "用户注册或绑定手机号接口")
pu... |
User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getNickName, userPwdUpdateParam.getNickName()));
if (user == null) {
// 无法获取用户信息
throw new YamiShopBindException("无法获取用户信息");
}
String decryptPassword = passwordManager.decryptPassword(userPwd... | 591 | 258 | 849 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/listener/ConfirmOrderListener.java | ConfirmOrderListener | defaultConfirmOrderEvent | class ConfirmOrderListener {
private final UserAddrService userAddrService;
private final TransportManagerService transportManagerService;
private final ProductService productService;
private final SkuService skuService;
/**
* 计算订单金额
*/
@EventListener(ConfirmOrderEvent.class)
... |
ShopCartOrderDto shopCartOrderDto = event.getShopCartOrderDto();
OrderParam orderParam = event.getOrderParam();
String userId = SecurityUtils.getUser().getUserId();
// 订单的地址信息
UserAddr userAddr = userAddrService.getUserAddrByUserId(orderParam.getAddrId(), userId);
... | 123 | 511 | 634 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-api/src/main/java/com/yami/shop/api/listener/ShopCartListener.java | ShopCartListener | defaultShopCartEvent | class ShopCartListener {
/**
* 将店铺下的所有商品归属到该店铺的购物车当中
* @param event#getShopCart() 购物车
* @param event#shopCartItemDtoList 该购物车的商品
* @return 是否继续组装
*/
@EventListener(ShopCartEvent.class)
@Order(ShopCartEventOrder.DEFAULT)
public void defaultShopCartEvent(ShopCartEvent event) {<FI... |
ShopCartDto shopCart = event.getShopCartDto();
List<ShopCartItemDto> shopCartItemDtoList = event.getShopCartItemDtoList();
// 对数据进行组装
List<ShopCartItemDiscountDto> shopCartItemDiscountDtoList = Lists.newArrayList();
ShopCartItemDiscountDto shopCartItemDiscountDto = new ShopCartI... | 128 | 176 | 304 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-bean/src/main/java/com/yami/shop/bean/SmsInfoContext.java | SmsInfoContext | put | class SmsInfoContext {
/** The request holder. */
private static ThreadLocal<List<SmsInfoBo>> smsInfoHolder = new ThreadLocal<List<SmsInfoBo>>();
public static List<SmsInfoBo> get(){
List<SmsInfoBo> list = smsInfoHolder.get();
if (CollectionUtil.isEmpty(list)) {
return new ArrayList<>();
}
return smsIn... |
List<SmsInfoBo> smsInfoBos = smsInfoHolder.get();
if (CollectionUtil.isEmpty(smsInfoBos)) {
smsInfoBos = new ArrayList<>();
}
smsInfoBos.add(smsInfoBo);
smsInfoHolder.set(smsInfoBos);
| 220 | 87 | 307 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/aspect/RedisLockAspect.java | RedisLockAspect | around | class RedisLockAspect {
@Autowired
private RedissonClient redissonClient;
private static final String REDISSON_LOCK_PREFIX = "redisson_lock:";
@Around("@annotation(redisLock)")
public Object around(ProceedingJoinPoint joinPoint, RedisLock redisLock) throws Throwable {<FILL_FUNCTION_BODY>}
/**
* 将spel表达式转换为字... |
String spel = redisLock.key();
String lockName = redisLock.lockName();
RLock rLock = redissonClient.getLock(getRedisKey(joinPoint,lockName,spel));
rLock.lock(redisLock.expire(),redisLock.timeUnit());
Object result = null;
try {
//执行方法
result = joinPoint.proceed();
} finally {
rLock.unlock();... | 269 | 133 | 402 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/config/DefaultExceptionHandlerConfig.java | DefaultExceptionHandlerConfig | unauthorizedExceptionHandler | class DefaultExceptionHandlerConfig {
@ExceptionHandler({ MethodArgumentNotValidException.class, BindException.class })
public ResponseEntity<ServerResponseEntity<List<String>>> methodArgumentNotValidExceptionHandler(Exception e) {
log.error("methodArgumentNotValidExceptionHandler", e);
List<Fi... |
log.error("mall4jExceptionHandler", e);
ServerResponseEntity<?> serverResponseEntity = e.getServerResponseEntity();
if (serverResponseEntity!=null) {
return ResponseEntity.status(HttpStatus.OK).body(serverResponseEntity);
}
// 失败返回消息 状态码固定为直接显示消息的状态码
return ... | 471 | 121 | 592 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/config/FileUploadConfig.java | FileUploadConfig | qiniuConfig | class FileUploadConfig {
@Autowired
private Qiniu qiniu;
/**
* 根据配置文件选择机房
*/
@Bean
public com.qiniu.storage.Configuration qiniuConfig() {<FILL_FUNCTION_BODY>}
/**
* 构建一个七牛上传工具实例
*/
@Bean
public UploadManager uploadManager() {
return new UploadManager(qiniuConfig... |
Zone zone = null;
if (Objects.equals(qiniu.getZone(), QiniuZone.HUA_BEI)) {
zone = Zone.huabei();
} else if (Objects.equals(qiniu.getZone(), QiniuZone.HUA_DONG)) {
zone = Zone.huadong();
} else if (Objects.equals(qiniu.getZone(), QiniuZone.HUA_NAN)) {
... | 232 | 226 | 458 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/config/MybatisPlusConfig.java | MybatisPlusConfig | optimisticLockerInterceptor | class MybatisPlusConfig {
/**
* 逻辑删除插件
* @return LogicSqlInjector
*/
@Bean
@ConditionalOnMissingBean
public ISqlInjector sqlInjector() {
return new DefaultSqlInjector();
}
/**
* mybatis-plus插件
*/
@Bean
public MybatisPlusInterceptor optimisticLockerInter... |
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return mybatisPlusInterceptor;
| 128 | 97 | 225 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/config/RedisCacheConfig.java | RedisCacheConfig | redisSerializer | class RedisCacheConfig {
@Bean
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory, RedisSerializer<Object> redisSerializer) {
RedisCacheManager redisCacheManager = new RedisCacheManager(
RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory),
... |
ObjectMapper objectMapper = JsonMapper.builder().disable(MapperFeature.USE_ANNOTATIONS).build();
// 反序列化时候遇到不匹配的属性并不抛出异常
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 序列化时候遇到空对象不抛出异常
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY... | 737 | 369 | 1,106 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/filter/XssFilter.java | XssFilter | doFilter | class XssFilter implements Filter {
Logger logger = LoggerFactory.getLogger(getClass().getName());
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOExc... |
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
logger.info("uri:{}",req.getRequestURI());
// xss 过滤
chain.doFilter(new XssWrapper(req), resp);
| 113 | 74 | 187 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/handler/HttpHandler.java | HttpHandler | printServerResponseToWeb | class HttpHandler {
private static final Logger logger = LoggerFactory.getLogger(HttpHandler.class);
@Autowired
private ObjectMapper objectMapper;
public <T> void printServerResponseToWeb(ServerResponseEntity<T> serverResponseEntity) {
if (serverResponseEntity == null) {
logger.in... |
if (yamiShopBindException == null) {
logger.info("print obj is null");
return;
}
if (Objects.nonNull(yamiShopBindException.getServerResponseEntity())) {
printServerResponseToWeb(yamiShopBindException.getServerResponseEntity());
return;
}
... | 370 | 148 | 518 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/response/ServerResponseEntity.java | ServerResponseEntity | fail | class ServerResponseEntity<T> implements Serializable {
/**
* 状态码
*/
private String code;
/**
* 信息
*/
private String msg;
/**
* 数据
*/
private T data;
/**
* 版本
*/
private String version;
/**
* 时间
*/
private Long timestamp;
... |
log.error(responseEnum.toString());
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(responseEnum.getMsg());
serverResponseEntity.setCode(responseEnum.value());
return serverResponseEntity;
| 1,286 | 68 | 1,354 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/serializer/json/ImgJsonSerializer.java | ImgJsonSerializer | serialize | class ImgJsonSerializer extends JsonSerializer<String> {
@Autowired
private Qiniu qiniu;
@Autowired
private ImgUploadUtil imgUploadUtil;
@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {<FILL_FUNCTION_BODY>}
} |
if (StrUtil.isBlank(value)) {
gen.writeString(StrUtil.EMPTY);
return;
}
String[] imgs = value.split(StrUtil.COMMA);
StringBuilder sb = new StringBuilder();
String resourceUrl = "";
if (Objects.equals(imgUploadUtil.getUploadType(), 2)) {
... | 89 | 203 | 292 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/Arith.java | Arith | div | class Arith {
/**
* 默认除法运算精度
*/
private static final int DEF_DIV_SCALE = 2;
/**
* 这个类不能实例化
*/
private Arith() {
}
/**
* 提供精确的加法运算。.
*
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2) {
... |
if (scale < 0) {
throw new IllegalArgumentException("The scale must be a positive integer or zero");
}
String s1 = Double.toString(v1);
String s2 = Double.toString(v2);
BigDecimal b1 = new BigDecimal(s1);
BigDecimal b2 = new BigDecimal(s2);
return b1.... | 1,137 | 119 | 1,256 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/CacheManagerUtil.java | CacheManagerUtil | getCache | class CacheManagerUtil {
private CacheManager cacheManager;
@SuppressWarnings({"unchecked"})
public <T> T getCache(String cacheName,String key) {<FILL_FUNCTION_BODY>}
public void putCache(String cacheName,String key, Object value) {
Cache cache = cacheManager.getCache(cacheName);
if (... |
Cache cache = cacheManager.getCache(cacheName);
if (cache == null) {
return null;
}
Cache.ValueWrapper valueWrapper = cache.get(key);
if (valueWrapper == null) {
return null;
}
return (T)valueWrapper.get();
| 177 | 78 | 255 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/HttpContextUtils.java | HttpContextUtils | getDomain | class HttpContextUtils {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
public static String getDomain(){<FILL_FUNCTION_BODY>}
public static String getOrigin(){
HttpServletRequest request = getHttpServ... |
HttpServletRequest request = getHttpServletRequest();
StringBuffer url = request.getRequestURL();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
| 95 | 54 | 149 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/IdUtil.java | IdUtil | encode | class IdUtil {
@Autowired
private Snowflake snowflake;
private static final String DICT = "0123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
private static final int SEED = DICT.length();
private static final int ID_MIN_LENGTH = 6;
/**
* 数字->字符映射
*/
private static fi... |
StringBuilder shortUrl = new StringBuilder();
while (id > 0) {
int r = (int) (id % SEED);
shortUrl.insert(0, CHARS[r]);
id = id / SEED;
}
int len = shortUrl.length();
while (len < ID_MIN_LENGTH) {
shortUrl.insert(0, CHARS[0]);
... | 498 | 117 | 615 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/ImgUploadUtil.java | ImgUploadUtil | getUploadPath | class ImgUploadUtil {
@Autowired
private ImgUpload imgUpload;
public Integer getUploadType() {
Integer uploadType = imgUpload.getUploadType();
if (Objects.isNull(uploadType)) {
throw new YamiShopBindException("请配置图片存储方式");
}
return uploadType;
}
public ... |
String imagePath = imgUpload.getImagePath();
if (Objects.isNull(imagePath) || StrUtil.isBlank(imagePath)) {
throw new YamiShopBindException("请配置图片存储路径");
}
return imagePath;
| 387 | 67 | 454 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/IpHelper.java | IpHelper | getIpAddr | class IpHelper {
private static final String UNKNOWN = "unknown";
/**
* 得到用户的真实地址,如果有多个就取第一个
*
* @return
*/
public static String getIpAddr() {<FILL_FUNCTION_BODY>}
} |
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
if (request == null) {
return null;
}
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("Pr... | 78 | 209 | 287 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/Json.java | Json | parseArray | class Json {
private static ObjectMapper objectMapper = new ObjectMapper();
static {
// 如果为空则不输出
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
// 对于空的对象转json的时候不抛出错误
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
// 禁用序列化日期为time... |
T[] result = null;
try {
result = objectMapper.readValue(json, clazz);
} catch (Exception e) {
log.error("Json转换错误:", e);
}
if (result == null) {
return Collections.emptyList();
}
return Arrays.asList(result);
| 709 | 93 | 802 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/PageParam.java | PageParam | setSize | class PageParam<T> extends Page<T> {
/**
* 每页显示条数,默认 10
*/
@Schema(description = "每页大小,默认10")
private long size = 10;
/**
* 当前页
*/
@Schema(description = "当前页,默认1")
private long current = 1;
/**
* 查询数据列表
*/
@Hidden
private List<T> records;
/**
... |
int maxSize = 100;
if (size > maxSize) {
this.size = maxSize;
} else {
this.size = size;
}
return this;
| 548 | 53 | 601 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/PrincipalUtil.java | PrincipalUtil | isMatching | class PrincipalUtil {
/**
* 以1开头,后面跟10位数
*/
public static final String MOBILE_REGEXP = "1[0-9]{10}";
/**
* 数字字母下划线 4-16位
*/
public static final String USER_NAME_REGEXP = "([a-zA-Z0-9_]{4,16})";
/**
* 由简单的字母数字拼接而成的字符串 不含有下划线,大写字母
*/
public static final String SIMP... |
if (StrUtil.isBlank(value)) {
return false;
}
return Pattern.matches(regexp, value);
| 396 | 39 | 435 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/RedisUtil.java | RedisUtil | set | class RedisUtil {
private static RedisTemplate<String, Object> redisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class);
public static final StringRedisTemplate STRING_REDIS_TEMPLATE = SpringContextUtils.getBean("stringRedisTemplate",StringRedisTemplate.class);
//==================... |
try {
if (time > 0) {
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
} else {
set(key, value);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
... | 1,151 | 87 | 1,238 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/util/SpelUtil.java | SpelUtil | parse | class SpelUtil {
/**
* 支持 #p0 参数索引的表达式解析
* @param rootObject 根对象,method 所在的对象
* @param spel 表达式
* @param method ,目标方法
* @param args 方法入参
* @return 解析后的字符串
*/
public static String parse(Object rootObject,String spel, Method method, Object[] args) {<FILL_FUNCTION_BODY>}
} |
if (StrUtil.isBlank(spel)) {
return StrUtil.EMPTY;
}
//获取被拦截方法参数名列表(使用Spring支持类库)
StandardReflectionParameterNameDiscoverer standardReflectionParameterNameDiscoverer = new StandardReflectionParameterNameDiscoverer();
String[] paraNameArr = standardReflectionParameter... | 125 | 268 | 393 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-common/src/main/java/com/yami/shop/common/xss/XssWrapper.java | XssWrapper | getParameterValues | class XssWrapper extends HttpServletRequestWrapper {
/**
* Constructs a request object wrapping the given request.
*
* @param request The request to wrap
* @throws IllegalArgumentException if the request is null
*/
public XssWrapper(HttpServletRequest request) {
super(request);
... |
String[] values = super.getParameterValues(name);
if (values == null) {
return null;
}
int count = values.length;
String[] encodedValues = new String[count];
for (int i = 0; i < count; i++) {
encodedValues[i] = cleanXss(values[i]);
}
... | 409 | 97 | 506 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-admin/src/main/java/com/yami/shop/security/admin/util/SecurityUtils.java | SecurityUtils | getSysUser | class SecurityUtils {
/**
* 获取用户
*/
public YamiSysUser getSysUser() {<FILL_FUNCTION_BODY>}
} |
UserInfoInTokenBO userInfoInTokenBO = AuthUserContext.get();
YamiSysUser details = new YamiSysUser();
details.setUserId(Long.valueOf(userInfoInTokenBO.getUserId()));
details.setEnabled(userInfoInTokenBO.getEnabled());
details.setUsername(userInfoInTokenBO.getNickName());
... | 45 | 138 | 183 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-api/src/main/java/com/yami/shop/security/api/controller/LoginController.java | LoginController | login | class LoginController {
@Autowired
private TokenStore tokenStore;
@Autowired
private UserMapper userMapper;
@Autowired
private PasswordCheckManager passwordCheckManager;
@Autowired
private PasswordManager passwordManager;
@PostMapping("/login")
@Operation(summary = "账号密码(用于前端... |
String mobileOrUserName = authenticationDTO.getUserName();
User user = getUser(mobileOrUserName);
String decryptPassword = passwordManager.decryptPassword(authenticationDTO.getPassWord());
// 半小时内密码输入错误十次,已限制登录30分钟
passwordCheckManager.checkPassword(SysTypeEnum.ORDINARY,authen... | 357 | 240 | 597 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-api/src/main/java/com/yami/shop/security/api/util/SecurityUtils.java | SecurityUtils | getUser | class SecurityUtils {
private static final String USER_REQUEST = "/p/";
/**
* 获取用户
*/
public YamiUser getUser() {<FILL_FUNCTION_BODY>}
} |
if (!HttpContextUtils.getHttpServletRequest().getRequestURI().startsWith(USER_REQUEST)) {
// 用户相关的请求,应该以/p开头!!!
throw new RuntimeException("yami.user.request.error");
}
UserInfoInTokenBO userInfoInTokenBO = AuthUserContext.get();
YamiUser yamiUser = new YamiUser... | 58 | 209 | 267 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/adapter/MallWebSecurityConfigurerAdapter.java | MallWebSecurityConfigurerAdapter | filterChain | class MallWebSecurityConfigurerAdapter {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{<FILL_FUNCTION_BODY>}
} |
// We don't need CSRF for token based authentication
return http.csrf().disable().cors()
.and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().authorizeRequests().requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
... | 45 | 111 | 156 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/config/AuthConfig.java | AuthConfig | filterRegistration | class AuthConfig {
@Autowired
private AuthFilter authFilter;
@Bean
@ConditionalOnMissingBean
public AuthConfigAdapter authConfigAdapter() {
return new DefaultAuthConfigAdapter();
}
@Bean
@Lazy
public FilterRegistrationBean<AuthFilter> filterRegistration(AuthConfigAdapter ... |
FilterRegistrationBean<AuthFilter> registration = new FilterRegistrationBean<>();
// 添加过滤器
registration.setFilter(authFilter);
// 设置过滤路径,/*所有路径
registration.addUrlPatterns(ArrayUtil.toArray(authConfigAdapter.pathPatterns(), String.class));
registration.setName("authFilte... | 105 | 127 | 232 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/config/CaptchaConfig.java | CaptchaConfig | getResourcesImagesFile | class CaptchaConfig {
@Bean
public CaptchaService captchaService() {
Properties config = new Properties();
config.put(Const.CAPTCHA_CACHETYPE, "redis");
config.put(Const.CAPTCHA_WATER_MARK, "");
// 滑动验证
config.put(Const.CAPTCHA_TYPE, CaptchaTypeEnum.BLOCKPUZZLE.getCodeVa... |
Map<String, String> imgMap = new HashMap<>(16);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
Resource[] resources = resolver.getResources(path);
Resource[] var4 = resources;
int var5 = resources.length;
... | 263 | 203 | 466 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/config/CorsConfig.java | CorsConfig | corsConfigurationSource | class CorsConfig {
/**
* 修改为添加而不是设置,* 最好生产环境改为实际的需要, 这里可以用多个add配置多个域名
* configuration.addAllowedOrigin("http://localhost:8080");
* configuration.addAllowedOrigin("http://192.168.1.6:8080");
* @return CorsConfigurationSource
*/
@Bean
public CorsConfigurationSource corsConfigurati... |
CorsConfiguration configuration = new CorsConfiguration();
configuration.addAllowedOriginPattern("*");
//修改为添加而不是设置
configuration.addAllowedMethod("*");
//这里很重要,起码需要允许 Access-Control-Allow-Origin
configuration.addAllowedHeader("*");
configuration.setAllowCredenti... | 136 | 144 | 280 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/controller/CaptchaController.java | CaptchaController | check | class CaptchaController {
private final CaptchaService captchaService;
public CaptchaController(CaptchaService captchaService) {
this.captchaService = captchaService;
}
@PostMapping({ "/get" })
public ServerResponseEntity<ResponseModel> get(@RequestBody CaptchaVO captchaVO) {
retu... |
ResponseModel responseModel;
try {
responseModel = captchaService.check(captchaVO);
}catch (Exception e) {
return ServerResponseEntity.success(ResponseModel.errorMsg(RepCodeEnum.API_CAPTCHA_COORDINATE_ERROR));
}
return ServerResponseEntity.success(respons... | 158 | 86 | 244 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/controller/LogoutController.java | LogoutController | logOut | class LogoutController {
@Autowired
private TokenStore tokenStore;
@PostMapping("/logOut")
@Operation(summary = "退出登陆" , description = "点击退出登陆,清除token,清除菜单缓存")
public ServerResponseEntity<Void> logOut(HttpServletRequest request) {<FILL_FUNCTION_BODY>}
} |
String accessToken = request.getHeader("Authorization");
if (StrUtil.isBlank(accessToken)) {
return ServerResponseEntity.success();
}
// 删除该用户在该系统当前的token
tokenStore.deleteCurrentToken(accessToken);
return ServerResponseEntity.success();
| 99 | 79 | 178 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/controller/TokenController.java | TokenController | refreshToken | class TokenController {
@Autowired
private TokenStore tokenStore;
@PostMapping("/token/refresh")
public ServerResponseEntity<TokenInfoVO> refreshToken(@Valid @RequestBody RefreshTokenDTO refreshTokenDTO) {<FILL_FUNCTION_BODY>}
} |
TokenInfoBO tokenInfoServerResponseEntity = tokenStore
.refreshToken(refreshTokenDTO.getRefreshToken());
return ServerResponseEntity
.success(BeanUtil.copyProperties(tokenInfoServerResponseEntity, TokenInfoVO.class));
| 79 | 65 | 144 | <no_super_class> |
gz-yami_mall4j | mall4j/yami-shop-security/yami-shop-security-common/src/main/java/com/yami/shop/security/common/dto/RefreshTokenDTO.java | RefreshTokenDTO | toString | class RefreshTokenDTO {
/**
* refreshToken
*/
@NotBlank(message = "refreshToken不能为空")
@Schema(description = "refreshToken" , required = true)
private String refreshToken;
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshT... |
return "RefreshTokenDTO{" + "refreshToken='" + refreshToken + '\'' + '}';
| 138 | 30 | 168 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.