|
@@ -0,0 +1,97 @@
|
|
|
|
|
+package com.zhongshu.card.server.core.service.devices.permiss;
|
|
|
|
|
+
|
|
|
|
|
+import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
|
|
+import com.github.microservice.net.ResultMessage;
|
|
|
|
|
+import com.zhongshu.card.client.model.devices.permiss.PermissTimeSlotModel;
|
|
|
|
|
+import com.zhongshu.card.client.model.devices.permiss.PermissTimeSlotParam;
|
|
|
|
|
+import com.zhongshu.card.client.model.devices.permiss.PermissTimeSlotSearch;
|
|
|
|
|
+import com.zhongshu.card.client.type.device.TimeSlotType;
|
|
|
|
|
+import com.zhongshu.card.server.core.dao.devices.PermissTimeSlotDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
|
|
|
|
|
+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.service.base.SuperService;
|
|
|
|
|
+import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 权限时间段管理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author TRX
|
|
|
|
|
+ * @date 2024/12/19
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Service
|
|
|
|
|
+public class PermissTimeSlotService extends SuperService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PermissTimeSlotDao permissTimeSlotDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent saveInfo(PermissTimeSlotParam param) {
|
|
|
|
|
+ Assert.hasText(param.getProjectOid(), "projectOid不能为空");
|
|
|
|
|
+ if (param.getType() == null) {
|
|
|
|
|
+ param.setType(TimeSlotType.Week);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PermissTimeSlot entity = null;
|
|
|
|
|
+ if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
|
|
+ entity = permissTimeSlotDao.findTopById(param.getId());
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ initUpdateEntity(entity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ entity = new PermissTimeSlot();
|
|
|
|
|
+ initEntityNoCheckOid(entity);
|
|
|
|
|
+ }
|
|
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
|
|
+ permissTimeSlotDao.save(entity);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent<Page<PermissTimeSlotModel>> page(PermissTimeSlotSearch param, Pageable pageable) {
|
|
|
|
|
+ String projectOid = param.getProjectOid();
|
|
|
|
|
+ Organization organization = organizationDao.findTopByOid(projectOid);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
|
|
+ return ResultContent.buildFail("projectOid不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<PermissTimeSlot> page = permissTimeSlotDao.page(pageable, param);
|
|
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent deleteInfo(String id) {
|
|
|
|
|
+ PermissTimeSlot entity = permissTimeSlotDao.findTopById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
|
|
+ }
|
|
|
|
|
+ permissTimeSlotDao.delete(entity);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent<PermissTimeSlotModel> getDetailInfo(String id) {
|
|
|
|
|
+ PermissTimeSlot entity = permissTimeSlotDao.findTopById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultContent.buildSuccess(toModel(entity));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private PermissTimeSlotModel toModel(PermissTimeSlot entity) {
|
|
|
|
|
+ PermissTimeSlotModel model = new PermissTimeSlotModel();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
|
|
+ }
|
|
|
|
|
+ return model;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|