Commit f0b8b43b by songyinghui

feat: 活码分权

parent 0d05a335
...@@ -11,6 +11,8 @@ import com.gic.haoban.base.api.common.BasePageInfo; ...@@ -11,6 +11,8 @@ import com.gic.haoban.base.api.common.BasePageInfo;
public class HmGroupQueryDTO extends BasePageInfo { public class HmGroupQueryDTO extends BasePageInfo {
private static final long serialVersionUID = 6456482769128766297L; private static final long serialVersionUID = 6456482769128766297L;
private String clerkId;
private String groupName; private String groupName;
private String enterpriseId; private String enterpriseId;
...@@ -43,4 +45,12 @@ public class HmGroupQueryDTO extends BasePageInfo { ...@@ -43,4 +45,12 @@ public class HmGroupQueryDTO extends BasePageInfo {
public void setEnterpriseId(String enterpriseId) { public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId; this.enterpriseId = enterpriseId;
} }
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
} }
...@@ -168,7 +168,7 @@ public interface TabHaobanHmQrcodeMapper { ...@@ -168,7 +168,7 @@ public interface TabHaobanHmQrcodeMapper {
* @author mozhu * @author mozhu
* @date 2022-07-12 17:39:12 * @date 2022-07-12 17:39:12
*/ */
List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(@Param("enterpriseId") String enterpriseId,@Param("groupIds") List<Long> groupIds); List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(@Param("enterpriseId") String enterpriseId,@Param("groupIds") List<Long> groupIds, @Param("hmIds") List<String> hmIds);
/** /**
* 获取总数 * 获取总数
......
...@@ -157,7 +157,7 @@ public interface HmQrcodeService { ...@@ -157,7 +157,7 @@ public interface HmQrcodeService {
* @author mozhu * @author mozhu
* @date 2022-07-12 17:38:43 * @date 2022-07-12 17:38:43
*/ */
List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String enterpriseId,List<Long> groupIds); List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String enterpriseId,List<Long> groupIds, List<String> hmIds);
/** /**
* 获取总数 * 获取总数
......
...@@ -123,8 +123,8 @@ public class HmQrcodeServiceImpl implements HmQrcodeService { ...@@ -123,8 +123,8 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
} }
@Override @Override
public List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String enterpriseId, List<Long> groupIds) { public List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String enterpriseId, List<Long> groupIds, List<String> hmIds) {
return tabHaobanHmQrcodeMapper.getGroupIdNumByEnterpriseId(enterpriseId, groupIds); return tabHaobanHmQrcodeMapper.getGroupIdNumByEnterpriseId(enterpriseId, groupIds, hmIds);
} }
@Override @Override
......
package com.gic.haoban.manage.service.service.out.impl.hm; package com.gic.haoban.manage.service.service.out.impl.hm;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon; import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.hm.HmGroupDTO; import com.gic.haoban.manage.api.dto.hm.HmGroupDTO;
import com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO; import com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.enums.hm.HmGroupStatus; import com.gic.haoban.manage.api.enums.hm.HmGroupStatus;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService; import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
import com.gic.haoban.manage.service.errorcode.HaoBanErrCode; import com.gic.haoban.manage.service.errorcode.HaoBanErrCode;
import com.gic.haoban.manage.service.pojo.bo.hm.HmGroupSettingBO; import com.gic.haoban.manage.service.pojo.bo.hm.HmGroupSettingBO;
...@@ -52,6 +56,9 @@ public class HmGroupApiServiceImpl implements HmGroupApiService { ...@@ -52,6 +56,9 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
@Autowired @Autowired
private HmQrcodeService qrcodeService; private HmQrcodeService qrcodeService;
@Autowired
private StaffApiService staffApiService;
@Override @Override
public ServiceResponse<Long> saveOrUpdateHmGroupSetting(HmGroupDTO hmGroupDTO) { public ServiceResponse<Long> saveOrUpdateHmGroupSetting(HmGroupDTO hmGroupDTO) {
log.info("[saveOrUpdateHmGroupSetting] params:{}", JSON.toJSONString(hmGroupDTO)); log.info("[saveOrUpdateHmGroupSetting] params:{}", JSON.toJSONString(hmGroupDTO));
...@@ -110,12 +117,23 @@ public class HmGroupApiServiceImpl implements HmGroupApiService { ...@@ -110,12 +117,23 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
} }
result.addAll(groupDtoPage.getResult()); result.addAll(groupDtoPage.getResult());
List<Long> groupIds = result.stream().map(HmGroupDTO::getGroupId).collect(Collectors.toList()); List<Long> groupIds = result.stream().map(HmGroupDTO::getGroupId).collect(Collectors.toList());
List<HmQrcodeGroupNumBO> qrcodeGroupNumBoList = qrcodeService.getGroupIdNumByEnterpriseId(groupQueryDTO.getEnterpriseId(), groupIds);
Map<Long, Integer> qrcodeGroupNumMap = Collections.emptyMap(); Map<Long, Integer> qrcodeGroupNumMap = Collections.emptyMap();
List<String> storeList = staffApiService.getHaoBanStoreIdsRolesByClerkId(groupQueryDTO.getClerkId(), groupQueryDTO.getWxEnterpriseId());
log.info("导购拥有的门店权限 clerkId:{}, storeIds:{}", groupQueryDTO.getClerkId(), JSON.toJSONString(storeList));
if (!CollectionUtils.isEmpty(storeList)) {
List<String> hmIds = null;
if (!storeList.contains("-1")) {
HmQrcodeListQDTO hmQrcodeListQDTO = new HmQrcodeListQDTO();
hmQrcodeListQDTO.setEnterpriseId(groupQueryDTO.getEnterpriseId());
hmQrcodeListQDTO.setStoreId(storeList);
hmIds = qrcodeService.listHmIdForIndex(hmQrcodeListQDTO);
}
List<HmQrcodeGroupNumBO> qrcodeGroupNumBoList = qrcodeService.getGroupIdNumByEnterpriseId(groupQueryDTO.getEnterpriseId(), groupIds, hmIds);
if (CollectionUtils.isNotEmpty(qrcodeGroupNumBoList)) { if (CollectionUtils.isNotEmpty(qrcodeGroupNumBoList)) {
qrcodeGroupNumMap = qrcodeGroupNumBoList.stream() qrcodeGroupNumMap = qrcodeGroupNumBoList.stream()
.collect(Collectors.toMap(HmQrcodeGroupNumBO::getHmGroupId, HmQrcodeGroupNumBO::getNum, (v1, v2) -> v1)); .collect(Collectors.toMap(HmQrcodeGroupNumBO::getHmGroupId, HmQrcodeGroupNumBO::getNum, (v1, v2) -> v1));
} }
}
for (HmGroupDTO groupDTO : result) { for (HmGroupDTO groupDTO : result) {
Integer referNum = Optional.ofNullable(qrcodeGroupNumMap.get(groupDTO.getGroupId())).orElse(0); Integer referNum = Optional.ofNullable(qrcodeGroupNumMap.get(groupDTO.getGroupId())).orElse(0);
groupDTO.setReferNum(referNum); groupDTO.setReferNum(referNum);
......
...@@ -377,6 +377,12 @@ ...@@ -377,6 +377,12 @@
#{id,jdbcType=VARCHAR} #{id,jdbcType=VARCHAR}
</foreach> </foreach>
</if> </if>
<if test="hmIds != null and hmIds.size > 0">
and hm_id in
<foreach collection="hmIds" open="(" close=")" separator="," item="hmId">
#{hmId}
</foreach>
</if>
GROUP BY hm_group_id GROUP BY hm_group_id
</select> </select>
......
...@@ -79,6 +79,7 @@ public class HmPageServiceTest { ...@@ -79,6 +79,7 @@ public class HmPageServiceTest {
HmGroupQueryDTO groupQueryDTO = new HmGroupQueryDTO(); HmGroupQueryDTO groupQueryDTO = new HmGroupQueryDTO();
//groupQueryDTO.setGroupName("默认"); //groupQueryDTO.setGroupName("默认");
groupQueryDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000"); groupQueryDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
groupQueryDTO.setClerkId("b7279937120a433b9d96ae3c9abedb04");
ServiceResponse<Page<HmGroupDTO>> pageServiceResponse = groupService.queryHmGroupSettingList(groupQueryDTO); ServiceResponse<Page<HmGroupDTO>> pageServiceResponse = groupService.queryHmGroupSettingList(groupQueryDTO);
System.out.println(JSON.toJSONString(pageServiceResponse)); System.out.println(JSON.toJSONString(pageServiceResponse));
} }
......
...@@ -74,6 +74,7 @@ public class HmGroupController extends WebBaseController { ...@@ -74,6 +74,7 @@ public class HmGroupController extends WebBaseController {
hmGroupQueryDTO.setPageSize(hmGroupQo.getPageSize()); hmGroupQueryDTO.setPageSize(hmGroupQo.getPageSize());
hmGroupQueryDTO.setWxEnterpriseId(wxEnterpriseId); hmGroupQueryDTO.setWxEnterpriseId(wxEnterpriseId);
hmGroupQueryDTO.setEnterpriseId(enterpriseId); hmGroupQueryDTO.setEnterpriseId(enterpriseId);
hmGroupQueryDTO.setClerkId(loginUser.getClerkId());
ServiceResponse<Page<HmGroupDTO>> serviceResponse = groupApiService.queryHmGroupSettingList(hmGroupQueryDTO); ServiceResponse<Page<HmGroupDTO>> serviceResponse = groupApiService.queryHmGroupSettingList(hmGroupQueryDTO);
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
......
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