diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/component/FeignRequestHader.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/component/FeignRequestHader.java new file mode 100644 index 0000000..ebc4d8a --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/component/FeignRequestHader.java @@ -0,0 +1,41 @@ +package com.ecell.internationalize.system.component; +import com.ecell.internationalize.common.core.utils.StringUtils; +import com.ecell.internationalize.system.constant.DeviceModelConstants; +import com.ecell.internationalize.system.utils.HttpServletUtil; +import com.ecell.internationalize.system.utils.IpUtil; +import feign.RequestInterceptor; +import feign.RequestTemplate; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +//@Component +public class FeignRequestHader implements RequestInterceptor { + @Override + public void apply(RequestTemplate requestTemplate) { + HttpServletRequest request = HttpServletUtil.getRequest(); + if (StringUtils.isNotNull(request)){ + Map headers = HttpServletUtil.getHeaders(request); + String userId = headers.get(DeviceModelConstants.DETAILS_USER_ID); + if (StringUtils.isNotEmpty(userId)) + { + requestTemplate.header(DeviceModelConstants.DETAILS_USER_ID, userId); + } + String userName = headers.get(DeviceModelConstants.DETAILS_USERNAME); + if (StringUtils.isNotEmpty(userName)) + { + requestTemplate.header(DeviceModelConstants.DETAILS_USERNAME, userName); + } + String authentication = headers.get(DeviceModelConstants.AUTHORIZATION_HEADER); + if (StringUtils.isNotEmpty(authentication)) + { + requestTemplate.header(DeviceModelConstants.AUTHORIZATION_HEADER, authentication); + } + + + } + + // 配置客户端IP + requestTemplate.header("X-Forwarded-For", IpUtil.getIpAddr(HttpServletUtil.getRequest())); + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FirmManageController.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FirmManageController.java new file mode 100644 index 0000000..e6b55ee --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FirmManageController.java @@ -0,0 +1,174 @@ +package com.ecell.internationalize.system.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ecell.internationalize.common.core.utils.StringUtils; +import com.ecell.internationalize.common.core.utils.locale.LocaleUtil; +import com.ecell.internationalize.common.core.utils.uuid.UUID; +import com.ecell.internationalize.common.core.web.controller.BaseController; +import com.ecell.internationalize.common.core.web.domain.AjaxResult; +import com.ecell.internationalize.common.security.utils.SecurityUtils; +import com.ecell.internationalize.common.system.annotation.SystemLog; +import com.ecell.internationalize.common.system.constant.FieldConstant; +import com.ecell.internationalize.system.entity.FirmManage; +import com.ecell.internationalize.system.entity.vo.DeviceActivaVO; +import com.ecell.internationalize.system.service.FirmManageService; +import com.ecell.internationalize.system.service.impl.DeviceInfoServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + *

+ * 代理商管理入口 + *

