mirror of https://github.com/elunez/eladmin
增加工单模块
parent
b877fbc791
commit
2b0a94e235
|
@ -39,6 +39,20 @@
|
|||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 单位管理 -->
|
||||
<dependency>
|
||||
<groupId>com.uueo.itam.company</groupId>
|
||||
<artifactId>itam-company</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 工单管理 -->
|
||||
<dependency>
|
||||
<groupId>com.uueo.itam</groupId>
|
||||
<artifactId>itam-ticket</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring boot websocket -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -20,10 +20,14 @@ import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
|||
import me.zhengjie.utils.SpringContextHolder;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScans;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -37,9 +41,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@EnableAsync
|
||||
@RestController
|
||||
@Api(hidden = true)
|
||||
@SpringBootApplication
|
||||
//@ComponentScan({"me.zhengjie", "com.uueo"})
|
||||
@SpringBootApplication(scanBasePackages = {"me.zhengjie", "com.uueo.itam"})
|
||||
@EnableTransactionManagement
|
||||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||||
@EnableJpaRepositories(basePackages = {"me.zhengjie.**.repository","com.uueo.itam.**.repository"})
|
||||
@EntityScan(basePackages = {"me.zhengjie","com.uueo.itam"})
|
||||
public class AppRun {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>eladmin</artifactId>
|
||||
<groupId>me.zhengjie</groupId>
|
||||
<version>2.6</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.uueo.itam</groupId>
|
||||
<artifactId>itam-ticket</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>工单管理</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>me.zhengjie</groupId>
|
||||
<artifactId>eladmin-logging</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description /
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="itam_event")
|
||||
public class Event implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "eid")
|
||||
@ApiModelProperty(value = "事件ID")
|
||||
private Integer eid;
|
||||
|
||||
@Column(name = "etid")
|
||||
@ApiModelProperty(value = "事件类型")
|
||||
private Integer etid;
|
||||
|
||||
@Column(name = "grade")
|
||||
@ApiModelProperty(value = "重要程度")
|
||||
private Integer grade;
|
||||
|
||||
@Column(name = "content")
|
||||
@ApiModelProperty(value = "详情描述")
|
||||
private String content;
|
||||
|
||||
@Column(name = "kid")
|
||||
@ApiModelProperty(value = "反馈科室")
|
||||
private String kid;
|
||||
|
||||
@Column(name = "reportid")
|
||||
@ApiModelProperty(value = "反馈人")
|
||||
private String reportid;
|
||||
|
||||
@Column(name = "reporttime")
|
||||
@ApiModelProperty(value = "反馈时间")
|
||||
private Timestamp reporttime;
|
||||
|
||||
@Column(name = "recorderid")
|
||||
@ApiModelProperty(value = "记录人")
|
||||
private Integer recorderid;
|
||||
|
||||
@Column(name = "recordetime")
|
||||
@ApiModelProperty(value = "记录时间")
|
||||
private Timestamp recordetime;
|
||||
|
||||
@Column(name = "dealerid")
|
||||
@ApiModelProperty(value = "处理人")
|
||||
private Integer dealerid;
|
||||
|
||||
@Column(name = "dealtime")
|
||||
@ApiModelProperty(value = "处理时间")
|
||||
private Timestamp dealtime;
|
||||
|
||||
@Column(name = "updatetime")
|
||||
@ApiModelProperty(value = "最后更新时间")
|
||||
private Timestamp updatetime;
|
||||
|
||||
@Column(name = "dealflg")
|
||||
@ApiModelProperty(value = "处理标识")
|
||||
private Integer dealflg;
|
||||
|
||||
@Column(name = "relatedid")
|
||||
@ApiModelProperty(value = "关联事件ID")
|
||||
private Integer relatedid;
|
||||
|
||||
@Column(name = "bz")
|
||||
@ApiModelProperty(value = "状态标识")
|
||||
private Integer bz;
|
||||
|
||||
public void copy(Event source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description /
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="itam_event_type")
|
||||
public class EventType implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
@ApiModelProperty(value = "id", hidden = true)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "typename",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "事件类型名称")
|
||||
private String typename;
|
||||
|
||||
@Column(name = "parentid")
|
||||
@ApiModelProperty(value = "parentid")
|
||||
private Integer parentid;
|
||||
|
||||
@ApiModelProperty(value = "subCount", hidden = true)
|
||||
private Integer subCount = 0;
|
||||
|
||||
@Column(name = "level")
|
||||
@ApiModelProperty(value = "层级路径")
|
||||
private String level;
|
||||
|
||||
@Column(name = "seq")
|
||||
@ApiModelProperty(value = "层级")
|
||||
private Integer seq;
|
||||
|
||||
@Column(name = "pinyin")
|
||||
@ApiModelProperty(value = "拼音")
|
||||
private String pinyin;
|
||||
|
||||
@Column(name = "bz")
|
||||
@ApiModelProperty(value = "启用标识")
|
||||
private Integer bz;
|
||||
|
||||
public void copy(EventType source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.uueo.itam.ticket.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class EventTypeVo {
|
||||
|
||||
/** 事件类型名称 */
|
||||
private String typename;
|
||||
|
||||
private Integer parentid;
|
||||
|
||||
/** 层级路径 */
|
||||
private String level;
|
||||
|
||||
/** 层级 */
|
||||
private Integer seq;
|
||||
|
||||
/** 拼音 */
|
||||
private String pinyin;
|
||||
|
||||
/** 启用标识 */
|
||||
private Integer bz;
|
||||
|
||||
private List<EventTypeVo> children;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.repository;
|
||||
|
||||
import com.uueo.itam.ticket.domain.Event;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
public interface EventRepository extends JpaRepository<Event, Integer>, JpaSpecificationExecutor<Event> {
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.repository;
|
||||
|
||||
import com.uueo.itam.ticket.domain.EventType;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
// 继承自JpaSpecificationExecutor,支持动态查询
|
||||
public interface EventTypeRepository extends JpaRepository<EventType, Integer>, JpaSpecificationExecutor<EventType> {
|
||||
|
||||
/**
|
||||
* 根据parentid查询子项目
|
||||
* @param parentid
|
||||
* @return List<EventType>
|
||||
*/
|
||||
List<EventType> findByParentid(int parentid);
|
||||
|
||||
/**
|
||||
* 获取一级项目
|
||||
* @return
|
||||
*/
|
||||
List<EventType> getByParentidIsNull();
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import com.uueo.itam.ticket.domain.Event;
|
||||
import com.uueo.itam.ticket.service.EventService;
|
||||
import com.uueo.itam.ticket.service.dto.EventQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "工单管理管理")
|
||||
@RequestMapping("/api/event")
|
||||
public class EventController {
|
||||
|
||||
private final EventService eventService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('event:list')")
|
||||
public void download(HttpServletResponse response, EventQueryCriteria criteria) throws IOException {
|
||||
eventService.download(eventService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询工单管理")
|
||||
@ApiOperation("查询工单管理")
|
||||
@PreAuthorize("@el.check('event:list')")
|
||||
public ResponseEntity<Object> query(EventQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(eventService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增工单管理")
|
||||
@ApiOperation("新增工单管理")
|
||||
@PreAuthorize("@el.check('event:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody Event resources){
|
||||
return new ResponseEntity<>(eventService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改工单管理")
|
||||
@ApiOperation("修改工单管理")
|
||||
@PreAuthorize("@el.check('event:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody Event resources){
|
||||
eventService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除工单管理")
|
||||
@ApiOperation("删除工单管理")
|
||||
@PreAuthorize("@el.check('event:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
eventService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.rest;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeDto;
|
||||
import me.zhengjie.annotation.Log;
|
||||
import com.uueo.itam.ticket.domain.EventType;
|
||||
import com.uueo.itam.ticket.service.EventTypeService;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "事件类型管理")
|
||||
@RequestMapping("/api/eventType")
|
||||
public class EventTypeController {
|
||||
|
||||
private final EventTypeService eventTypeService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('eventType:list')")
|
||||
public void download(HttpServletResponse response, EventTypeQueryCriteria criteria) throws IOException {
|
||||
eventTypeService.download(eventTypeService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("获取全部类型")
|
||||
@GetMapping(value = "/lazy")
|
||||
@Log("获取全部类型")
|
||||
@PreAuthorize("@el.check('eventType:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Integer pid) {
|
||||
return new ResponseEntity<>(eventTypeService.getEventTypes(pid),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询事件类型")
|
||||
@ApiOperation("查询事件类型")
|
||||
@PreAuthorize("@el.check('eventType:list')")
|
||||
public ResponseEntity<Object> query(EventTypeQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(eventTypeService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("根据ID查询上级目录")
|
||||
@PostMapping("/superior")
|
||||
@PreAuthorize("@el.check('eventType:list')")
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody List<Integer> ids) {
|
||||
Set<EventTypeDto> etDtos = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
for (Integer id : ids) {
|
||||
EventTypeDto etDto = eventTypeService.findById(id);
|
||||
etDtos.addAll(eventTypeService.getSuperior(etDto, new ArrayList<>()));
|
||||
}
|
||||
return new ResponseEntity<>(eventTypeService.buildTree(new ArrayList<>(etDtos)),HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(eventTypeService.getEventTypes(null),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增事件类型")
|
||||
@ApiOperation("新增事件类型")
|
||||
@PreAuthorize("@el.check('eventType:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody EventType resources){
|
||||
return new ResponseEntity<>(eventTypeService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改事件类型")
|
||||
@ApiOperation("修改事件类型")
|
||||
@PreAuthorize("@el.check('eventType:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody EventType resources){
|
||||
eventTypeService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除事件类型")
|
||||
@ApiOperation("删除事件类型")
|
||||
@PreAuthorize("@el.check('eventType:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
eventTypeService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service;
|
||||
|
||||
import com.uueo.itam.ticket.domain.Event;
|
||||
import com.uueo.itam.ticket.service.dto.EventDto;
|
||||
import com.uueo.itam.ticket.service.dto.EventQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description 服务接口
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
public interface EventService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(EventQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<EventDto>
|
||||
*/
|
||||
List<EventDto> queryAll(EventQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param eid ID
|
||||
* @return EventDto
|
||||
*/
|
||||
EventDto findById(Integer eid);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return EventDto
|
||||
*/
|
||||
EventDto create(Event resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(Event resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<EventDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service;
|
||||
|
||||
import com.uueo.itam.ticket.domain.EventType;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeDto;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description 服务接口
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
public interface EventTypeService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(EventTypeQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<EventTypeDto>
|
||||
*/
|
||||
List<EventTypeDto> queryAll(EventTypeQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return EventTypeDto
|
||||
*/
|
||||
EventTypeDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return EventTypeDto
|
||||
*/
|
||||
EventTypeDto create(EventType resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(EventType resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<EventTypeDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 根据parentid获取子项目
|
||||
* @param parentid
|
||||
* @return List<EventTypeDto>
|
||||
*/
|
||||
List<EventTypeDto> getEventTypes(Integer parentid);
|
||||
|
||||
/**
|
||||
* 获取上级事件类型
|
||||
* @param etDto
|
||||
* @param objects
|
||||
* @return
|
||||
*/
|
||||
List<EventTypeDto> getSuperior(EventTypeDto etDto, List<EventType> objects);
|
||||
|
||||
/**
|
||||
* 生成树形结构
|
||||
* @param ets
|
||||
* @return
|
||||
*/
|
||||
List<EventTypeDto> buildTree(List<EventTypeDto> ets);
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description /
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
@Data
|
||||
public class EventDto implements Serializable {
|
||||
|
||||
/** 事件ID */
|
||||
private Integer eid;
|
||||
|
||||
/** 事件类型 */
|
||||
private Integer etid;
|
||||
|
||||
/** 重要程度 */
|
||||
private Integer grade;
|
||||
|
||||
/** 详情描述 */
|
||||
private String content;
|
||||
|
||||
/** 反馈科室 */
|
||||
private String kid;
|
||||
|
||||
/** 反馈人 */
|
||||
private String reportid;
|
||||
|
||||
/** 反馈时间 */
|
||||
private Timestamp reporttime;
|
||||
|
||||
/** 记录人 */
|
||||
private Integer recorderid;
|
||||
|
||||
/** 记录时间 */
|
||||
private Timestamp recordetime;
|
||||
|
||||
/** 处理人 */
|
||||
private Integer dealerid;
|
||||
|
||||
/** 处理时间 */
|
||||
private Timestamp dealtime;
|
||||
|
||||
/** 最后更新时间 */
|
||||
private Timestamp updatetime;
|
||||
|
||||
/** 处理标识 */
|
||||
private Integer dealflg;
|
||||
|
||||
/** 关联事件ID */
|
||||
private Integer relatedid;
|
||||
|
||||
/** 状态标识 */
|
||||
private Integer bz;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
@Data
|
||||
public class EventQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer grade;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import me.zhengjie.base.BaseDTO;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description /
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
@Data
|
||||
public class EventTypeDto extends BaseDTO implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private List<EventTypeDto> children;
|
||||
|
||||
/** 事件类型名称 */
|
||||
private String typename;
|
||||
|
||||
private Integer parentid;
|
||||
|
||||
/** 子项数 */
|
||||
private Integer subCount;
|
||||
|
||||
/** 层级路径 */
|
||||
private String level;
|
||||
|
||||
/** 层级 */
|
||||
private Integer seq;
|
||||
|
||||
/** 拼音 */
|
||||
private String pinyin;
|
||||
|
||||
/** 启用标识 */
|
||||
private Integer bz;
|
||||
|
||||
public Boolean getHasChildren() {
|
||||
return subCount > 0;
|
||||
}
|
||||
|
||||
public Boolean getLeaf() {
|
||||
return subCount <= 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
@Data
|
||||
public class EventTypeQueryCriteria{
|
||||
|
||||
@Query(type = Query.Type.EQUAL, propName = "parentid")
|
||||
private Boolean isPid;
|
||||
|
||||
@Query
|
||||
private Integer parentid;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.impl;
|
||||
|
||||
import com.uueo.itam.ticket.domain.Event;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.uueo.itam.ticket.repository.EventRepository;
|
||||
import com.uueo.itam.ticket.service.EventService;
|
||||
import com.uueo.itam.ticket.service.dto.EventDto;
|
||||
import com.uueo.itam.ticket.service.dto.EventQueryCriteria;
|
||||
import com.uueo.itam.ticket.service.mapstruct.EventMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description 服务实现
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EventServiceImpl implements EventService {
|
||||
|
||||
private final EventRepository eventRepository;
|
||||
private final EventMapper eventMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(EventQueryCriteria criteria, Pageable pageable){
|
||||
Page<Event> page = eventRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(eventMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventDto> queryAll(EventQueryCriteria criteria){
|
||||
return eventMapper.toDto(eventRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public EventDto findById(Integer eid) {
|
||||
Event event = eventRepository.findById(eid).orElseGet(Event::new);
|
||||
ValidationUtil.isNull(event.getEid(),"Event","eid",eid);
|
||||
return eventMapper.toDto(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public EventDto create(Event resources) {
|
||||
return eventMapper.toDto(eventRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Event resources) {
|
||||
Event event = eventRepository.findById(resources.getEid()).orElseGet(Event::new);
|
||||
ValidationUtil.isNull( event.getEid(),"Event","id",resources.getEid());
|
||||
event.copy(resources);
|
||||
eventRepository.save(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer eid : ids) {
|
||||
eventRepository.deleteById(eid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<EventDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (EventDto event : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("事件类型", event.getEtid());
|
||||
map.put("重要程度", event.getGrade());
|
||||
map.put("详情描述", event.getContent());
|
||||
map.put("反馈科室", event.getKid());
|
||||
map.put("反馈人", event.getReportid());
|
||||
map.put("反馈时间", event.getReporttime());
|
||||
map.put("记录人", event.getRecorderid());
|
||||
map.put("记录时间", event.getRecordetime());
|
||||
map.put("处理人", event.getDealerid());
|
||||
map.put("处理时间", event.getDealtime());
|
||||
map.put("最后更新时间", event.getUpdatetime());
|
||||
map.put("处理标识", event.getDealflg());
|
||||
map.put("关联事件ID", event.getRelatedid());
|
||||
map.put("状态标识", event.getBz());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.uueo.itam.ticket.domain.EventType;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.uueo.itam.ticket.repository.EventTypeRepository;
|
||||
import com.uueo.itam.ticket.service.EventTypeService;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeDto;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeQueryCriteria;
|
||||
import com.uueo.itam.ticket.service.mapstruct.EventTypeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @description 服务实现
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EventTypeServiceImpl implements EventTypeService {
|
||||
|
||||
private final EventTypeRepository eventTypeRepository;
|
||||
private final EventTypeMapper eventTypeMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(EventTypeQueryCriteria criteria, Pageable pageable){
|
||||
/*
|
||||
eventTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))
|
||||
等效于
|
||||
eventTypeRepository.findAll(new Specification() {
|
||||
@Override
|
||||
Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
|
||||
return QueryHelp.getPredicate(root,criteria,criteriaBuilder);
|
||||
}
|
||||
});
|
||||
*/
|
||||
if (ObjectUtil.isNull(criteria.getParentid())) {
|
||||
criteria.setParentid(0);
|
||||
}
|
||||
|
||||
Page<EventType> page = eventTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(eventTypeMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventTypeDto> queryAll(EventTypeQueryCriteria criteria){
|
||||
return eventTypeMapper.toDto(eventTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public EventTypeDto findById(Integer id) {
|
||||
EventType eventType = eventTypeRepository.findById(id).orElseGet(EventType::new);
|
||||
ValidationUtil.isNull(eventType.getId(),"EventType","id",id);
|
||||
return eventTypeMapper.toDto(eventType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public EventTypeDto create(EventType resources) {
|
||||
return eventTypeMapper.toDto(eventTypeRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(EventType resources) {
|
||||
EventType eventType = eventTypeRepository.findById(resources.getId()).orElseGet(EventType::new);
|
||||
ValidationUtil.isNull( eventType.getId(),"EventType","id",resources.getId());
|
||||
eventType.copy(resources);
|
||||
eventTypeRepository.save(eventType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
eventTypeRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<EventTypeDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (EventTypeDto eventType : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("事件类型名称", eventType.getTypename());
|
||||
map.put(" parentid", eventType.getParentid());
|
||||
map.put("层级路径", eventType.getLevel());
|
||||
map.put("层级", eventType.getSeq());
|
||||
map.put("拼音", eventType.getPinyin());
|
||||
map.put("启用标识", eventType.getBz());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventTypeDto> getEventTypes(Integer parentid) {
|
||||
List<EventType> et;
|
||||
if (parentid != null || !parentid.equals(0)) {
|
||||
et = eventTypeRepository.findByParentid(parentid);
|
||||
} else {
|
||||
et = eventTypeRepository.findByParentid(0);
|
||||
}
|
||||
return eventTypeMapper.toDto(et);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventTypeDto> getSuperior(EventTypeDto etDto, List<EventType> ets) {
|
||||
if (etDto.getParentid() == null || etDto.getParentid() == 0) {
|
||||
ets.addAll(eventTypeRepository.findByParentid(0));
|
||||
return eventTypeMapper.toDto(ets);
|
||||
}
|
||||
ets.addAll(eventTypeRepository.findByParentid(etDto.getParentid()));
|
||||
return getSuperior(findById(etDto.getParentid()), ets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventTypeDto> buildTree(List<EventTypeDto> ets) {
|
||||
List<EventTypeDto> trees = new ArrayList<>();
|
||||
Set<Integer> ids = new HashSet<>();
|
||||
for (EventTypeDto et : ets) {
|
||||
if (et.getParentid() == null || et.getParentid() == 0) {
|
||||
trees.add(et);
|
||||
}
|
||||
for (EventTypeDto id : ets) {
|
||||
if (id.getParentid().equals(et.getId())) {
|
||||
if (et.getChildren() == null) {
|
||||
et.setChildren(new ArrayList<>());
|
||||
}
|
||||
et.getChildren().add(id);
|
||||
ids.add(id.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trees.size() == 0) {
|
||||
trees = ets.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import com.uueo.itam.ticket.domain.Event;
|
||||
import com.uueo.itam.ticket.service.dto.EventDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-19
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface EventMapper extends BaseMapper<EventDto, Event> {
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uueo.itam.ticket.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import com.uueo.itam.ticket.domain.EventType;
|
||||
import com.uueo.itam.ticket.service.dto.EventTypeDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://el-admin.vip
|
||||
* @author esinhee
|
||||
* @date 2021-01-20
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface EventTypeMapper extends BaseMapper<EventTypeDto, EventType> {
|
||||
|
||||
}
|
Loading…
Reference in New Issue