|
@@ -63,12 +63,12 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
.setName("管理员").setType("customerAdmin");
|
|
.setName("管理员").setType("customerAdmin");
|
|
spRoleMapper.add(spRole);
|
|
spRoleMapper.add(spRole);
|
|
long roleId = SP.publicMapper.getPrimarykey();
|
|
long roleId = SP.publicMapper.getPrimarykey();
|
|
- List<String>codeList=new ArrayList<>();
|
|
|
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
for (String type : StrUtil.splitTrim(t.getType(), ",")) {
|
|
for (String type : StrUtil.splitTrim(t.getType(), ",")) {
|
|
- SoMap perSoMap = SoMap.getRequestSoMap();
|
|
|
|
|
|
+ SoMap perSoMap = SoMap.getRequestSoMap();
|
|
perSoMap.put("type", type);
|
|
perSoMap.put("type", type);
|
|
- List<TbInitPermission>permissions= tbInitPermissionService.getList(perSoMap);
|
|
|
|
- codeList.addAll(permissions.stream().map(TbInitPermission::getCode).distinct().collect(Collectors.toList()));
|
|
|
|
|
|
+ List<TbInitPermission> permissions = tbInitPermissionService.getList(perSoMap);
|
|
|
|
+ codeList.addAll(permissions.stream().map(TbInitPermission::getCode).distinct().collect(Collectors.toList()));
|
|
}
|
|
}
|
|
spRolePermissionMapper.saveRolePer(roleId, codeList);
|
|
spRolePermissionMapper.saveRolePer(roleId, codeList);
|
|
return 1;
|
|
return 1;
|
|
@@ -83,7 +83,7 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
return StrUtil.equals(db.getId(), t.getId());
|
|
return StrUtil.equals(db.getId(), t.getId());
|
|
}
|
|
}
|
|
|
|
|
|
- public TbCostomer findByName(String name){
|
|
|
|
|
|
+ public TbCostomer findByName(String name) {
|
|
QueryWrapper<TbCostomer> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TbCostomer> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("name", name);
|
|
queryWrapper.eq("name", name);
|
|
return this.getOne(queryWrapper);
|
|
return this.getOne(queryWrapper);
|
|
@@ -97,7 +97,7 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
SoMap soMap = SoMap.getRequestSoMap();
|
|
SoMap soMap = SoMap.getRequestSoMap();
|
|
soMap.put("customerId", id);
|
|
soMap.put("customerId", id);
|
|
List<SpRole> roles = spRoleMapper.getList(soMap);
|
|
List<SpRole> roles = spRoleMapper.getList(soMap);
|
|
- if (roles.isEmpty()){
|
|
|
|
|
|
+ if (roles.isEmpty()) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
spRoleMapper.removeByCustomerId(id);
|
|
spRoleMapper.removeByCustomerId(id);
|
|
@@ -118,7 +118,6 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
* 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
*/
|
|
*/
|
|
@@ -130,22 +129,22 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
|
|
|
|
public int updateStatus(String id, int value) {
|
|
public int updateStatus(String id, int value) {
|
|
int line = SP.publicMapper.updateColumnById(TbCostomer.TABLE_NAME, "status", value, id);
|
|
int line = SP.publicMapper.updateColumnById(TbCostomer.TABLE_NAME, "status", value, id);
|
|
- int status=value==1?1:2;
|
|
|
|
- spAdminMapper.updateCustomerAdmin(id,status);
|
|
|
|
|
|
+ int status = value == 1 ? 1 : 2;
|
|
|
|
+ spAdminMapper.updateCustomerAdmin(id, status);
|
|
return line;
|
|
return line;
|
|
}
|
|
}
|
|
|
|
|
|
- public void judge(String id, int status,String judgeContent) {
|
|
|
|
- TbCostomer costomer= this.getById(id);
|
|
|
|
|
|
+ public void judge(String id, int status, String judgeContent) {
|
|
|
|
+ TbCostomer costomer = this.getById(id);
|
|
costomer.setJudgeContent(judgeContent)
|
|
costomer.setJudgeContent(judgeContent)
|
|
- .setJudgeStatus(status).setJudgeTime(new Date());
|
|
|
|
|
|
+ .setJudgeStatus(status).setJudgeTime(new Date());
|
|
this.updateById(costomer);
|
|
this.updateById(costomer);
|
|
|
|
|
|
//审核不通过禁用用户
|
|
//审核不通过禁用用户
|
|
int isBan = status == 3 ? 2 : 1;//账号状态(1=正常, 2=禁用)
|
|
int isBan = status == 3 ? 2 : 1;//账号状态(1=正常, 2=禁用)
|
|
List<SpAdmin> spAdminList = spAdminMapper.getByCostomerId(costomer.getId());
|
|
List<SpAdmin> spAdminList = spAdminMapper.getByCostomerId(costomer.getId());
|
|
for (SpAdmin spAdmin : spAdminList) {
|
|
for (SpAdmin spAdmin : spAdminList) {
|
|
- if(spAdmin != null) {
|
|
|
|
|
|
+ if (spAdmin != null) {
|
|
spAdmin.setStatus(isBan);
|
|
spAdmin.setStatus(isBan);
|
|
spAdminMapper.updateCustomerAdmin(costomer.getId(), isBan);
|
|
spAdminMapper.updateCustomerAdmin(costomer.getId(), isBan);
|
|
}
|
|
}
|
|
@@ -161,7 +160,7 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
spAdmin.setId(0L);
|
|
spAdmin.setId(0L);
|
|
spAdmin.setCustomerId(costomer.getId());
|
|
spAdmin.setCustomerId(costomer.getId());
|
|
spAdmin.setName(costomer.getDutyPeople());
|
|
spAdmin.setName(costomer.getDutyPeople());
|
|
- spAdmin.setPassword(costomer.getPhone().substring(costomer.getPhone().length()-6));
|
|
|
|
|
|
+ spAdmin.setPassword(costomer.getPhone().substring(costomer.getPhone().length() - 6));
|
|
SoMap so = new SoMap();
|
|
SoMap so = new SoMap();
|
|
so.put("customerId", costomer.getId());
|
|
so.put("customerId", costomer.getId());
|
|
List<SpRole> roleList = spRoleMapper.getList(so);
|
|
List<SpRole> roleList = spRoleMapper.getList(so);
|
|
@@ -173,7 +172,89 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
|
|
}
|
|
}
|
|
|
|
|
|
public List<String> findByMessageTypeOpenid(String businessType, String messageType) {
|
|
public List<String> findByMessageTypeOpenid(String businessType, String messageType) {
|
|
- return tbCostomerMapper.findByMessageTypeOpenid(businessType, messageType);
|
|
|
|
|
|
+ return tbCostomerMapper.findByMessageTypeOpenid(businessType, messageType);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加客户权限
|
|
|
|
+ *
|
|
|
|
+ * @param perStr
|
|
|
|
+ */
|
|
|
|
+ public void addMenu(String customerTypeStr, String perStr) {
|
|
|
|
+ List<Integer> customerTypeList = StrUtil.splitTrim(customerTypeStr, ",").stream().map(Integer::new).collect(Collectors.toList());
|
|
|
|
+ List<TbCostomer> costomerList = this.findCustomerList(customerTypeList);
|
|
|
|
+ List<String> customerIdList = costomerList.stream().map(TbCostomer::getId).collect(Collectors.toList());
|
|
|
|
+ List<SpAdmin> spAdminList = spAdminService.findByCustomerIdList(customerIdList);
|
|
|
|
+ List<String> roleList = spAdminList.stream().map(SpAdmin::getRoleId).collect(Collectors.toList());
|
|
|
|
+ //权限列表
|
|
|
|
+ List<String> list = StrUtil.splitTrim(perStr, ",");
|
|
|
|
+ //初始化新增客户时的权限
|
|
|
|
+ list.forEach(code -> {
|
|
|
|
+ List<TbInitPermission> initPermissions = tbInitPermissionService.findByCode(code);
|
|
|
|
+ if (initPermissions.isEmpty()) {
|
|
|
|
+ TbInitPermission tbInitPermission = new TbInitPermission();
|
|
|
|
+ tbInitPermission.setCode(code).setType(TbCostomer.CustomerEnum.BUSINESS_TYPE.getType());
|
|
|
|
+ initPermissions.add(tbInitPermission);
|
|
|
|
+ } else {
|
|
|
|
+ initPermissions.forEach(tbInitPermission -> {
|
|
|
|
+ tbInitPermission.setCode(tbInitPermission.getCode() + "," + code);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tbInitPermissionService.saveOrUpdateBatch(initPermissions);
|
|
|
|
+ });
|
|
|
|
+ //增加旧客户的权限
|
|
|
|
+ roleList.forEach(roleId -> {
|
|
|
|
+ spRolePermissionMapper.saveRolePer(Long.valueOf(roleId), list);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取客户列表
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<TbCostomer> findCustomerList(List<Integer> list) {
|
|
|
|
+ QueryWrapper<TbCostomer> ew = new QueryWrapper<>();
|
|
|
|
+ ew.lambda().in(TbCostomer::getType, list);
|
|
|
|
+ return list(ew);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除对应客户、合作伙伴的权限
|
|
|
|
+ *
|
|
|
|
+ * @param customerTypeStr
|
|
|
|
+ * @param perStr
|
|
|
|
+ */
|
|
|
|
+ public void delCustomerMenu(String customerTypeStr, String perStr) {
|
|
|
|
+ List<Integer> customerTypeList = StrUtil.splitTrim(customerTypeStr, ",").stream().map(Integer::new).collect(Collectors.toList());
|
|
|
|
+ List<TbCostomer> costomerList = this.findCustomerList(customerTypeList);
|
|
|
|
+ List<String> customerIdList = costomerList.stream().map(TbCostomer::getId).collect(Collectors.toList());
|
|
|
|
+ List<SpAdmin> spAdminList = spAdminService.findByCustomerIdList(customerIdList);
|
|
|
|
+ List<String> roleList = spAdminList.stream().map(SpAdmin::getRoleId).collect(Collectors.toList());
|
|
|
|
+ //权限列表
|
|
|
|
+ List<String> list = StrUtil.splitTrim(perStr, ",");
|
|
|
|
+ //删除角色-权限表数据
|
|
|
|
+ spRolePermissionMapper.deleteByRoleAndCode(roleList, list);
|
|
|
|
+ //删除tb_init_permission
|
|
|
|
+ List<TbInitPermission> initPermissionList = tbInitPermissionService.findByCode(list);
|
|
|
|
+ initPermissionList.forEach(tbInitPermission -> {
|
|
|
|
+ String type = tbInitPermission.getType();
|
|
|
|
+ List<String> typeList = StrUtil.splitTrim(type, ",");
|
|
|
|
+ typeList.removeIf(typeStr -> customerTypeList.contains(Integer.valueOf(typeStr)));
|
|
|
|
+ if (typeList.isEmpty()) {
|
|
|
|
+ tbInitPermissionService.removeById(tbInitPermission.getId());
|
|
|
|
+ } else {
|
|
|
|
+ tbInitPermission.setType(String.join(",", typeList));
|
|
|
|
+ tbInitPermissionService.updateById(tbInitPermission);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ public void delAdminMenu(String perStr) {
|
|
|
|
+ StrUtil.splitTrim(perStr, ",").forEach(perCode -> {
|
|
|
|
+ tbCostomerMapper.addAdminPermission(perCode);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|