作者 lyh

gx脚本demo

@@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel @@ -20,7 +20,7 @@ class Kernel extends ConsoleKernel
20 $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块 20 $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
21 $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块 21 $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
22 // $schedule->command('inspire')->hourly(); 22 // $schedule->command('inspire')->hourly();
23 - $schedule->command('remain_day')->dailyAt('06:00')->withoutOverlapping(1); // 项目剩余服务时长 23 + $schedule->command('remain_day')->dailyAt('08:30')->withoutOverlapping(1); // 项目剩余服务时长
24 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 24 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
25 $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次 25 $schedule->command('service_count')->dailyAt('01:00')->withoutOverlapping(1); //服务器使用情况,每天凌晨1点执行一次
26 $schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流 26 $schedule->command('web_traffic_special')->everyMinute()->withoutOverlapping(1); // 特殊引流
@@ -24,6 +24,7 @@ use App\Models\Sms\SmsLog; @@ -24,6 +24,7 @@ use App\Models\Sms\SmsLog;
24 use App\Models\User\DeptUser; 24 use App\Models\User\DeptUser;
25 use App\Models\User\ProjectRole; 25 use App\Models\User\ProjectRole;
26 use App\Models\User\User; 26 use App\Models\User\User;
  27 +use App\Services\CosService;
27 use App\Utils\EncryptUtils; 28 use App\Utils\EncryptUtils;
28 use http\Client\Response; 29 use http\Client\Response;
29 use Illuminate\Support\Facades\Cache; 30 use Illuminate\Support\Facades\Cache;
@@ -323,4 +324,9 @@ class LoginController extends BaseController @@ -323,4 +324,9 @@ class LoginController extends BaseController
323 } 324 }
324 return $data; 325 return $data;
325 } 326 }
  327 +
  328 + public function ceshi(){
  329 + $cos = new CosService();
  330 + return $cos->addFieldImage('https://ecdn6.globalso.com/upload/p/2000/image_product/2024-07/aero-y50-introduction-3.jpg',['characters'=>'这是水印'],false);
  331 + }
326 } 332 }
@@ -148,4 +148,48 @@ class CosService @@ -148,4 +148,48 @@ class CosService
148 'mime' => $file->getMimeType(), 148 'mime' => $file->getMimeType(),
149 ]; 149 ];
150 } 150 }
  151 +
  152 +
  153 + /**
  154 + * @remark :生成带水印的图片文件
  155 + * @name :addFieldImage
  156 + * @author :lyh
  157 + * @method :post
  158 + * @time :2024/8/19 11:01
  159 + * gravity/SouthEast:
  160 + gravity:表示水印的对齐方式。常见的值有:
  161 + NorthWest:左上角
  162 + North:顶部中间
  163 + NorthEast:右上角
  164 + West:左侧中间
  165 + Center:中心
  166 + East:右侧中间
  167 + SouthWest:左下角
  168 + South:底部中间
  169 + SouthEast:右下角
  170 + */
  171 + public function addFieldImage($cdnUrl = '',$data = [],$is_image = true){
  172 + if($is_image){
  173 + $param = [
  174 + $data['characters'] ?? 'image/'.urlencode(base64_encode("{$data['image']}")),//文字水印名称
  175 + $data['position'] ?? 'gravity/SouthEast',
  176 + $data['dx'] ?? 'dx/10/dy/10',
  177 + $data['font'] ?? 'font/5bCP6aOe',//默认宋体
  178 + $data['fontsize'] ?? 'fontsize/24',//大小
  179 + $data['fill'] ?? 'fill/I0ZGRkZGRg==',//颜色
  180 + ];
  181 + $cdnUrl = $cdnUrl.'?imageMogr2/watermark/1/'.implode('/',$param);
  182 + }else{
  183 + $param = [
  184 + $data['characters'] ?? 'text/'.urlencode(base64_encode("{$data['characters']}")),//文字水印名称
  185 + $data['position'] ?? 'gravity/SouthEast',
  186 + $data['dx'] ?? 'dx/10/dy/10',
  187 + $data['font'] ?? 'font/5bCP6aOe',//默认宋体
  188 + $data['fontsize'] ?? 'fontsize/24',//大小
  189 + $data['fill'] ?? 'fill/I0ZGRkZGRg==',//颜色
  190 + ];
  191 + $cdnUrl = $cdnUrl.'?imageMogr2/watermark/3/'.implode('/',$param);
  192 + }
  193 + return $cdnUrl;
  194 + }
151 } 195 }