|
|
@@ -9,10 +9,14 @@ import com.zhongshu.card.client.type.device.PermissSettingType;
|
|
|
import com.zhongshu.card.server.core.dao.devices.PermissSettingDao;
|
|
|
import com.zhongshu.card.server.core.dao.devices.PermissTimeSlotDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
+import com.zhongshu.card.server.core.dao.org.RoleDao;
|
|
|
+import com.zhongshu.card.server.core.dao.school.AreaDao;
|
|
|
import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
|
|
|
import com.zhongshu.card.server.core.domain.devices.permiss.PermissSetting;
|
|
|
import com.zhongshu.card.server.core.domain.devices.permiss.PermissTimeSlot;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Role;
|
|
|
+import com.zhongshu.card.server.core.domain.school.Area;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
@@ -25,10 +29,11 @@ import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
- * 权限时间段管理
|
|
|
+ * 设备权限规则服务
|
|
|
*
|
|
|
* @author TRX
|
|
|
* @date 2024/12/19
|
|
|
@@ -52,6 +57,18 @@ public class PermissSettingService extends SuperService {
|
|
|
@Autowired
|
|
|
private DeviceInfoServiceImpl deviceInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RoleDao roleDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AreaDao areaDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存设备权限规则数据
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ResultContent saveInfo(PermissSettingParam param) {
|
|
|
Assert.hasText(param.getProjectOid(), "projectOid不能为空");
|
|
|
if (StringUtils.isEmpty(param.getTimeSlotId())) {
|
|
|
@@ -149,11 +166,36 @@ public class PermissSettingService extends SuperService {
|
|
|
String aboutShowDataName = "";
|
|
|
// 关联的数据名称
|
|
|
if (param.getPermissSettingType() == PermissSettingType.Sex) {
|
|
|
+ // 性别
|
|
|
if (param.getSex() != null) {
|
|
|
aboutShowDataName = param.getSex().getRemark();
|
|
|
}
|
|
|
- } else if (param.getPermissSettingType() == PermissSettingType.Role) {
|
|
|
-
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNotEmpty(param.getDataIds())) {
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
+ if (param.getPermissSettingType() == PermissSettingType.Role) {
|
|
|
+ // 角色
|
|
|
+ List<Role> roles = roleDao.findByIdIn(param.getDataIds());
|
|
|
+ if (ObjectUtils.isNotEmpty(roles)) {
|
|
|
+ names = roles.stream().map(it -> it.getName()).toList();
|
|
|
+ }
|
|
|
+ } else if (param.getPermissSettingType() == PermissSettingType.Org) {
|
|
|
+ // 机构
|
|
|
+ List<Organization> orgs = organizationDao.findByOidIn(param.getDataIds());
|
|
|
+ if (ObjectUtils.isNotEmpty(orgs)) {
|
|
|
+ names = orgs.stream().map(it -> it.getName()).toList();
|
|
|
+ }
|
|
|
+ } else if (param.getPermissSettingType() == PermissSettingType.Area) {
|
|
|
+ // 区域
|
|
|
+ List<Area> areas = areaDao.findByIdIn(param.getDataIds());
|
|
|
+ if (ObjectUtils.isNotEmpty(areas)) {
|
|
|
+ names = areas.stream().map(it -> it.getName()).toList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotEmpty(names)) {
|
|
|
+ aboutShowDataName = String.join(",", names);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
model.setAboutShowDataName(aboutShowDataName);
|
|
|
}
|