first commit

This commit is contained in:
annnj-company
2026-04-17 18:29:53 +08:00
parent e49fa5a215
commit 130c1026c4
5615 changed files with 1639145 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
<?php
namespace app\admin\controller;
use think\Db;
use think\Request;
class BranchComConfig extends Base
{
/**
* 获取分公司列表
*/
public function list()
{
try {
$list = Db::name('branchcom_config')
->where('del_tag', 0)
->order('order asc')
->select();
return $this->buildSuccess([
'list' => $list
]);
} catch (\Exception $e) {
return $this->buildFailed('获取失败:' . $e->getMessage());
}
}
/**
* 新增分公司
*/
public function add()
{
$data = input('post.');
// 验证必填字段
if (empty($data['full_name']) || empty($data['short_name'])) {
return $this->buildFailed('分公司名称和简称不能为空');
}
try {
$data['create_uid'] = $this->getUserId(); // 获取当前登录用户ID
$data['update_time'] = date('Y-m-d H-i-s');
$data['create_time'] = date('Y-m-d H-i-s');
$data['del_tag'] = 0;
// 如果未设置order则设置为当前最大order + 1
if (empty($data['order'])) {
$maxOrder = Db::name('branchcom_config')->max('order');
$data['order'] = $maxOrder ? $maxOrder + 1 : 1;
}
$id = Db::name('branchcom_config')->insertGetId($data);
return $this->buildSuccess([
'id' => $id
], '添加成功');
} catch (\Exception $e) {
return $this->buildFailed('添加失败:' . $e->getMessage());
}
}
/**
* 更新分公司信息
*/
public function update()
{
$data = input('post.');
// 验证必填字段
if (empty($data['id'])) {
return $this->buildFailed('缺少ID参数');
}
if (empty($data['full_name']) || empty($data['short_name'])) {
return $this->buildFailed('分公司名称和简称不能为空');
}
try {
$data['update_time'] = date('Y-m-d H-i-s');
Db::name('branchcom_config')
->where('id', $data['id'])
->update($data);
return $this->buildSuccess([], '更新成功');
} catch (\Exception $e) {
return $this->buildFailed('更新失败:' . $e->getMessage());
}
}
/**
* 删除分公司(逻辑删除)
*/
public function delete()
{
$id = input('post.id');
if (empty($id)) {
return $this->buildFailed('缺少ID参数');
}
try {
$data = [
'del_tag' => 2,
'create_uid' => $this->getUserId(), // 记录删除人ID
'update_time' => date('Y-m-d H-i-s')
];
Db::name('branchcom_config')
->where('id', $id)
->update($data);
return $this->buildSuccess([], '删除成功');
} catch (\Exception $e) {
return $this->buildFailed('删除失败:' . $e->getMessage());
}
}
}