Skip to content

Commit

Permalink
升级mybatis-plus到3.5.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenWatermelon committed Mar 15, 2023
1 parent d723131 commit 07f919b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 54 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<orika.version>1.5.4</orika.version>
<aliyun-core.version>4.3.9</aliyun-core.version>
<aliyun-dysmsapi.version>1.1.0</aliyun-dysmsapi.version>
<mybatis-plus.version>3.1.0</mybatis-plus.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
<redisson.version>3.12.5</redisson.version>
<transmittable-thread-local.version>2.12.1</transmittable-thread-local.version>
<log4j.version>2.17.2</log4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public ServerResponseEntity<Void> delete(@PathVariable Long id) {
}

private void hasSameName(Area area) {
int count = areaService.count(new LambdaQueryWrapper<Area>()
long count = areaService.count(new LambdaQueryWrapper<Area>()
.eq(Area::getParentId, area.getParentId())
.eq(Area::getAreaName, area.getAreaName())
.ne(Objects.nonNull(area.getAreaId()) && !Objects.equals(area.getAreaId(), 0L), Area::getAreaId, area.getAreaId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ public class BrandController {
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin:brand:page')")
public ServerResponseEntity<IPage<Brand>> page(Brand brand,PageParam<Brand> page) {
page.setAsc("first_char");
IPage<Brand> brands = brandService.page(page,
new LambdaQueryWrapper<Brand>()
.like(StrUtil.isNotBlank(brand.getBrandName()), Brand::getBrandName, brand.getBrandName()));
.like(StrUtil.isNotBlank(brand.getBrandName()), Brand::getBrandName, brand.getBrandName()).orderByAsc(Brand::getFirstChar));
return ServerResponseEntity.success(brands);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ServerResponseEntity<String> addAddr(@Valid @RequestBody AddrParam addrPa
if (addrParam.getAddrId() != null && addrParam.getAddrId() != 0) {
return ServerResponseEntity.showFailMsg("该地址已存在");
}
int addrCount = userAddrService.count(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId));
long addrCount = userAddrService.count(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId));
UserAddr userAddr = mapperFacade.map(addrParam, UserAddr.class);

if (addrCount == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public ServerResponseEntity<Void> addOrCancel(@RequestBody Long prodId) {
*/
@GetMapping("count")
@Operation(summary = "查询用户收藏商品数量" , description = "查询用户收藏商品数量")
public int findUserCollectionCount() {
public ServerResponseEntity<Long> findUserCollectionCount() {
String userId = SecurityUtils.getUser().getUserId();
return userCollectionService.count(new LambdaQueryWrapper<UserCollection>().eq(UserCollection::getUserId, userId));
return ServerResponseEntity.success(userCollectionService.count(new LambdaQueryWrapper<UserCollection>().eq(UserCollection::getUserId, userId)));
}

@GetMapping("/prods")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

package com.yami.shop.common.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
Expand All @@ -26,32 +28,24 @@
@MapperScan({"com.yami.shop.**.dao"})
public class MybatisPlusConfig {

/**
* 分页插件
* @return PaginationInterceptor
*/
@Bean
@ConditionalOnMissingBean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* 逻辑删除插件
*
* @return LogicSqlInjector
*/
@Bean
@ConditionalOnMissingBean
public ISqlInjector sqlInjector() {
return new LogicSqlInjector();
return new DefaultSqlInjector();
}

/**
* 乐观锁插件
* @return
* mybatis-plus插件
*/
@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
return new OptimisticLockerInterceptor();
public MybatisPlusInterceptor optimisticLockerInterceptor() {
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return mybatisPlusInterceptor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ public boolean getSearchCount() {
return isSearchCount;
}

@Override
public boolean isSearchCount() {
if (total < 0) {
return false;
}
return isSearchCount;
}

@Override
public Page<T> setSearchCount(boolean isSearchCount) {
this.isSearchCount = isSearchCount;
Expand Down Expand Up @@ -132,24 +124,4 @@ public Page<T> setCurrent(long current) {
this.current = current;
return this;
}

/** @deprecated */
@Deprecated
public String getCountId() {
return this.countId;
}

/** @deprecated */
@Deprecated
public Long getMaxLimit() {
return this.maxLimit;
}


/** @deprecated */
@Deprecated
public boolean isOptimizeCountSql() {
return this.optimizeCountSql;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void sendSms(SmsType smsType, String userId, String mobile, Map<String, S

SmsLog smsLog = new SmsLog();
if (smsType.equals(SmsType.VALID)) {
int todaySendSmsNumber = smsLogMapper.selectCount(new LambdaQueryWrapper<SmsLog>()
long todaySendSmsNumber = smsLogMapper.selectCount(new LambdaQueryWrapper<SmsLog>()
.gt(SmsLog::getRecDate, DateUtil.beginOfDay(new Date()))
.lt(SmsLog::getRecDate, DateUtil.endOfDay(new Date()))
.eq(SmsLog::getUserId, userId)
Expand Down

0 comments on commit 07f919b

Please sign in to comment.