Uninote
Uninote
用户根目录
每日点滴

<!DOCTYPE html> <html><head><meta http-equiv='Content-Type' content='text/html; charset=utf8'><title>mynote todo 3.4</title> <script> var g_resRoot = '../../__res/'; var g_json_outline = '{"children":[{"children":[],"level":1,"lvNumber":"1","text":"php编码规范"},{"children":[],"level":1,"lvNumber":"2","text":"标签"},{"children":[],"level":1,"lvNumber":"3","text":"首页作者推荐"},{"children":[],"level":1,"lvNumber":"4","text":"重构"},{"children":[],"level":1,"lvNumber":"5","text":"优化"},{"children":[],"level":1,"lvNumber":"6","text":"做一次全量review"},{"children":[],"level":1,"lvNumber":"7","text":"遗留问题"}],"level":0,"lvNumber":"","text":"mynote todo 3.4"}'; </script> <link rel='stylesheet' type='text/css' href='../../__res/common.css'><style>.s0{color:#000000;} .s1{color:#000000;} .s2{color:#000000;} .s3{color:#660000;} .s4{color:#000000;} .s5{color:#660e7a;} .s6{color:#000080;} .s7{color:#008000;} .s8{color:#c80000;} .s9{color:#000000;} .s10{color:#808080;} .s11{color:#000080;} .s12{color:#000000;} .s13{color:#660e7a;} .s14{color:#660000;} .s15{color:#008000;} </style> </head><body> <script src='../../__res/util.js'></script><div id='outline'> <li><a href='#ol_0' style='font-weight:bold; font-size:22px'>mynote todo 3.4</a></li> <li> <a href='#ol_1' >php编码规范</a></li> <li> <a href='#ol_2' >标签</a></li> <li> <a href='#ol_3' >首页作者推荐</a></li> <li> <a href='#ol_4' >重构</a></li> <li> <a href='#ol_5' >优化</a></li> <li> <a href='#ol_6' >做一次全量review</a></li> <li> <a href='#ol_7' >遗留问题</a></li> </div>

<pre id='ol_0' class='title'>mynote todo 3.4</pre> <pre><d class='s0'></d></pre> <h1 id='ol_1'>php编码规范</h1> <pre><d class='s1'>php规范整理,难懂的给个demo,最必要的注释</d></pre> <pre><d class='s1'>php 批量格式化 phplint</d></pre> <pre><d class='s2'></d></pre> <pre><d class='s3'>$arr </d><d class='s4'>= \Yii::</d><d class='s5'>$app</d><d class='s4'>-></d><d class='s6'>db</d><d class='s4'>->createCommand(</d><d class='s3'>$sql</d><d class='s4'>)</d></pre> <pre><d class='s4'> ->bindValue(</d><d class='s7'>':rs'</d><d class='s4'>, trim(</d><d class='s3'>$id</d><d class='s4'>))</d></pre> <pre><d class='s4'> ->queryOne();</d></pre> <pre><d class='s1'>不要这样:</d></pre> <pre><d class='s3'>$arr </d><d class='s4'>= \Yii::</d><d class='s5'>$app</d><d class='s4'>-></d><d class='s6'>db</d><d class='s4'>->createCommand(</d><d class='s3'>$sql</d><d class='s4'>)-></d></pre> <pre><d class='s4'>bindValue(</d><d class='s7'>':rs'</d><d class='s4'>,trim(</d><d class='s3'>$id</d><d class='s4'>))-></d></pre> <pre><d class='s4'>queryOne();</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>合并</d></pre> <pre><d class='s6'>if </d><d class='s4'>(</d><d class='s3'>$aid</d><d class='s4'>) {</d></pre> <pre><d class='s4'> </d><d class='s3'>$artshow_arr </d><d class='s4'>= </d><d class='s3'>$article_logic</d><d class='s4'>->getArticleContent(</d><d class='s3'>$aid</d><d class='s4'>);</d></pre> <pre><d class='s4'>}</d></pre> <pre><d class='s4'></d></pre> <pre><d class='s6'>if </d><d class='s4'>(</d><d class='s3'>$aid</d><d class='s4'>) {</d></pre> <pre><d class='s4'> !</d><d class='s6'>empty</d><d class='s4'>(</d><d class='s3'>$_SERVER</d><d class='s4'>[</d><d class='s7'>'HTTP_REFERER'</d><d class='s4'>]) ?</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>提取公共代码,不能copy代码,实在必须,加上uTODO: *</d></pre> <pre><d class='s1'> public function actionCataitem()</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>命名</d></pre> <pre><d class='s1'>if ($this->is_login_bool) {</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s2'>引用的第三方代码,必须要注明出处</d></pre> <pre><d class='s2'>private $myde_total; </d></pre> <pre><d class='s2'></d></pre> <pre><d class='s2'>wrap_err_msg 简单的,而且只有一处调用,就不要再封装函数了</d></pre> <pre><d class='s2'></d></pre> <h1 id='ol_2'>标签</h1> <pre><d class='s8'>标签:系统定义、用户自定义</d></pre> <pre><d class='s8'>用户可以新增,用户输入时记录</d></pre> <pre><d class='s8'>提示标签时,同时使用 系统 和 用户 的标签</d></pre> <pre><d class='s8'>大小写无关</d><d class='s1'></d></pre> <pre><d class='s1'></d></pre> <h1 id='ol_3'>首页作者推荐</h1> <pre><d class='s8'>换一换,可以循环</d><d class='s1'></d></pre> <pre><d class='s1'></d></pre> <h1 id='ol_4'>重构</h1> <pre><d class='s8'>确认重构前版本 测试稳定后 开始重构</d><d class='s1'></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>确认session仅后端保存?</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>username问题,移除此字段</d></pre> <pre><d class='s1'>影响:</d></pre> <pre><d class='s1'>docs目录</d></pre> <pre><d class='s1'>gogs用户名</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>分类 errocode数字</d></pre> <pre><d class='s1'><a href='https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&token=&lang=zh_CN'>https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&token=&lang=zh_CN</a></d></pre> <pre><d class='s1'><a href='https://dev.yunxin.163.com/docs/product/IM即时通讯/服务端API文档/消息功能'>https://dev.yunxin.163.com/docs/product/IM即时通讯/服务端API文档/消息功能</a></d></pre> <pre><d class='s1'>obsolete:status字段逐渐移除</d></pre> <pre><d class='s1'></d></pre> <h1 id='ol_5'>优化</h1> <pre><d class='s4'>ProxyController</d><d class='s9'> 限制只能调用logic</d><d class='s4'></d></pre> <pre><d class='s0'></d></pre> <h1 id='ol_6'>做一次全量review</h1> <pre><d class='s0'></d></pre> <h1 id='ol_7'>遗留问题</h1> <pre><d class='s1'></d></pre> <pre><d class='s1'>抽取logic</d></pre> <pre><d class='s1'> /</d></pre> <pre><d class='s1'> * 文章统计汇总接口</d></pre> <pre><d class='s1'> * @return array</d></pre> <pre><d class='s1'> */</d></pre> <pre><d class='s1'> public function actionCount()</d></pre> <pre><d class='s1'> {</d></pre> <pre><d class='s1'> if (!empty($_POST)) {</d></pre> <pre><d class='s1'> $data = $this->article_model->count();</d></pre> <pre><d class='s1'> return $this->make_result($data,$this->article_model->errno);</d></pre> <pre><d class='s1'> }</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'> return ResponseTools::return_error(ResponseCode::INCORRECT_PARAMETER);</d></pre> <pre><d class='s1'> }</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s10'>//获取图形验证码</d></pre> <pre><d class='s11'>public function </d><d class='s12'>actionGetvcode()</d></pre> <pre><d class='s12'>{</d></pre> <pre><d class='s12'> </d><d class='s11'>if </d><d class='s12'>(</d><d class='s11'>isset</d><d class='s12'>(\Yii::</d><d class='s13'>$app</d><d class='s12'>-></d><d class='s13'>api</d><d class='s12'>-></d><d class='s13'>api_proxy_url</d><d class='s12'>)) {</d></pre> <pre><d class='s12'> </d><d class='s14'>$curl_model</d><d class='s12'>= </d><d class='s11'>new </d><d class='s12'>Curl();</d></pre> <pre><d class='s12'> </d><d class='s14'>$curl_model</d><d class='s12'>->http_get(\Yii::</d><d class='s13'>$app</d><d class='s12'>-></d><d class='s13'>api</d><d class='s12'>-></d><d class='s13'>api_proxy_url </d><d class='s12'>. </d><d class='s15'>"/vcode/tmp"</d><d class='s12'>);</d></pre> <pre><d class='s12'> </d><d class='s14'>$result </d><d class='s12'>= </d><d class='s14'>$curl_model</d><d class='s12'>-></d><d class='s13'>tmp_info</d><d class='s12'>;</d></pre> <pre><d class='s12'> } </d><d class='s11'>else </d><d class='s12'>{</d></pre> <pre><d class='s12'> </d><d class='s14'>$result </d><d class='s12'>= \Yii::</d><d class='s13'>$app</d><d class='s12'>->runAction(</d><d class='s15'>'/api/vcode/tmp'</d><d class='s12'>, []);</d></pre> <pre><d class='s12'> }</d></pre> <pre><d class='s12'> header(</d><d class='s15'>"Content-type: image/png"</d><d class='s12'>);</d></pre> <pre><d class='s12'> </d><d class='s11'>echo </d><d class='s14'>$result</d><d class='s12'>;</d></pre> <pre><d class='s12'>}</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>logic跳转:??</d></pre> <pre><d class='s6'>public function </d><d class='s4'>getag (</d><d class='s3'>$aid</d><d class='s4'>)</d></pre> <pre><d class='s6'>public function </d><d class='s4'>getags ()</d></pre> <pre><d class='s6'>public function </d><d class='s4'>addtag (</d><d class='s3'>$aid</d><d class='s4'>, </d><d class='s3'>$tags</d><d class='s4'>)</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'> if ($arr) {</d></pre> <pre><d class='s1'> /零时拼接字段/</d></pre> <pre><d class='s1'> $arr = $this->_make_art_url($arr);</d></pre> <pre><d class='s1'> $data['status'] = TRUE;</d></pre> <pre><d class='s1'> $data['data'] = $arr;</d></pre> <pre><d class='s1'> } else {</d></pre> <pre><d class='s1'> $this->errno = ResponseCode::NOT_FIND_ACCOUNT;</d></pre> <pre><d class='s1'> $data['status'] = TRUE;</d></pre> <pre><d class='s1'> $data['data'] = [];</d></pre> <pre><d class='s1'> }</d></pre> </body></html>

mynote_todo

mynote_todo0311

点赞(0) 阅读(54) 举报
目录
标题