feat:iec104点表配置、CRUD操作
parent
5f967278f5
commit
e38515bf10
@ -0,0 +1,60 @@
|
||||
package com.xydl.cac.controller;
|
||||
|
||||
import com.xydl.cac.entity.Iec104Point;
|
||||
import com.xydl.cac.exception.BusinessException;
|
||||
import com.xydl.cac.model.Response;
|
||||
import com.xydl.cac.service.Iec104PointService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(tags = {"Iec104点表接口"})
|
||||
@RequestMapping("iec104")
|
||||
@Slf4j
|
||||
public class Iec104PointController extends BasicController {
|
||||
|
||||
@Resource
|
||||
Iec104PointService iec104PointService;
|
||||
|
||||
@GetMapping("list")
|
||||
@ApiOperation("查询iec104列表")
|
||||
public Response<List<Iec104Point>> list() {
|
||||
List<Iec104Point> result = iec104PointService.findAll();
|
||||
return Response.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation("新增")
|
||||
public Response<Iec104Point> add(@Validated @RequestBody Iec104Point iec104Point) {
|
||||
Iec104Point add = iec104PointService.add(iec104Point);
|
||||
return Response.success(add);
|
||||
}
|
||||
|
||||
@PostMapping("update")
|
||||
@ApiOperation("更新")
|
||||
public Response<String> update(@Validated @RequestBody Iec104Point iec104Point) throws Exception {
|
||||
if (iec104Point.getId() == null) {
|
||||
throw new BusinessException("id不能为空!");
|
||||
}
|
||||
iec104PointService.update(iec104Point);
|
||||
return Response.success("OK");
|
||||
}
|
||||
|
||||
@PostMapping("del")
|
||||
@ApiOperation("删除")
|
||||
public Response<String> del(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
|
||||
if (id == null) {
|
||||
throw new BusinessException("id不能为空!");
|
||||
}
|
||||
iec104PointService.delete(id);
|
||||
return Response.success("OK");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.xydl.cac.entity;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "iec_104_point")
|
||||
@ApiModel("IEC104点表配置")
|
||||
public class Iec104Point {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "eqmid")
|
||||
private String eqmid;
|
||||
|
||||
@ApiModelProperty("字段")
|
||||
@Column(name = "filed")
|
||||
private String filed;
|
||||
|
||||
@ApiModelProperty("点位类型")
|
||||
@Column(name = "stype")
|
||||
private String stype;
|
||||
|
||||
@ApiModelProperty("点位")
|
||||
@Column(name = "sadr")
|
||||
private Integer sadr;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.xydl.cac.repository;
|
||||
|
||||
import com.xydl.cac.entity.Iec104Point;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface Iec104PointRepository extends JpaRepository<Iec104Point, Integer>, JpaSpecificationExecutor<Iec104Point> {
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.xydl.cac.service;
|
||||
|
||||
import com.xydl.cac.entity.Iec104Point;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Iec104PointService {
|
||||
|
||||
List<Iec104Point> findAll();
|
||||
|
||||
Iec104Point add(Iec104Point point);
|
||||
|
||||
void update(Iec104Point point);
|
||||
|
||||
void delete(Integer id);
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.xydl.cac.service.impl;
|
||||
|
||||
import com.xydl.cac.entity.Iec104Point;
|
||||
import com.xydl.cac.repository.Iec104PointRepository;
|
||||
import com.xydl.cac.service.Iec104PointService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class Iec104PointServiceImpl implements Iec104PointService {
|
||||
|
||||
@Resource
|
||||
Iec104PointRepository iec104PointRepository;
|
||||
|
||||
@Override
|
||||
public List<Iec104Point> findAll() {
|
||||
return iec104PointRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iec104Point add(Iec104Point point) {
|
||||
point.setId(null);
|
||||
point.setCreateTime(new Date());
|
||||
return iec104PointRepository.save(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Iec104Point point) {
|
||||
iec104PointRepository.save(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer id) {
|
||||
iec104PointRepository.deleteById(id);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue