caipin před 5 roky
rodič
revize
7ed8905de4
3 změnil soubory, kde provedl 16 přidání a 14 odebrání
  1. 2 5
      app/models/client.js
  2. 14 4
      app/models/operate_log.js
  3. 0 5
      app/models/staff.js

+ 2 - 5
app/models/client.js

@@ -111,16 +111,13 @@ client.findById=async function(cid,attributes){
     sequelize.query(sqlQuery,
     		  { replacements: [cid], type: sequelize.QueryTypes.SELECT }
     		).then(function(projects) {
-    		  console.log(projects[0])
+    			staffDetail=projects[0];
     		})
-    
 
-    
 //    await this.sequelize.query('SELECT b.* FROM CLD_client_staff as a left join CLD_staff as b on (a.sid=b.sid) where a.cid=7').spread((results, metadata) => {
 //        staffDetail=results[0];
 //    });
-    
-    
+
     detail['staff']=staffDetail;
 
     detail.cidKey=hash.hashEncode(detail.cid.toString());

+ 14 - 4
app/models/operate_log.js

@@ -46,11 +46,21 @@ module.exports = (sequelize, DataTypes) => {
         //var idList = await this.findAll(condition);//获得idList
         //var yearList= await this.findAll(condition);//获得yearList
         //console.log(logType+'d'+dataId);
+        
         var list=[];
-        await this.sequelize.query('select  CONVERT(GROUP_CONCAT(id) USING utf8)   as id,date_format(createDate,"%Y") as year FROM operate_log where ' +
-            'logType='+logType+' and dataId='+dataId+' GROUP BY Year(createDate) ').spread((results, metadata) => {
-            list=results;
-        });
+        var sqlQuery = 'select  CONVERT(GROUP_CONCAT(id) USING utf8)   as id,date_format(createDate,"%Y") as year FROM operate_log where ' +
+        'logType=? and dataId=? GROUP BY Year(createDate) ';
+        sequelize.query(sqlQuery,
+        		  { replacements: [logType,dataId], type: sequelize.QueryTypes.SELECT }
+        		).then(function(projects) {
+        			list=projects;
+        		})
+        
+//        var list=[];
+//        await this.sequelize.query('select  CONVERT(GROUP_CONCAT(id) USING utf8)   as id,date_format(createDate,"%Y") as year FROM operate_log where ' +
+//            'logType='+logType+' and dataId='+dataId+' GROUP BY Year(createDate) ').spread((results, metadata) => {
+//            list=results;
+//        });
 
         var sqlArray=[];
         list.forEach(function(v,i){

+ 0 - 5
app/models/staff.js

@@ -129,11 +129,6 @@ module.exports = (sequelize, DataTypes) => {
 
         detail.sid=hash.hashEncode(detail.sid.toString());
 
-        /*list.forEach(function(v,i){
-            list[i].sid=hash.hashEncode(v.sid.toString());
-            //console.log(clientList[i].dataValues.cidKey);
-            //console.log(hash.hashDecode(clientList[i].dataValues.cidKey.toString()));
-        });*/
         return detail;
     };