init
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
package com.mgm.mcrm.approval.controller;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.mgm.mcrm.approval.dtos.GetApproverRequest;
|
||||
import com.mgm.mcrm.approval.dtos.RejectApprovalResponse;
|
||||
import com.mgm.mcrm.approval.dtos.SubmitApprovalResponse;
|
||||
import com.mgm.mcrm.approval.models.ApprovalDetail;
|
||||
import com.mgm.mcrm.approval.models.CfgRequestReason;
|
||||
import com.mgm.mcrm.approval.service.ApprovalService;
|
||||
import com.mgm.mcrm.authorization.services.SysGroupPermissionService;
|
||||
import com.mgm.mcrm.booking.models.Bookings;
|
||||
import com.mgm.mcrm.booking.models.BookingsView;
|
||||
import com.mgm.mcrm.common.annotation.logging.OperationLog;
|
||||
import com.mgm.mcrm.common.dtos.BaseApiResponse;
|
||||
import com.mgm.mcrm.common.dtos.mgm_api.ApproverResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.coyote.Response;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class ApprovalController {
|
||||
|
||||
@Resource
|
||||
private ApprovalService approvalService;
|
||||
@Resource
|
||||
private SysGroupPermissionService sysGroupPermissionService;
|
||||
|
||||
|
||||
@OperationLog(actionName = "Cancel Approval Booking", eventCode = "approval_booking_cancel")
|
||||
@RequestMapping(value = "/app/approval/cancel_approval", method = RequestMethod.POST, produces = "application/json;charset=UTF-8",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<Long>> cancelApprovalBooking(HttpServletRequest request, @RequestBody Map<String, Object> booking) {
|
||||
|
||||
String token = request.getHeader("Authorization");
|
||||
String userId = JWT.decode(token).getClaim("login_id").asString();
|
||||
BaseApiResponse<Long> result = approvalService.cancelApprovalBooking(booking, userId, request);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@OperationLog(actionName = "Cancel Approval Booking", eventCode = "approval_booking_cancel")
|
||||
@RequestMapping(value = "/app/approval/batch_cancel_approval", method = RequestMethod.POST, produces = "application/json;charset=UTF-8",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<Bookings>> batchCancelApproval(HttpServletRequest request, @RequestBody Map<String, Object> booking) {
|
||||
|
||||
String token = request.getHeader("Authorization");
|
||||
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
token = token.replace("Bearer ", "").replace("bearer ", "");
|
||||
}
|
||||
|
||||
String userId = JWT.decode(token).getClaim("login_id").asString();
|
||||
BaseApiResponse<Bookings> result = approvalService.batchCancelApprovalBooking(booking, userId, request);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@OperationLog(actionName = "Get Approval Reason", eventCode = "get_approval_reason")
|
||||
@RequestMapping(value = "/app/approval/get_reason", method = RequestMethod.POST, produces = "application/json;charset=UTF-8",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<List<CfgRequestReason>>> getApprovalReason(HttpServletRequest request, @RequestBody Map<String, Object> booking) throws Exception {
|
||||
BaseApiResponse<List<CfgRequestReason>> result = approvalService.getRequestReason();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@OperationLog(actionName = "Get Approver", eventCode = "get_approver")
|
||||
@RequestMapping(value = "/app/approval/get_approver", method = RequestMethod.POST, produces = "application/json;charset=UTF-8",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<ApproverResult>> getESBApprover(HttpServletRequest request, @RequestBody GetApproverRequest params) throws Exception {
|
||||
BaseApiResponse<ApproverResult> result = approvalService.getApprover(request, params);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@PostMapping(value="/app/approval/approval_list",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<List<BookingsView>>> getPendingApprovalBookingList(HttpServletRequest request, @RequestBody Map<String, Object> params) throws Exception {
|
||||
BaseApiResponse<List<BookingsView>> pendingApprovalList = approvalService.getPendingApprovalList(request,params);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(pendingApprovalList);
|
||||
}
|
||||
|
||||
@PostMapping("/app/approval/get_approval_count")
|
||||
public ResponseEntity<BaseApiResponse<Long>> getPendingApprovalCount(HttpServletRequest request) {
|
||||
BaseApiResponse<Long> result = approvalService.getCountPendingApproval(request);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@PostMapping(value="/app/approval/reject_approval",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<RejectApprovalResponse>> rejectApprovalRecord(HttpServletRequest request, @RequestBody Map<String, Object> params) throws Exception {
|
||||
String token = request.getHeader("Authorization");
|
||||
String userId = JWT.decode(token).getClaim("login_id").asString();
|
||||
Long bookingId = params.get("bookingId") == null ? null : Long.valueOf(params.get("bookingId").toString());
|
||||
BaseApiResponse<RejectApprovalResponse> result = approvalService.rejectApprovalBooking(bookingId, userId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@PostMapping(value="/app/approval/get_approval_data",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<ApprovalDetail>> getApprovalData(HttpServletRequest request, @RequestBody Map<String, Object> params) throws Exception {
|
||||
BaseApiResponse<ApprovalDetail> result = approvalService.getApprovalDetail(request, params);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@PostMapping(value="/app/approval/submit_approval",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<SubmitApprovalResponse>> submitApproval(HttpServletRequest request, @RequestBody Map<String, Object> params) throws Exception {
|
||||
String token = request.getHeader("Authorization");
|
||||
String userId = JWT.decode(token).getClaim("login_id").asString();
|
||||
String checkinDate = params.get("checkinDate") == null ? null : params.get("checkinDate").toString();
|
||||
String checkoutDate = params.get("checkoutDate") == null ? null : params.get("checkoutDate").toString();
|
||||
String bookingId = params.get("bookingId") == null ? null : params.get("bookingId").toString();
|
||||
BaseApiResponse<SubmitApprovalResponse> serviceResult = new BaseApiResponse<>();
|
||||
try{
|
||||
serviceResult = approvalService.submitApproval(bookingId, checkinDate, checkoutDate, userId,request);
|
||||
} catch (Exception e) {
|
||||
approvalService.setFailApprovalRouting(bookingId);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(serviceResult);
|
||||
}
|
||||
|
||||
@PostMapping(value="/app/approval/batch_submit_approval",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<List<Map<String, String>>>> batchApproveBooking(HttpServletRequest request, @RequestBody Map<String, Object> params) throws Exception {
|
||||
BaseApiResponse<List<Map<String, String>>> result = approvalService.batchApproval(request, params);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(result);
|
||||
}
|
||||
|
||||
@PostMapping(value="/app/approval/batch_submit_reject",consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<BaseApiResponse<List<String>>> batchRejectApproval(HttpServletRequest request, @RequestBody Map<String, Object> params) throws Exception {
|
||||
|
||||
String token = request.getHeader("Authorization");
|
||||
String userId = JWT.decode(token).getClaim("login_id").asString();
|
||||
// 修改这里:从 submitInfoList 获取数据
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> submitInfoList = params.get("submitInfoList") != null
|
||||
? (List<Map<String, Object>>) params.get("submitInfoList")
|
||||
: null;
|
||||
|
||||
|
||||
BaseApiResponse<List<String>> serviceResult = new BaseApiResponse<>();
|
||||
if (submitInfoList != null && !submitInfoList.isEmpty()) {
|
||||
// 提取 bookingId 列表
|
||||
List<String> bookingIdList = submitInfoList.stream()
|
||||
.map(item -> String.valueOf(item.get("bookingId")))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
serviceResult = approvalService.batchReject(bookingIdList, userId);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(serviceResult);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mgm.mcrm.approval.dtos;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GetApproverRequest {
|
||||
private String playerId;
|
||||
private String bookingType;
|
||||
private String propertyName;
|
||||
private String roomCategory;
|
||||
private String checkInDate;
|
||||
private String checkOutDate;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mgm.mcrm.approval.dtos;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* API response returned after an approval is rejected.
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class RejectApprovalResponse {
|
||||
|
||||
private final Long bookingId;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mgm.mcrm.approval.dtos;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* API response returned after an approval is submitted.
|
||||
*
|
||||
* <p>The API exposes only the identifier clients need and does not leak the
|
||||
* Hibernate-managed {@code Bookings} entity.</p>
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class SubmitApprovalResponse {
|
||||
|
||||
private final Long bookingId;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mgm.mcrm.approval.mappers;
|
||||
|
||||
import com.mgm.mcrm.approval.dtos.RejectApprovalResponse;
|
||||
import com.mgm.mcrm.approval.dtos.SubmitApprovalResponse;
|
||||
import com.mgm.mcrm.booking.models.Bookings;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApprovalMapper {
|
||||
|
||||
public SubmitApprovalResponse toSubmitApprovalResponse(Bookings booking) {
|
||||
if (booking == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new SubmitApprovalResponse(booking.getId());
|
||||
}
|
||||
|
||||
public RejectApprovalResponse toRejectApprovalResponse(Bookings booking) {
|
||||
if (booking == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new RejectApprovalResponse(booking.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mgm.mcrm.approval.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.mgm.mcrm.booking.models.BookingsView;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 审批详情返回:前端请使用 {@link #cfgApprovalRoutingList}(与 {@link #bookingsViewList} 顺序一致)。
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ApprovalDetail implements Serializable {
|
||||
|
||||
List<BookingsView> bookingsViewList = new ArrayList<BookingsView>();
|
||||
|
||||
List<ApprovalGamingData> approvalGamingData = new ArrayList<ApprovalGamingData>();
|
||||
|
||||
/** @deprecated 请使用 {@link #cfgApprovalRoutingList} */
|
||||
CfgApprovalRouting cfgApprovalRouting;
|
||||
|
||||
/** 与 {@link #bookingsViewList} 顺序一致,每条 booking 对应一条审批路由 */
|
||||
List<CfgApprovalRouting> cfgApprovalRoutingList = new ArrayList<CfgApprovalRouting>();
|
||||
|
||||
public List<BookingsView> getBookingsViewList() {
|
||||
return bookingsViewList;
|
||||
}
|
||||
|
||||
public void setBookingsViewList(List<BookingsView> bookingsViewgList) {
|
||||
this.bookingsViewList = bookingsViewgList;
|
||||
}
|
||||
|
||||
public List<ApprovalGamingData> getApprovalGamingData() {
|
||||
return approvalGamingData;
|
||||
}
|
||||
|
||||
public void setApprovalGamingData(List<ApprovalGamingData> approvalGamingData) {
|
||||
this.approvalGamingData = approvalGamingData;
|
||||
}
|
||||
|
||||
public CfgApprovalRouting getCfgApprovalRouting() {
|
||||
return cfgApprovalRouting;
|
||||
}
|
||||
|
||||
public void setCfgApprovalRouting(CfgApprovalRouting cfgApprovalRouting) {
|
||||
this.cfgApprovalRouting = cfgApprovalRouting;
|
||||
}
|
||||
|
||||
public List<CfgApprovalRouting> getCfgApprovalRoutingList() {
|
||||
return cfgApprovalRoutingList;
|
||||
}
|
||||
|
||||
public void setCfgApprovalRoutingList(List<CfgApprovalRouting> cfgApprovalRoutingList) {
|
||||
this.cfgApprovalRoutingList = cfgApprovalRoutingList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.mgm.mcrm.approval.models;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public class ApprovalGamingData implements Serializable {
|
||||
|
||||
@JSONField(name = "BookingId")
|
||||
private String bookingId;
|
||||
@JSONField(name = "PlayerId")
|
||||
private String playerId;
|
||||
@JSONField(name = "CurrentTripTheoWinAmount")
|
||||
private String currentTripTheoWinAmount=null;
|
||||
@JSONField(name = "Last2DayTheoWinAmount")
|
||||
private String last2DayTheoWinAmount=null;
|
||||
@JSONField(name = "R3TheoWin")
|
||||
private String r3TheoWin=null;
|
||||
@JSONField(name = "R3TPD")
|
||||
private String r3TPD=null;
|
||||
@JSONField(name = "R3ActualWin")
|
||||
private String r3ActualWin=null;
|
||||
@JSONField(name = "R6TheoWin")
|
||||
private String r6TheoWin=null;
|
||||
@JSONField(name = "R6TPD")
|
||||
private String r6TPD=null;
|
||||
@JSONField(name = "R6ActualWin")
|
||||
private String r6ActualWin=null;
|
||||
@JSONField(name = "R12TheoWin")
|
||||
private String r12TheoWin=null;
|
||||
@JSONField(name = "R12TPD")
|
||||
private String r12TPD=null;
|
||||
@JSONField(name = "R12ActualWin")
|
||||
private String r12ActualWin=null;
|
||||
@JSONField(name = "OverlapBooking")
|
||||
private String overlapBooking=null;
|
||||
@JSONField(name = "RoomCount")
|
||||
private String roomCount=null;
|
||||
|
||||
public String getBookingId() {
|
||||
return bookingId;
|
||||
}
|
||||
|
||||
public void setBookingId(String bookingId) {
|
||||
this.bookingId = bookingId;
|
||||
}
|
||||
|
||||
public String getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public void setPlayerId(String playerId) {
|
||||
this.playerId = playerId;
|
||||
}
|
||||
|
||||
public String getCurrentTripTheoWinAmount() {
|
||||
return currentTripTheoWinAmount;
|
||||
}
|
||||
|
||||
public void setCurrentTripTheoWinAmount(String currentTripTheoWinAmount) {
|
||||
this.currentTripTheoWinAmount = currentTripTheoWinAmount;
|
||||
}
|
||||
|
||||
public String getLast2DayTheoWinAmount() {
|
||||
return last2DayTheoWinAmount;
|
||||
}
|
||||
|
||||
public void setLast2DayTheoWinAmount(String last2DayTheoWinAmount) {
|
||||
this.last2DayTheoWinAmount = last2DayTheoWinAmount;
|
||||
}
|
||||
|
||||
public String getR3TheoWin() {
|
||||
return r3TheoWin;
|
||||
}
|
||||
|
||||
public void setR3TheoWin(String r3TheoWin) {
|
||||
this.r3TheoWin = r3TheoWin;
|
||||
}
|
||||
|
||||
public String getR3TPD() {
|
||||
return r3TPD;
|
||||
}
|
||||
|
||||
public void setR3TPD(String r3TPD) {
|
||||
this.r3TPD = r3TPD;
|
||||
}
|
||||
|
||||
public String getR3ActualWin() {
|
||||
return r3ActualWin;
|
||||
}
|
||||
|
||||
public void setR3ActualWin(String r3ActualWin) {
|
||||
this.r3ActualWin = r3ActualWin;
|
||||
}
|
||||
|
||||
public String getR6TheoWin() {
|
||||
return r6TheoWin;
|
||||
}
|
||||
|
||||
public void setR6TheoWin(String r6TheoWin) {
|
||||
this.r6TheoWin = r6TheoWin;
|
||||
}
|
||||
|
||||
public String getR6TPD() {
|
||||
return r6TPD;
|
||||
}
|
||||
|
||||
public void setR6TPD(String r6TPD) {
|
||||
this.r6TPD = r6TPD;
|
||||
}
|
||||
|
||||
public String getR6ActualWin() {
|
||||
return r6ActualWin;
|
||||
}
|
||||
|
||||
public void setR6ActualWin(String r6ActualWin) {
|
||||
this.r6ActualWin = r6ActualWin;
|
||||
}
|
||||
|
||||
public String getR12TheoWin() {
|
||||
return r12TheoWin;
|
||||
}
|
||||
|
||||
public void setR12TheoWin(String r12TheoWin) {
|
||||
this.r12TheoWin = r12TheoWin;
|
||||
}
|
||||
|
||||
public String getR12TPD() {
|
||||
return r12TPD;
|
||||
}
|
||||
|
||||
public void setR12TPD(String r12TPD) {
|
||||
this.r12TPD = r12TPD;
|
||||
}
|
||||
|
||||
public String getR12ActualWin() {
|
||||
return r12ActualWin;
|
||||
}
|
||||
|
||||
public void setR12ActualWin(String r12ActualWin) {
|
||||
this.r12ActualWin = r12ActualWin;
|
||||
}
|
||||
|
||||
public String getOverlapBooking() {
|
||||
return overlapBooking;
|
||||
}
|
||||
|
||||
public void setOverlapBooking(String overlapBooking) {
|
||||
this.overlapBooking = overlapBooking;
|
||||
}
|
||||
|
||||
public String getRoomCount() {
|
||||
return roomCount;
|
||||
}
|
||||
|
||||
public void setRoomCount(String roomCount) {
|
||||
this.roomCount = roomCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.mgm.mcrm.approval.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name="cfg_approval_routing")
|
||||
public class CfgApprovalRouting implements Serializable {
|
||||
//fields in table
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
@Column(name="booking_id")
|
||||
private Long bookingId;
|
||||
@Column(name="approval_reason")
|
||||
private String approvalReason;
|
||||
@Column(name="approver_id")
|
||||
private String approverId;
|
||||
@Column(name="approver_name")
|
||||
private String approverName;
|
||||
@Column(name="booking_status")
|
||||
private String bookingStatus;
|
||||
@Column(name="created_at")
|
||||
private Date createdAt;
|
||||
@Column(name="created_by")
|
||||
private String createdBy;
|
||||
@Column(name="updated_at")
|
||||
private Date updatedAt;
|
||||
@Column(name="updated_by")
|
||||
private String updatedBy;
|
||||
@Column(name="routing_reason")
|
||||
private String routingReason;
|
||||
|
||||
@Version
|
||||
@Column(name = "version")
|
||||
private Long version;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getBookingId() {
|
||||
return bookingId;
|
||||
}
|
||||
|
||||
public void setBookingId(Long bookingId) {
|
||||
this.bookingId = bookingId;
|
||||
}
|
||||
|
||||
public String getApprovalReason() {
|
||||
return approvalReason;
|
||||
}
|
||||
|
||||
public void setApprovalReason(String approvalReason) {
|
||||
this.approvalReason = approvalReason;
|
||||
}
|
||||
|
||||
public String getApproverId() {
|
||||
return approverId;
|
||||
}
|
||||
|
||||
public void setApproverId(String approverId) {
|
||||
this.approverId = approverId;
|
||||
}
|
||||
|
||||
public String getApproverName() {
|
||||
return approverName;
|
||||
}
|
||||
|
||||
public void setApproverName(String approverName) {
|
||||
this.approverName = approverName;
|
||||
}
|
||||
|
||||
public String getBookingStatus() {
|
||||
return bookingStatus;
|
||||
}
|
||||
|
||||
public void setBookingStatus(String bookingStatus) {
|
||||
this.bookingStatus = bookingStatus;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getUpdatedBy() {
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy;
|
||||
}
|
||||
|
||||
public String getRoutingReason() {
|
||||
return routingReason;
|
||||
}
|
||||
|
||||
public void setRoutingReason(String routingReason) {
|
||||
this.routingReason = routingReason;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.mgm.mcrm.approval.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name="cfg_request_reason")
|
||||
public class CfgRequestReason implements Serializable {
|
||||
//fields in table
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
@Column(name="description")
|
||||
private String description;
|
||||
@Column(name="code")
|
||||
private String code;
|
||||
@Column(name="is_show")
|
||||
private int isShow;
|
||||
@Column(name="created_at")
|
||||
private Date createdAt;
|
||||
@Column(name="created_by")
|
||||
private String createdBy;
|
||||
@Column(name="updated_at")
|
||||
private Date updatedAt;
|
||||
@Column(name="updated_by")
|
||||
private String updatedBy;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getIsShow() {
|
||||
return isShow;
|
||||
}
|
||||
|
||||
public void setIsShow(int isShow) {
|
||||
this.isShow = isShow;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getUpdatedBy() {
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.mgm.mcrm.approval.repositories;
|
||||
|
||||
import com.mgm.mcrm.approval.models.CfgApprovalRouting;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface ApprovalRoutingDao extends JpaRepository<CfgApprovalRouting, Long> {
|
||||
CfgApprovalRouting findById(long id);
|
||||
List<CfgApprovalRouting> findAll(Specification<CfgApprovalRouting> spec,Sort sort);
|
||||
List<CfgApprovalRouting> findAll(Specification<CfgApprovalRouting> spec);
|
||||
Page<CfgApprovalRouting> findAll(Specification<CfgApprovalRouting> spec, Pageable pageable);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query(value = " delete from cfg_approval_routing where id=?1 ",nativeQuery=true)
|
||||
int deleteById(long id);
|
||||
|
||||
@Query(value="select * from cfg_approval_routing where id =?1",nativeQuery=true)
|
||||
CfgApprovalRouting getById(Long id);
|
||||
|
||||
@Query(value="select * from cfg_approval_routing where id =?1",nativeQuery=true)
|
||||
CfgApprovalRouting getById(Integer id);
|
||||
|
||||
@Query(value="select * from cfg_approval_routing where name =?1",nativeQuery=true)
|
||||
CfgApprovalRouting getByName(String name);
|
||||
|
||||
|
||||
List<CfgApprovalRouting> findByBookingStatus(String bookingStatus);
|
||||
|
||||
Integer countByBookingStatus(String bookingStatus);
|
||||
|
||||
Integer countByBookingStatusAndApproverId(String bookingStatus, String approverId);
|
||||
|
||||
CfgApprovalRouting getByBookingId(Long bookingId);
|
||||
|
||||
List<CfgApprovalRouting> findByBookingStatusAndApproverId(String ap, String userId);
|
||||
|
||||
@Query(value = "select * from cfg_approval_routing where booking_status = 'AP' and approver_id like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<CfgApprovalRouting> getApprovalList(String userId);
|
||||
|
||||
@Query(value = "select count(*) from cfg_approval_routing where booking_status = 'AP' and approver_id like concat('%', ?1, '%')", nativeQuery = true)
|
||||
Long countApprovalList(String userId);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.mgm.mcrm.approval.repositories;
|
||||
|
||||
import com.mgm.mcrm.approval.models.CfgRequestReason;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface RequestReasonDao extends JpaRepository<CfgRequestReason, Long> {
|
||||
CfgRequestReason findById(long id);
|
||||
List<CfgRequestReason> findAll(Specification<CfgRequestReason> spec, Sort sort);
|
||||
List<CfgRequestReason> findAll(Specification<CfgRequestReason> spec);
|
||||
Page<CfgRequestReason> findAll(Specification<CfgRequestReason> spec, Pageable pageable);
|
||||
CfgRequestReason findByCode(String code);
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query(value = " delete from cfg_request_reason where id=?1 ",nativeQuery=true)
|
||||
int deleteById(long id);
|
||||
|
||||
@Query(value="select * from cfg_request_reason where id =?1",nativeQuery=true)
|
||||
CfgRequestReason getById(Long id);
|
||||
|
||||
@Query(value="select * from cfg_request_reason where id =?1",nativeQuery=true)
|
||||
CfgRequestReason getById(Integer id);
|
||||
|
||||
|
||||
|
||||
CfgRequestReason getByCode(String code);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user