CRMEB/backend/app/adminapi/controller/product/StoreProductParamController.php
吴昊天 27d33410a8 fix(商品参数): 模板名称必填校验与提示文案统一
表单项 prop 误写 rule_name 致校验不生效,改为 name/sort 并加必填规则;后端提示文案同步为「模板名称」
2026-10-21 16:54:00 +08:00

145 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\product;
use app\adminapi\controller\AuthController;
use app\services\product\product\StoreProductParamServices;
use think\facade\App;
/**
* 商品参数
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
class StoreProductParamController extends AuthController
{
/**
* @var StoreProductParamServices
*/
protected $services;
/**
* @param App $app
* @param StoreProductParamServices $services
*/
public function __construct(App $app, StoreProductParamServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取参数列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
public function getParamList()
{
$where = $this->request->getMore([
['name', '']
]);
return app('json')->success($this->services->getParamList($where));
}
/**
* 获取参数详情
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
public function getParamInfo($id)
{
if (!$id) return app('json')->fail('参数错误');
$info = $this->services->getParamInfo($id);
return app('json')->success($info);
}
/**
* 获取参数值
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
public function getParamValue($id)
{
if (!$id) return app('json')->fail('参数错误');
$info = $this->services->getParamValue($id);
return app('json')->success($info);
}
/**
* 保存参数
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
public function saveParamData($id)
{
$data = $this->request->postMore([
['name', ''],
['value', []],
['sort', 0],
['status', 1]
]);
if (!$data['name']) return app('json')->fail('请输入模板名称');
if (!count($data['value'])) return app('json')->fail('请输入参数值');
$this->services->saveParamData($id, $data);
return app('json')->success('保存成功');
}
/**
* 修改参数状态
* @param $id
* @param $status
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
public function setParamStatus($id, $status)
{
if (!$id) return app('json')->fail('参数错误');
$this->services->setParamStatus($id, $status);
return app('json')->success('修改成功');
}
/**
* 删除参数
* @param $id
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/12/17
*/
public function delParamData($id)
{
if (!$id) return app('json')->fail('参数错误');
$this->services->delParamData($id);
return app('json')->success('删除成功');
}
}