commit
aec930528f
@ -1,86 +0,0 @@
|
||||
package com.example.api.controller;
|
||||
|
||||
import com.example.api.annotation.Log;
|
||||
import com.example.api.model.entity.Commodity;
|
||||
import com.example.api.model.enums.BusinessType;
|
||||
import com.example.api.service.CommodityService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CommodityController 类是商品管理的 RESTful API 控制器。
|
||||
*/
|
||||
@RestController // 表明这是一个 REST 控制器,其方法的返回值会自动作为 HTTP 响应体
|
||||
@RequestMapping("/api/commodity") // 定义类级别的路由:/api/commodity
|
||||
@PreAuthorize("hasAnyRole('ROLE_SUPER_ADMIN','ROLE_COMMODITY','ROLE_SALE')") // 权限注解,只有具有指定角色的用户才能访问
|
||||
public class CommodityController {
|
||||
|
||||
@Resource // 自动注入 CommodityService
|
||||
private CommodityService commodityService;
|
||||
|
||||
/**
|
||||
* 保存商品信息。
|
||||
* @param commodity 商品实体
|
||||
* @return 保存后的商品实体
|
||||
*/
|
||||
@Log(module = "商品管理", type = BusinessType.INSERT) // 记录日志,标记为插入操作
|
||||
@PostMapping("") // 定义 POST 请求的路由
|
||||
public Commodity save(@RequestBody Commodity commodity) {
|
||||
return commodityService.save(commodity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品信息。
|
||||
* @param id 商品的 ID
|
||||
*/
|
||||
@Log(module = "商品管理", type = BusinessType.DELETE) // 记录日志,标记为删除操作
|
||||
@DeleteMapping("") // 定义 DELETE 请求的路由
|
||||
public void delete(String id) {
|
||||
commodityService.delete(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品信息。
|
||||
* @param commodity 商品实体
|
||||
*/
|
||||
@Log(module = "商品管理", type = BusinessType.UPDATE) // 记录日志,标记为更新操作
|
||||
@PutMapping("") // 定义 PUT 请求的路由
|
||||
public void update(@RequestBody Commodity commodity) {
|
||||
commodityService.update(commodity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有商品信息。
|
||||
* @return 商品列表
|
||||
*/
|
||||
@Log(module = "商品管理", type = BusinessType.QUERY) // 记录日志,标记为查询操作
|
||||
@GetMapping("") // 定义 GET 请求的路由
|
||||
public List<Commodity> findAll() {
|
||||
return commodityService.findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称模糊查询商品信息。
|
||||
* @param name 名称关键字
|
||||
* @return 匹配的商品列表
|
||||
*/
|
||||
@Log(module = "商品管理", type = BusinessType.QUERY) // 记录日志,标记为查询操作
|
||||
@GetMapping("/search/{name}") // 定义 GET 请求的路由,包含路径变量
|
||||
public List<Commodity> findByLikeName(@PathVariable String name) {
|
||||
return commodityService.findAllByLikeName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ID 查询商品信息。
|
||||
* @param id 商品的 ID
|
||||
* @return 商品实体
|
||||
*/
|
||||
@Log(module = "商品管理", type = BusinessType.QUERY) // 记录日志,标记为查询操作
|
||||
@GetMapping("/{id}") // 定义 GET 请求的路由,包含路径变量
|
||||
public Commodity findById(@PathVariable String id) {
|
||||
return commodityService.findById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.api.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 登录传输数据
|
||||
*/
|
||||
@Data
|
||||
public class LoginDto {
|
||||
|
||||
private String email;
|
||||
|
||||
private String password;
|
||||
|
||||
private String code;
|
||||
|
||||
private boolean remember;
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.example.api.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CommodityChartVo {
|
||||
|
||||
//商品名
|
||||
private Integer value;
|
||||
|
||||
//数量
|
||||
private String name;
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.example.api.repository;
|
||||
|
||||
import com.example.api.model.entity.Distribution;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DistributionRepository extends JpaRepository<Distribution, String> {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.example.api.repository;
|
||||
|
||||
import com.example.api.model.entity.Employee;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, String> {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.example.api.repository;
|
||||
|
||||
import com.example.api.model.entity.LoginLog;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LoginLogRepository extends JpaRepository<LoginLog,String> {
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.example.api.repository;
|
||||
|
||||
import com.example.api.model.entity.SystemLog;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SystemLogRepository extends JpaRepository<SystemLog,String>, JpaSpecificationExecutor<SystemLog> {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.example.api.repository;
|
||||
|
||||
import com.example.api.model.entity.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, String> {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.example.api.repository;
|
||||
|
||||
import com.example.api.model.entity.Warehouse;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WareHouseRepository extends JpaRepository<Warehouse, String> {
|
||||
}
|
Loading…
Reference in new issue