|
|
@@ -1,6 +1,7 @@
|
|
|
package shop.alien.store.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -51,7 +52,8 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
|
|
|
IPage<StoreStaffConfig> storePage = new Page<>(page, size);
|
|
|
QueryWrapper<StoreStaffConfig> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.like(null != status && !status.isEmpty(), "status", status);
|
|
|
- queryWrapper.orderByDesc("created_time");
|
|
|
+ // 排序规则:先按置顶状态降序(置顶的在前),再按置顶时间降序,最后按创建时间降序
|
|
|
+ queryWrapper.orderByDesc("top_status", "top_time", "created_time");
|
|
|
return storeStaffConfigMapper.selectPage(storePage, queryWrapper);
|
|
|
}
|
|
|
|
|
|
@@ -60,7 +62,7 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
|
|
|
// 判断是新增还是更新:id为null或0或负数表示新增
|
|
|
// 注意:新增时不应该传入id,如果传入了非0的id,需要先查询是否存在
|
|
|
Integer id = storeStaffConfig.getId();
|
|
|
-
|
|
|
+
|
|
|
if (id == null || id == 0) {
|
|
|
// 新增操作:id为null或0
|
|
|
Date nowDate = new Date(System.currentTimeMillis());
|
|
|
@@ -153,6 +155,22 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Integer setTopStatus(Integer id, Integer topStatus) {
|
|
|
+ if (id == null || topStatus == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<StoreStaffConfig> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ lambdaUpdateWrapper.eq(StoreStaffConfig::getId, id);
|
|
|
+ lambdaUpdateWrapper.set(StoreStaffConfig::getTopStatus, topStatus);
|
|
|
+ if (topStatus == 0) {
|
|
|
+ lambdaUpdateWrapper.set(StoreStaffConfig::getTopTime, null);
|
|
|
+ } else {
|
|
|
+ lambdaUpdateWrapper.set(StoreStaffConfig::getTopTime, new Date());
|
|
|
+ }
|
|
|
+ return storeStaffConfigMapper.update(null, lambdaUpdateWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public IPage<StoreStaffConfig> queryStaffList(Integer page, Integer size, Integer storeId, String status) {
|
|
|
IPage<StoreStaffConfig> storePage = new Page<>(page, size);
|
|
|
QueryWrapper<StoreStaffConfig> queryWrapper = new QueryWrapper<>();
|