修改公告逻辑
This commit is contained in:
parent
bfa2e83a6d
commit
1cf110095b
|
@ -2,8 +2,6 @@ package com.chint.application.dtos;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SystemAnnouncementDTO {
|
||||
private Long announcementId; // 公告的唯一标识符
|
||||
|
@ -13,4 +11,5 @@ public class SystemAnnouncementDTO {
|
|||
private String postDate; // 公告发布的日期和时间
|
||||
private String expiryDate; // 公告的过期日期
|
||||
private Integer priority; // 公告的优先级,用于排序
|
||||
private String employeeNo;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.application.system;
|
|||
|
||||
import com.chint.application.dtos.SystemAnnouncementDTO;
|
||||
import com.chint.domain.aggregates.system.SystemAnnouncement;
|
||||
import com.chint.domain.aggregates.system.SystemAnnouncementEmployee;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.SystemAnnouncementRepository;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
|
@ -35,6 +36,20 @@ public class SystemController {
|
|||
return Result.Success(SUCCESS, systemAnnouncementRepository.save(systemAnnouncement));
|
||||
}
|
||||
|
||||
@ApiOperation("新增已查看用户")
|
||||
@PostMapping("/announcement/save")
|
||||
public Result<String> saveAnnouncementEmployee(@RequestBody SystemAnnouncementDTO systemAnnouncementDTO) {
|
||||
systemAnnouncementRepository.findById(systemAnnouncementDTO.getAnnouncementId())
|
||||
.ifPresent(systemAnnouncement -> {
|
||||
String employeeNo = systemAnnouncementDTO.getEmployeeNo();
|
||||
if (employeeNo != null && !employeeNo.isEmpty()) {
|
||||
systemAnnouncement.addSystemAnnouncementEmployee(employeeNo);
|
||||
systemAnnouncementRepository.save(systemAnnouncement);
|
||||
}
|
||||
});
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
@ApiOperation("更新公告")
|
||||
@PostMapping("/announcement/update")
|
||||
public Result<String> updateAnnouncement(@RequestBody SystemAnnouncementDTO systemAnnouncementDTO) {
|
||||
|
@ -51,17 +66,31 @@ public class SystemController {
|
|||
|
||||
@ApiOperation("查询最新公告")
|
||||
@PostMapping("/announcement/query/last")
|
||||
public Result<SystemAnnouncement> queryLastAnnouncement() {
|
||||
return Result.Success(SUCCESS, systemAnnouncementRepository.findNew().orElseThrow(() -> new NotFoundException(NOT_FOUND)));
|
||||
public Result<SystemAnnouncement> queryLastAnnouncement(@RequestBody SystemAnnouncementDTO systemAnnouncementDTO) {
|
||||
SystemAnnouncement systemAnnouncement = systemAnnouncementRepository
|
||||
.findNew()
|
||||
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
|
||||
List<SystemAnnouncementEmployee> systemAnnouncementEmployeeList = systemAnnouncement.getSystemAnnouncementEmployeeList();
|
||||
if (systemAnnouncementEmployeeList != null && !systemAnnouncementEmployeeList.isEmpty()) {
|
||||
List<String> employeeNoList = systemAnnouncementEmployeeList
|
||||
.stream()
|
||||
.map(SystemAnnouncementEmployee::getEmployeeNo)
|
||||
.toList();
|
||||
if (employeeNoList.contains(systemAnnouncementDTO.getEmployeeNo())) {
|
||||
return Result.Success(SUCCESS, null);
|
||||
}
|
||||
}
|
||||
return Result.Success(SUCCESS, systemAnnouncement);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询有效公告")
|
||||
@PostMapping("/announcement/query/effective")
|
||||
public Result<List<SystemAnnouncement>> queryEffectiveAnnouncement() {
|
||||
List<SystemAnnouncement> effective = systemAnnouncementRepository.findEffective();
|
||||
effective.forEach(it->{
|
||||
effective.forEach(it -> {
|
||||
LocalDateTime expiryDate = it.getExpiryDate();
|
||||
if(expiryDate.isBefore(LocalDateTime.now())) {
|
||||
if (expiryDate.isBefore(LocalDateTime.now())) {
|
||||
it.setStatus("0");
|
||||
systemAnnouncementRepository.save(it);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.chint.infrastructure.util.BaseContext;
|
|||
import com.chint.infrastructure.util.DateTimeUtil;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
|
@ -14,6 +15,8 @@ import java.io.Serializable;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Table("system_announcements")
|
||||
|
@ -29,6 +32,18 @@ public class SystemAnnouncement implements Serializable {
|
|||
private LocalDateTime expiryDate; // 公告的过期日期
|
||||
private String status; // 公告的状态
|
||||
private Integer priority; // 公告的优先级,用于排序
|
||||
@MappedCollection(idColumn = "announcement_id" , keyColumn = "announcement_key")
|
||||
private List<SystemAnnouncementEmployee> systemAnnouncementEmployeeList;
|
||||
|
||||
public SystemAnnouncement addSystemAnnouncementEmployee(String employeeNo) {
|
||||
SystemAnnouncementEmployee systemAnnouncementEmployee = new SystemAnnouncementEmployee();
|
||||
systemAnnouncementEmployee.setEmployeeNo(employeeNo);
|
||||
if(systemAnnouncementEmployeeList == null){
|
||||
systemAnnouncementEmployeeList = new ArrayList<>();
|
||||
}
|
||||
systemAnnouncementEmployeeList.add(systemAnnouncementEmployee);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static SystemAnnouncement of(SystemAnnouncementDTO dto) {
|
||||
SystemAnnouncement systemAnnouncement = BeanUtil.copyProperties(dto, SystemAnnouncement.class);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.chint.domain.aggregates.system;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
@Table("system_announcements_employee")
|
||||
public class SystemAnnouncementEmployee implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1926351891678893214L;
|
||||
private Long id;
|
||||
private Long announcementId;
|
||||
private Integer announcementKey;
|
||||
private String employeeNo;
|
||||
private String extension;
|
||||
}
|
|
@ -35,12 +35,12 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.BPMConstant.*;
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
|
||||
import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND;
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.*;
|
||||
|
@ -205,10 +205,7 @@ public class LegEventHandler implements LegEventService {
|
|||
OrderLegData data = command.getData();
|
||||
String orderNo = data.getSelfOrderNo();
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo);
|
||||
//获取行程规划单创建者作为该订单
|
||||
if (routeOrder == null) {
|
||||
throw new OrderException(NOT_FOUND + "单号为" + orderNo);
|
||||
}
|
||||
|
||||
String employeeNo = routeOrder.getUserId();
|
||||
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo);
|
||||
BaseContext.setCurrentUser(byUserEmployeeNo);
|
||||
|
|
Loading…
Reference in New Issue