# 添加到 ~/.zshrc echo 'alias php="/usr/local/opt/php@8.1/bin/php"' >> ~/.zshrc echo 'alias composer="php /usr/local/bin/composer"' >> ~/.zshrc source ~/.zshrc # 验证 php -v
2025年09月26日
# 添加到 ~/.zshrc echo 'alias php="/usr/local/opt/php@8.1/bin/php"' >> ~/.zshrc echo 'alias composer="php /usr/local/bin/composer"' >> ~/.zshrc source ~/.zshrc # 验证 php -v
2025年09月09日
登录主服务器的宝塔面板,进入 软件商店 -> 找到你的MySQL实例 -> 点击 设置 -> 配置修改。
2025年06月29日
链接storage目录
php artisan storage:link
重新生成composer自动加载文件
composer dump-autoload
清理全部缓存
2025年03月31日
package com.yunjiani.controller;
import com.yunjiani.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
@Slf4j
@RestController
public class UploadController {
@PostMapping("/upload")
public Result upload(MultipartFile file) throws IOException {
log.info("文件上传开始:{}",file);
//文件名
String fileName = file.getOriginalFilename();
String suffix = fileName.substring(fileName.lastIndexOf("."));
file.transferTo(new File("D:/" + UUID.randomUUID().toString() + suffix));
return Result.success();
}
}2025年03月28日
生命周期
创建
beforeCreate
created
挂载
beforeMount
monted
更新
beforeUpdate
updated
销毁
beforDestroy
destroy
2025年03月19日
oop是什么?
oop是面向对象编程,php的单继承,特性封装性、多态性、继承性。
合并数组的方法?
第一种,使用内置函数array_merge(),第二种。用foreach循环重新新建一个变量去接收存储。
php垃圾回收装置?
php可以自动进行内容管理,清楚不在需要的对象。
2025年03月16日
Controller方法
package com.yunjiani.controller;
import com.yunjiani.pojo.Dept;
import com.yunjiani.pojo.Result;
import com.yunjiani.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class DeptController {
@Autowired
private DeptService deptService;
/**
* 部门列表
*/
@GetMapping("/depts")
public Result list(){
List<Dept> list = deptService.findAll();
return Result.success(list);
}
/**
* 删除部门
*/
@DeleteMapping("/depts")
public Result delete(Integer id){
if(id == null){
return Result.error("id不能为空");
}
System.out.println("id:" + id);
deptService.delete(id);
return Result.success();
}
/**
* 新增部门
*/
@PostMapping("/depts")
public Result add(String name){
if(name == null || "".equals(name)){
return Result.error("部门名称不能为空");
}
deptService.add(name);
return Result.success();
}
/**
* 修改部门
*/
@PutMapping("/depts")
public Result update(@RequestBody Dept dept){
if(dept.getId() == null || "".equals(dept.getId())){
return Result.error("id不能为空");
}
if(dept.getName() == null || "".equals(dept.getName())){
return Result.error("部门名称不能为空");
}
System.out.println(dept);
deptService.update(dept);
return Result.success();
}
/**
* 部门详情
*/
@GetMapping("/depts/{id}")
public Result getInfo(@PathVariable Integer id){
if(id == null || "".equals(id)){
return Result.error("id不能为空");
}
Dept dept = deptService.findById(id);
return Result.success(dept);
}
}2025年03月13日
//mapper文件
package com.yunjiani.mapper;
import com.yunjiani.pojo.User;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface UserMapper {
/**
* 查询所有用户
*/
@Select("select id, username, password, name, age from user")
public List<User> findAll();
/**
* 根据ID删除用户
*/
@Delete("delete from user where id=#{id}")
public Integer deleteById(Integer id);
/**
* 新增数据
*/
@Insert("insert into user(username,password,name,age) values(#{username},#{password},#{name},#{age})")
public Integer insertUser(User user);
/**
* 修改用户信息
*/
@Update("update user set username = #{username},password = #{password},name = #{name},age = #{age} where id = #{id}")
public Integer updateUser(User user);
/**
* 根据用户名和密码查询用户
*/
@Select("select * from user where username = #{username} and password = #{password}")
public User queryInfo(String username, String password);
}
}Powered By Z-BlogPHP 1.7.4
Copyright fengqiangjun.com Rights Reserved.