Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李洋
/
消息系统
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d624e727
authored
Dec 07, 2017
by
李洋
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加修改数据库api
parent
42bcfda6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
17 deletions
app/Http/Controllers/MessageApiController.php
app/Http/routes.php
public/js/Message/AddTemplate.js
app/Http/Controllers/MessageApiController.php
0 → 100644
View file @
d624e727
<?php
/**
* Created by PhpStorm.
* User: leo
* Date: 2017/12/7
* Time: 13:04
*/
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\Http\Requests
;
use
DB
;
use
RedisDB
;
class
MessageApiController
extends
Controller
{
public
function
Entrance
(
Request
$request
,
$id
){
//统一入口
$this
->
$id
(
$request
,
$id
);
}
private
function
Export
(
$errcode
=
0
,
$errmsg
=
'成功'
,
$data
=
''
){
echo
json_encode
([
'errcode'
=>
$errcode
,
'errmsg'
=>
$errmsg
,
'data'
=>
$data
]);
exit
();
}
//新增/编辑 消息模板
private
function
addTemplate
(
$request
)
{
$data
=
$request
->
input
();
//至少选择一个渠道
if
(
empty
(
$data
[
'channels'
]))
{
$this
->
Export
(
11001
,
'请选择渠道'
);
}
else
{
//选了站内信渠道 就要选站内信类型
if
(
strpos
(
$data
[
'channels'
],
'1'
))
{
if
(
empty
(
$data
[
'msg_type'
]))
{
$this
->
Export
(
11001
,
'请选择选择站内信类型'
);
}
}
}
$input_model
=
[];
$input_model
[
'brand_id'
]
=
$data
[
'brand_id'
];
$input_model
[
'brand_name'
]
=
$data
[
'brand_name'
];
$input_model
[
'brand_logo'
]
=
$data
[
'brand_logo'
];
$input_model
[
'brand_desc'
]
=
$data
[
'brand_desc'
];
$input_model
[
'status'
]
=
$data
[
'status'
];
$input_model
[
'main_product'
]
=
$data
[
'main_product'
];
$input_model
[
'brand_brief'
]
=
$data
[
'brand_brief'
];
if
(
isset
(
$data
[
'brand_area'
]))
{
$input_model
[
'brand_area'
]
=
$data
[
'brand_area'
];
}
$db
=
DB
::
connection
(
'spu'
)
->
table
(
'lie_brand'
);
if
(
!
empty
(
$input_model
[
'brand_id'
])){
$resurt
=
$db
->
where
(
'brand_id'
,
$input_model
[
'brand_id'
])
->
update
(
$input_model
);
if
(
!
$resurt
)
{
$this
->
Export
(
11011
,
'修改制造商失败'
,
'sql'
);
}
}
else
{
$find
=
DB
::
connection
(
'spu'
)
->
table
(
'lie_brand'
)
->
where
(
'brand_name'
,
$input_model
[
'brand_name'
])
->
first
();
if
(
$find
){
$this
->
Export
(
11012
,
'当前品牌名字已经存在'
,
'brand_name'
);
}
$input_model
[
'create_time'
]
=
time
();
$resurt
=
$db
->
insert
(
$input_model
);
if
(
!
$resurt
)
{
$this
->
Export
(
11013
,
'新增制造商失败'
,
'sql'
);
}
}
$this
->
Export
(
0
,
empty
(
$input_model
[
'brand_id'
])
?
'新增成功'
:
'修改成功'
);
}
//编辑手动消息
//发送手动消息
private
function
sendManualMessage
(
$request
)
{
}
}
\ No newline at end of file
app/Http/routes.php
View file @
d624e727
...
...
@@ -52,7 +52,7 @@ Route::group(['middleware' => 'web'], function () {
Route
::
post
(
'/api/user/register'
,
'LoginController@register'
);
//Message
Route
::
match
([
'get'
,
'post'
],
'/
fs
api/{key}'
,
'MessageApiController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/
msg
api/{key}'
,
'MessageApiController@Entrance'
);
// 页面
Route
::
get
(
'/page/{id?}'
,
'TablePageController@page'
);
...
...
public/js/Message/AddTemplate.js
View file @
d624e727
...
...
@@ -94,22 +94,20 @@ function addTemplate()
url
:
'/msgapi/addTemplate'
,
timeout
:
10000
,
//超时时间设置,单位毫秒
data
:
{
spu_id
:
$
(
'#spu_id'
).
val
(),
class_id1
:
$
(
'#class_id1'
).
val
(),
class_id2
:
$
(
'#class_id2'
).
val
(),
class_id3
:
$
(
'#class_id3'
).
val
(),
brand_id
:
$
(
'#brand_id'
).
val
(),
spu_name
:
$
(
'#spu_name'
).
val
(),
status
:
$
(
"input[name='status']:checked"
).
val
(),
images_l
:
$
(
'#images_l'
).
val
(),
images_s
:
$
(
'#images_s'
).
val
(),
encap
:
$
(
'#encap'
).
val
(),
pdf
:
$
(
'#pdf'
).
val
(),
spu_brief
:
$
(
'#spu_brief'
).
val
(),
has_rohs
:
$
(
"input[name='has_rohs']:checked"
).
val
(),
attrs
:
$
(
'#spu_attrs'
).
val
(),
spu_detail
:
ue
.
getContent
(),
bussiness_area
:
checkBoxes
,
tpl_id
:
$
(
'#spu_id'
).
val
(),
channels
:
$
(
'#class_id1'
).
val
(),
msg_type
:
$
(
'#class_id2'
).
val
(),
source_type
:
$
(
'#class_id3'
).
val
(),
creater
:
$
(
'#brand_id'
).
val
(),
obj_user
:
$
(
'#spu_name'
).
val
(),
description
:
$
(
"input[name='status']:checked"
).
val
(),
channel_tpl_id
:
$
(
'#images_l'
).
val
(),
channel_type
:
$
(
'#images_s'
).
val
(),
title
:
$
(
'#encap'
).
val
(),
content
:
$
(
'#pdf'
).
val
(),
op_type
:
$
(
'#spu_brief'
).
val
(),
url
:
$
(
"input[name='has_rohs']:checked"
).
val
(),
},
dataType
:
'json'
,
success
:
function
(
resp
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment