mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.panzhihua.service_equipment.api;
 
import com.panzhihua.common.model.dtos.equipment.UnionUserDto;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_equipment.annotation.CurrentUser;
import com.panzhihua.service_equipment.model.dos.UnionUser;
import com.panzhihua.service_equipment.service.UnionUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.Map;
 
@Slf4j
@RestController
@RequestMapping("/unionUser")
public class UnionUserApi {
 
     @Resource
     private UnionUserService userService;
 
    /**
     * 总工会户外劳登录
     *
     * @param loginUserInfoVO
     * @return 总工会户外劳共用户
     */
    @PostMapping("/login")
    public R<UnionUser> login(@RequestBody  LoginUserInfoVO loginUserInfoVO){
         return  userService.login(loginUserInfoVO);
    }
 
 
    /**
     * 总工会户外劳登录(H5)
     *
     * @param phone
     * @return 总工会户外劳共用户
     */
    @GetMapping("/loginH5")
    public R<Map<String, Object>> loginH5(@RequestParam(value = "phone") String phone){
        return  userService.loginByUnion(phone);
    }
    /**
     * 总工会户外劳工站用户认证
     *
     * @param unionUserDto
     * @return 总工会户外劳共用户
     */
    @PostMapping("/authentication")
    public R authentication(@RequestBody UnionUserDto unionUserDto, @CurrentUser UnionUserDto unionUser){
        if (unionUserDto.getIsApplets().equals(1)) {
            log.info("小程序进入无需验证");
            return  userService.authentication(unionUserDto);
        }
        else {
            log.info("h5进入");
            if (unionUser != null) {
                unionUserDto.setId(unionUser.getId());
                return  userService.authentication(unionUserDto);
            }
            else {
                return R.fail("请重新登录");
            }
        }
    }
 
    /**
     * 使用id查找用户
     *
     * @param id
     * @return 总工会户外劳共用户
     */
    @GetMapping("/selectById")
    public UnionUserDto  selectById(@RequestParam(value = "id") Long id){
        return  userService.selectById(id);
    }
 
 
    /**
     * 用户开门
     *
     * @return 总工会户外劳共用户
     */
    @GetMapping("/openDoor")
    public  R openDoor(@RequestParam(value = "qRCode")  String qRCode,@CurrentUser UnionUserDto unionUser){
        if (unionUser != null) {
            return  userService.openDoor(unionUser,qRCode);
        }
        else {
            return R.fail("请重新登录");
        }
    }
 
}