增加项目自定义信息
Signed-off-by: vilson <545522390@qq.com>
This commit is contained in:
parent
5d5a3d2694
commit
b8df927ec7
42
application/common/Model/ProjectInfo.php
Normal file
42
application/common/Model/ProjectInfo.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\Model;
|
||||
|
||||
class ProjectInfo extends CommonModel
|
||||
{
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 创建项目信息
|
||||
* @param $name
|
||||
* @param $description
|
||||
* @param $projectCode
|
||||
* @param $organizationCode
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function createData($name, $value, $description, $projectCode, $organizationCode, $sort = 0)
|
||||
{
|
||||
if (!$name) {
|
||||
return error(1, '请填写项目信息名称');
|
||||
}
|
||||
$project = Project::where(['code' => $projectCode, 'deleted' => 0])->field('id')->find();
|
||||
if (!$project) {
|
||||
return error(3, '该项目已失效');
|
||||
}
|
||||
$data = [
|
||||
'create_time' => nowTime(),
|
||||
'code' => createUniqueCode('ProjectInfo'),
|
||||
'project_code' => $projectCode,
|
||||
'description' => $description,
|
||||
'organization_code' => $organizationCode,
|
||||
'value' => trim($value),
|
||||
'sort' => $sort,
|
||||
'name' => trim($name),
|
||||
];
|
||||
$result = self::create($data)->toArray();
|
||||
return $result;
|
||||
}
|
||||
}
|
114
application/project/controller/ProjectInfo.php
Normal file
114
application/project/controller/ProjectInfo.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace app\project\controller;
|
||||
|
||||
use controller\BasicApi;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\Exception;
|
||||
use think\exception\DbException;
|
||||
use think\exception\PDOException;
|
||||
use think\facade\Request;
|
||||
|
||||
class ProjectInfo extends BasicApi
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (!$this->model) {
|
||||
$this->model = new \app\common\Model\ProjectInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源项目信息
|
||||
* @return void
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = [];
|
||||
$code = Request::post('projectCode');
|
||||
if (!$code) {
|
||||
$this->error("请选择一个项目");
|
||||
}
|
||||
$where[] = ['project_code', '=', $code];
|
||||
// $list = $this->model->_list($where, 'sort asc,id asc');
|
||||
$list = $this->model->where($where)->order('id desc')->select()->toArray();
|
||||
$this->success('', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param Request $request
|
||||
* @return void
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$data = $request::only('name,value,sort,projectCode,description');
|
||||
if (!$request::post('name')) {
|
||||
$this->error("请填写项目信息名称");
|
||||
}
|
||||
$result = $this->model->createData($data['name'], $data['value'], $data['description'], $data['projectCode'], getCurrentOrganizationCode());
|
||||
if (!isError($result)) {
|
||||
$this->success('添加成功', $result);
|
||||
}
|
||||
$this->error($result['msg']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param Request $request
|
||||
* @return void
|
||||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$data = $request::only('name,value,sort,projectCode,description,infoCode');
|
||||
if (!$request::post('name')) {
|
||||
$this->error("请填写项目信息名称");
|
||||
}
|
||||
if (!$data['infoCode']) {
|
||||
$this->error("请选择一个项目信息");
|
||||
}
|
||||
$info = $this->model->where(['code' => $data['infoCode']])->field('id,project_code')->find();
|
||||
if (!$info) {
|
||||
$this->error("该项目信息已失效");
|
||||
}
|
||||
$has = $this->model->where(['name' => $data['name'], 'project_code' => $info['project_code']])->field('id,sort')->find();
|
||||
if ($has && $has['id'] != $info['id']) {
|
||||
$this->error("该项目信息名称已存在");
|
||||
}
|
||||
$result = $this->model->_edit(['name' => $data['name'], 'description' => $data['description'], 'value' => $data['value'], 'sort' => isset($data['sort']) ? $data['sort'] : $has['sort']], ['code' => $data['infoCode']]);
|
||||
if ($result) {
|
||||
$this->success('');
|
||||
}
|
||||
$this->error("操作失败,请稍候再试!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目信息
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$code = Request::post('infoCode');
|
||||
if (!$code) {
|
||||
$this->error("请选择一个项目信息");
|
||||
}
|
||||
$result = $this->model->where('code', $code)->delete();
|
||||
if (isError($result)) {
|
||||
$this->error($result['msg'], $result['errno']);
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
}
|
3067
data/2.8.0/2.8.6-2.8.8.sql
Normal file
3067
data/2.8.0/2.8.6-2.8.8.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,15 +3,15 @@
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80012
|
||||
Source Server Version : 50726
|
||||
Source Host : localhost:3306
|
||||
Source Schema : pearproject
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80012
|
||||
Target Server Version : 50726
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 13/09/2019 10:29:28
|
||||
Date: 22/02/2020 20:22:08
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@ -1263,6 +1263,27 @@ CREATE TABLE `pear_project_features` (
|
||||
-- ----------------------------
|
||||
INSERT INTO `pear_project_features` VALUES (1, 'qtsxlwob1m0uja37y2g4pefc', '3.x', '3.x', '2019-06-23 11:17:48', NULL, '6v7be19pwman2fird04gqu53', 'mo4uqwfb06dxv8ez2spkl3rg');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pear_project_info
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pear_project_info`;
|
||||
CREATE TABLE `pear_project_info` (
|
||||
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
|
||||
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '值',
|
||||
`description` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
`create_time` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`update_time` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`organization_code` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '组织id',
|
||||
`project_code` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '项目id',
|
||||
`sort` int(11) NULL DEFAULT 0 COMMENT '排序',
|
||||
`code` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'code',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `code`(`code`) USING BTREE,
|
||||
INDEX `project_code`(`project_code`) USING BTREE,
|
||||
INDEX `organization_code`(`organization_code`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目自定义信息表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pear_project_log
|
||||
-- ----------------------------
|
||||
@ -2003,7 +2024,7 @@ CREATE TABLE `pear_project_node` (
|
||||
`create_at` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `index_system_node_node`(`node`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 635 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目端节点表' ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 641 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目端节点表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pear_project_node
|
||||
@ -2332,7 +2353,7 @@ CREATE TABLE `pear_system_config` (
|
||||
`value` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '配置值',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `index_system_config_name`(`name`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 43 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统参数配置' ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统参数配置' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pear_system_config
|
||||
|
@ -3,15 +3,15 @@
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80012
|
||||
Source Server Version : 50726
|
||||
Source Host : localhost:3306
|
||||
Source Schema : pearproject
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80012
|
||||
Target Server Version : 50726
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 13/09/2019 10:29:28
|
||||
Date: 22/02/2020 20:22:08
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@ -1263,6 +1263,27 @@ CREATE TABLE `pear_project_features` (
|
||||
-- ----------------------------
|
||||
INSERT INTO `pear_project_features` VALUES (1, 'qtsxlwob1m0uja37y2g4pefc', '3.x', '3.x', '2019-06-23 11:17:48', NULL, '6v7be19pwman2fird04gqu53', 'mo4uqwfb06dxv8ez2spkl3rg');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pear_project_info
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pear_project_info`;
|
||||
CREATE TABLE `pear_project_info` (
|
||||
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
|
||||
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '值',
|
||||
`description` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
`create_time` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`update_time` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`organization_code` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '组织id',
|
||||
`project_code` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '项目id',
|
||||
`sort` int(11) NULL DEFAULT 0 COMMENT '排序',
|
||||
`code` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'code',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `code`(`code`) USING BTREE,
|
||||
INDEX `project_code`(`project_code`) USING BTREE,
|
||||
INDEX `organization_code`(`organization_code`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目自定义信息表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pear_project_log
|
||||
-- ----------------------------
|
||||
@ -2003,7 +2024,7 @@ CREATE TABLE `pear_project_node` (
|
||||
`create_at` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `index_system_node_node`(`node`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 635 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目端节点表' ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 641 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目端节点表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pear_project_node
|
||||
@ -2332,7 +2353,7 @@ CREATE TABLE `pear_system_config` (
|
||||
`value` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '配置值',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `index_system_config_name`(`name`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 43 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统参数配置' ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统参数配置' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of pear_system_config
|
||||
|
Loading…
x
Reference in New Issue
Block a user