引入商户

This commit is contained in:
zjf committed 2024-12-12 19:17:38 +08:00
1 parent 423bfdac08
commit a37cf364c8
16 files changed
+781

No files matched your search

@@ -0,0 +1,171 @@
package com.bsd.pjcloud.canteen.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
import com.bsd.pjcloud.canteen.service.CanteenSpuService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
import com.bsd.pjcloud.canteen.service.CanteenDailyMenuService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 每日菜谱
*
* @author zjf
* @date 2024-12-11 14:44:13
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/canteenDailyMenu" )
@Tag(description = "canteenDailyMenu" , name = "每日菜谱管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class CanteenDailyMenuController {
private final CanteenDailyMenuService canteenDailyMenuService;
private final CanteenSpuService canteenSpuService;
/**
* 分页查询
* @param page 分页对象
* @param canteenDailyMenu 每日菜谱
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_canteenDailyMenu_view')" )
public R getCanteenDailyMenuPage(@ParameterObject Page page, @ParameterObject CanteenDailyMenuEntity canteenDailyMenu) {
LambdaQueryWrapper<CanteenDailyMenuEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(canteenDailyMenuService.page(page, wrapper));
}
/**
* 通过id查询每日菜谱
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_canteenDailyMenu_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(canteenDailyMenuService.getById(id));
}
/**
* 新增每日菜谱
* @param canteenDailyMenu 每日菜谱
* @return R
*/
@Operation(summary = "新增每日菜谱" , description = "新增每日菜谱" )
@SysLog("新增每日菜谱" )
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenDailyMenu_add')" )
public R save(@RequestBody CanteenDailyMenuEntity canteenDailyMenu) {
return R.ok(canteenDailyMenuService.save(canteenDailyMenu));
}
/**
* 修改每日菜谱
* @param canteenDailyMenu 每日菜谱
* @return R
*/
@Operation(summary = "修改每日菜谱" , description = "修改每日菜谱" )
@SysLog("修改每日菜谱" )
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenDailyMenu_edit')" )
public R updateById(@RequestBody CanteenDailyMenuEntity canteenDailyMenu) {
return R.ok(canteenDailyMenuService.updateById(canteenDailyMenu));
}
/**
* 通过id删除每日菜谱
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除每日菜谱" , description = "通过id删除每日菜谱" )
@SysLog("通过id删除每日菜谱" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_canteenDailyMenu_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(canteenDailyMenuService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param canteenDailyMenu 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_canteenDailyMenu_export')" )
public List<CanteenDailyMenuEntity> export(CanteenDailyMenuEntity canteenDailyMenu,Long[] ids) {
return canteenDailyMenuService.list(Wrappers.lambdaQuery(canteenDailyMenu).in(ArrayUtil.isNotEmpty(ids), CanteenDailyMenuEntity::getId, ids));
}
/**
* 获取指定周时间
*
* @param index
* @return
*/
@GetMapping("selectWeekInfo")
public R<List<String>> selectWeekInfo(Integer index) {
return R.ok(canteenDailyMenuService.selectWeekInfo(index));
}
/**
* 通过id查询每日菜谱
* @return R
*/
@Operation(summary = "菜品下拉列表" )
@GetMapping("/selectFoodList" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')" )
public R selectFoodList(@RequestParam(value = "spuName",required = false) String skuName) {
LambdaQueryWrapper<CanteenSpuEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(skuName),CanteenSpuEntity::getName,skuName);
wrapper.eq(CanteenSpuEntity::getSystemType,"2");
return R.ok(canteenSpuService.selectFoodList(wrapper));
}
/**
* 获取当天指定菜品
*/
@Operation(summary = "获取当天指定菜品" )
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')" )
@GetMapping("/selectTimeFood")
public R<List<DailyMenuAll>> selectTimeFood(String time, Long merchantId, Long categoryId) {
if (ObjectUtil.isEmpty(time)) {
time = DateUtil.today();
}
return R.ok(canteenDailyMenuService.selectTimeFood(time, merchantId, categoryId));
}
}
@@ -0,0 +1,131 @@
package com.bsd.pjcloud.canteen.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.canteen.entity.MerchantInfoEntity;
import com.bsd.pjcloud.canteen.service.MerchantInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 商户管理
*
* @author zjf
* @date 2024-12-12 14:39:52
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/merchantInfo" )
@Tag(description = "merchantInfo" , name = "商户管理管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MerchantInfoController {
private final MerchantInfoService merchantInfoService;
private final RemoteDeptService remoteDeptService;
/**
* 分页查询
* @param page 分页对象
* @param merchantInfo 商户管理
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_view')" )
public R getMerchantInfoPage(@ParameterObject Page page, @ParameterObject MerchantInfoEntity merchantInfo) {
LambdaQueryWrapper<MerchantInfoEntity> wrapper = Wrappers.lambdaQuery();
Page pageData = merchantInfoService.page(page, wrapper);
List<MerchantInfoEntity> records = pageData.getRecords();
List<Long> deptIds =
records.stream().map(MerchantInfoEntity::getDeptId).distinct().collect(Collectors.toList());
Map<Long, SysDept> sysDeptMap=remoteDeptService.getDeptByDeptIds(deptIds).getData();
records.forEach(record->{record.setDeptName(sysDeptMap.get(record.getDeptId())==null?"":sysDeptMap.get(record.getDeptId()).getName());});
return R.ok(pageData);
}
/**
* 通过id查询商户管理
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(merchantInfoService.getById(id));
}
/**
* 新增商户管理
* @param merchantInfo 商户管理
* @return R
*/
@Operation(summary = "新增商户管理" , description = "新增商户管理" )
@SysLog("新增商户管理" )
@PostMapping
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_add')" )
public R save(@RequestBody MerchantInfoEntity merchantInfo) {
return R.ok(merchantInfoService.save(merchantInfo));
}
/**
* 修改商户管理
* @param merchantInfo 商户管理
* @return R
*/
@Operation(summary = "修改商户管理" , description = "修改商户管理" )
@SysLog("修改商户管理" )
@PutMapping
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_edit')" )
public R updateById(@RequestBody MerchantInfoEntity merchantInfo) {
return R.ok(merchantInfoService.updateById(merchantInfo));
}
/**
* 通过id删除商户管理
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除商户管理" , description = "通过id删除商户管理" )
@SysLog("通过id删除商户管理" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(merchantInfoService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param merchantInfo 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('canteen_merchantInfo_export')" )
public List<MerchantInfoEntity> export(MerchantInfoEntity merchantInfo,Long[] ids) {
return merchantInfoService.list(Wrappers.lambdaQuery(merchantInfo).in(ArrayUtil.isNotEmpty(ids), MerchantInfoEntity::getId, ids));
}
}
@@ -0,0 +1,104 @@
package com.bsd.pjcloud.canteen.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 每日菜谱
*
* @author zjf
* @date 2024-12-11 14:44:13
*/
@Data
@TenantTable
@TableName("canteen_daily_menu")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "每日菜谱")
public class CanteenDailyMenuEntity extends Model<CanteenDailyMenuEntity> {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="主键id")
private Long id;
/**
* 开始时间
*/
@Schema(description="开始时间")
private LocalDate startTime;
/**
* 商品 SPU 编号
*/
@Schema(description="商品 SPU 编号")
private Long spuId;
/**
* 归属时间 1早餐 2午餐 3晚餐
*/
@Schema(description="归属时间 1早餐 2午餐 3晚餐")
private Integer hourType;
/**
* 商户id
*/
@Schema(description="商户id")
private Long merchantId;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
}
@@ -0,0 +1,132 @@
package com.bsd.pjcloud.canteen.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
* 商户管理
*
* @author zjf
* @date 2024-12-12 14:39:52
*/
@Data
@TenantTable
@TableName("merchant_info")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "商户管理")
public class MerchantInfoEntity extends Model<MerchantInfoEntity> {
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
private Long id;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 商户名
*/
@Schema(description="商户名")
private String name;
/**
* 商户类型(字典,1食堂 2超时)
*/
@Schema(description="商户类型(字典,1食堂 2超时)")
private String merchantType;
/**
* 商户logog
*/
@Schema(description="商户logog")
private String logo;
/**
* 商户收款二维码
*/
@Schema(description="商户收款二维码")
private String collectMoneyCode;
/**
* 轮播图
*/
@Schema(description="轮播图")
private String swiper;
/**
* 联系电话
*/
@Schema(description="联系电话")
private String phone;
/**
* 结束营业时间
*/
@Schema(description="结束营业时间")
private String businessTime;
/**
* 店铺地址
*/
@Schema(description="店铺地址")
private String address;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建者")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新者")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
@Schema(description = "部门名称")
@TableField(exist = false)
private String deptName;
}
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.canteen.mapper;
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
import com.bsd.pjcloud.canteen.dto.DailyMenuVO;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CanteenDailyMenuMapper extends PjcloudBaseMapper<CanteenDailyMenuEntity> {
List<DailyMenuVO> selectTimeFood(String time, Long merchantId, Long categoryId, DataScope dataScope);
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.canteen.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.canteen.entity.MerchantInfoEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MerchantInfoMapper extends PjcloudBaseMapper<MerchantInfoEntity> {
}
@@ -0,0 +1,28 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
import java.util.List;
public interface CanteenDailyMenuService extends IService<CanteenDailyMenuEntity> {
/**
* 获取当天指定菜品
* @param time
* @param merchantId
* @param categoryId
* @return
*/
List<DailyMenuAll> selectTimeFood(String time, Long merchantId, Long categoryId);
/**
* 获取指定周时间
* @param index
* @return
*/
List<String> selectWeekInfo(Integer index);
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.canteen.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.canteen.entity.MerchantInfoEntity;
public interface MerchantInfoService extends IService<MerchantInfoEntity> {
}
@@ -0,0 +1,75 @@
package com.bsd.pjcloud.canteen.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.dto.DailyMenuAll;
import com.bsd.pjcloud.canteen.dto.DailyMenuVO;
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
import com.bsd.pjcloud.canteen.mapper.CanteenDailyMenuMapper;
import com.bsd.pjcloud.canteen.service.CanteenDailyMenuService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
* 每日菜谱
*
* @author zjf
* @date 2024-12-11 14:44:13
*/
@Service
public class CanteenDailyMenuServiceImpl extends ServiceImpl<CanteenDailyMenuMapper, CanteenDailyMenuEntity> implements CanteenDailyMenuService {
@Override
public List<DailyMenuAll> selectTimeFood(String time, Long merchantId, Long categoryId) {
List<DailyMenuAll> dailyMenuAllES = new ArrayList<>();
List<DailyMenuVO> dailyMenuVOS = baseMapper.selectTimeFood(time, merchantId, categoryId, new DataScope());
Map<Integer, List<DailyMenuVO>> collect = dailyMenuVOS.stream().collect(Collectors.groupingBy(DailyMenuVO::getHourType));
collect.keySet().forEach(x -> {
DailyMenuAll dailyMenuAll = new DailyMenuAll();
dailyMenuAll.setDailyMenuVOS(collect.get(x));
dailyMenuAll.setHourType(x);
dailyMenuAllES.add(dailyMenuAll);
});
return dailyMenuAllES;
}
@Override
public List<String> selectWeekInfo(Integer index) {
List<String> weekSrt = Arrays.asList("(周一)", "(周二)", "(周三)", "(周四)", "(周五)", "(周六)", "(周天)");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
List<String> str = new ArrayList<>();
LocalDate monday = null;
//获取本周数据
if (index == null || index == 0) {
Calendar calendar = Calendar.getInstance();
// 获取今天的日期
LocalDate today = LocalDate.now();
// 获取当前周一的日期
monday = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
} else {
//实际时间算出周一
if (index > 0) {
monday = LocalDate.now().plusWeeks(index).with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
} else {
index = Math.abs(index);
monday = LocalDate.now().minusWeeks(index).with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
}
}
//数据转移
for (int i = 0; i < 7; i++) {
String time = monday.format(formatter);
str.add(time + weekSrt.get(i));
monday = monday.plusDays(1);
}
return str;
}
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.canteen.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.canteen.entity.MerchantInfoEntity;
import com.bsd.pjcloud.canteen.mapper.MerchantInfoMapper;
import com.bsd.pjcloud.canteen.service.MerchantInfoService;
import org.springframework.stereotype.Service;
/**
* 商户管理
*
* @author zjf
* @date 2024-12-12 14:39:52
*/
@Service
public class MerchantInfoServiceImpl extends ServiceImpl<MerchantInfoMapper, MerchantInfoEntity> implements MerchantInfoService {
}
@@ -0,0 +1,36 @@
<?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">
<mapper namespace="com.bsd.pjcloud.canteen.mapper.CanteenDailyMenuMapper">
<resultMap id="canteenDailyMenuMap" type="com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity">
<id property="id" column="id"/>
<result property="startTime" column="start_time"/>
<result property="spuId" column="spu_id"/>
<result property="hourType" column="hour_type"/>
<result property="merchantId" column="merchant_id"/>
<result property="deptId" column="dept_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<select id="selectTimeFood" resultType="com.bsd.pjcloud.canteen.dto.DailyMenuVO">
SELECT
sp.id,
t.id as tid,
sp.name,
sp.pic_url,
t.hour_type
FROM canteen_daily_menu t
LEFT JOIN canteen_spu sp
WHERE t.hour_type = #{hourType}
AND t.merchant_id = #{merchantId}
AND sp.category_id = #{categoryId}
AND sp.del_flag = 0
AND sp.start_time = #{time}
And t.del_flag = 0
</select>
</mapper>
@@ -0,0 +1,24 @@
<?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">
<mapper namespace="com.bsd.pjcloud.canteen.mapper.MerchantInfoMapper">
<resultMap id="merchantInfoMap" type="com.bsd.pjcloud.canteen.entity.MerchantInfoEntity">
<id property="id" column="id"/>
<result property="deptId" column="dept_id"/>
<result property="name" column="name"/>
<result property="merchantType" column="merchant_type"/>
<result property="logo" column="logo"/>
<result property="collectMoneyCode" column="collect_money_code"/>
<result property="swiper" column="swiper"/>
<result property="phone" column="phone"/>
<result property="businessTime" column="business_time"/>
<result property="address" column="address"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* @author pjcloud
@@ -52,4 +53,11 @@ public interface RemoteDeptService {
@GetMapping("/dept/leader/{deptId}")
R<List<Long>> getAllDeptLeader(@PathVariable("deptId") Long deptId);
/**
* 根据部门id集合查询
* @param deptIds
* @return
*/
@GetMapping("/dept/getDeptListByDeptIds")
R<Map<Long, SysDept>> getDeptByDeptIds(@RequestParam("deptIds")List<Long> deptIds);
}
@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -175,4 +176,10 @@ public class SysDeptController {
return R.ok(sysDeptService.getOrgTreeUser(username));
}
@GetMapping("/getDeptListByDeptIds")
public R<Map<Long,SysDept>> getDeptListByDeptIds(@RequestParam("deptIds") List<Long> deptIds) {
return R.ok(sysDeptService.getDeptListByDeptIds(deptIds));
}
}
@@ -86,4 +86,11 @@ public interface SysDeptService extends IService<SysDept> {
*/
List<OrgTreeVO> getOrgTreeUser(String username);
/**
* 根据ids查询map集合
* @param deptIds
* @return
*/
Map<Long, SysDept> getDeptListByDeptIds(List<Long> deptIds);
}
@@ -341,6 +341,12 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
.collect(Collectors.toList());
}
@Override
public Map<Long, SysDept> getDeptListByDeptIds(List<Long> deptIds) {
List<SysDept> sysDepts = baseMapper.selectList(Wrappers.<SysDept>lambdaQuery().in(SysDept::getDeptId, deptIds));
return sysDepts.stream().collect(Collectors.toMap(SysDept::getDeptId, sysDept -> sysDept));
}
/**
* 递归查询所有子节点。
* @param allDeptList 所有部门列表