CheckController.java 3.6 KB
Newer Older
1 2 3 4
package cn.timer.api.controller.check;

import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.bean.serverurl.CompanyServerUrl;
5 6 7 8
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
import cn.timer.api.dto.login.QysDto;
9 10 11 12
import cn.timer.api.utils.ResultUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
13
import org.springframework.beans.factory.annotation.Autowired;
14 15 16 17 18 19 20 21 22 23 24 25 26 27
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.transaction.Transactional;
import java.util.List;

@Api(tags = "服务器地址查询")
@Transactional(rollbackOn = Exception.class)
@RestController
@RequestMapping(value = "/check", produces = { "application/json" })
public class CheckController {

28 29 30 31 32
    @Autowired
    private YgglMainEmpMapper ygglMainEmpMapper;

    @Autowired
    private QyzxEmpLoginMapper qyzxEmpLoginMapper;
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

    @GetMapping(value = "/company_server_url_list")
    @ApiOperation(value = "公司服务端地址列表", httpMethod = "GET", notes = "公司服务端地址列表")
    public Object CompanyServerUrlList (){
        List<CompanyServerUrl> companyServerUrls = CompanyServerUrl.builder().build()
                .selectList(new QueryWrapper<CompanyServerUrl>().lambda()
                        .eq(CompanyServerUrl::getStatus, 1).orderByDesc(CompanyServerUrl::getSort));
        //System.out.println(companyServerUrls);

        return ResultUtil.data(companyServerUrls,"查询成功");
    }

    @GetMapping(value = "/check_account_exist/{account}")
    @ApiOperation(value = "检测该用户是否存在", httpMethod = "GET", notes = "检测该用户是否存在")
    public Object checkAccountExist (@PathVariable("account") String account){
        if (account == null || "".equals(account)) {
            return ResultUtil.error("手机号不能为空!");
        }

        List<QyzxEmpLogin> qyzxEmpLogins = QyzxEmpLogin.builder().build()
                .selectList(new QueryWrapper<QyzxEmpLogin>()
                        .lambda().eq(QyzxEmpLogin::getPhone, account).eq(QyzxEmpLogin::getSts, 1));
55

56
        //System.out.println(qyzxEmpLogins);
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
        if (qyzxEmpLogins.size() > 0){

            YgglMainEmp userInfo = ygglMainEmpMapper.selectOne(new QueryWrapper<YgglMainEmp>().lambda()
                    .select(YgglMainEmp::getEmpNum, YgglMainEmp::getName, YgglMainEmp::getPhone, YgglMainEmp::getBmgwId, YgglMainEmp::getOrgCode)
                    .eq(YgglMainEmp::getEmpNum, qyzxEmpLogins.get(0).getId())
                    .eq(YgglMainEmp::getOrgCode, qyzxEmpLogins.get(0).getOrgId()));

            List<QysDto> qys = qyzxEmpLoginMapper.getQys(qyzxEmpLogins.get(0).getId());

            QysDto ctrl = qys.get(0);

            if (userInfo == null) {
                return ResultUtil.error("账户不存在");
            }

            if (ctrl.getStatus() == null || ctrl.getStatus().equals(0)) {
                //return ResultUtil.error("帐号被禁用");
                return ResultUtil.error("账户不存在");
            }

            if (ctrl.getStatus().equals(9)) {
                //return ResultUtil.error("9","服务器变更");
                return ResultUtil.error("账户不存在");
            }

        }else{
83 84
            return ResultUtil.error("账户不存在");
        }
85 86


87 88 89 90
        return ResultUtil.success("OK");
    }

}