CREATE TABLE `orders_invoiced_record` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, `created_at` datetime(3) DEFAULT NULL, `updated_at` datetime(3) DEFAULT NULL, `order_id` bigint unsigned DEFAULT NULL COMMENT '订单ID', `before_invoiced` tinyint(1) DEFAULT '0' COMMENT '修改前开票状态:0未开票,1已开票', `after_invoiced` tinyint(1) DEFAULT '0' COMMENT '修改后开票状态:0未开票,1已开票', `operation` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作人', `approval_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '审批单号', `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '备注', PRIMARY KEY (`id`) USING BTREE, KEY `idx_order_id` (`order_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT '订单开票状态修改记录';根据表结构生成java的实体类,持久层,业务层,同时添加注释
时间: 2023-10-21 20:07:18 浏览: 131
好的,以下是根据该表结构生成的Java实体类、持久层和业务层的代码,以及注释。
1. Java实体类
```java
package com.example.demo.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
/**
* 订单开票状态修改记录实体类
*/
@Entity
@Table(name = "orders_invoiced_record")
@Data
public class OrdersInvoicedRecord {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "created_at")
@Temporal(TemporalType.TIMESTAMP)
private Date createdAt;
@Column(name = "updated_at")
@Temporal(TemporalType.TIMESTAMP)
private Date updatedAt;
@Column(name = "order_id")
private Long orderId;
@Column(name = "before_invoiced")
private Boolean beforeInvoiced;
@Column(name = "after_invoiced")
private Boolean afterInvoiced;
@Column(name = "operation", nullable = false, length = 50)
private String operation;
@Column(name = "approval_no", nullable = false, length = 50)
private String approvalNo;
@Column(name = "remark", nullable = false, length = 255)
private String remark;
}
```
2. 持久层
```java
package com.example.demo.repository;
import com.example.demo.entity.OrdersInvoicedRecord;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* 订单开票状态修改记录持久层
*/
public interface OrdersInvoicedRecordRepository extends JpaRepository<OrdersInvoicedRecord, Long> {
}
```
3. 业务层
```java
package com.example.demo.service;
import com.example.demo.entity.OrdersInvoicedRecord;
import com.example.demo.repository.OrdersInvoicedRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 订单开票状态修改记录业务层
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class OrdersInvoicedRecordService {
@Autowired
private OrdersInvoicedRecordRepository ordersInvoicedRecordRepository;
/**
* 创建订单开票状态修改记录
*
* @param ordersInvoicedRecord 订单开票状态修改记录
* @return 创建的订单开票状态修改记录
*/
public OrdersInvoicedRecord createOrdersInvoicedRecord(OrdersInvoicedRecord ordersInvoicedRecord) {
return ordersInvoicedRecordRepository.save(ordersInvoicedRecord);
}
}
```
注释已经添加在代码中了,如果您有其他问题或需要进一步的帮助,请随时提出。
阅读全文