Commit 59d0ab4f authored by wwccw0591's avatar wwccw0591

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into ccw

parents 3ba40e3f eb91a3bf
......@@ -70,13 +70,17 @@ class CommonController extends \Our\Controller_AbstractIndex{
}
public function logAction(){
$logContent = trim($this->req[\Our\NameConst::data]['content']);
if(!$logContent){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyLog);
}
$log = \Our\Log::getInstance();
// $log->write(print_r($data, true));
$log->write($logContent,\Our\NameConst::frontLogPath);
$logContent = $this->req[\Our\NameConst::data]['content'];
$commonServiceModel = \Business\Common\CommonServiceModel::getInstance();
$commonServiceModel->log($logContent);
$this->success(new stdClass(),\Our\DescribeConst::logWriteSuccess,\Our\DescribeConst::logWriteSuccess);
}
public function readLogAction(){
$where = $this->req[\Our\NameConst::data];
$commonServiceModel = \Business\Common\CommonServiceModel::getInstance();
$logList = $commonServiceModel->readLog($where);
$this->success($logList);
}
}
\ No newline at end of file
......@@ -79,6 +79,8 @@ class ImageConst{
//店铺广告位路径
const advSrcImagePath = 'mall/adv_src/';
const frontLogPath = 'mall/log/';
//可上传图片类型
const uploadTypes = array(
0=>self::defaultPath,
......
......@@ -103,7 +103,6 @@ class ImageUtil {
$ossUploadFilePath = $path.$uploadImageName;
//return $ossUploadFilePath;
$return = $ossClient->uploadFile($bucketName, $ossUploadFilePath, $filePath);
\Our\Log::getInstance()->write(json_encode($return,true));
return $return['oss-request-url'];
}
......
......@@ -159,7 +159,9 @@ class NameConst {
const cancelUnPayedOrderTimePrefix = 'cancelUnPayedOrderTime';
const cancelUnReceivedOrderTimePrefix = 'cancelUnReceivedOrderTime';
const frontLogPath = '/data/log/front';
const frontLogPath = '/data/log/';
const frontPrefix = 'front';
}
?>
\ No newline at end of file
......@@ -110,6 +110,45 @@ class CommonServiceModel extends \Business\AbstractModel
return $share;
}
public function log($content){
$logContent = $content;
if(!$logContent){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyLog);
}
$log['content']= $logContent;
$frontLogDao = \DAO\FrontLogModel::getInstance(\Our\DbNameConst::masterDBConnectName);
$result = $frontLogDao->insert($log);
if(!$result){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::writeLogFailed);
}
return true;
}
public function readLog($where){
$logList = array();
$condition = array();
if(empty($where['startTime'])&&empty($where['endTime'])){
$condition['gmt_create'] = array('egt',TIMESTAMP-\Our\ApiConst::oneDaySecond);
$condition['gmt_create'] = array('lt',TIMESTAMP);
}else{
if((isset($where['startTime'])&&$where['startTime'])&&(isset($where['endTime'])&&$where['endTime'])){
if($where['startTime']>$where['endTime']){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::wrongTimeForReadLog);
}
$condition['gmt_create'] = array('between',$where['startTime'],$where['endTime']);
}else if(isset($where['startTime'])&&$where['startTime']){
$condition['gmt_create'] = array('egt',$where['startTime']);
}else if(isset($where['endTime'])&&$where['endTime']){
$condition['gmt_create'] = array('lt',$where['endTime']);
}
}
$frontLogDao = \DAO\FrontLogModel::getInstance();
$logList = $frontLogDao->getList($condition);
return $logList;
}
private static $_instance = null;
/**
......
<?php
namespace DAO;
/**
* User: liuyuzhen
* Date: 2018/8/29
* Time: 15:01
* Description:
*/
class FrontLogModel extends \DAO\AbstractModel {
private $logField = 'content as logContent , gmt_create as logTime';
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_front_log';
/**
* 主键
*
* @var string
*/
protected $_primaryKey = 'id';
public function init(){
}
public function insert($param){
$param['gmt_create'] =TIMESTAMP;
$this->setDb(\Our\DbNameConst::masterDBConnectName);
return $this->db->insert($this->_tableName)->rows($param)->execute();
}
public function getList($where){
$this->setDb($this->dbName);
if(is_array($where)){
$where=$this->db->getSqlWhereByArray($where);
}
$result = $this->db->select($this->logField)->from($this->_tableName)->where($where)->fetchAll();
return $result;
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private static $_instance = null;
/**
* 获取类实例
*
* @return \DAO\UserModel
*/
public static function getInstance($dbName=\Our\DbNameConst::salveDBConnectName) {
if (!(self::$_instance instanceof self)) {
self::$_instance = new self($dbName);
}
return self::$_instance;
}
}
......@@ -91,6 +91,9 @@ class CodeConfigModel {
const currentMobileHasBeenBind = 10078;
const otherDriverLogin=10105;
const emptyLog = 10106;
const writeLogFailed = 10107;
const wrongTimeForReadLog = 10108;
//访问错误
const illegalAccess=200001;
......@@ -747,7 +750,9 @@ class CodeConfigModel {
self::currentMobileHasBeenBind => '当前手机号码已经绑定其他微信,如需绑定,请先手机号码登录app进行微信解绑',
self::otherDriverLogin=>'当前用户已被其他设备登录,请重新登录',
self::elasticsError=>'全文索引连接出错',
self::emptyLog => '日志内容不能为空'
self::emptyLog => '日志内容不能为空',
self::writeLogFailed => '日志写入失败',
self::wrongTimeForReadLog => '读日志时写入时间段查询开始时间不能大于结束时间'
);
}
......
......@@ -858,7 +858,11 @@ class LinkMySQLModel{
$where .= $this->getJointWhereByTwoArray($key, $value);
}
if (count($value) == 3) {
$where .= $this->getJointWhereBySecondArray($key, $value);
if($value[0]=='between'){
$where .= $this->getJointWhereByTwoArray($key, $value);
}else{
$where .= $this->getJointWhereBySecondArray($key, $value);
}
}
......@@ -926,9 +930,14 @@ class LinkMySQLModel{
public function getJointWhereByTwoArray($key, $array)
{
if (empty($array) || !$key || count($array) != 2 || $array[1] === '' || $array[1] === null) {
return false;
if(count($array)==3){
if(!($array[0]=='between'&&!(empty($array[1])&&empty($array[2]))&&$key)){
return false;
}
}else{
if (empty($array) || !$key ||( count($array) != 2)|| $array[1] === '' || $array[1] === null) {
return false;
}
}
$return = '';
$strArray = explode('|', $key);
......@@ -967,6 +976,9 @@ class LinkMySQLModel{
$return .= " {$value} not in('" . implode("','", $array[1]) . "')";
break;
case 'between':
$return .= " {$value} between '$array[1]' and '$array[2]' ";
break;
}
if ($k < $count - 1) $return .= " or ";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment