statistic.js 810 B

1
  1. "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const egg_1=require("egg");class StatisticService extends egg_1.Service{async add(h,l){const{mysql:a}=this.app,b=["station_id","excellent","good","ordinary","bad","abandoned","sum","score","month","update_day"],c=Array(b.length).fill("?").join(", "),d=Array(h.length).fill(`(${c})`).join(", "),e=`INSERT INTO statistic (${b.join(", ")}) VALUES `+d;a.query(e,h.reduce((b,{stationId:a,excellent:c,good:d,ordinary:e,bad:f,abandoned:g,sumTrade:h,score:i,updateTime:j})=>b.concat(a,c,d,e,f,g,h,i,l,j),[]))}async selectRange(e,a){const{mysql:b}=this.app,c=await b.query("SELECT station_id AS stationId, excellent, good, ordinary, bad, abandoned, sum FROM statistic WHERE month >= ? AND month <= ?",[e,a]);return c}}exports.default=StatisticService;