🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ package com.zzzz.controller; import com.zzzz.dto.BranchParam; import com.zzzz.po.Branch; import com.zzzz.service.BranchService; import com.zzzz.service.BranchServiceException; import com.zzzz.vo.ListResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.sql.SQLException; @RestController @RequestMapping("/api/v1") public class BranchController { @Autowired private BranchService branchService; @PostMapping(value = "/course/{id}/branch") public ResponseEntity<Long> create(@PathVariable("id") String enterpriseId, @RequestBody BranchParam branchParam) throws BranchServiceException, SQLException { // TODO authentication not implemented yet long branchId = branchService.insert(enterpriseId, branchParam.getName(), branchParam.getAddress(), branchParam.getLatitude(), branchParam.getLongitude(), branchParam.getTelephone()); return ResponseEntity.ok(branchId); } @GetMapping(value = "/branch/{id}") public ResponseEntity<Branch> getById(@PathVariable("id") String branchId) throws BranchServiceException, SQLException { // TODO authentication not implemented yet Branch branch = branchService.getById(branchId); return ResponseEntity.ok(branch); } @PutMapping(value = "/branch/{id}") public ResponseEntity update(@PathVariable("id") String targetBranchId, @RequestBody BranchParam branchParam) throws BranchServiceException, SQLException { // TODO authentication not implemented yet branchService.update(targetBranchId, branchParam.getName(), branchParam.getAddress(), branchParam.getLatitude(), branchParam.getLongitude(), branchParam.getTelephone()); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } @GetMapping(value = "/enterprise/{id}/branch/list") public ResponseEntity<ListResult<Branch>> list(@PathVariable("id") String enterpriseId, String usePagination, String targetPage, String pageSize, String branchId, String nameContaining, String addressContaining) throws BranchServiceException, SQLException { // TODO authentication not implemented yet ListResult<Branch> result = branchService.list(usePagination, targetPage, pageSize, enterpriseId, branchId, nameContaining, addressContaining); return ResponseEntity.ok(result); } } ~~~