GarbageUserController.java
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.trash.garbage.controller;
import com.trash.garbage.global.Result;
import com.trash.garbage.pojo.domain.GarAddress;
import com.trash.garbage.pojo.dto.AddressDto;
import com.trash.garbage.pojo.dto.LoginDto;
import com.trash.garbage.service.GarUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author 20412
*/
@RestController
@RequestMapping("user")
public class GarbageUserController {
@Autowired
private GarUserService garUserService;
/**
* 用户登录
*
* @param user
* @return
*/
@PostMapping("/login")
public Result<String> login(@RequestBody LoginDto user) {
return Result.OK(garUserService.login(user));
}
@GetMapping("/send/verify")
public Result<?> sendVerify(@RequestParam("tel") String tel) {
try {
garUserService.sendVerify(tel);
return Result.OK();
} catch (Exception e) {
e.printStackTrace();
return Result.ERROR();
}
}
@GetMapping("/query/address/{type}")
public Result<List<GarAddress>> queryAddress(@PathVariable("type") String type) {
return Result.OK(garUserService.queryAddress(type));
}
@PostMapping("/save/address")
public Result<String> saveAddress(@Validated @RequestBody AddressDto dto) {
return Result.OK(null, garUserService.saveAddress(dto));
}
@PostMapping("/update/address")
public Result<String> updateAddress(@Validated @RequestBody AddressDto dto) {
return Result.OK(null, garUserService.updateAddress(dto));
}
@DeleteMapping("/delete/address/{addressId}")
public Result<String> deleteAddress(@PathVariable("addressId") String addressId) {
return Result.OK(null, garUserService.deleteAddress(addressId));
}
}