chore: 将服务器接入悟空系统的nacos服务管理
This commit is contained in:
1 parent
1c274b93c3
commit
9413a78cc1
3 files changed
+64
-1
No files matched your search
@@ -101,6 +101,13 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<version>4.9.2</version> <!-- 请使用适当的版本号 -->
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -19,6 +19,29 @@ public class OrderController {
|
||||
@PostMapping
|
||||
public Response addOrder(@RequestBody Order order) {
|
||||
int result = orderService.addOrder(order);
|
||||
|
||||
if (result > 0) {
|
||||
return new Response("ok", true, null);
|
||||
} else {
|
||||
return new Response("error", false, null);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Response updateOrder(@RequestBody Order order) {
|
||||
int result = orderService.updateOrder(order);
|
||||
|
||||
if (result > 0) {
|
||||
return new Response("ok", true, null);
|
||||
} else {
|
||||
return new Response("error", false, null);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/no/{orderNo}")
|
||||
public Response deleteOrderByNo(@PathVariable String orderNo) {
|
||||
int result = orderService.deleteByNo(orderNo);
|
||||
|
||||
if (result > 0) {
|
||||
return new Response("ok", true, null);
|
||||
} else {
|
||||
@@ -37,7 +60,12 @@ public class OrderController {
|
||||
@GetMapping("/{id}")
|
||||
public Response getOrderById(@PathVariable int id) {
|
||||
Order order = orderService.getOrderById(id);
|
||||
return Response.success(order);
|
||||
}
|
||||
|
||||
@GetMapping("/no/{orderNo}")
|
||||
public Response getOrderByNo(@PathVariable String orderNo) {
|
||||
Order order = orderService.getOrderByNo(orderNo);
|
||||
return Response.success(order);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.binary.weight.service;
|
||||
import com.binary.weight.entity.Order;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,17 +21,44 @@ public class OrderService {
|
||||
}
|
||||
|
||||
public int addOrder(Order order) {
|
||||
String sql = "INSERT INTO tbl_order (orderno, receiver, salesty, goods1, tonnage1, goods2, tonnage2, goods3, tonnage3, goods4, tonnage4, shipno, transportinfo, wharf, car_team1, cars1, car_team2, cars2, car_team3, cars3, car_team4, cars4, order_time, remark) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
String sql = "INSERT INTO tbl_order (orderno, receiver, salesty, goods1, tonnage1, goods2, tonnage2, goods3, tonnage3, goods4, tonnage4, shipno, transportinfo, wharf, car_team1, cars1, car_team2, cars2, car_team3, cars3, car_team4, cars4, order_time, remark) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
return jdbcTemplate.update(sql, order.getOrderNo(), order.getReceiver(), order.getSalesTy(), order.getGoods1(), order.getTonnage1(), order.getGoods2(), order.getTonnage2(), order.getGoods3(), order.getTonnage3(), order.getGoods4(), order.getTonnage4(), order.getShipNo(), order.getTransportInfo(), order.getWharf(), order.getCarTeam1(), order.getCars1(), order.getCarTeam2(), order.getCars2(), order.getCarTeam3(), order.getCars3(), order.getCarTeam4(), order.getCars4(), order.getOrderTime(), order.getRemark());
|
||||
}
|
||||
|
||||
public int updateOrder(Order order) {
|
||||
String sql = "UPDATE tbl_order set orderno = ?, receiver = ?, salesty = ?, goods1 = ?, tonnage1 = ?, goods2 = ?, tonnage2 = ?, goods3 = ?, tonnage3 = ?, goods4 = ?, tonnage4 = ?, shipno = ?, transportinfo = ?, wharf = ?, car_team1 = ?, cars1 = ?, car_team2 = ?, cars2 = ?, car_team3 = ?, cars3 = ?, car_team4 = ?, cars4 = ?, order_time = ?, remark = ? where id = ?";
|
||||
return jdbcTemplate.update(sql, order.getOrderNo(), order.getReceiver(), order.getSalesTy(), order.getGoods1(), order.getTonnage1(), order.getGoods2(), order.getTonnage2(), order.getGoods3(), order.getTonnage3(), order.getGoods4(), order.getTonnage4(), order.getShipNo(), order.getTransportInfo(), order.getWharf(), order.getCarTeam1(), order.getCars1(), order.getCarTeam2(), order.getCars2(), order.getCarTeam3(), order.getCars3(), order.getCarTeam4(), order.getCars4(), order.getOrderTime(), order.getRemark(), order.getId());
|
||||
}
|
||||
|
||||
public int deleteByNo(String orderNo) {
|
||||
String sql = "delete from tbl_order where orderno = ?";
|
||||
return jdbcTemplate.update(sql, orderNo);
|
||||
}
|
||||
|
||||
public List<Order> getOrders() {
|
||||
try {
|
||||
String sql = "SELECT * FROM tbl_order";
|
||||
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Order.class));
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Order getOrderById(int id) {
|
||||
try {
|
||||
String sql = "SELECT * FROM tbl_order WHERE id = ?";
|
||||
return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(Order.class), id);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Order getOrderByNo(String orderNo) {
|
||||
try {
|
||||
String sql = "SELECT * FROM tbl_order WHERE orderno = ?";
|
||||
return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(Order.class), orderNo);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user