主要框架
- SpringBoot
- SpringData
- SpringSecurity
- Vue2
package com.example.api.controller;
import com.example.api.model.entity.Warehouse;
import com.example.api.service.WarehouseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/api/warehouse")
@PreAuthorize("hasAnyRole('ROLE_SUPER_ADMIN' ,'ROLE_WAREHOUSE')")
public class WarehouseController {
@Resource
private WarehouseService warehouseService;
@PostMapping("")
public Warehouse save(@RequestBody Warehouse warehouse) {
return warehouseService.save(warehouse);
}
@GetMapping("")
public List<Warehouse> findAll() {
return warehouseService.findAll();
}
@DeleteMapping("")
public void delete(String id) {
warehouseService.delete(id);
}
}
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_at` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`roles` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of admin
-- ----------------------------
INSERT INTO `admin` VALUES ('0ac99550-2977-4c09-b2c4-c4702ec81ef8', '2021-12-02 14:27:02', '123123@qq.com', '123123', 'ROLE_EMPLOYEE');
INSERT INTO `admin` VALUES ('d7a8b4f6-db03-4660-9c93-e9c1f385581e', '2021-12-01 16:52:54', 'super_admin@qq.com', '121212', 'ROLE_SUPER_ADMIN');
-- ----------------------------
-- Table structure for code
-- ----------------------------
DROP TABLE IF EXISTS `code`;
CREATE TABLE `code` (
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`exp` bigint(0) NOT NULL,
`value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`email`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for commodity
-- ----------------------------
DROP TABLE IF EXISTS `commodity`;
CREATE TABLE `commodity` (
`id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`count` int(0) NOT NULL,
`create_at` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`price` double NOT NULL,
`update_at` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of