Browse Source

更改die表

master
maochaoying 2 years ago
parent
commit
edc4127479
  1. 22
      src/controller/die.controller.js
  2. 11
      src/model/die.model.js
  3. 16
      src/router/die.route.js
  4. 9
      src/service/die.service.js

22
src/controller/die.controller.js

@ -0,0 +1,22 @@
const {
addDieLog,
getDieInfoById,
getAllDieInfo,
} = require("../service/die.service");
const Response = require("../utils/response");
class DieController {
async add(ctx, next) {
const { house_id, coop_id, reason_id, die_number, put_time } =
ctx.request.body;
ctx.body = Response(0, "新增死淘记录成功", null);
}
async info(ctx, next) {
ctx.body = Response(0, "查询单条死淘记录成功", null);
}
async all(ctx, next) {
ctx.body = Response(0, "查询死淘记录成功", null);
}
}
module.exports = new DieController();

11
src/model/die.model.js

@ -4,6 +4,11 @@ const seq = require("../db/seq");
const Die = seq.define("chicken_die", { const Die = seq.define("chicken_die", {
// id 会被sequelize自动创建, 管理 // id 会被sequelize自动创建, 管理
house_id: {
type: DataTypes.INTEGER,
allowNull: false,
comment: "鸡场id",
},
coop_id: { coop_id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
allowNull: false, allowNull: false,
@ -19,6 +24,12 @@ const Die = seq.define("chicken_die", {
allowNull: false, allowNull: false,
comment: "死淘数量", comment: "死淘数量",
}, },
put_time: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
comment: "录入时间",
},
}); });
// 强制同步数据库(创建数据表) // 强制同步数据库(创建数据表)

16
src/router/die.route.js

@ -0,0 +1,16 @@
const Router = require("koa-router");
const router = new Router({ prefix: "/die" });
const { auth, hasAdminPermission } = require("../middleware/auth.middleware");
const { add, info, all } = require("../controller/die.controller");
router.post("/add", auth, add);
// 根据id获取新进鸡苗记录详情。
router.get("/info", auth, info);
// 根据条件查询新进记录
router.post("/all", auth, all);
module.exports = router;

9
src/service/die.service.js

@ -0,0 +1,9 @@
const Die = require("../model/die.model");
const { Op } = require("sequelize");
class DieService {
async addDieLog() {}
async getDieInfoById() {}
async getAllDieInfo() {}
}
module.exports = new DieService();
Loading…
Cancel
Save