UserController.java 4.15 KB
Newer Older
mlchun's avatar
mlchun committed
1 2 3
package io.hmit.controller;

import ch.qos.logback.core.pattern.ConverterUtil;
mlchun's avatar
mlchun committed
4
import com.alibaba.fastjson.JSON;
mlchun's avatar
mlchun committed
5 6 7 8
import io.hmit.annotation.Login;
import io.hmit.annotation.LoginUser;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.Result;
Shen's avatar
Shen committed
9
import io.hmit.dto.*;
mlchun's avatar
mlchun committed
10
import io.hmit.entity.UserEntity;
mlchun's avatar
mlchun committed
11
import io.hmit.modules.serviceOrder.dto.PensionOldFamilyDTO;
mlchun's avatar
mlchun committed
12
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
mlchun's avatar
mlchun committed
13
import io.hmit.modules.serviceOrder.dto.PensionOrderEvaluationDTO;
14
import io.hmit.modules.serviceOrder.dto.UserAddressDTO;
mlchun's avatar
mlchun committed
15
import io.hmit.modules.serviceOrder.service.PensionOldFamilyService;
mlchun's avatar
mlchun committed
16 17 18 19
import io.hmit.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
mlchun's avatar
mlchun committed
20
import org.apache.commons.codec.digest.DigestUtils;
mlchun's avatar
mlchun committed
21
import org.springframework.beans.factory.annotation.Autowired;
mlchun's avatar
mlchun committed
22
import org.springframework.web.bind.annotation.*;
mlchun's avatar
mlchun committed
23 24
import springfox.documentation.annotations.ApiIgnore;

mlchun's avatar
mlchun committed
25 26
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
mlchun's avatar
mlchun committed
27 28
import java.util.List;

mlchun's avatar
mlchun committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/**
 * @Description :
 * @Author : Shen Yuanfeng
 * @Date: 2021/3/17 16:35
 */

@Slf4j
@RestController
@RequestMapping("api/user")
@Api(tags = "用户接口")
public class UserController {

    @Autowired
    private UserService userService;

mlchun's avatar
mlchun committed
44 45 46
    @Autowired
    private PensionOldFamilyService pensionOldFamilyService;

mlchun's avatar
mlchun committed
47
    @Login
mlchun's avatar
mlchun committed
48 49 50
    @GetMapping("oldinfo")
    @ApiOperation("老人个人信息")
    public Result<UserInfoDTO> getOldInfo(@ApiIgnore @LoginUser UserEntity user){
51 52
        UserInfoDTO userDetails = userService.getUserDetails(user.getId());
        return new Result<UserInfoDTO>().ok(userDetails);
mlchun's avatar
mlchun committed
53
    }
mlchun's avatar
mlchun committed
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

    @Login
    @GetMapping("oldfamilyinfo")
    @ApiOperation("老人家属信息")
    public Result<List<PensionOldFamilyDTO>> getOldFamilyInfo(@ApiIgnore @LoginUser UserEntity user){
        List<PensionOldFamilyDTO> familyDTOS = pensionOldFamilyService.findByOldId(user.getId());
        return new Result<List<PensionOldFamilyDTO>>().ok(familyDTOS);
    }

    @Login
    @GetMapping("orginfo")
    @ApiOperation("机构信息")
    public Result<OrgUserInfoDTO> getOrgUserInfo(@ApiIgnore @LoginUser UserEntity user){
        OrgUserInfoDTO orgUserInfo = userService.getOrgUserByUserId(user.getId());
        return new Result<OrgUserInfoDTO>().ok(orgUserInfo);
    }

    @Login
    @GetMapping("serviceinfo")
    @ApiOperation("服务人员信息")
    public Result<ServiceUserInfoDTO> serviceinfo(@ApiIgnore @LoginUser UserEntity user){
        ServiceUserInfoDTO serviceUser = userService.getServiceUserByUserId(user.getId());
        return new Result<ServiceUserInfoDTO>().ok(serviceUser);
    }

mlchun's avatar
mlchun committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    @GetMapping("checkIdCardNo")
    @ApiOperation("注册身份证ID查询")
    public Result<UserRegisterDTO> checkIdCardNo(@RequestParam("idCardNo") Long idCardNo){
        UserRegisterDTO userRegisterDTO = userService.getUserInfoByIdCardNo(idCardNo);
        return new Result<UserRegisterDTO>().ok(userRegisterDTO);
    }

    @PostMapping("registerUser")
    @ApiOperation("注册用户")
    public Result registerUser(@RequestBody String dto){
        UserRegisterDTO userRegisterDTO = null;
        try {
            userRegisterDTO = JSON.parseObject(URLDecoder.decode(dto,"UTF-8"), UserRegisterDTO.class);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        userService.registerUser(userRegisterDTO);
        return new Result();
    }

Shen's avatar
Shen committed
99 100 101 102 103 104 105 106

    @PostMapping("registerService")
    @ApiOperation("注册服务人员")
    public Result registerService(@RequestBody ServiceRegisterDTO dto){
        userService.registerService(dto);
        return new Result();
    }

107 108 109 110 111 112 113 114 115 116
    @Login
    @GetMapping("findUserAdderss")
    @ApiOperation("根据手机号或用户姓名查找用户地址")
    public Result<List<UserAddressDTO>> findUserAdderss(@RequestParam("str") String str){
        if (str.trim().isEmpty()) {
            return new Result<List<UserAddressDTO>>().ok(null);
        }
        List<UserAddressDTO> userAddressDTOList = userService.findUserAddressByUsernameOrMobile(str);
        return new Result<List<UserAddressDTO>>().ok(userAddressDTOList);
    }
mlchun's avatar
mlchun committed
117

mlchun's avatar
mlchun committed
118
}