diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java index c4cbb3a0c..f8a4e92cf 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java @@ -6,6 +6,7 @@ import com.fuint.business.fleet.service.FleetInfoService; import com.fuint.business.fleet.vo.FleetInfoVo; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; +import org.apache.ibatis.annotations.Param; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -84,5 +85,14 @@ public class FleetInfoController extends BaseController { return getSuccessResult(fleetInfoService.deleteById(id)); } + /** + * 根据storeId获取车队信息 + * @return + */ + @GetMapping("/getFleetInfoByStoreId") + public ResponseObject getFleetInfoByStoreId(@Param("storeId")Integer storeId){ + return getSuccessResult(fleetInfoService.queryByStoreId(storeId)); + } + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java index a194782f4..3d89e4eee 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java @@ -3,6 +3,7 @@ package com.fuint.business.fleet.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.fleet.entity.FleetInfo; +import com.fuint.business.fleet.vo.FleetInfoUniVo; import com.fuint.business.fleet.vo.FleetInfoVo; /** @@ -59,4 +60,10 @@ public interface FleetInfoService { */ int deleteById(Integer id); + /** + * 根据storeId查询车队信息 + * @param storeId + * @return + */ + FleetInfoUniVo queryByStoreId(Integer storeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java index c78f22a2f..1a81425ea 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java @@ -1,18 +1,26 @@ package com.fuint.business.fleet.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.business.fleet.entity.FleetInfo; +import com.fuint.business.fleet.entity.FleetMember; import com.fuint.business.fleet.mapper.FleetInfoMapper; +import com.fuint.business.fleet.mapper.FleetMemberMapper; import com.fuint.business.fleet.service.FleetInfoService; +import com.fuint.business.fleet.vo.FleetInfoUniVo; import com.fuint.business.fleet.vo.FleetInfoVo; import com.fuint.business.member.entity.LJStaff; import com.fuint.business.member.service.ILJStaffService; +import com.fuint.business.store.mapper.MtStoreMapper; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.MtUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -32,6 +40,15 @@ public class FleetInfoServiceImpl extends ServiceImpl @Autowired private ILJStaffService mtStaffService; + @Autowired + private MtUserMapper mtUserMapper; + + @Autowired + private FleetMemberMapper fleetMemberMapper; + + @Autowired + private MtStoreMapper mtStoreMapper; + @Override public IPage queryPage(Page page, FleetInfoVo fleetInfo) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); @@ -121,4 +138,36 @@ public class FleetInfoServiceImpl extends ServiceImpl public int deleteById(Integer id) { return baseMapper.deleteById(id); } + + /** + * 根据storeId查询车队信息 + * + * @param storeId + * @return + */ + @Override + public FleetInfoUniVo queryByStoreId(Integer storeId) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + + LambdaQueryWrapper lambdaQueryWrapper1 = new LambdaQueryWrapper<>(); +// lambdaQueryWrapper1.eq(MtUser::getStoreId, storeId); + lambdaQueryWrapper1.eq(MtUser::getId, nowAccountInfo.getId()); + lambdaQueryWrapper1.last("limit 1"); + MtUser mtUser = mtUserMapper.selectOne(lambdaQueryWrapper1); + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(FleetMember::getStoreId, storeId); + lambdaQueryWrapper.eq(FleetMember::getUserCardNum, mtUser.getUserNo()); + lambdaQueryWrapper.last("limit 1"); + FleetMember fleetMember = fleetMemberMapper.selectOne(lambdaQueryWrapper); + + if (ObjectUtil.isEmpty(fleetMember)) { + throw new RuntimeException("该会员未绑定车队"); + } + + FleetInfo fleetInfo = baseMapper.selectById(fleetMember.getFleetId()); + FleetInfoUniVo fleetInfoUniVo = BeanUtil.copyProperties(fleetInfo, FleetInfoUniVo.class); + fleetInfoUniVo.setStoreName(mtStoreMapper.selectById(storeId).getName()); + return fleetInfoUniVo; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/vo/FleetInfoUniVo.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/vo/FleetInfoUniVo.java new file mode 100644 index 000000000..255abc6e2 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/vo/FleetInfoUniVo.java @@ -0,0 +1,11 @@ +package com.fuint.business.fleet.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fuint.business.fleet.entity.FleetInfo; +import lombok.Data; + +@Data +public class FleetInfoUniVo extends FleetInfo { + + private String storeName; +} diff --git a/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java b/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java index 7f2ce6144..ba934b195 100644 --- a/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java +++ b/fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtUser.java @@ -86,12 +86,14 @@ public class MtUser implements Serializable { @ApiModelProperty("密码") private String password; + @TableField(exist = false) @ApiModelProperty("salt") private String salt; @ApiModelProperty("地址") private String address; + @TableField(exist = false) @ApiModelProperty("所属商户ID") private Integer merchantId; @@ -112,6 +114,7 @@ public class MtUser implements Serializable { @ApiModelProperty("备注信息") private String description; + @TableField(exist = false) @ApiModelProperty("最后操作人") private String operator; }