This commit is contained in:
weiz 2024-05-23 17:54:55 +08:00
parent e311fd042d
commit c872aefd92
6 changed files with 435 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\works\rcbg;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\works\rcbg\OaWorkCommentLists;
use app\adminapi\logic\works\rcbg\OaWorkCommentLogic;
use app\adminapi\validate\works\rcbg\OaWorkCommentValidate;
/**
* 工作汇报点评表控制器
* Class OaWorkCommentController
* @package app\adminapi\controller\works\rcbg
*/
class OaWorkCommentController extends BaseAdminController
{
/**
* @notes 获取工作汇报点评表列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function lists()
{
return $this->dataLists(new OaWorkCommentLists());
}
/**
* @notes 添加工作汇报点评表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function add()
{
$params = (new OaWorkCommentValidate())->post()->goCheck('add');
$result = OaWorkCommentLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(OaWorkCommentLogic::getError());
}
/**
* @notes 编辑工作汇报点评表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function edit()
{
$params = (new OaWorkCommentValidate())->post()->goCheck('edit');
$result = OaWorkCommentLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(OaWorkCommentLogic::getError());
}
/**
* @notes 删除工作汇报点评表
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function delete()
{
$params = (new OaWorkCommentValidate())->post()->goCheck('delete');
OaWorkCommentLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工作汇报点评表详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function detail()
{
$params = (new OaWorkCommentValidate())->goCheck('detail');
$result = OaWorkCommentLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\works\rcbg;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\auth\Admin;
use app\common\model\works\rcbg\OaWorkComment;
use app\common\lists\ListsSearchInterface;
/**
* 工作汇报点评表列表
* Class OaWorkCommentLists
* @package app\adminapi\listsworks\rcbg
*/
class OaWorkCommentLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function setSearch(): array
{
return [
'=' => ['work_id']
];
}
/**
* @notes 获取工作汇报点评表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function lists(): array
{
return OaWorkComment::where($this->searchWhere)
->field(['id', 'work_id', 'admin_id', 'content'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$user = Admin::field('name,avatar')->where('id',$data['admin_id'])->findOrEmpty();
$data['admin_name'] = $user['name'];
$data['admin_avatar'] = $user['avatar'];
})
->toArray();
}
/**
* @notes 获取工作汇报点评表数量
* @return int
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function count(): int
{
return OaWorkComment::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,109 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\works\rcbg;
use app\common\model\works\rcbg\OaWorkComment;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 工作汇报点评表逻辑
* Class OaWorkCommentLogic
* @package app\adminapi\logic\works\rcbg
*/
class OaWorkCommentLogic extends BaseLogic
{
/**
* @notes 添加工作汇报点评表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/23 17:39
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
OaWorkComment::create([
'work_id' => $params['work_id'],
'admin_id' => $admin_id,
'content' => $params['content']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑工作汇报点评表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/23 17:39
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
OaWorkComment::where('id', $params['id'])->update([
'work_id' => $params['work_id'],
'content' => $params['content']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除工作汇报点评表
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/05/23 17:39
*/
public static function delete(array $params): bool
{
return OaWorkComment::destroy($params['id']);
}
/**
* @notes 获取工作汇报点评表详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/05/23 17:39
*/
public static function detail($params): array
{
return OaWorkComment::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -18,6 +18,7 @@ namespace app\adminapi\logic\works\rcbg;
use app\common\model\auth\Admin;
use app\common\model\works\rcbg\OaWork;
use app\common\logic\BaseLogic;
use app\common\model\works\rcbg\OaWorkComment;
use app\common\model\works\rcbg\OaWorkRecord;
use think\facade\Db;
@ -117,6 +118,9 @@ class OaWorkLogic extends BaseLogic
OaWorkRecord::destroy(function($query)use($params){
$query->where('wid','=',$params['id']);
});
OaWorkComment::destroy(function($query)use($params){
$query->where('work_id','=',$params['id']);
});
Db::commit();
return true;
} catch (\Exception $e) {

View File

@ -0,0 +1,98 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\works\rcbg;
use app\common\validate\BaseValidate;
/**
* 工作汇报点评表验证器
* Class OaWorkCommentValidate
* @package app\adminapi\validate\works\rcbg
*/
class OaWorkCommentValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'work_id' => 'require',
'content' => 'require'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'work_id' => '工作汇报id',
'content' => '点评内容',
];
/**
* @notes 添加场景
* @return OaWorkCommentValidate
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function sceneAdd()
{
return $this->only(['work_id','content']);
}
/**
* @notes 编辑场景
* @return OaWorkCommentValidate
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function sceneEdit()
{
return $this->only(['id','work_id','content']);
}
/**
* @notes 删除场景
* @return OaWorkCommentValidate
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return OaWorkCommentValidate
* @author likeadmin
* @date 2024/05/23 17:39
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,34 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\works\rcbg;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 工作汇报点评表模型
* Class OaWorkComment
* @package app\common\model\works\rcbg
*/
class OaWorkComment extends BaseModel
{
use SoftDelete;
protected $name = 'oa_work_comment';
protected $deleteTime = 'delete_time';
}