add store sort api
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/// GAO 门店接口
|
/// GAO 门店接口
|
||||||
///
|
///
|
||||||
@@ -80,6 +81,14 @@ public class GaoStoreController {
|
|||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireGaoPermission(GaoPermissionCode.STORE_UPDATE)
|
||||||
|
@PostMapping("/sort")
|
||||||
|
public void sort(@RequestBody List<String> idList) {
|
||||||
|
service.sort(idList);
|
||||||
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@IgnoreGlobalReturn
|
@IgnoreGlobalReturn
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import com.imyeyu.api.modules.gao.entity.GaoStore;
|
|||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GAO 门店 Mapper
|
/// GAO 门店 Mapper
|
||||||
///
|
///
|
||||||
@@ -11,6 +14,8 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
/// @since 2026-08-06
|
/// @since 2026-08-06
|
||||||
public interface GaoStoreMapper extends BaseMapper<GaoStore, String> {
|
public interface GaoStoreMapper extends BaseMapper<GaoStore, String> {
|
||||||
|
|
||||||
|
List<GaoStore> selectByIdList(@Param("idList") Collection<String> idList);
|
||||||
|
|
||||||
/// 查询用户所属的可用门店
|
/// 查询用户所属的可用门店
|
||||||
///
|
///
|
||||||
/// @param userId 用户 ID
|
/// @param userId 用户 ID
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.imyeyu.spring.bean.Page;
|
|||||||
import com.imyeyu.spring.service.BaseService;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GAO 门店服务
|
/// GAO 门店服务
|
||||||
@@ -24,4 +25,9 @@ public interface GaoStoreService extends BaseService<GaoStore, String> {
|
|||||||
/// @param page 分页查询条件
|
/// @param page 分页查询条件
|
||||||
/// @return xlsx 文件字节
|
/// @return xlsx 文件字节
|
||||||
byte[] export(Page<GaoStore> page) throws IOException;
|
byte[] export(Page<GaoStore> page) throws IOException;
|
||||||
|
|
||||||
|
/// 按客户端提交的顺序更新排序
|
||||||
|
///
|
||||||
|
/// @param idList 门店 ID 列表
|
||||||
|
void sort(List<String> idList);
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-1
@@ -1,6 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.gao.service.implement;
|
package com.imyeyu.api.modules.gao.service.implement;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoStoreMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoStoreMapper;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
import com.imyeyu.api.modules.gao.service.GaoStoreService;
|
||||||
@@ -16,9 +17,14 @@ import com.imyeyu.spring.service.AbstractEntityService;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GAO 门店服务实现
|
/// GAO 门店服务实现
|
||||||
@@ -89,7 +95,6 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
dbStore.setTelephone(store.getTelephone());
|
dbStore.setTelephone(store.getTelephone());
|
||||||
dbStore.setAddress(store.getAddress());
|
dbStore.setAddress(store.getAddress());
|
||||||
dbStore.setRemark(store.getRemark());
|
dbStore.setRemark(store.getRemark());
|
||||||
dbStore.setSort(store.getSort());
|
|
||||||
super.update(dbStore);
|
super.update(dbStore);
|
||||||
logger.setLevel(Logger.Level.INFO);
|
logger.setLevel(Logger.Level.INFO);
|
||||||
logger.setResult(store.getId());
|
logger.setResult(store.getId());
|
||||||
@@ -146,6 +151,25 @@ public class GaoStoreServiceImplement extends AbstractEntityService<GaoStore, St
|
|||||||
return storeXSSFBuilder.build(list);
|
return storeXSSFBuilder.build(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
|
@Override
|
||||||
|
public void sort(List<String> idList) {
|
||||||
|
if (TimiJava.isEmpty(idList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GaoStore> storeList = mapper.selectByIdList(new LinkedHashSet<>(idList));
|
||||||
|
Map<String, GaoStore> storeMap = storeList.stream().collect(Collectors.toMap(GaoStore::getId, Function.identity()));
|
||||||
|
for (int i = 0; i < idList.size(); i++) {
|
||||||
|
GaoStore store = storeMap.get(idList.get(i));
|
||||||
|
if (store == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
store.setSort(i);
|
||||||
|
mapper.update(store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkUnique(GaoStore store) {
|
private void checkUnique(GaoStore store) {
|
||||||
GaoStore codeExample = new GaoStore();
|
GaoStore codeExample = new GaoStore();
|
||||||
codeExample.setCode(store.getCode());
|
codeExample.setCode(store.getCode());
|
||||||
|
|||||||
@@ -1,6 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoStoreMapper">
|
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoStoreMapper">
|
||||||
|
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoStore">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM `gao_store`
|
||||||
|
WHERE
|
||||||
|
TRUE
|
||||||
|
<if test="idList != null and !idList.isEmpty()">
|
||||||
|
AND `id` IN
|
||||||
|
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="idList == null or idList.isEmpty()">
|
||||||
|
AND FALSE
|
||||||
|
</if>
|
||||||
|
AND `deleted_at` IS NULL
|
||||||
|
</select>
|
||||||
<select id="selectByUserId" resultType="com.imyeyu.api.modules.gao.entity.GaoStore">
|
<select id="selectByUserId" resultType="com.imyeyu.api.modules.gao.entity.GaoStore">
|
||||||
SELECT
|
SELECT
|
||||||
s.*
|
s.*
|
||||||
|
|||||||
Reference in New Issue
Block a user