增加文章发布功能
This commit is contained in:
@@ -19,38 +19,63 @@ class Yunzer extends Base{
|
||||
return View::fetch();
|
||||
}
|
||||
# 菜单添加
|
||||
public function menuadd(){
|
||||
public function menuadd()
|
||||
{
|
||||
$req = request();
|
||||
if($req->isPost()){
|
||||
if ($req->isPost()) {
|
||||
$data['label'] = trim(input('post.label'));
|
||||
if(empty($data['label'])){
|
||||
View::returnCode('90000009');
|
||||
if (empty($data['label'])) {
|
||||
$this->returnCode(1, '请输入菜单名称');
|
||||
}
|
||||
$data['icon_class'] = trim(input('post.icon_class'));
|
||||
$data['sort'] = (int)trim(input('post.sort'));
|
||||
$data['status'] = (int)trim(input('post.status'));
|
||||
$data['type'] = (int)trim(input('post.type',0));
|
||||
if($data['type'] == 1){
|
||||
$data['sort'] = (int) trim(input('post.sort'));
|
||||
$data['status'] = (int) trim(input('post.status'));
|
||||
$data['type'] = (int) trim(input('post.type', 0));
|
||||
if ($data['type'] == 1) {
|
||||
$data['src'] = trim(input('post.src1'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000012');
|
||||
if (empty($data['src'])) {
|
||||
$this->returnCode(1, '请输入内部跳转地址');
|
||||
}
|
||||
}else if($data['type'] == 2){
|
||||
} else if ($data['type'] == 2) {
|
||||
$data['src'] = trim(input('post.src2'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000013');
|
||||
if (empty($data['src'])) {
|
||||
$this->returnCode(1, '请输入超链接地址');
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$data['src'] = '';
|
||||
}
|
||||
// 保存用户
|
||||
// 保存菜单
|
||||
$res = Db::table('yz_admin_sys_menu')->insert($data);
|
||||
if(!$res){
|
||||
$this->returnCode('91000001');
|
||||
if (!$res) {
|
||||
$this->returnCode(1, '添加菜单失败');
|
||||
}
|
||||
|
||||
// 获取新插入的菜单ID
|
||||
$newMenuId = Db::table('yz_admin_sys_menu')->getLastInsID();
|
||||
|
||||
// 获取所有管理员用户组
|
||||
$adminGroups = Db::table('yz_admin_user_group')->select();
|
||||
foreach ($adminGroups as $group) {
|
||||
// 获取现有权限
|
||||
$rights = [];
|
||||
if (!empty($group['rights'])) {
|
||||
$rights = json_decode($group['rights'], true);
|
||||
}
|
||||
|
||||
// 添加新菜单ID到权限列表
|
||||
if (!in_array($newMenuId, $rights)) {
|
||||
$rights[] = $newMenuId;
|
||||
|
||||
// 更新用户组权限
|
||||
Db::table('yz_admin_user_group')
|
||||
->where('group_id', $group['group_id'])
|
||||
->update(['rights' => json_encode($rights)]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
$iconfont = Db::table('yz_z_iconfont')->where('status',1)->select();
|
||||
} else {
|
||||
$iconfont = Db::table('yz_z_iconfont')->where('status', 1)->select();
|
||||
View::assign([
|
||||
'iconfont' => $iconfont
|
||||
]);
|
||||
@@ -64,7 +89,7 @@ class Yunzer extends Base{
|
||||
$smid = (int)input('post.smid');
|
||||
$data['label'] = trim(input('post.label'));
|
||||
if(!$data['label']){
|
||||
$this->returnCode('90000009');
|
||||
$this->returnCode(1, '请输入菜单名称');
|
||||
}
|
||||
$data['icon_class'] = trim(input('post.icon_class'));
|
||||
$data['sort'] = (int)trim(input('post.sort'));
|
||||
@@ -73,12 +98,12 @@ class Yunzer extends Base{
|
||||
if($data['type'] == 1){
|
||||
$data['src'] = trim(input('post.src1'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000012');
|
||||
$this->returnCode(1, '请输入内部跳转地址');
|
||||
}
|
||||
}else if($data['type'] == 2){
|
||||
$data['src'] = trim(input('post.src2'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000013');
|
||||
$this->returnCode(1, '请输入超链接地址');
|
||||
}
|
||||
}else{
|
||||
$data['src'] = '';
|
||||
@@ -86,7 +111,7 @@ class Yunzer extends Base{
|
||||
// 保存用户
|
||||
$res = Db::table('yz_admin_sys_menu')->where('smid',$smid)->update($data);
|
||||
if(!$res){
|
||||
$this->returnCode('91000002');
|
||||
$this->returnCode(1, '修改菜单失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
@@ -105,11 +130,11 @@ class Yunzer extends Base{
|
||||
$smid = (int)input('post.smid');
|
||||
$count = Db::table('yz_admin_sys_menu')->where('parent_id',$smid)->count();
|
||||
if($count > 0){
|
||||
$this->returnCode('90000010');
|
||||
$this->returnCode(1, '该菜单下还有子菜单,不能删除');
|
||||
}
|
||||
$res = Db::table('yz_admin_sys_menu')->where('smid',$smid)->delete();
|
||||
if(empty($res)){
|
||||
$this->returnCode('91000003');
|
||||
$this->returnCode(1, '删除菜单失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}
|
||||
@@ -148,30 +173,30 @@ class Yunzer extends Base{
|
||||
$smid = (int)input('post.smid');
|
||||
$data['label'] = trim(input('post.label'));
|
||||
if(!$data['label']){
|
||||
$this->returnCode('90000015');
|
||||
$this->returnCode(1, '请输入按钮名称');
|
||||
}
|
||||
$data['icon_class'] = trim(input('post.icon_class'));
|
||||
$data['sort'] = (int)trim(input('post.sort'));
|
||||
$data['status'] = (int)trim(input('post.status'));
|
||||
$data['type'] = (int)trim(input('post.type'));
|
||||
if(empty($data['type'])){
|
||||
$this->returnCode('90000011');
|
||||
$this->returnCode(1, '请选择按钮类型');
|
||||
}
|
||||
if($data['type'] == 1){
|
||||
$data['src'] = trim(input('post.src1'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000012');
|
||||
$this->returnCode(1, '请输入内部跳转地址');
|
||||
}
|
||||
}else if($data['type'] == 2){
|
||||
$data['src'] = trim(input('post.src2'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000013');
|
||||
$this->returnCode(1, '请输入超链接地址');
|
||||
}
|
||||
}
|
||||
$data['parent_id'] = $smid;
|
||||
$res = Db::table('yz_admin_sys_menu')->insert($data);
|
||||
if(!$res){
|
||||
$this->returnCode('91000001');
|
||||
$this->returnCode(1, '添加按钮失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
@@ -191,29 +216,29 @@ class Yunzer extends Base{
|
||||
$smid = (int)input('post.smid');
|
||||
$data['label'] = trim(input('post.label'));
|
||||
if(!$data['label']){
|
||||
$this->returnCode('90000015');
|
||||
$this->returnCode(1, '请输入按钮名称');
|
||||
}
|
||||
$data['icon_class'] = trim(input('post.icon_class'));
|
||||
$data['sort'] = (int)trim(input('post.sort'));
|
||||
$data['status'] = (int)trim(input('post.status'));
|
||||
$data['type'] = (int)trim(input('post.type'));
|
||||
if(empty($data['type'])){
|
||||
$this->returnCode('90000011');
|
||||
$this->returnCode(1, '请选择按钮类型');
|
||||
}
|
||||
if($data['type'] == 1){
|
||||
$data['src'] = trim(input('post.src1'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000012');
|
||||
$this->returnCode(1, '请输入内部跳转地址');
|
||||
}
|
||||
}else if($data['type'] == 2){
|
||||
$data['src'] = trim(input('post.src2'));
|
||||
if(empty($data['src'])){
|
||||
$this->returnCode('90000013');
|
||||
$this->returnCode(1, '请输入超链接地址');
|
||||
}
|
||||
}
|
||||
$res = Db::table('yz_admin_sys_menu')->where('smid',$smid)->update($data);
|
||||
if(!$res){
|
||||
$this->returnCode('91000002');
|
||||
$this->returnCode(1, '修改按钮失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
@@ -232,7 +257,7 @@ class Yunzer extends Base{
|
||||
$smid = (int)input('post.smid');
|
||||
$res = Db::table('yz_admin_sys_menu')->where('smid',$smid)->delete();
|
||||
if(empty($res)){
|
||||
$this->returnCode('91000003');
|
||||
$this->returnCode(1, '删除按钮失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}
|
||||
@@ -267,7 +292,7 @@ class Yunzer extends Base{
|
||||
$data['config_sort'] = trim(input('post.config_sort'));
|
||||
$res = Db::table('yz_admin_config')->insert($data);
|
||||
if(empty($res)){
|
||||
$this->returnCode('91000001');
|
||||
$this->returnCode(1, '添加配置失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
@@ -296,7 +321,7 @@ class Yunzer extends Base{
|
||||
$data['config_sort'] = trim(input('post.config_sort'));
|
||||
$res = Db::table('yz_admin_config')->where('config_id',$config_id)->update($data);
|
||||
if(empty($res)){
|
||||
$this->returnCode('91000002');
|
||||
$this->returnCode(1, '修改配置失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
@@ -316,7 +341,7 @@ class Yunzer extends Base{
|
||||
}
|
||||
$res = Db::table('yz_admin_config')->where('config_id',$config_id)->delete();
|
||||
if(empty($res)){
|
||||
$this->returnCode('91000003');
|
||||
$this->returnCode(1, '删除配置失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}
|
||||
@@ -331,7 +356,7 @@ class Yunzer extends Base{
|
||||
$oConfig = new YzAdminConfig();
|
||||
$updateAll = $oConfig->updateAll($post);
|
||||
if(empty($updateAll)){
|
||||
$this->returnCode('91000002');
|
||||
$this->returnCode(1, '更新配置值失败');
|
||||
}
|
||||
$this->returnCode(0);
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user