mirror of https://github.com/elunez/eladmin
added NwIncidents ORM
parent
11dc9b6c78
commit
aa6ce24ba9
|
@ -0,0 +1,204 @@
|
|||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="nw_incidents")
|
||||
public class NwIncidents implements Serializable {
|
||||
|
||||
// ID
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Integer id;
|
||||
|
||||
// Fault Clearance Time
|
||||
@Column(name = "faultclearancetime")
|
||||
private Timestamp faultclearancetime;
|
||||
|
||||
// Fault Contractor TicketNo
|
||||
@Column(name = "faultcontractorticketno")
|
||||
private String faultcontractorticketno;
|
||||
|
||||
// Fault Customer Name
|
||||
@Column(name = "faultcustomername")
|
||||
private String faultcustomername;
|
||||
|
||||
// Fault Customer Response Time
|
||||
@Column(name = "faultcustomereesponsetime")
|
||||
private String faultcustomerresponsetime;
|
||||
|
||||
// Fault Description
|
||||
@Column(name = "faultdescription")
|
||||
private String faultdescription;
|
||||
|
||||
// Fault Excused Outage Type1
|
||||
@Column(name = "faultexcusedoutagetype1")
|
||||
private String faultexcusedoutagetype1;
|
||||
|
||||
// Fault Excused Outage Type1 EndTime
|
||||
@Column(name = "faultexcusedoutagetype1endtime")
|
||||
private Timestamp faultexcusedoutagetype1endtime;
|
||||
|
||||
// Fault Excused Outage Type1 Start Time
|
||||
@Column(name = "faultexcusedoutagetype1starttime")
|
||||
private Timestamp faultexcusedoutagetype1starttime;
|
||||
|
||||
// Fault Excused Outage Type2
|
||||
@Column(name = "faultexcusedoutagetype2")
|
||||
private String faultexcusedoutagetype2;
|
||||
|
||||
// Fault Excused Outage Type2 End Time
|
||||
@Column(name = "faultexcusedoutagetype2endtime")
|
||||
private Timestamp faultexcusedoutagetype2endtime;
|
||||
|
||||
// Fault Excused Outage Type2 Start Time
|
||||
@Column(name = "faultexcusedoutagetype2starttime")
|
||||
private Timestamp faultexcusedoutagetype2starttime;
|
||||
|
||||
// Fault Excused Outage Type3
|
||||
@Column(name = "faultexcusedoutagetype3")
|
||||
private String faultexcusedoutagetype3;
|
||||
|
||||
// Fault Excused Outage Type3 End Time
|
||||
@Column(name = "faultexcusedoutagetype3endtime")
|
||||
private Timestamp faultexcusedoutagetype3endtime;
|
||||
|
||||
// Fault Excused OutageType3 Start Time
|
||||
@Column(name = "FaultExcusedOutageType3StartTime")
|
||||
private Timestamp faultexcusedoutagetype3starttime;
|
||||
|
||||
// Fault Incident ID
|
||||
@Column(name = "faultincidentid")
|
||||
private String faultincidentid;
|
||||
|
||||
// Fault Link SiteA
|
||||
@Column(name = "faultlinksitea")
|
||||
private String faultlinksitea;
|
||||
|
||||
// Fault Link SiteB
|
||||
@Column(name = "faultlinksiteb")
|
||||
private String faultlinksiteb;
|
||||
|
||||
// Fault Location
|
||||
@Column(name = "faultlocation")
|
||||
private String faultlocation;
|
||||
|
||||
// Fault Occurrence Time
|
||||
@Column(name = "faultoccurrencetime")
|
||||
private Timestamp faultoccurrencetime;
|
||||
|
||||
// Fault Priority
|
||||
@Column(name = "faultpriority")
|
||||
private String faultpriority;
|
||||
|
||||
// Fault Responsibility
|
||||
@Column(name = "faultresponsibility")
|
||||
private String faultresponsibility;
|
||||
|
||||
// Fault Site ID
|
||||
@Column(name = "faultsiteid")
|
||||
private String faultsiteid;
|
||||
|
||||
// Fault Site Name
|
||||
@Column(name = "faultsitename")
|
||||
private String faultsitename;
|
||||
|
||||
// Fault Ticket No
|
||||
@Column(name = "faultticketno")
|
||||
private String faultticketno;
|
||||
|
||||
// Fault Ticket Open Time
|
||||
@Column(name = "faultticketopentime")
|
||||
private Timestamp faultticketopentime;
|
||||
|
||||
// Fault Type
|
||||
@Column(name = "faulttype")
|
||||
private String faulttype;
|
||||
|
||||
// is Fault Excused Outages Reported
|
||||
@Column(name = "isfaultexcusedoutagesreported")
|
||||
private Integer isfaultexcusedoutagesreported;
|
||||
|
||||
// is Fault Origin
|
||||
@Column(name = "isfaultorigin")
|
||||
private Integer isfaultorigin;
|
||||
|
||||
// Resubmission
|
||||
@Column(name = "resubmission")
|
||||
private String resubmission;
|
||||
|
||||
// Timestamp
|
||||
@Column(name = "timestamp")
|
||||
private Timestamp timestamp;
|
||||
|
||||
// Username
|
||||
@Column(name = "username")
|
||||
private String username;
|
||||
|
||||
// incidents_id
|
||||
@Column(name = "incidents_id",nullable = false)
|
||||
private Integer incidentsId;
|
||||
|
||||
// DaysInMonth
|
||||
@Column(name = "daysinmonth")
|
||||
private String daysinmonth;
|
||||
|
||||
// Fault Additional Details
|
||||
@Column(name = "faultadditionaldetails")
|
||||
private String faultadditionaldetails;
|
||||
|
||||
// Fault Contractor Ticket Id
|
||||
@Column(name = "faultcontractorticketid")
|
||||
private String faultcontractorticketid;
|
||||
|
||||
// Fault Country
|
||||
@Column(name = "faultcountry")
|
||||
private String faultcountry;
|
||||
|
||||
// Fault Site Deactivation Date
|
||||
@Column(name = "faultsitedeactivationdate")
|
||||
private String faultsitedeactivationdate;
|
||||
|
||||
// Fault Site Lc Prorated Days
|
||||
@Column(name = "faultsitelcprorateddays")
|
||||
private String faultsitelcprorateddays;
|
||||
|
||||
// Fault Site Product
|
||||
@Column(name = "faultsiteproduct")
|
||||
private String faultsiteproduct;
|
||||
|
||||
// Fault Site Protection Status
|
||||
@Column(name = "faultsiteprotectionstatus")
|
||||
private String faultsiteprotectionstatus;
|
||||
|
||||
// Fault Site Protection Status Date
|
||||
@Column(name = "faultsiteprotectionstatusdate")
|
||||
private String faultsiteprotectionstatusdate;
|
||||
|
||||
// Fault Site Service Commencement Date
|
||||
@Column(name = "faultsiteservicecommencementdate")
|
||||
private String faultsiteservicecommencementdate;
|
||||
|
||||
// Fault Site SLA
|
||||
@Column(name = "faultsitesla")
|
||||
private String faultsitesla;
|
||||
|
||||
// Fault Site isBillable
|
||||
@Column(name = "faultsiteisbillable")
|
||||
private String faultsiteisbillable;
|
||||
|
||||
public void copy(NwIncidents source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package me.zhengjie.modules.system.repository;
|
||||
|
||||
import me.zhengjie.modules.system.domain.NwIncidents;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
public interface NwIncidentsRepository extends JpaRepository<NwIncidents, Integer>, JpaSpecificationExecutor {
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package me.zhengjie.modules.system.rest;
|
||||
|
||||
import me.zhengjie.aop.log.Log;
|
||||
import me.zhengjie.modules.system.domain.NwIncidents;
|
||||
import me.zhengjie.modules.system.service.NwIncidentsService;
|
||||
import me.zhengjie.modules.system.service.dto.NwIncidentsQueryCriteria;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
@Api(tags = "NwIncidents management")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class NwIncidentsController {
|
||||
|
||||
@Autowired
|
||||
private NwIncidentsService nwIncidentsService;
|
||||
|
||||
@Log("查询NwIncidents")
|
||||
@ApiOperation(value = "查询NwIncidents")
|
||||
@GetMapping(value = "/nwIncidents")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','NWINCIDENTS_ALL','NWINCIDENTS_SELECT')")
|
||||
public ResponseEntity getNwIncidentss(NwIncidentsQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(nwIncidentsService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增NwIncidents")
|
||||
@ApiOperation(value = "新增NwIncidents")
|
||||
@PostMapping(value = "/nwIncidents")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','NWINCIDENTS_ALL','NWINCIDENTS_CREATE')")
|
||||
public ResponseEntity create(@Validated @RequestBody NwIncidents resources){
|
||||
return new ResponseEntity(nwIncidentsService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Log("修改NwIncidents")
|
||||
@ApiOperation(value = "修改NwIncidents")
|
||||
@PutMapping(value = "/nwIncidents")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','NWINCIDENTS_ALL','NWINCIDENTS_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody NwIncidents resources){
|
||||
nwIncidentsService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除NwIncidents")
|
||||
@ApiOperation(value = "删除NwIncidents")
|
||||
@DeleteMapping(value = "/nwIncidents/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','NWINCIDENTS_ALL','NWINCIDENTS_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Integer id){
|
||||
nwIncidentsService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package me.zhengjie.modules.system.service;
|
||||
|
||||
import me.zhengjie.modules.system.domain.NwIncidents;
|
||||
import me.zhengjie.modules.system.service.dto.NwIncidentsDTO;
|
||||
import me.zhengjie.modules.system.service.dto.NwIncidentsQueryCriteria;
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
//@CacheConfig(cacheNames = "nwIncidents")
|
||||
public interface NwIncidentsService {
|
||||
|
||||
/**
|
||||
* queryAll 分页
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(keyGenerator = "keyGenerator")
|
||||
Object queryAll(NwIncidentsQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* queryAll 不分页
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(keyGenerator = "keyGenerator")
|
||||
public Object queryAll(NwIncidentsQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* findById
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(key = "#p0")
|
||||
NwIncidentsDTO findById(Integer id);
|
||||
|
||||
/**
|
||||
* create
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
NwIncidentsDTO create(NwIncidents resources);
|
||||
|
||||
/**
|
||||
* update
|
||||
* @param resources
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void update(NwIncidents resources);
|
||||
|
||||
/**
|
||||
* delete
|
||||
* @param id
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void delete(Integer id);
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package me.zhengjie.modules.system.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
@Data
|
||||
public class NwIncidentsDTO implements Serializable {
|
||||
|
||||
// ID
|
||||
private Integer id;
|
||||
|
||||
// Fault Clearance Time
|
||||
private Timestamp faultclearancetime;
|
||||
|
||||
// Fault Contractor TicketNo
|
||||
private String faultcontractorticketno;
|
||||
|
||||
// Fault Customer Name
|
||||
private String faultcustomername;
|
||||
|
||||
// Fault Customer Response Time
|
||||
private String faultcustomerresponsetime;
|
||||
|
||||
// Fault Description
|
||||
private String faultdescription;
|
||||
|
||||
// Fault Excused Outage Type1
|
||||
private String faultexcusedoutagetype1;
|
||||
|
||||
// Fault Excused Outage Type1 EndTime
|
||||
private Timestamp faultexcusedoutagetype1endtime;
|
||||
|
||||
// Fault Excused Outage Type1 Start Time
|
||||
private Timestamp faultexcusedoutagetype1starttime;
|
||||
|
||||
// Fault Excused Outage Type2
|
||||
private String faultexcusedoutagetype2;
|
||||
|
||||
// Fault Excused Outage Type2 End Time
|
||||
private Timestamp faultexcusedoutagetype2endtime;
|
||||
|
||||
// Fault Excused Outage Type2 Start Time
|
||||
private Timestamp faultexcusedoutagetype2starttime;
|
||||
|
||||
// Fault Excused Outage Type3
|
||||
private String faultexcusedoutagetype3;
|
||||
|
||||
// Fault Excused Outage Type3 End Time
|
||||
private Timestamp faultexcusedoutagetype3endtime;
|
||||
|
||||
// Fault Excused OutageType3 Start Time
|
||||
private Timestamp faultexcusedoutagetype3starttime;
|
||||
|
||||
// Fault Incident ID
|
||||
private String faultincidentid;
|
||||
|
||||
// Fault Link SiteA
|
||||
private String faultlinksitea;
|
||||
|
||||
// Fault Link SiteB
|
||||
private String faultlinksiteb;
|
||||
|
||||
// Fault Location
|
||||
private String faultlocation;
|
||||
|
||||
// Fault Occurrence Time
|
||||
private Timestamp faultoccurrencetime;
|
||||
|
||||
// Fault Priority
|
||||
private String faultpriority;
|
||||
|
||||
// Fault Responsibility
|
||||
private String faultresponsibility;
|
||||
|
||||
// Fault Site ID
|
||||
private String faultsiteid;
|
||||
|
||||
// Fault Site Name
|
||||
private String faultsitename;
|
||||
|
||||
// Fault Ticket No
|
||||
private String faultticketno;
|
||||
|
||||
// Fault Ticket Open Time
|
||||
private Timestamp faultticketopentime;
|
||||
|
||||
// Fault Type
|
||||
private String faulttype;
|
||||
|
||||
// is Fault Excused Outages Reported
|
||||
private Integer isfaultexcusedoutagesreported;
|
||||
|
||||
// is Fault Origin
|
||||
private Integer isfaultorigin;
|
||||
|
||||
// Resubmission
|
||||
private String resubmission;
|
||||
|
||||
// Timestamp
|
||||
private Timestamp timestamp;
|
||||
|
||||
// Username
|
||||
private String username;
|
||||
|
||||
// incidents_id
|
||||
private Integer incidentsId;
|
||||
|
||||
// DaysInMonth
|
||||
private String daysinmonth;
|
||||
|
||||
// Fault Additional Details
|
||||
private String faultadditionaldetails;
|
||||
|
||||
// Fault Contractor Ticket Id
|
||||
private String faultcontractorticketid;
|
||||
|
||||
// Fault Country
|
||||
private String faultcountry;
|
||||
|
||||
// Fault Site Deactivation Date
|
||||
private String faultsitedeactivationdate;
|
||||
|
||||
// Fault Site Lc Prorated Days
|
||||
private String faultsitelcprorateddays;
|
||||
|
||||
// Fault Site Product
|
||||
private String faultsiteproduct;
|
||||
|
||||
// Fault Site Protection Status
|
||||
private String faultsiteprotectionstatus;
|
||||
|
||||
// Fault Site Protection Status Date
|
||||
private String faultsiteprotectionstatusdate;
|
||||
|
||||
// Fault Site Service Commencement Date
|
||||
private String faultsiteservicecommencementdate;
|
||||
|
||||
// Fault Site SLA
|
||||
private String faultsitesla;
|
||||
|
||||
// Fault Site isBillable
|
||||
private String faultsiteisbillable;
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
package me.zhengjie.modules.system.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
@Data
|
||||
public class NwIncidentsQueryCriteria{
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Integer id;
|
||||
|
||||
// 精确
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private Timestamp faultclearancetime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultcontractorticketno;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultcustomername;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultcustomerresponsetime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultdescription;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultexcusedoutagetype1;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultexcusedoutagetype1endtime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultexcusedoutagetype1starttime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultexcusedoutagetype2;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultexcusedoutagetype2endtime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultexcusedoutagetype2starttime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultexcusedoutagetype3;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultexcusedoutagetype3endtime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultexcusedoutagetype3starttime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultincidentid;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultlinksitea;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultlinksiteb;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultlocation;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultoccurrencetime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultpriority;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultresponsibility;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsiteid;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsitename;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultticketno;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp faultticketopentime;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faulttype;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Integer isfaultexcusedoutagesreported;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Integer isfaultorigin;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String resubmission;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Timestamp timestamp;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String username;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private Integer incidentsId;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String daysinmonth;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultadditionaldetails;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultcontractorticketid;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultcountry;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsitedeactivationdate;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsitelcprorateddays;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsiteproduct;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsiteprotectionstatus;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsiteprotectionstatusdate;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsiteservicecommencementdate;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsitesla;
|
||||
|
||||
// 精确
|
||||
@Query
|
||||
private String faultsiteisbillable;
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package me.zhengjie.modules.system.service.impl;
|
||||
|
||||
import me.zhengjie.modules.system.domain.NwIncidents;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.modules.system.repository.NwIncidentsRepository;
|
||||
import me.zhengjie.modules.system.service.NwIncidentsService;
|
||||
import me.zhengjie.modules.system.service.dto.NwIncidentsDTO;
|
||||
import me.zhengjie.modules.system.service.dto.NwIncidentsQueryCriteria;
|
||||
import me.zhengjie.modules.system.service.mapper.NwIncidentsMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class NwIncidentsServiceImpl implements NwIncidentsService {
|
||||
|
||||
@Autowired
|
||||
private NwIncidentsRepository nwIncidentsRepository;
|
||||
|
||||
@Autowired
|
||||
private NwIncidentsMapper nwIncidentsMapper;
|
||||
|
||||
@Override
|
||||
public Object queryAll(NwIncidentsQueryCriteria criteria, Pageable pageable){
|
||||
Page<NwIncidents> page = nwIncidentsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(nwIncidentsMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(NwIncidentsQueryCriteria criteria){
|
||||
return nwIncidentsMapper.toDto(nwIncidentsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NwIncidentsDTO findById(Integer id) {
|
||||
Optional<NwIncidents> nwIncidents = nwIncidentsRepository.findById(id);
|
||||
ValidationUtil.isNull(nwIncidents,"NwIncidents","id",id);
|
||||
return nwIncidentsMapper.toDto(nwIncidents.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public NwIncidentsDTO create(NwIncidents resources) {
|
||||
return nwIncidentsMapper.toDto(nwIncidentsRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(NwIncidents resources) {
|
||||
Optional<NwIncidents> optionalNwIncidents = nwIncidentsRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalNwIncidents,"NwIncidents","id",resources.getId());
|
||||
NwIncidents nwIncidents = optionalNwIncidents.get();
|
||||
nwIncidents.copy(resources);
|
||||
nwIncidentsRepository.save(nwIncidents);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Integer id) {
|
||||
nwIncidentsRepository.deleteById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package me.zhengjie.modules.system.service.mapper;
|
||||
|
||||
import me.zhengjie.mapper.EntityMapper;
|
||||
import me.zhengjie.modules.system.domain.NwIncidents;
|
||||
import me.zhengjie.modules.system.service.dto.NwIncidentsDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author Bobby Kimutai
|
||||
* @date 2019-08-05
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface NwIncidentsMapper extends EntityMapper<NwIncidentsDTO, NwIncidents> {
|
||||
|
||||
}
|
Loading…
Reference in New Issue