+ * + * @author liy + * @since 2022-07-06 + */ +@Api(value="厂商管理",tags={"厂商管理接口"}) +@RestController +@RequestMapping("/firm_manage") +public class FirmManageController extends BaseController { + @Autowired + private FirmManageService firmManageService; + @Autowired + private DeviceInfoServiceImpl deviceInfoService; + /** + * 厂商管理条件分页查询 + * @Author liy + * @Date 2022/7/6 10:38 + * @param map 分页条件查询体 + * @Return AjaxResult + */ + @ApiOperation("条件分页查询厂商管理信息") + @PostMapping("firm/pageList") + public AjaxResult queryAllByPage(@RequestBody Map map){ + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManageService.findAllByPage(map)); + } + /** + * 显示所有父级厂商名称 + * @Author liy + * @Date 2022/7/12 14:38 + * @Return AjaxResult + */ + @ApiOperation("查询接口显示树形结构") + @GetMapping("firm/queryAll") + public AjaxResult queryAll(){ + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManageService.queryAll()); + } + /** + * 新增厂商信息 + * @Author liy + * @Date 2022/7/6 16:38 + * @param firmManage 代理商 + * @Return AjaxResult + */ + @ApiOperation("新增厂商信息") + @SystemLog(msg =FieldConstant.FIRM_MANAGE,operation = FieldConstant.SAVE_OPERATOR) + @PostMapping("firm/save") + public AjaxResult insertFirm(@RequestBody FirmManage firmManage){ + int count = firmManageService.count(new QueryWrapper() + .eq(FieldConstant.FIRM_NAME_COLUMN,firmManage.getFirmName()) + .eq(FieldConstant.PARENT_ID,FieldConstant.TREE_ROOT_ID)); + if (count>0){ + //存在相同父厂商名称,直接返回结果 + return AjaxResult.error(LocaleUtil.getMessage(FieldConstant.FIRM_NAME_EXIT)); + } + String parentId= StringUtils.isEmpty(firmManage.getParentId())?FieldConstant.TREE_ROOT_ID:firmManage.getId(); + firmManage.setParentId(parentId); + String firmId= UUID.randomUUID().toString(true); + firmManage.setFirmId(firmId); + firmManage.setCreateUser(SecurityUtils.getUsername()); + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManageService.save(firmManage)); + } + /** + * 修改厂商信息 + * @Author liy + * @Date 2022/7/6 16:38 + * @param firmManage 代理商 + * @Return AjaxResult + */ + @ApiOperation("修改厂商信息") + @SystemLog(msg =FieldConstant.FIRM_MANAGE,operation = FieldConstant.UPDATE_OPERATOR) + @PostMapping("firm/update") + public AjaxResult updateFirm(@RequestBody FirmManage firmManage){ + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(FirmManage::getFirmName,firmManage.getFirmName()); + lambdaQueryWrapper.eq(FirmManage::getParentId,FieldConstant.TREE_ROOT_ID); + FirmManage firmManage1 = firmManageService.getBaseMapper().selectOne(lambdaQueryWrapper); + //修改名称相同 + if (null!=firmManage1&&!firmManage1.getFirmId().equals(firmManage.getFirmId())){ + //存在相同父厂商名称,直接返回结果 + return AjaxResult.error(LocaleUtil.getMessage(FieldConstant.FIRM_NAME_EXIT)); + } + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManageService.updateById(firmManage)); + } + /** + * 构建树 + * @Author liy + * @Date 2022/7/19 10:38 + * @param lazy 是否是懒加载 + * @param parentId 父节点ID + * @Return AjaxResult + */ + @ApiOperation("构建厂商父子节点树") + @GetMapping(value = "firm/queryTree") + public AjaxResult getTree(boolean lazy, String parentId) { + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManageService.queryTree(lazy,parentId)); + } + /** + * 根据父级Id查询下面的所有代理商 + * @Author liy + * @Date 2022/7/19 10:38 + * @param firmId 父级Id + * @Return AjaxResult + */ + @ApiOperation("根据Id查询厂商下面所有的代理商") + @GetMapping(value = "firm/queryById") + public AjaxResult queryById(@ApiParam(value="父级Id",required=true)String firmId) { + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(FirmManage::getParentId,firmId); + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManageService.getBaseMapper().selectList(lambdaQueryWrapper)); + } + /** + * 根据firmId查询代理商 + * @Author liy + * @Date 2022/7/19 10:38 + * @param id 父级Id + * @Return AjaxResult + */ + @ApiOperation("据firmId查询代理商") + @GetMapping(value = "firm/queryByAgentId") + public AjaxResult queryByAgentId(@ApiParam(value="firmId",required=true)String id) { + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(FirmManage::getFirmId,id); + FirmManage firmManage = firmManageService.getBaseMapper().selectOne(lambdaQueryWrapper); + DeviceActivaVO deviceActivaVO; + if (FieldConstant.TREE_ROOT_ID.equals(firmManage.getParentId())){ + deviceActivaVO= deviceInfoService.queryFirmCountDevice(id,null); + }else { + deviceActivaVO = deviceInfoService.queryFirmCountDevice(null,id); + } + firmManage.setImportNum(deviceActivaVO.getInputDevice()); + firmManage.setActiveNum(deviceActivaVO.getActivateDevice()); + return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS),firmManage); + } + /** + * 显示所有厂商代理商名称 + * @Author liy + * @Date 2022/7/12 14:38 + * @Return AjaxResult + */ + @ApiOperation("查询所有厂商/代理商信息") + @GetMapping("firm/queryAllData") + public List queryAllData(){ + return firmManageService.getBaseMapper().selectList(null); + } +} + diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FirmManage.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FirmManage.java new file mode 100644 index 0000000..6ecb4d3 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FirmManage.java @@ -0,0 +1,152 @@ +package com.ecell.internationalize.system.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + *

+ * 代理商实体类 + *

+ * + * @author liy + * @since 2022-07-06 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("firm_manage") +public class FirmManage{ + + private static final long serialVersionUID = 1L; + + /** + * 厂商Id + */ + @TableId("firm_id") + private String firmId; + /** + * 子节点Id + */ + @TableField(exist = false) + private String id; + /** + * 父类Id + */ + private String parentId; + /** + * 联系人电话号码 + */ + @NotBlank(message = "联系人电话号码不能为空") + private String phone; + /** + * 代理商昵称 + */ + @TableField("firm_name") + @NotBlank(message = "厂商名称不能为空") + private String firmName; + /** + * 账号状态 0:禁用 1:启用 + */ + private String status; + /** + * 后台账号 + */ + private String account; + /** + * 后台密码 + */ + private String password; + /** + * 截至时间 + */ + @TableField("last_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date lastTime; + /** + * 联系人 + */ + @TableField("link_man") + @NotBlank(message = "企业联系人不能为空") + private String linkMan; + /** + * 合作开始时间 + */ + @TableField("start_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @NotNull(message = "合作开始时间不能为空") + private Date startTime; + /** + * 企业地址 + */ + @NotBlank(message = "企业地址不能为空") + private String location; + /** + * 代理商编号 + */ + @TableField("firm_code") + @NotBlank(message = "厂商编号不能为空") + private String firmCode; + /** + * 推广人员 + */ + @TableField("sales_man") + @NotBlank(message = "推广人员不能为空") + private String salesMan; + /** + * 企业邮箱 + */ + @TableField("firm_email") + @NotBlank(message = "企业邮箱不能为空") + private String firmEmail; + /** + * 合作结束时间 + */ + @TableField("end_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @NotNull(message = "合作结束时间不能为空") + private Date endTime; + /** + * 导入个数 + */ + @TableField("import_num") + private Integer importNum; + /** + * 激活个数 + */ + @TableField("active_num") + private Integer activeNum; + /** + * 创建人 + */ + @TableField(value = "create_user") + private String createUser; + /** + * 创建时间 + */ + @TableField(value = "create_time",fill = FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /** + * 修改人 + */ + @TableField(value = "update_user") + private String updateUser; + /** + * 修改时间 + */ + @TableField(value = "update_time",fill = FieldFill.UPDATE) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/FirmDeviceInfo.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/FirmDeviceInfo.java new file mode 100644 index 0000000..e39edbe --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/FirmDeviceInfo.java @@ -0,0 +1,34 @@ +package com.ecell.internationalize.system.entity.api; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author borui + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class FirmDeviceInfo implements Serializable { + private static final long serialVersionUID=1L; + private String imei; + private String vendor; + private String name; + private String phone; + private String sex; + private String birthday; + private String height; + private String weight; + private String image; + + private int dialSwitch; + private int rejectStrange; + private int positioningInterval; + + private ApiLastLocationInfo apiLastLocationInfo; + + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/FirmManageVO.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/FirmManageVO.java new file mode 100644 index 0000000..f4ddca0 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/FirmManageVO.java @@ -0,0 +1,112 @@ +package com.ecell.internationalize.system.entity.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; + +/** + * @Title: FirmManageVO + * @Author: liy + * @Date: 2022/7/19 9:22 + * @Description: + * @Version:1.0 + */ +@Data +public class FirmManageVO { + /** + * 厂商Id + */ + private String firmId; + /** + * 父类Id + */ + private String parentId; + /** + * 联系人电话号码 + */ + private String phone; + /** + * 代理商昵称 + */ + private String firmName; + /** + * 账号状态 0:禁用 1:启用 + */ + private String status; + /** + * 后台账号 + */ + private String account; + /** + * 后台密码 + */ + private String password; + /** + * 截至时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date lastTime; + /** + * 联系人 + */ + private String linkMan; + /** + * 合作开始时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + /** + * 企业地址 + */ + private String location; + /** + * 代理商编号 + */ + @TableField("firm_code") + private String firmCode; + /** + * 推广人员 + */ + @TableField("sales_man") + private String salesMan; + /** + * 企业邮箱 + */ + @TableField("firm_email") + private String firmEmail; + /** + * 合作结束时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + /** + * 导入个数 + */ + @TableField("import_num") + private Integer importNum; + /** + * 激活个数 + */ + private Integer activeNum; + /** + * 创建人 + */ + private String createUser; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /** + * 修改人 + */ + private String updateUser; + /** + * 修改时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FirmManageMapper.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FirmManageMapper.java new file mode 100644 index 0000000..81234e8 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FirmManageMapper.java @@ -0,0 +1,19 @@ +package com.ecell.internationalize.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ecell.internationalize.common.system.entity.SysUser; +import com.ecell.internationalize.system.entity.FirmManage; + + +/** + *

+ * 代理商Mapper 接口 + *

+ * + * @author liy + * @since 2022-07-06 + */ +public interface FirmManageMapper extends BaseMapper { + + SysUser queryFirmId(String userId); +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FirmManageService.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FirmManageService.java new file mode 100644 index 0000000..1bcbe64 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FirmManageService.java @@ -0,0 +1,43 @@ +package com.ecell.internationalize.system.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ecell.internationalize.system.entity.FirmManage; +import com.ecell.internationalize.system.entity.vo.FirmTree; + +import java.util.List; +import java.util.Map; + +/** + *

+ * 代理商服务类 + *

+ * + * @author liy + * @since 2022-07-06 + */ +public interface FirmManageService extends IService { + /** + * 代理商分页查询 + * @Author liy + * @Date 2022/7/6 10:42 + * @param map 分页查询体 + * @return IPage + */ + IPage findAllByPage(Map map); + /** + * 显示所有厂商名称 + * @Author liy + * @Date 2022/7/12 16:42 + * @return list + */ + List queryAll(); + /** + * 构建树 + * @Author liy + * @Date 2022/7/19 11:07 + * @param lazy 是否是懒加载 + * @param parentId 父节点ID + * @return List 权限树集合 + */ + List queryTree(boolean lazy, String parentId); +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FirmManageServiceImpl.java b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FirmManageServiceImpl.java new file mode 100644 index 0000000..1a63bab --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FirmManageServiceImpl.java @@ -0,0 +1,122 @@ +package com.ecell.internationalize.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.ecell.internationalize.common.core.context.SecurityContextHolder; +import com.ecell.internationalize.common.system.constant.FieldConstant; +import com.ecell.internationalize.common.system.entity.SysUser; +import com.ecell.internationalize.system.entity.FirmManage; +import com.ecell.internationalize.system.entity.vo.FirmTree; +import com.ecell.internationalize.system.mapper.FirmManageMapper; +import com.ecell.internationalize.system.service.FirmManageService; +import com.ecell.internationalize.system.utils.TreeUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + *

+ * 服务实现类 + *

+ * + * @author liy + * @since 2022-07-06 + */ +@Service +public class FirmManageServiceImpl extends ServiceImpl implements FirmManageService { + @Autowired + private FirmManageMapper firmManageMapper; + /** + * 代理商分页查询 + * @Author liy + * @Date 2022/7/6 10:42 + * @param map 分页查询体 + * @return IPage + */ + @Override + public IPage findAllByPage(Map map) { + Page page=new Page<>(Integer.parseInt(map.get(FieldConstant.CURRENT).toString()),Integer.parseInt(map.get(FieldConstant.SIZE).toString())); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (map.containsKey(FieldConstant.FIRM_NAME)&&null!=map.get(FieldConstant.FIRM_NAME).toString()){ + queryWrapper.eq(FirmManage::getFirmName,map.get(FieldConstant.FIRM_NAME).toString()); + } + return firmManageMapper.selectPage(page,queryWrapper); + } + /** + * 显示所有厂商名称 + * @Author liy + * @Date 2022/7/12 16:42 + * @return list + */ + @Override + public List queryAll() { + String userId = SecurityContextHolder.getStringUserId(); + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.orderByDesc(FirmManage::getCreateTime); + SysUser sysUser = firmManageMapper.queryFirmId(userId); + if (FieldConstant.ADMIN.equals(userId) || "3".equals(sysUser.getFirmFlag())){ + //管理员或者超级厂商显示所有厂商 + return TreeUtil.buildFirmTree(firmManageMapper.selectList(lambdaQueryWrapper),FieldConstant.TREE_ROOT_ID); + } + //厂商 + if (FieldConstant.MATH_ONE.equals(sysUser.getFirmFlag())){ + //如果该用户选择的是厂商,显示厂商以及厂商下面的所有代理商 + lambdaQueryWrapper.eq(FirmManage::getFirmId,sysUser.getFirmId()); + lambdaQueryWrapper.or().eq(FirmManage::getParentId,sysUser.getFirmId()); + return TreeUtil.buildFirmTree(firmManageMapper.selectList(lambdaQueryWrapper),FieldConstant.TREE_ROOT_ID); + } + //代理商 + else { + List list=new ArrayList<>(); + //为代理商 + lambdaQueryWrapper.or().eq(FirmManage::getFirmId,sysUser.getSecondFirmId()); + FirmManage firmManage = firmManageMapper.selectOne(lambdaQueryWrapper); + FirmTree firmTree=new FirmTree(); + firmTree.setFirmName(firmManage.getFirmName()); + firmTree.setCreateTime(new Date()); + firmTree.setId(firmManage.getFirmId()); + list.add(firmTree); + return list; + } + } + + /** + * 构建树查询 1. 不是懒加载情况,查询全部 2. 是懒加载,根据parentId 查询 2.1 父节点为空,则查询ID -1 + * @Author liy + * @Date 2022/7/19 11:07 + * @param lazy 是否是懒加载 + * @param parentId 父节点ID + * @return List 树形集合 + */ + @Override + public List queryTree(boolean lazy, String parentId) { + String userId = SecurityContextHolder.getStringUserId(); + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); + lambdaQueryWrapper.orderByDesc(FirmManage::getCreateTime); + SysUser sysUser = firmManageMapper.queryFirmId(userId); + if (FieldConstant.ADMIN.equals(userId) || "3".equals(sysUser.getFirmFlag())){ + //管理员或者超级厂商显示所有厂商 + return TreeUtil.buildFirmTree(firmManageMapper.selectList(lambdaQueryWrapper),FieldConstant.TREE_ROOT_ID); + } + //厂商 + if (FieldConstant.MATH_ONE.equals(sysUser.getFirmFlag())){ + //如果该用户选择的是厂商,显示厂商以及厂商下面的所有代理商 + lambdaQueryWrapper.eq(FirmManage::getFirmId,sysUser.getFirmId()); + lambdaQueryWrapper.or().eq(FirmManage::getParentId,sysUser.getFirmId()); + } + //代理商 + else { + //为代理商 + lambdaQueryWrapper.eq(FirmManage::getFirmId,sysUser.getFirmId()); + lambdaQueryWrapper.or().eq(FirmManage::getFirmId,sysUser.getSecondFirmId()); + } + + return TreeUtil.buildFirmTree(firmManageMapper.selectList(lambdaQueryWrapper),FieldConstant.TREE_ROOT_ID); + } +} diff --git a/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/FirmManageMapper.xml b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/FirmManageMapper.xml new file mode 100644 index 0000000..14b1a59 --- /dev/null +++ b/ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/FirmManageMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file