Commit 8e2effe3 by wenyi.chen

线上

parent e270b40c
<?php
/**
* Create by wenyi
* E-mail: wesley_prc@163.com
* Description: data-collect-api
* Date: 2024/2/27 23:37
* Update: 2024/2/27 23:37
* 数据管理
*/
namespace app\api\controller;
use app\common\model\redis\RedisModel;
use app\common\model\mysql\EnterpriseInfo as EnterpriseInfoModel;
use app\common\model\mysql\Department as DepartmentModel;
use think\facade\Db;
class Task extends AuthBase
{ public static $name = 'controller.EnterpriseInfo';
/**
* 列表
* @return \josn|void
*/
public function list()
{
try{ // 数据接收
$page = input("param.page",0,"intval");
$limit = input("param.limit",10,"intval");
$DepartmentModel =new DepartmentModel();
$result = $DepartmentModel->where('slug','gather')
->where('statues',1)
->paginate([
'list_rows'=>$limit,
'page'=>$page
]);
if($result){
$result = $result->toArray();
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),$result);
}
}catch (\Exception $e){
exception($e,self::$name.'.list');
}
}
public function getNameInfo()
{
try{
$name = input("param.name");
$enterpriseAudit = new EnterpriseInfoModel();
$result = $enterpriseAudit->where('enterprise_name',$name)->find();
if($result){
$result = $result->toArray();
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),$result);
}
}catch (\Exception $e){
exception($e,self::$name.'.getNameInfo');
}
}
/**
*
* @return \josn|void
*/
public function add()
{
try{
$data = array();
// 数据接收
$data['enterprise_name'] = input("param.enterprise_name",'',"trim");
$data['enterprise_shxydm'] = input("param.enterprise_shxydm",'',"trim");
$data['enterprise_website_official'] = input("param.enterprise_website_official",'',"trim");
$data['enterprise_website_language'] = input("param.enterprise_website_language",'',"trim");
$data['enterprise_website_oriignal'] = input("param.enterprise_website_oriignal",'',"trim");
$data['enterprise_websitessl'] = input("param.enterprise_websitessl",'',"trim");
$data['product_source_address'] = input("param.product_source_address",'',"trim");
$data['unique_product_source'] = input("param.unique_product_source",'',"trim");
$data['structured_product_source'] = input("param.structured_product_source",'',"trim");
$data['unavailable'] = input("param.unavailable",'',"trim");
$data['initial_screening_remarks'] = input("param.initial_screening_remarks",'',"trim");
$data['collection_type'] = input("param.collection_type",'',"trim");
$data['collection_status'] = input("param.collection_status",'',"trim");
$data['enterprise_chain'] = input("param.enterprise_chain",'',"trim");
$data['enterprise_type'] = input("param.enterprise_type",'',"trim");
$data['enterprise_note'] = input("param.enterprise_note",'',"trim");
$timestamp = time(); // 当前时间戳
$randomNumber = mt_rand(100000, 999999); // 生成一个六位的随机数
$uniqueIdentifier = $timestamp . $randomNumber; // 时间戳和随机数拼接
$data['enterprise_id'] =$uniqueIdentifier;
$enterpriseAudit = new EnterpriseInfoModel();
$result = $enterpriseAudit->insert($data);
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),$result);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),$result);
}
}catch (\Exception $e){
exception($e,self::$name.'.add');
}
}
public function save()
{
try{
$data = array();
// 数据接收
$id= input("param.id",'',"trim");
$data['enterprise_shxydm'] = input("param.enterprise_shxydm",'',"trim");
$data['enterprise_website_official'] = input("param.enterprise_website_official",'',"trim");
$data['enterprise_website_language'] = input("param.enterprise_website_language",'',"trim");
$data['enterprise_website_oriignal'] = input("param.enterprise_website_oriignal",'',"trim");
$data['enterprise_websitessl'] = input("param.enterprise_websitessl",'',"trim");
$data['product_source_address'] = input("param.product_source_address",'',"trim");
$data['unique_product_source'] = input("param.unique_product_source",'',"trim");
$data['structured_product_source'] = input("param.structured_product_source",'',"trim");
$data['unavailable'] = input("param.unavailable",'',"trim");
$data['initial_screening_remarks'] = input("param.initial_screening_remarks",'',"trim");
$data['collection_type'] = input("param.collection_type",'',"trim");
$data['collection_status'] = input("param.collection_status",'',"trim");
$data['enterprise_chain'] = input("param.enterprise_chain",'',"trim");
$data['enterprise_type'] = input("param.enterprise_type",'',"trim");
$data['enterprise_note'] = input("param.enterprise_note",'',"trim");
$data['update_time'] = date('Y-m-d H:i:s');
$enterpriseAudit = new EnterpriseInfoModel();
$result = $enterpriseAudit->where('id',$id)->update($data);
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),[]);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),$result);
}
}catch (\Exception $e){
exception($e,self::$name.'.save');
}
}
/**
* 删除信息
*
* @param int $id
* @return \think\Response
*/
public function delete()
{
try{
$id = input('param.id','',"intval");
if(!is_numeric($id) || $id==0 ){
return returnResult(config("config.code.error"),config("config.describe.error_id"));
}
// 业务处理
$enterpriseAudit = new EnterpriseInfoModel();
$res = $enterpriseAudit->where('id',$id)->find();
if(empty($res)){
return returnResult(config("config.code.error"),config("config.describe.error_id"));
}
$result = $res->where('id',$id)->update(['status'=>0]);
if($result){
return returnResult(config("config.code.success"),config("config.describe.success"),[]);
}else{
return returnResult(config("config.code.success"),config("config.describe.deletion_failed"),[]);
}
}catch (\Exception $e){
exception($e,'Equipment.delete');
}
}
}
\ No newline at end of file
...@@ -88,12 +88,11 @@ Route::rule("product/save","Product/save"); ...@@ -88,12 +88,11 @@ Route::rule("product/save","Product/save");
Route::rule("product/delete","Product/delete"); Route::rule("product/delete","Product/delete");
Route::rule("product/add","Product/add"); Route::rule("product/add","Product/add");
Route::rule("product/unallocatedProducts","product/unallocatedProducts"); Route::rule("product/unallocatedProducts","product/unallocatedProducts"); // 未分配的产品列表
Route::rule("productAllocation/add","productAllocation/add"); Route::rule("productAllocation/add","productAllocation/add");
Route::rule("productAllocation/list","productAllocation/list"); Route::rule("productAllocation/list","productAllocation/list");
Route::rule("productAllocation/see","productAllocation/see"); Route::rule("productAllocation/see","productAllocation/see");
Route::rule("productAllocation/save","productAllocation/save"); Route::rule("productAllocation/save","productAllocation/save");
Route::rule("productAllocation/abnormal","productAllocation/abnormal");
Route::rule("service/product","Service/product"); Route::rule("service/product","Service/product");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment