feat(店铺): 增加按模式列表查询店铺接口

- 在getShopListByCorpid方法中新增modeList参数,支持按多个模式筛选店铺
- 在Controller层新增modeList参数处理逻辑
- 为ShopServiceImpl添加Slf4j日志注解
- 在AssetApplicationService中设置默认校验状态
- 新增AdminLoginController用于管理系统登录相关接口
This commit is contained in:
dzq 2025-12-30 16:23:33 +08:00
parent 27ea67f58a
commit 268e690278
6 changed files with 134 additions and 7 deletions

View File

@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -54,14 +55,19 @@ public class ShopController {
@GetMapping("/list")
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid,
@RequestParam(required = false) Long mode,
@RequestParam(required = false) Long eqMode) {
@RequestParam(required = false) Long eqMode,
@RequestParam(required = false) String modeList) {
List<ShopEntity> shopList;
Long modeValue = mode != null ? mode : 4L;
List<Long> modeListValue = null;
if (StringUtils.isNotBlank(modeList)) {
modeListValue = Arrays.asList(modeList.split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
}
if (StringUtils.isNotBlank(corpid)) {
shopList = shopApplicationService.getShopListByCorpid(corpid, modeValue, eqMode);
shopList = shopApplicationService.getShopListByCorpid(corpid, modeValue, eqMode, modeListValue);
} else {
log.warn("getShopList接口未接收到corpid参数使用默认corpid: {}", WeixinConstants.corpid);
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid, modeValue, eqMode);
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid, modeValue, eqMode, modeListValue);
}
return ResponseDTO.ok(shopList);
}

View File

@ -0,0 +1,111 @@
package com.agileboot.api.controller.manage;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.enums.BasicEnumUtil;
import com.agileboot.domain.qywx.userQySys.SysUserQyUserApplicationService;
import com.agileboot.domain.qywx.userQySys.db.SysUserQyUserEntity;
import com.agileboot.domain.system.menu.MenuApplicationService;
import com.agileboot.domain.system.menu.dto.RouterDTO;
import com.agileboot.domain.system.menu.db.SysMenuEntity;
import com.agileboot.domain.system.role.db.SysRoleEntity;
import com.agileboot.domain.system.role.db.SysRoleService;
import com.agileboot.domain.system.user.db.SysUserEntity;
import com.agileboot.domain.system.user.db.SysUserService;
import com.agileboot.infrastructure.user.web.DataScopeEnum;
import com.agileboot.infrastructure.user.web.RoleInfo;
import com.agileboot.infrastructure.user.web.SystemLoginUser;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.SetUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/manage/admin/login")
@CrossOrigin(origins = "*", allowedHeaders = "*")
@Slf4j
@RequiredArgsConstructor
public class AdminLoginController {
private final MenuApplicationService menuApplicationService;
private final SysUserService userService;
private final SysRoleService roleService;
private final SysUserQyUserApplicationService sysUserQyUserApplicationService;
@GetMapping("/getRouters")
public ResponseDTO<List<RouterDTO>> getRouters(
@RequestParam Integer qyUserId,
@RequestParam(required = false) String corpid) {
// 1. 获取用户信息
SysUserQyUserEntity sysUserQyUserEntity = sysUserQyUserApplicationService.getByQyUserId(qyUserId);
Long userId = sysUserQyUserEntity.getSysUserId();
SysUserEntity userEntity = userService.getById(userId);
if (userEntity == null) {
log.warn("用户不存在, userId: {}", userId);
return ResponseDTO.ok(List.of()); // 返回空列表而不是错误
}
// 2. 检查用户状态 (可选根据需求决定)
if (userEntity.getStatus() != 1) { // 1表示正常状态
log.warn("用户状态异常, userId: {}, status: {}", userId, userEntity.getStatus());
return ResponseDTO.ok(List.of());
}
// 4. 构造 SystemLoginUser (isAdmin设置为false)
SystemLoginUser loginUser = new SystemLoginUser(
userId,
false, // isAdmin = false
userEntity.getUsername(),
userEntity.getPassword(),
null,
userEntity.getDeptId()
);
// 5. 调用 menuApplicationService.getRouterTree()
List<RouterDTO> routerTree = menuApplicationService.getRouterTree(loginUser);
// 6. 返回结果
return ResponseDTO.ok(routerTree);
}
@GetMapping("/getPermissions")
public ResponseDTO<List<String>> getPermissions(
@RequestParam Integer qyUserId,
@RequestParam(required = false) String corpid) {
SysUserQyUserEntity sysUserQyUserEntity = sysUserQyUserApplicationService.getByQyUserId(qyUserId);
Long userId = sysUserQyUserEntity.getSysUserId();
SysUserEntity userEntity = userService.getById(userId);
if (userEntity == null) {
log.warn("用户不存在, userId: {}", userId);
return ResponseDTO.ok(List.of());
}
if (userEntity.getStatus() != 1) {
log.warn("用户状态异常, userId: {}, status: {}", userId, userEntity.getStatus());
return ResponseDTO.ok(List.of());
}
SystemLoginUser loginUser = new SystemLoginUser(
userId,
false,
userEntity.getUsername(),
userEntity.getPassword(),
null,
userEntity.getDeptId()
);
List<String> permissions = menuApplicationService.getPermissions(loginUser);
return ResponseDTO.ok(permissions);
}
}

View File

@ -139,6 +139,8 @@ public class AssetApplicationService {
ReturnApprovalModel returnApprovalModel = returnApprovalModelFactory.create();
returnApprovalModel.initBaseEntity();
returnApprovalModel.loadAddCommand(returnApprovalCommand);
// 默认为已校验
returnApprovalModel.setCodeCheck(1);
List<ApprovalGoodsModel> approvalGoodsModels = new ArrayList<>();
for (PostAssetApprovalCommand.ApprovalGoodsInfo command : postAssetApprovalCommand.getGoodsInfoList()) {

View File

@ -56,8 +56,8 @@ public class ShopApplicationService {
return new ShopDTO(shopEntity);
}
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode) {
return shopService.getShopListByCorpid(corpid, mode, eqMode);
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode, List<Long> modeList) {
return shopService.getShopListByCorpid(corpid, mode, eqMode, modeList);
}
public void addShop(AddShopCommand command) {

View File

@ -30,5 +30,5 @@ public interface ShopService extends IService<ShopEntity> {
List<Integer> getDistinctModeList();
List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode);
List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode, List<Long> modeList);
}

View File

@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@ -17,6 +21,7 @@ import java.util.List;
* @since 2025-05-09
*/
@Service
@Slf4j
public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> implements ShopService {
@Override
@ -55,7 +60,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> impleme
}
@Override
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode) {
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode, List<Long> modeList) {
QueryWrapper<ShopEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("corpid", corpid)
.eq("deleted", 0);
@ -63,6 +68,9 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> impleme
queryWrapper.eq("mode", eqMode);
} else {
queryWrapper.ne("mode", mode);
if (modeList != null && !modeList.isEmpty()) {
queryWrapper.in("mode", modeList);
}
}
return this.list(queryWrapper);
}