Browse Source

重构国际化,代理商接口开发

master
caojianbin 8 months ago
parent
commit
701d91c470
  1. 41
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/component/FeignRequestHader.java
  2. 174
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FirmManageController.java
  3. 152
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FirmManage.java
  4. 34
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/FirmDeviceInfo.java
  5. 112
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/FirmManageVO.java
  6. 19
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FirmManageMapper.java
  7. 43
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FirmManageService.java
  8. 122
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FirmManageServiceImpl.java
  9. 16
      ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/FirmManageMapper.xml

41
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/component/FeignRequestHader.java

@ -0,0 +1,41 @@ @@ -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<String, String> 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()));
}
}

174
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FirmManageController.java

@ -0,0 +1,174 @@ @@ -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;
/**
* <p>
* 代理商管理入口
* </p>
*
* @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<String,Object> 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<FirmManage>()
.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<FirmManage> 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<FirmManage> 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<FirmManage> 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<FirmManage> queryAllData(){
return firmManageService.getBaseMapper().selectList(null);
}
}

152
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FirmManage.java

@ -0,0 +1,152 @@ @@ -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;
/**
* <p>
* 代理商实体类
* </p>
*
* @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;
}

34
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/FirmDeviceInfo.java

@ -0,0 +1,34 @@ @@ -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;
}

112
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/vo/FirmManageVO.java

@ -0,0 +1,112 @@ @@ -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;
}

19
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FirmManageMapper.java

@ -0,0 +1,19 @@ @@ -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;
/**
* <p>
* 代理商Mapper 接口
* </p>
*
* @author liy
* @since 2022-07-06
*/
public interface FirmManageMapper extends BaseMapper<FirmManage> {
SysUser queryFirmId(String userId);
}

43
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FirmManageService.java

@ -0,0 +1,43 @@ @@ -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;
/**
* <p>
* 代理商服务类
* </p>
*
* @author liy
* @since 2022-07-06
*/
public interface FirmManageService extends IService<FirmManage> {
/**
* 代理商分页查询
* @Author liy
* @Date 2022/7/6 10:42
* @param map 分页查询体
* @return IPage
*/
IPage<FirmManage> findAllByPage(Map<String,Object> map);
/**
* 显示所有厂商名称
* @Author liy
* @Date 2022/7/12 16:42
* @return list
*/
List<FirmTree> queryAll();
/**
* 构建树
* @Author liy
* @Date 2022/7/19 11:07
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return List<FirmTree> 权限树集合
*/
List<FirmTree> queryTree(boolean lazy, String parentId);
}

122
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FirmManageServiceImpl.java

@ -0,0 +1,122 @@ @@ -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;
/**
* <p>
* 服务实现类
* </p>
*
* @author liy
* @since 2022-07-06
*/
@Service
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper, FirmManage> implements FirmManageService {
@Autowired
private FirmManageMapper firmManageMapper;
/**
* 代理商分页查询
* @Author liy
* @Date 2022/7/6 10:42
* @param map 分页查询体
* @return IPage
*/
@Override
public IPage<FirmManage> findAllByPage(Map<String,Object> map) {
Page<FirmManage> page=new Page<>(Integer.parseInt(map.get(FieldConstant.CURRENT).toString()),Integer.parseInt(map.get(FieldConstant.SIZE).toString()));
LambdaQueryWrapper<FirmManage> 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<FirmTree> queryAll() {
String userId = SecurityContextHolder.getStringUserId();
LambdaQueryWrapper<FirmManage> 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<FirmTree> 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<FirmTree> 树形集合
*/
@Override
public List<FirmTree> queryTree(boolean lazy, String parentId) {
String userId = SecurityContextHolder.getStringUserId();
LambdaQueryWrapper<FirmManage> 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);
}
}

16
ecell-internationalize/ecell-internationalize-system/src/main/resources/com/ecell/internationalize/system/mapper/FirmManageMapper.xml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<?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.ecell.internationalize.system.mapper.FirmManageMapper">
<resultMap id="BaseMapResult" type="com.ecell.internationalize.system.entity.FirmManage">
<id property="firmId" column="firm_id"/>
<result property="phone" column="phone"/>
<result property="firmName" column="firm_Name"/>
</resultMap>
<select id="queryFirmId" resultType="com.ecell.internationalize.common.system.entity.SysUser" parameterType="java.lang.String">
select * from sys_user where user_id=#{userId}
</select>
</mapper>
Loading…
Cancel
Save