|
@@ -25,27 +25,38 @@ class Specvalue extends BaseController
|
|
|
$list = Db::name('spec_value')->where($where)->page($page,$size)->order("addtime desc")->select();
|
|
|
return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
|
|
|
}
|
|
|
- public function create(){
|
|
|
- $spec_id = isset($this->post['spec_id']) && $this->post['spec_id'] !=="" ? intval($this->post['spec_id']):"";
|
|
|
- if($spec_id==""){
|
|
|
- return error_show(1002,"参数spec_id不能为空");
|
|
|
+
|
|
|
+ public function create()
|
|
|
+ {
|
|
|
+ $spec_id = isset($this->post['spec_id']) && $this->post['spec_id'] !== "" ? intval($this->post['spec_id']) : "";
|
|
|
+ if ($spec_id == "") {
|
|
|
+ return error_show(1002, "参数spec_id不能为空");
|
|
|
}
|
|
|
- $spec_value = isset($this->post['spec_value']) && $this->post['spec_value'] !=="" ? trim($this->post['spec_value']):"";
|
|
|
- if($spec_value==""){
|
|
|
- return error_show(1002,"参数spec_value不能为空");
|
|
|
+ $spec_value = isset($this->post['spec_value']) && $this->post['spec_value'] !== "" ? trim($this->post['spec_value']) : "";
|
|
|
+ if ($spec_value == "") {
|
|
|
+ return error_show(1002, "参数spec_value不能为空");
|
|
|
}
|
|
|
- $data = [
|
|
|
- "spec_id"=>$spec_id,
|
|
|
- "spec_value"=>$spec_value,
|
|
|
- "is_del"=>0,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $info = Db::name("spec_value")->insert($data);
|
|
|
- if($info){
|
|
|
- return error_show(0,"新建成功");
|
|
|
- }else{
|
|
|
- return error_show(1002,"新建失败");
|
|
|
+
|
|
|
+ $id_is_empty = Db::name('spec_value')
|
|
|
+ ->field('id')
|
|
|
+ ->where([
|
|
|
+ 'spec_id' => $spec_id,
|
|
|
+ 'spec_value' => $spec_value,
|
|
|
+ 'is_del' => 0
|
|
|
+ ])->find();
|
|
|
+
|
|
|
+ if ($id_is_empty) return error_show(1005, '数据库已存在该规格值');
|
|
|
+ else {
|
|
|
+ $data = [
|
|
|
+ "spec_id" => $spec_id,
|
|
|
+ "spec_value" => $spec_value,
|
|
|
+ "is_del" => 0,
|
|
|
+ "addtime" => date("Y-m-d H:i:s"),
|
|
|
+ "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $info = Db::name("spec_value")->insert($data);
|
|
|
+ if ($info) return error_show(0, "新建成功");
|
|
|
+ else return error_show(1002, "新建失败");
|
|
|
}
|
|
|
}
|
|
|
public function all(){
|