Commit 98f6cc3b authored by hezhen's avatar hezhen

Merge branch 'master-tiande' into dev-tiande

parents cba554d7 1b4a4edc
package com.github.wxiaoqi.security.common.vo;
import java.util.List;
public interface DataInter {
List<Integer> getDataCompanyIds();
List<Integer> getDataCorporationIds();
void setDataCompanyIds(List<Integer> dataCompanyIds);
void setDataCorporationIds(List<Integer> dataCorporationIds);
}
...@@ -20,6 +20,10 @@ public class UserDTO extends User { ...@@ -20,6 +20,10 @@ public class UserDTO extends User {
return str2List(getDataCompany()); return str2List(getDataCompany());
} }
public List<Integer> dataCorporation2List() {
return str2List(getDataCorporation());
}
private List<Integer> str2List(String str) { private List<Integer> str2List(String str) {
if(StringUtils.isNotBlank(str)) { if(StringUtils.isNotBlank(str)) {
return Arrays.asList(str.split(",")).parallelStream().map(s -> Integer.valueOf(s)).collect(Collectors.toList()); return Arrays.asList(str.split(",")).parallelStream().map(s -> Integer.valueOf(s)).collect(Collectors.toList());
......
...@@ -6,12 +6,15 @@ import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; ...@@ -6,12 +6,15 @@ import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.DataInter;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
public interface UserRestInterface { public interface UserRestInterface {
public UserFeign getUserFeign(); public UserFeign getUserFeign();
default HttpServletRequest getRequest() { default HttpServletRequest getRequest() {
...@@ -41,4 +44,28 @@ public interface UserRestInterface { ...@@ -41,4 +44,28 @@ public interface UserRestInterface {
throw new BaseException(ResultCode.NOTEXIST_CODE); throw new BaseException(ResultCode.NOTEXIST_CODE);
} }
} }
default void setPowerData(DataInter dataInter){
UserDTO userDTO = getAdminUserInfo();
if (userDTO == null) {
return;
}
Integer dataAll=userDTO.getDataAll()== null ? 2 : userDTO.getDataAll();
if (dataAll == 2){
List<Integer> dataCompany2List = userDTO.dataCompany2List();
if (dataCompany2List != null && dataCompany2List.size() > 0){
dataInter.setDataCompanyIds(dataCompany2List);
}else {
List<Integer> dataCorporation2List = userDTO.dataCorporation2List();
if (dataCorporation2List != null && dataCorporation2List.size() > 0){
dataInter.setDataCorporationIds(dataCorporation2List);
}else {
List<Integer> ids=new ArrayList<>();
ids.add(0);
dataInter.setDataCompanyIds(ids);
}
}
}
}
} }
package com.xxfc.platform.vehicle.pojo; package com.xxfc.platform.vehicle.pojo;
import com.github.wxiaoqi.security.common.vo.DataInter;
import com.github.wxiaoqi.security.common.vo.PageParam; import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@Data @Data
public class CompanySearchDTO extends PageParam { public class CompanySearchDTO extends PageParam implements DataInter {
Integer addrCity; Integer addrCity;
String lon; String lon;
String lat; String lat;
...@@ -23,4 +24,9 @@ public class CompanySearchDTO extends PageParam { ...@@ -23,4 +24,9 @@ public class CompanySearchDTO extends PageParam {
List<Integer> companyIds; List<Integer> companyIds;
List<Integer> dataCorporationIds;
List<Integer> dataCompanyIds;
} }
...@@ -54,8 +54,7 @@ import java.util.concurrent.TimeUnit; ...@@ -54,8 +54,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.auth.common.constatns.CommonConstants.DATA_ALL_FALSE; import static com.github.wxiaoqi.security.auth.common.constatns.CommonConstants.DATA_ALL_FALSE;
import static com.xxfc.platform.vehicle.constant.DbColumnConstant.COMPANY_ZONE_ID; import static com.xxfc.platform.vehicle.constant.DbColumnConstant.*;
import static com.xxfc.platform.vehicle.constant.DbColumnConstant.ID;
import static com.xxfc.platform.vehicle.constant.RedisKey.BRANCH_COMPANY_CACHE_DATAZONE; import static com.xxfc.platform.vehicle.constant.RedisKey.BRANCH_COMPANY_CACHE_DATAZONE;
@Service @Service
...@@ -208,6 +207,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -208,6 +207,9 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
if (StringUtils.isNotBlank(userDTO.getDataCompany())) { if (StringUtils.isNotBlank(userDTO.getDataCompany())) {
criteria.andIn(ID, userDTO.dataCompany2List()); criteria.andIn(ID, userDTO.dataCompany2List());
} }
if (StringUtils.isNotBlank(userDTO.getDataCorporation())) {
criteria.andIn(COMPANY_COMPANY_ID, userDTO.dataCorporation2List());
}
} }
example.setOrderByClause("`id` desc"); example.setOrderByClause("`id` desc");
PageHelper.startPage(page, limit); PageHelper.startPage(page, limit);
......
package com.xxfc.platform.vehicle.rest.admin; package com.xxfc.platform.vehicle.rest.admin;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
...@@ -11,6 +13,7 @@ import com.xxfc.platform.vehicle.pojo.CompanySearchDTO; ...@@ -11,6 +13,7 @@ import com.xxfc.platform.vehicle.pojo.CompanySearchDTO;
import com.xxfc.platform.vehicle.pojo.CompanySearchVO; import com.xxfc.platform.vehicle.pojo.CompanySearchVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -22,11 +25,20 @@ import java.util.List; ...@@ -22,11 +25,20 @@ import java.util.List;
@IgnoreClientToken @IgnoreClientToken
@IgnoreUserToken @IgnoreUserToken
@Api(value="公司controller",tags={"公司操作接口"}) @Api(value="公司controller",tags={"公司操作接口"})
public class AdminBranchCompanyController extends BaseController<BranchCompanyBiz,BranchCompany> { public class AdminBranchCompanyController extends BaseController<BranchCompanyBiz,BranchCompany> implements UserRestInterface {
@Autowired
UserFeign userFeign;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@RequestMapping(value ="/search",method = RequestMethod.GET) @RequestMapping(value ="/search",method = RequestMethod.GET)
public RestResponse<PageDataVO<CompanySearchVO>> search(@Validated CompanySearchDTO vo) { public RestResponse<PageDataVO<CompanySearchVO>> search(@Validated CompanySearchDTO vo) {
setPowerData(vo);
return RestResponse.data(baseBiz.search(vo)); return RestResponse.data(baseBiz.search(vo));
} }
......
...@@ -63,6 +63,18 @@ ...@@ -63,6 +63,18 @@
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="dataCompanyIds != null and dataCompanyIds.size > 0">
and c.id in
<foreach collection="dataCompanyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="dataCorporationIds != null and dataCorporationIds.size > 0">
and c.company_id in
<foreach collection="dataCorporationIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where> </where>
<choose> <choose>
<when test="lon != null and lat != null"> <when test="lon != null and lat != null">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment