[add]新增设备管理
This commit is contained in:
parent
42dc0c37e9
commit
a71ef52c00
@ -0,0 +1,67 @@
|
||||
package com.jdc.jdcproject.controller;
|
||||
|
||||
import com.jdc.jdcproject.entity.Equipment;
|
||||
import com.jdc.jdcproject.service.EquipmentService;
|
||||
import com.jdc.jdcproject.utils.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/equipmentController")
|
||||
public class EquipmentController {
|
||||
@Autowired
|
||||
private EquipmentService equipmentService;
|
||||
|
||||
@Operation(summary = "查询所有设备")
|
||||
@GetMapping("findAllEquipment")
|
||||
public Result findAllEquipment() {
|
||||
List<Equipment> equipment = equipmentService.list();
|
||||
return Result.successResult().data("equipment", equipment);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询设备信息")
|
||||
@GetMapping("findEquipmentById/{id}")
|
||||
public Result findEquipmentById(@PathVariable String id) {
|
||||
Equipment equipment = equipmentService.getById(id);
|
||||
return Result.successResult().data("equipment", equipment);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "修改设备信息")
|
||||
@PostMapping("updateEquipment")
|
||||
public Result updateEquipment(@RequestBody Equipment equipment) {
|
||||
boolean updateflag = equipmentService.updateById(equipment);
|
||||
if (updateflag) {
|
||||
return Result.successResult();
|
||||
} else {
|
||||
return Result.errorResult();
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "删除设备信息")
|
||||
@DeleteMapping("deleteEquipment/{id}")
|
||||
public Result deleteEquipment(@PathVariable String id) {
|
||||
boolean updateflag = equipmentService.removeById(id);
|
||||
if (updateflag) {
|
||||
return Result.successResult();
|
||||
} else {
|
||||
return Result.errorResult();
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "新增设备信息")
|
||||
@PostMapping("addEquipment")
|
||||
public Result addEquipment(@RequestBody Equipment equipment) {
|
||||
System.out.println(equipment);
|
||||
|
||||
boolean updateflag = equipmentService.save(equipment);
|
||||
if (updateflag) {
|
||||
return Result.successResult();
|
||||
} else {
|
||||
return Result.errorResult();
|
||||
}
|
||||
}
|
||||
}
|
78
src/main/java/com/jdc/jdcproject/entity/Equipment.java
Normal file
78
src/main/java/com/jdc/jdcproject/entity/Equipment.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.jdc.jdcproject.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设备表;
|
||||
* @TableName equipment
|
||||
*/
|
||||
@TableName(value ="equipment")
|
||||
@Data
|
||||
public class Equipment implements Serializable {
|
||||
/**
|
||||
* 主键,唯一标识设备
|
||||
*/
|
||||
@TableId(value = "EquipmentId", type = IdType.AUTO)
|
||||
private Integer equipmentId;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@TableField(value = "EquipmentName")
|
||||
private String equipmentName;
|
||||
|
||||
/**
|
||||
* 车间ID
|
||||
*/
|
||||
@TableField(value = "WorkShopId")
|
||||
private Integer workShopId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Equipment other = (Equipment) that;
|
||||
return (this.getEquipmentId() == null ? other.getEquipmentId() == null : this.getEquipmentId().equals(other.getEquipmentId()))
|
||||
&& (this.getEquipmentName() == null ? other.getEquipmentName() == null : this.getEquipmentName().equals(other.getEquipmentName()))
|
||||
&& (this.getWorkShopId() == null ? other.getWorkShopId() == null : this.getWorkShopId().equals(other.getWorkShopId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getEquipmentId() == null) ? 0 : getEquipmentId().hashCode());
|
||||
result = prime * result + ((getEquipmentName() == null) ? 0 : getEquipmentName().hashCode());
|
||||
result = prime * result + ((getWorkShopId() == null) ? 0 : getWorkShopId().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", equipmentId=").append(equipmentId);
|
||||
sb.append(", equipmentName=").append(equipmentName);
|
||||
sb.append(", workShopId=").append(workShopId);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
18
src/main/java/com/jdc/jdcproject/mapper/EquipmentMapper.java
Normal file
18
src/main/java/com/jdc/jdcproject/mapper/EquipmentMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.jdc.jdcproject.mapper;
|
||||
|
||||
import com.jdc.jdcproject.entity.Equipment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 95262
|
||||
* @description 针对表【equipment(设备表;)】的数据库操作Mapper
|
||||
* @createDate 2025-05-06 16:02:19
|
||||
* @Entity com.jdc.jdcproject.entity.Equipment
|
||||
*/
|
||||
public interface EquipmentMapper extends BaseMapper<Equipment> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jdc.jdcproject.mapper.EquipmentMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.jdc.jdcproject.entity.Equipment">
|
||||
<id property="equipmentId" column="EquipmentId" jdbcType="INTEGER"/>
|
||||
<result property="equipmentName" column="EquipmentName" jdbcType="VARCHAR"/>
|
||||
<result property="workShopId" column="WorkShopId" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
EquipmentId,EquipmentName,WorkShopId
|
||||
</sql>
|
||||
</mapper>
|
@ -0,0 +1,13 @@
|
||||
package com.jdc.jdcproject.service;
|
||||
|
||||
import com.jdc.jdcproject.entity.Equipment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 95262
|
||||
* @description 针对表【equipment(设备表;)】的数据库操作Service
|
||||
* @createDate 2025-05-06 16:02:19
|
||||
*/
|
||||
public interface EquipmentService extends IService<Equipment> {
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.jdc.jdcproject.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jdc.jdcproject.entity.Equipment;
|
||||
import com.jdc.jdcproject.service.EquipmentService;
|
||||
import com.jdc.jdcproject.mapper.EquipmentMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 95262
|
||||
* @description 针对表【equipment(设备表;)】的数据库操作Service实现
|
||||
* @createDate 2025-05-06 16:02:19
|
||||
*/
|
||||
@Service
|
||||
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment>
|
||||
implements EquipmentService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user