feat: 增加变电站和设备类型的相关接口
parent
7e1d79f60c
commit
f2eae6c235
@ -0,0 +1,72 @@
|
|||||||
|
package com.xydl.cac.controller;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Bdz;
|
||||||
|
import com.xydl.cac.model.Response;
|
||||||
|
import com.xydl.cac.service.BdzService;
|
||||||
|
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 = {"变电站相关接口"})
|
||||||
|
@RequestMapping("bdz")
|
||||||
|
@Slf4j
|
||||||
|
public class BdzController extends BasicController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
BdzService service;
|
||||||
|
|
||||||
|
@GetMapping("listAll")
|
||||||
|
@ApiOperation("查询全部列表")
|
||||||
|
public Response<List<Bdz>> listAll() {
|
||||||
|
try {
|
||||||
|
List<Bdz> result = service.listAll();
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@ApiOperation("新增")
|
||||||
|
public Response<Bdz> add(@RequestBody Bdz item) {
|
||||||
|
try {
|
||||||
|
Bdz result = service.add(item);
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("update")
|
||||||
|
@ApiOperation("更新")
|
||||||
|
public Response<String> update(@RequestBody Bdz item) {
|
||||||
|
try {
|
||||||
|
if (item.getId() == null) {
|
||||||
|
throw new Exception("ID不能为空!");
|
||||||
|
}
|
||||||
|
service.update(item);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
@ApiOperation("删除")
|
||||||
|
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
|
||||||
|
try {
|
||||||
|
service.delete(id);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.xydl.cac.controller;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Lx;
|
||||||
|
import com.xydl.cac.model.Response;
|
||||||
|
import com.xydl.cac.service.LxService;
|
||||||
|
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 = {"设备类型相关接口"})
|
||||||
|
@RequestMapping("lx")
|
||||||
|
@Slf4j
|
||||||
|
public class LxController extends BasicController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
LxService service;
|
||||||
|
|
||||||
|
@GetMapping("listAll")
|
||||||
|
@ApiOperation("查询全部列表")
|
||||||
|
public Response<List<Lx>> listAll() {
|
||||||
|
try {
|
||||||
|
List<Lx> result = service.listAll();
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@ApiOperation("新增")
|
||||||
|
public Response<Lx> add(@RequestBody Lx item) {
|
||||||
|
try {
|
||||||
|
Lx result = service.add(item);
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("update")
|
||||||
|
@ApiOperation("更新")
|
||||||
|
public Response<String> update(@RequestBody Lx item) {
|
||||||
|
try {
|
||||||
|
if (item.getId() == null) {
|
||||||
|
throw new Exception("ID不能为空!");
|
||||||
|
}
|
||||||
|
service.update(item);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
@ApiOperation("删除")
|
||||||
|
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
|
||||||
|
try {
|
||||||
|
service.delete(id);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.xydl.cac.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "bdz")
|
||||||
|
@ApiModel("变电站表")
|
||||||
|
public class Bdz {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(name = "mc")
|
||||||
|
private String mc;
|
||||||
|
|
||||||
|
@Column(name = "lx")
|
||||||
|
private String lx;
|
||||||
|
|
||||||
|
@Column(name = "pid")
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
@Column(name = "gkjip")
|
||||||
|
private String gkjip;
|
||||||
|
|
||||||
|
@Column(name = "xfport")
|
||||||
|
private Integer xfport;
|
||||||
|
|
||||||
|
@Column(name = "znxj")
|
||||||
|
private Short znxj;
|
||||||
|
|
||||||
|
@Column(name = "ztjcid")
|
||||||
|
private String ztjcid;
|
||||||
|
|
||||||
|
@Column(name = "enable")
|
||||||
|
private BigDecimal enable;
|
||||||
|
|
||||||
|
@Column(name = "xh")
|
||||||
|
private BigDecimal xh;
|
||||||
|
|
||||||
|
@Column(name = "bz")
|
||||||
|
private String bz;
|
||||||
|
|
||||||
|
@Column(name = "hascac")
|
||||||
|
private Boolean hascac;
|
||||||
|
|
||||||
|
@Column(name = "coordinate")
|
||||||
|
private String coordinate;
|
||||||
|
|
||||||
|
@Column(name = "voltagegrade")
|
||||||
|
private Integer voltagegrade;
|
||||||
|
|
||||||
|
@Column(name = "scale")
|
||||||
|
private Float scale;
|
||||||
|
|
||||||
|
@Column(name = "note")
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@Column(name = "icon1")
|
||||||
|
private String icon1;
|
||||||
|
|
||||||
|
@Column(name = "icon2")
|
||||||
|
private String icon2;
|
||||||
|
|
||||||
|
@Column(name = "icon3")
|
||||||
|
private String icon3;
|
||||||
|
|
||||||
|
@Column(name = "icon4")
|
||||||
|
private String icon4;
|
||||||
|
|
||||||
|
@Column(name = "svgurl")
|
||||||
|
private String svgurl;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.xydl.cac.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "bdz")
|
||||||
|
@ApiModel("设备类型表")
|
||||||
|
public class Lx {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(name = "mc")
|
||||||
|
private String mc;
|
||||||
|
|
||||||
|
@Column(name = "ls")
|
||||||
|
private BigDecimal ls;
|
||||||
|
|
||||||
|
@Column(name = "zxjc")
|
||||||
|
private BigDecimal zxjc;
|
||||||
|
|
||||||
|
@Column(name = "zxjcurl")
|
||||||
|
private String zxjcurl;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.xydl.cac.repository;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Bdz;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface BdzRepository extends JpaRepository<Bdz, Integer>, JpaSpecificationExecutor<Bdz> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.xydl.cac.repository;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Lx;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface LxRepository extends JpaRepository<Lx, Integer>, JpaSpecificationExecutor<Lx> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.xydl.cac.service;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Bdz;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface BdzService {
|
||||||
|
|
||||||
|
List<Bdz> listAll();
|
||||||
|
|
||||||
|
Bdz add(Bdz item);
|
||||||
|
|
||||||
|
void update(Bdz item);
|
||||||
|
|
||||||
|
void delete(Integer id);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.xydl.cac.service;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Lx;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface LxService {
|
||||||
|
|
||||||
|
List<Lx> listAll();
|
||||||
|
|
||||||
|
Lx add(Lx item);
|
||||||
|
|
||||||
|
void update(Lx item);
|
||||||
|
|
||||||
|
void delete(Integer id);
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.xydl.cac.service.impl;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Bdz;
|
||||||
|
import com.xydl.cac.repository.BdzRepository;
|
||||||
|
import com.xydl.cac.service.BdzService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class BdzServiceImpl implements BdzService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
BdzRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Bdz> listAll() {
|
||||||
|
return repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Bdz add(Bdz item) {
|
||||||
|
item.setId(null);
|
||||||
|
return repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Bdz item) {
|
||||||
|
repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Integer id) {
|
||||||
|
repository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.xydl.cac.service.impl;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Lx;
|
||||||
|
import com.xydl.cac.repository.LxRepository;
|
||||||
|
import com.xydl.cac.service.LxService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class LxServiceImpl implements LxService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
LxRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Lx> listAll() {
|
||||||
|
return repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Lx add(Lx item) {
|
||||||
|
item.setId(null);
|
||||||
|
return repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Lx item) {
|
||||||
|
repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Integer id) {
|
||||||
|
repository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue