正在显示
3 个修改的文件
包含
8 行增加
和
15 行删除
@@ -336,9 +336,9 @@ class Study extends Backend | @@ -336,9 +336,9 @@ class Study extends Backend | ||
336 | } | 336 | } |
337 | $result = $this->model->allowField(true)->save($params); | 337 | $result = $this->model->allowField(true)->save($params); |
338 | $id = $this->model->id; | 338 | $id = $this->model->id; |
339 | - $sno = $this->model->sno; | ||
340 | - $barpath = Resource::StudyBar($sno); | ||
341 | - $this->model->save(['barcode'=>$barpath,'unique'=>$sno],['id'=>$id]); | 339 | + $res = str_pad($id,8,"0",STR_PAD_LEFT); |
340 | + $barpath = Resource::StudyBar($res); | ||
341 | + $this->model->save(['barcode'=>$barpath,'unique'=>$res],['id'=>$id]); | ||
342 | Db::commit(); | 342 | Db::commit(); |
343 | } catch (ValidateException|PDOException|Exception $e) { | 343 | } catch (ValidateException|PDOException|Exception $e) { |
344 | Db::rollback(); | 344 | Db::rollback(); |
@@ -5,7 +5,7 @@ namespace app\api\controller; | @@ -5,7 +5,7 @@ namespace app\api\controller; | ||
5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
6 | use app\common\controller\Resource; | 6 | use app\common\controller\Resource; |
7 | use tinymeng\code\Generate; | 7 | use tinymeng\code\Generate; |
8 | - | 8 | +mb_internal_encoding("UTF-8"); |
9 | /** | 9 | /** |
10 | * 示例接口 | 10 | * 示例接口 |
11 | */ | 11 | */ |
@@ -69,16 +69,9 @@ class Demo extends Api | @@ -69,16 +69,9 @@ class Demo extends Api | ||
69 | */ | 69 | */ |
70 | public function test3() | 70 | public function test3() |
71 | { | 71 | { |
72 | - $id = '三年级三班'; | ||
73 | - $arr = substr($id,0,1); | ||
74 | - $map = array('一' => '1','二' => '2','三' => '3','四' => '4','五' => '5','六' => '6'); | ||
75 | - foreach ($map as $k => $v){ | ||
76 | - $k = $arr; | ||
77 | - return $k; | ||
78 | - } | ||
79 | 72 | ||
80 | -// $res = str_pad($id,8,"0",STR_PAD_LEFT); | ||
81 | -// dump($res); | 73 | + |
74 | + dump($res); | ||
82 | } | 75 | } |
83 | 76 | ||
84 | } | 77 | } |
@@ -6,9 +6,9 @@ use tinymeng\code\Generate; | @@ -6,9 +6,9 @@ use tinymeng\code\Generate; | ||
6 | 6 | ||
7 | class Resource | 7 | class Resource |
8 | { | 8 | { |
9 | - public static function StudyBar($sno){ | 9 | + public static function StudyBar($res){ |
10 | $generate = Generate::bar(); | 10 | $generate = Generate::bar(); |
11 | - $file_path = $generate->create($sno,true,true); | 11 | + $file_path = $generate->create($res,true,true); |
12 | $file_path = substr($file_path,strripos($file_path,"public")+6); | 12 | $file_path = substr($file_path,strripos($file_path,"public")+6); |
13 | return $file_path; | 13 | return $file_path; |
14 | } | 14 | } |
-
请 注册 或 登录 后发表评论