first commit
This commit is contained in:
177
pgserver/application/admin/controller/Project.php
Normal file
177
pgserver/application/admin/controller/Project.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\model\ProjectTeam;
|
||||
|
||||
class Project extends Base
|
||||
{
|
||||
private $typearr=array(1=>'加急项目',2=>"拓展项目",3=>"特殊项目");
|
||||
/**
|
||||
* 获取住宅项目组列表
|
||||
* @author cavan
|
||||
*/
|
||||
public function ProjectList()
|
||||
{
|
||||
$ProjectTeam = new ProjectTeam();
|
||||
$list = $ProjectTeam->where("status",1)
|
||||
->field('*')
|
||||
->select()
|
||||
->toArray();
|
||||
if(!empty($list)){
|
||||
foreach ($list as $k => $v){
|
||||
$list[$k]['type_name'] = $this->typearr[$v['type']];
|
||||
}
|
||||
}
|
||||
return $this->buildSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目组详情
|
||||
* @author cavan
|
||||
*
|
||||
*/
|
||||
public function ProjectDetails(){
|
||||
$id = $this->request->post('id', '', 'trim');
|
||||
if(!$id){
|
||||
return $this->buildFailed("缺少参数id");
|
||||
}
|
||||
$ProjectTeam = new ProjectTeam();
|
||||
$list = $ProjectTeam->where("id",$id)
|
||||
->where("status",1)
|
||||
->field("*")
|
||||
->find();
|
||||
if(!empty($list)) {
|
||||
$list['type_name'] = $this->typearr[$list['type']];
|
||||
$list['uid_arr'] = array_filter(explode(",",$list['uid_str']));
|
||||
$list['username_arr'] = array_filter(explode(",",$list['username_str']));
|
||||
}else{
|
||||
return $this->buildFailed("未查的数据");
|
||||
}
|
||||
return $this->buildSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑项目组信息保存
|
||||
* @author cavan
|
||||
*
|
||||
* @parameter id 表id
|
||||
* @parameter name 项目组名称
|
||||
* @parameter uid_str 项目组成员id字符串
|
||||
* @parameter username_str 项目组成员名称字符串
|
||||
*/
|
||||
public function ProjectEdit(){
|
||||
$id = $this->request->post('id', '', 'trim');
|
||||
$name = $this->request->post('name', '', 'trim');
|
||||
$uid_str = $this->request->post('uid_str', '', 'trim');
|
||||
$username_str = $this->request->post('username_str', '', 'trim');
|
||||
|
||||
if(!$id){
|
||||
return $this->buildFailed("缺少参数id");
|
||||
}
|
||||
if(!$name){
|
||||
return $this->buildFailed("缺少参数项目组名称");
|
||||
}
|
||||
$update_date['name'] = $name;
|
||||
$update_date['uid_str'] = $uid_str;
|
||||
$update_date['username_str'] = $username_str;
|
||||
$update_date['update_time'] = time();
|
||||
|
||||
$ProjectTeam = new ProjectTeam();
|
||||
$ProjectTeam->where("id",$id)->update($update_date);
|
||||
|
||||
return $this->buildSuccess("编辑成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增项目组信息保存
|
||||
* @author cavan
|
||||
*
|
||||
* @parameter type 项目组类型
|
||||
* @parameter name 项目组名称
|
||||
* @parameter uid_str 项目组成员id字符串
|
||||
* @parameter username_str 项目组成员名称字符串
|
||||
*/
|
||||
public function ProjectAdd(){
|
||||
$type = $this->request->post('type', '', 'trim');
|
||||
$name = $this->request->post('name', '', 'trim');
|
||||
$uid_str = $this->request->post('uid_str', '', 'trim');
|
||||
$username_str = $this->request->post('username_str', '', 'trim');
|
||||
|
||||
if(!$type){
|
||||
return $this->buildFailed("缺少参数项目组分类");
|
||||
}
|
||||
if(!$name){
|
||||
return $this->buildFailed("缺少参数项目组名称");
|
||||
}
|
||||
$insert_date['type'] = $type;
|
||||
$insert_date['name'] = $name;
|
||||
$insert_date['uid_str'] = $uid_str;
|
||||
$insert_date['username_str'] = $username_str;
|
||||
$insert_date['status'] = 1;
|
||||
$insert_date['create_time'] = time();
|
||||
|
||||
$ProjectTeam = new ProjectTeam();
|
||||
$id = $ProjectTeam->insertGetId($insert_date);
|
||||
if($id){
|
||||
//删除除新增项目组之外同类的项目组
|
||||
$return = $ProjectTeam->where("type",$type)->where("id","<>",$id)->update(["status"=>2,"update_time"=>time()]);
|
||||
if($return){
|
||||
return $this->buildSuccess("新增成功");
|
||||
}else{
|
||||
$ProjectTeam->where("id",$id)->delete();
|
||||
return $this->buildFailed("新增失败");
|
||||
}
|
||||
}else{
|
||||
return $this->buildFailed("新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证新增的项目组分类是否存在正常项目组
|
||||
* @author cavan
|
||||
*
|
||||
* @parameter type 项目组类型
|
||||
*
|
||||
*/
|
||||
public function Verification(){
|
||||
$type = $this->request->post('type', '', 'trim');
|
||||
if(!$type){
|
||||
return $this->buildFailed("缺少参数项目组分类");
|
||||
}
|
||||
$ProjectTeam = new ProjectTeam();
|
||||
$id = $ProjectTeam->where(["status"=>1,"type"=>$type])->value("id");
|
||||
if($id){
|
||||
return $this->buildFailed("已存在同类进行中的项目组,继续新增将删除正在进行中的项目组");
|
||||
}else{
|
||||
return $this->buildSuccess("不存在进行中的项目组");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增项目组信息保存
|
||||
* @author cavan
|
||||
*
|
||||
* @parameter type 项目组类型
|
||||
* @parameter name 项目组名称
|
||||
* @parameter uid_str 项目组成员id字符串
|
||||
* @parameter username_str 项目组成员名称字符串
|
||||
*/
|
||||
public function ProjectDel(){
|
||||
$id = $this->request->post('id', '', 'trim');
|
||||
|
||||
if(!$id){
|
||||
return $this->buildFailed("缺少参数id");
|
||||
}
|
||||
|
||||
$ProjectTeam = new ProjectTeam();
|
||||
//删除除新增项目组之外同类的项目组
|
||||
$return = $ProjectTeam->where("id",$id)->update(["status"=>2,"update_time"=>time()]);
|
||||
if($return){
|
||||
return $this->buildSuccess("删除成功");
|
||||
}else{
|
||||
return $this->buildFailed("新增失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user